11Frequently Asked Questions
22==========================
33
4- Why isn't there an option for a flat non-struct hardware interface?
4+ Why isn't there an option for a flat non-record hardware interface?
55-------------------------------------------------------------------
66SystemRDL is inherently a very hierarchical language.
77For small register blocks, flattening the hardware interface may be acceptable,
88but this ends up scaling very poorly as the design becomes larger and has more
99complex hierarchy.
10- Using struct compositions for the hardware interface has the benefit of
10+ Using record compositions for the hardware interface has the benefit of
1111preserving conceptual hierarchy and arrays exactly as defined in the original
1212SystemRDL.
1313
14- How do I know I connected everything? Structs are harder to review
14+ How do I know I connected everything? Records are harder to review
1515~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616Initially this can be daunting, but fortunately the tool has an option to generate a
1717flattened hardware interface report upon export. Try using the ``--hwif-report ``
1818command line option when exporting. This is the easiest way to quickly
1919understand the structure of the hardware interface.
2020
21-
22-
23- Why does the tool generate un-packed structs? I prefer packed structs.
24- ----------------------------------------------------------------------
25- Packed structs are great when describing vectors that have bit-level structure.
26- In this tool, the use of un-packed structs is intentional since the hardware
27- interface is not something that is meant to be bit-accessible. In the case of
28- the hardware interface structs, using a packed struct is semantically inappropriate.
29-
30- ... Then how can I initialize the struct?
31- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32- We get this request most often because designers want to initialize the ``hwif_in ``
33- struct with a simple assignment:
34-
35- .. code :: systemverilog
36-
37- always_comb begin
38- hwif_in = '0;
39- end
40-
41- Of course since the struct actually is **unpacked **, this will result in a
42- compile error which usually leads to the inappropriate assumption that it ought
43- to be packed. (See this amusing blog post about `X/Y problems <https://xyproblem.info >`_)
44-
45- If your goal is to initialize the packed struct, fortunately SystemVerilog already
46- has syntax to do this:
47-
48- .. code :: systemverilog
49-
50- always_comb begin
51- hwif_in = '{default: '0};
52- end
53-
54- This is lesser-known syntax, but still very well supported by synthesis
55- tools, and is the recommended way to handle this.
56-
57- ... Why are unpacked structs preferred?
58- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59- In the case of the hardware interface ports, unpacked structs help prevent
60- mistakes that are very easy to make.
61- Consider the following situation - a designer has a field that sets the following
62- properties: ``sw=rw; hw=rw; we; ``, and wants to assign the hardware input value,
63- so they erroneously do the following assignment in Verilog:
64-
65- .. code :: systemverilog
66-
67- assign hwif_in.my_register.my_field = <some value>;
68-
69- This is actually a bug since the ``my_field `` member is actually a struct that
70- has two members: ``we `` and ``next ``. If this were a packed struct, this would
71- silently compile and you would potentially have a bug that may not be noticed
72- (depending on how thorough the test campaign is).
73- With an unpacked struct, this gets flagged immediately as a compile error since
74- the assignment is invalid.
75-
76- The designer may have simply forgotten that the field is an aggregate of multiple
77- members and intended to do the following:
78-
79- .. code :: systemverilog
80-
81- assign hwif.my_register.my_field.next = <some value>;
82- assign hwif.my_register.my_field.we = <some control signal>;
83-
84-
8521The generated output does not match our organization's coding style
8622-------------------------------------------------------------------
87- SystemVerilog coding styles vary wildly, and unfortunately there is little
23+ VHDL coding styles vary wildly, and unfortunately there is little
8824consensus on this topic within the digital design community.
8925
90- The output generated by PeakRDL-regblock strives to be as human-readable as possible,
26+ The output generated by PeakRDL-regblock-vhdl strives to be as human-readable as possible,
9127and follow consistent indentation and styling. We do our best to use the most
9228widely accepted coding style, but since this is a very opinionated space, it is
9329impossible to satisfy everyone.
9430
95- In general, we strive to follow the
96- `SystemVerilog style guide by lowRISC <https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md >`_,
97- but may deviate in some areas if not practical or would impose excessive complexity on the code generator.
98-
99-
10031The lint tool I am using is flagging violations in generated code
10132-----------------------------------------------------------------
10233Code linting tools are a great way to check for user-error, flag inconsistencies,
@@ -113,5 +44,5 @@ complexity to the tool.
11344
11445If you encounter a lint violation, please carefully review and consider waiving
11546it if it does not pose an actual danger. If you still believe it is a problem,
116- please let us know by `submitting an issue <https://github.com/SystemRDL/PeakRDL-regblock/issues >`_
47+ please let us know by `submitting an issue <https://github.com/SystemRDL/PeakRDL-regblock-vhdl /issues >`_
11748that describes the problem.
0 commit comments