I’m reading through and trying to understand some verilog, and sprinkled through is the compiler directive:
// synopsys template
But I do not know what this is or what it does. My Google Fu in researching variations of ‘verilog templates’ has lead to more example verilog code than answers.
I did find this synopsis user guide: http://acms.ucsd.edu/info/documents/dc/syn3.pdf, which on p282 provides some information, the directive seems to affect this variable:
hdlin_auto_save_templates
Controls whether HDL designs containing parameters are read in as templates.
...
It goes on to imply this directive affects “elaboration” (perhaps delaying it? to what end?), which my current understanding is loosely analogous to the code emission step of traditional compilation, when the verilog is converted to an “actual” hardware representation?
I would appreciate an explanation of what templates are / do in Verilog and perhaps a correction on my understanding of ‘elaboration’ in this context – Thanks!
Not really. Elaboration is part of the language specification and is a required step to process a design. Processing Verilog usually requires two distinct steps which the specification describes as parsing and elaboration. SystemVerilog more precisely defines these and calls them compilation and elaboration.
Verilog contains some constructs that makes it impossible to completely build a module then ‘link’ it to a larger design later. Consider the following code:
When the above module is read, the parser has no idea what WIDTH will be because the value given can be overridden in the instantiation. This prevents it from resolving the code inside the generate block until the entire Verilog source text is read. It gets more complicated with defparams, forward declarations of functions and hierarchical references.
The command
// synopsys templateand the term ‘templates’ are not part of verilog. Given toolic’s answer and the doc you linked, it appears to tell the tool that any module read after the command will need a parameter definition so it should not be elaborated when read. For instance a netlist will not have any parameter overrides in the instantiations so if you want to place an RTL instance in a netlist, you would need to tell the synthesis tool directly what the parameters should be.