!Field¶
The !Field tag declares a single field within a !Reg or !Inst declaration, providing a way to split the full width of register up into meaningful sub-divisions. It’s very useful for packing multi pieces of related information into a word that’s retrievable with a single fetch.
Placement of the !Field within the register’s width can be controlled by using the lsb (least-significant bit) and msb (most-significant bit) parameters. If both parameters are omitted then the field will be placed with its least-significant bit at the first available position, following the order that the !Fields have been declared in the !Reg or !Inst tag’s field list.
Where a field is used to represent a discrete value, it can be enumerated using !Enum tags - allowing a name to be associated with a particular value, along with a description of its purpose.
Usage¶
The !Field tag is relatively primative, so can be used with either sequence or mapping syntax - although the value cannot be enumerated when using sequence syntax. Examples of both forms are given below.
- !Reg
name : status
width : 32
fields:
- !Field [uptime, 24, 0, U, 0, "How many seconds system has been up"]
- !Field
name : state
width: 1
lsb : 24
sd : Current system state
reset: 0
enums:
- !Enum [inactive, 0, "System has not been configured"]
- !Enum [active, 1, "System is ready to receive data"]
- !Field
name : mode
width: 4
msb : 31
sd : Mode of operation
reset: 0
enums:
- !Enum [idle, 0, "Waiting for next instruction"]
- !Enum [transmit, 1, "Currently transmitting data"]
- !Enum [receive, 2, "Currently receiving data"]
...
-
class
blade.schema.ph_field.Field(name, width='-', lsb=None, type='-', reset='-', ld='', sd='', msb=None, enums=None, options=None, enum=None)¶ Defines a field within a register with name, width, type, and optional enumeration of the value.
-
__init__(name, width='-', lsb=None, type='-', reset='-', ld='', sd='', msb=None, enums=None, options=None, enum=None)¶ Initialisation for the !Field tag
- Parameters
name – The name of the field
width – How many bits wide it should be
lsb – Least significant bit, controls placement within the register
type – Whether the field holds a signed or unsigned value
reset – The value that should be taken at reset
ld – Long description of the field - no maximum length
sd – Short description of the field - maximum 150 characters
msb – Most significant bit, alternative placement within the register
enums – List of enumerated values using !Enum tags
options – List of optiosn either in the form ‘KEY=VALUE’ or just ‘KEY’ if a value is not required.
enum – Alternative to ‘enums’
-
set_file_marks(start, end)¶ Set start and end marks of the declaration and propagate to children
- Parameters
start – The starting mark
end – The ending mark
-
set_source_file(file)¶ Set the source file of this object and propagate it to children.
- Parameters
file – The source file path or object
-
validate()¶ Check that this tag agrees with our YAML schema
-