Skip to content

Commit ed43153

Browse files
committed
Add enums to tutorial
1 parent 2c794fa commit ed43153

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/systemrdl-tutorial.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,34 @@ parameterizations.
242242
my_reg_type #(.SIZE(16), .RESET(16'hABCD)) r3;
243243
244244
245+
Enumerated Fields
246+
-----------------
247+
In most cases, a field will represent a numeric value in your design. However,
248+
sometimes it is useful to ascribe names to enumerated values using an RDL ``enum``.
249+
An enumeration can be bound to a field using the ``encode`` property.
250+
251+
.. code-block:: systemrdl
252+
253+
// An enum associatyes names with values
254+
enum system_state_e {
255+
IDLE = 0 {
256+
desc = "The system is idle and ready for input";
257+
};
258+
259+
BUSY = 1 {
260+
desc = "Busy processing an input";
261+
};
262+
263+
SLEEP = 2; // No properties assigned
264+
SHUTDOWN; // Infers value of 3
265+
};
266+
267+
field {
268+
encode = system_state_e;
269+
reset = system_state_e::IDLE;
270+
} system_state[1:0];
271+
272+
245273
Some Examples
246274
-------------
247275
Here are a few interesting examples of what you can do with SystemRDL.

0 commit comments

Comments
 (0)