Offset types are denoted as
offset<base_type,unit[,ref_type]>
, where
base_type is an integer type, unit the specification of an
unit, and ref_type is an optional type of a referred
value.
The offset base type is the type of the magnitude part of the united value. It can be any integer type, signed or unsigned, of any size.
The unit specification should be one of the unit identifiers that are allowed in offset literals (see above), a constant positive integer or the name of a Poke type whose size is known at compile time.
If a referred type is specified, this tells poke that the offset may be used in order to refer to a value stored on some IO space. This is similar to the notion of a pointer in other programming languages.
Let’s see some examples. A signed 32-bit offset expressed in bytes
has type offset<int<32>,B>
. An unsigned 12-bit offset
expressed in kilobits has type offset<uint<12>,Kb>
. The latter
type can also be written using an explicit integer unit like in
offset<uint<12>,1024>
. Finally, a signed 64-bit offset in units
of “packets”, where a packet is denoted with a Poke type
Packet
has type offset<uint<64>,Packet>
.
An offset whose purpose is to refer to some data structure of type
Packet
stored in some IO space could have type
offset<uint<64>,B,Packet>
.