Bitfields are the representation of how the values (like registers) are specified on the machine code of the ISA. The syntax to declare a bitfield is:
bitfield <name>[<size>]
OR
bitfield <name>[<size>] {
<field-list>
}
<name>
should start with an uppercase letter
followed by any combination of [a-z][A-Z][0-9]_
characters.<size>
is a literal number that specifies the
size of the bitfield in bits.<field-list>
is a list of bitfield’s field names
and sizes1.bitfield Reg[4]
It’s a bitfield named Reg
with 4 bits size.
bitfield Opcode[8] {
imm[1]
op[7]
}
It’s a bitfield named Opcode
with 8 bits size and 2
fields:
imm
(1 bit size) is the first bit of the bitfield
Opcode
.op
(7 bits size) are the next 7 bits of the bitfield
Opcode
.The sum of all field sizes should be equal to bitfield’s size.↩︎