pcisim.lib.dataword
index
../../src/pcisim/lib/dataword.py

A module to group DataFields together.

 
Classes
       
__builtin__.object
DataWord
pcisim.lib.MyException(exceptions.Exception)
FieldNotFound
StructureNotLocked

 
class DataWord(__builtin__.object)
    Provides a container for DataField objects.
 
This can be used to describe bit-dependent data structures.
 
@ATTRIBS
    (list) fields : list of DataFields in the word.
 
@NOTES
    After building DataWord with add/add_field methods, call lock()
    to to calculate overall bitsize.
 
  Methods defined here:
__getattr__(self, attr)
Allows point notation to be used to access fields by name.
 
@PARAMS
    (str) attr : field or attribute to get
 
@RETURNS
    (int) field value
 
@RAISES
    AttributeError if field or attribute not found
__init__(self)
__iter__(self)
Iterate over structure fields.
 
@RETURN
    self.fields iterator.
__setattr__(self, attr, val)
Allows point notation to be used to set field value.
 
@PARAMS
    (str) attr : field or attribute to be set
    (int) val : value to set
__str__(self)
add(self, field)
Adds a field to the structure starting from bit 0.
 
@PARAMS
    (DataField) field : field to add
 
@NOTES
    Unlocks the structure if locked.
add_field(self, name, bits, *args, **kargs)
Creates a DataField and adds it to the structure starting from
bit 0.
 
@PARAMS
    (str) name : symbolic name for the field
    (int) bits : number of bits of the field
    *args : additional arguments to pass to DataField init
    **kargs : additional keyword arguments to pass to DataField init
 
@RETURN
    (DataField) added field.
 
@NOTES
    Unlocks the structure if locked.
get_bits(self)
Get structure overall bit size.
 
@RETURN
    (int) bit size.
 
@RAISES
    StructureNotLocked if lock() function was not called.
get_field(self, fieldname)
Get a field by field name.
 
@PARAMS
    (str) fieldname : name of the field to search
 
@RETURN
    (DataField) field found.
 
@RAISES
    FieldNotFound when given field name does not match any.
get_raw(self)
Get structure value as an integer value;
 
@RETURN
    (int) raw fields value.
is_locked(self)
True if structure is locked;
lock(self)
Calculates structure bitsize.
 
This method should be called after structure has been populated.
After this call, bitsize can be retrieved by get_bits() call.
set_field(self, fieldname, value)
Sets a specific field value;
 
@PARAMS
    (str) fieldname : name of the field to set
    (int) value : value to set
 
@RETURN
    (DataField) modified field.
set_raw(self, rawdata)
Set a raw value to the structure, overwriting fields value.
 
@PARAMS
    (int) rawdata : value to set

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class FieldNotFound(pcisim.lib.MyException)
    Occurs when a field name is not found in the DataWord.
 
@ATTRIBS
    (str) fieldname : name of the field
 
 
Method resolution order:
FieldNotFound
pcisim.lib.MyException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, fieldname)
@PARAMS
    (str) fieldname : name of the field
__str__(self)

Data descriptors inherited from pcisim.lib.MyException:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class StructureNotLocked(pcisim.lib.MyException)
    Occurs when a DataWord function requires 'lock' method to be called
but it wasn't.
 
@ATTRIBS
    (DataWord) data : subject structure
 
 
Method resolution order:
StructureNotLocked
pcisim.lib.MyException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, data)
@PARAMS
    (DataWord) data : subject structure
__str__(self)

Data descriptors inherited from pcisim.lib.MyException:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
Data
        __all__ = ['DataWord', 'FieldNotFound', 'StructureNotLocked']