Previous Contents Next

5   Registers

This section describes the register declaration aspects of a Devil specification.

register-definition   ::=   register ident ((register-params)) ? = register-def
register-params   ::=   register-param (, register-param) *
register-param   ::=   ident : type-expr
register-def   ::=   (register-ports | reg-params) (, register-attribute) * : type-expr
register-ports   ::=   register-port (, register-port) ?
reg-params   ::=   reg-param (, reg-param) ?
register-port   ::=   (rw) ? regport-def
exprs   ::=   expr (, expr) *
regport-def   ::=   ident
  | ident @ expr
reg-param   ::=   (rw) ? ident (exprs)
register-attribute   ::=   (rw) ? pre { (action-definition ;) + }
  | (rw) ? post { (action-definition ;) + }
  | (rw) ? mask bits-litteral

rw
  ::=   read
  | write
action-definition   ::=   ident = expr
  | ident.ident = expr
  | ident[expr] = expr
  | ident = { (action-definition ;) + }

A register identifies data that are present in the device as well as how these data can be accessed (read or written). If a register definition only has a read (resp. write) part, the register is said to be a read-only (resp. a write-only) register. Otherwise it is considered as a read-write register. The type of a register consists of a number of bits and is the same for both the read and write parts. In addition, the register definition may contain the description of other four components: port, bit-mask, pre-actions and post-actions.

Ports

A port is defined by the expression ident @ expr which can be optionally preceded by a read or write modifier. ident is the identifier name of a device parameter. expr is a static expression that must be evaluable at compile time. The @ expr can be omitted, in which case it defaults to @ 0. One or two ports must be provided in a register definition. The read (resp. write) part of a register is defined if and only if a read (resp. write) port definition is provided. If only one port is provided without a modifier, its definition is used both for the read and write parts.



Bit-masks

A bit-mask is introduced by the mask keyword, optionally preceded by a read or write modifier and followed by a bits-literal. If a bit-mask is preceded by a read modifier (respectively write modifier), its definition applies only to the read part (respectively write part) of the register definition. The bits-literal of a bit-mask is a sequence of n mask elements (0,1, * or .) where n stands for the size (number of bits) of the register. Mask elements are numbered from right to left so that the right hand side element of a bit-mask masks the lowest bit of the corresponding register. The table below shows, for each mask element, the constraint associated to its corresponding bit.

mask bit mapped bit value
0 no 0
1 no 1
* no any
. yes bit variable value

If no bit-mask is provided, it defaults to '......n' where n stands for the size of the register.

Unused declarations

The bit of a register masked with . (dot sign) has to be mapped by a device variable. The unused declaration can be used when the variable is conditionally defined to declare bits that are conditionnaly mapped.

unused-declaration   ::=   unused bit register-bits

The unused declaration is introduced by the unused bit keywords, optionally preceded by a read or write modifier, and followed by a register-bits expression (see section 7). An unused declaration has to be conditionally defined since a bit which is always irrelevant must be masked with the * sign.

Pre and post actions

Pre-actions specify a list of actions that have to be performed before reading or writing the register. Post-actions specify a list of actions that have to be performed after reading or writing the register. Pre-actions and post-actions are introduced by the pre and post keywords, optionally preceded by a read or write modifier and followed by a list of actions. An action is the assignment of an identifier to a specific value. The identifier designates a variable, the field of a structure or the element of an array. If no pre-actions or post-actions are provided, they default to pre {} or post {} where no actions have to be performed. If pre-actions or post-actions are preceded by a modifier, their definitions apply only to the read or write part of the register definition.

5.1   Register Extensions

This section describes some language extensions that introduce some short-hand notations for register definitions.

Parameterized registers

A parameterized register is introduced by appending a list of parameters to the identifier name of the register being defined. The right-hand side of the definition is identical to a standard register definition except that the parameters can appear in the expressions. Parameterized registers can be seen as functions from a set of parameters to a register definition.



Parameterized register applications

The parameterized register application of a register definition is replaced by the definition of the parameterized register where parameters have been replaced by specific values. If a component is specified in the parameterized register, it can not be redefined. That is, a component can not be specified both in the parameterized register definition and in the register-attribute part of the register definition. If the parameterized register application is preceded by a read or write modifier, the modifier is applied to all components of the parameterized register definition. Components that have the read and write modifiers are ignored.




Previous Contents Next