Template¶
RegFab uses template mechanism for extension, to generate various output based on tool’s core data. User can develop his own templates for different purposes.
Builtin Templates¶
RegFab comes with some builtin templates, they are located: templates/mako/register/
, including:
html.mako
- HTML doc templatecode-verilog.mako
- Register design code in Verilogcode-c-header.mako
- C language header fileuvm-regmodel.mako
- UVM register modelsvd.mako
- System-View-Description fileTrace32.mako
- Lauterbach Trace32 peripheral filedocx.mako
- Microsoft Word .docx file
To generate output with these templates, run command with switch -t <template>
. RegFab will search for the template from current directory and builtin location, and current directory has higher priority. Regarding the template name, you can specify the filename with or without extension .mako
, or the filename with full path.:
$> qk regfab -t html xxx.xml
$> qk regfab -t code-verilog xxx.xml
$> qk regfab -t code-c xxx.xml
$> qk regfab -t code-c-header xxx.xml
$> qk regfab -t uvm-regmodel xxx.xml
$> qk regfab -t svd xxx.xml
$> qk regfab -t Trace32 xxx.xml
$> qk regfab -t docx xxx.xml
With switch -o filename
, the generated content will write into a file, otherwise the content will print on screen.:
$> qk regfab -t html -o doc.html xxx.xml
Variable Context¶
When user is developing his own templates, he has to know the Variable Context which is defined by this tool.
From mako template point of view, some top-level variables can be seen:
module
- Component instanceregisters
- All registers ordered by addressmemories
- All memories ordered by addressregmems
- All registers & memories ordered by addressdinterfaces
- All interfacesregsets
- All regsets ordered by offset
- module property
Name
- module nameClkStyle
- clock style, values can be: synchronous, asynchronousVersion
- tool version
- register property
isMemory
- always FalseName
- register nameRegType
- register type, values can be user defined typesOffset
- register offset to regsetifOffset
- register offset to interfaceaddress
- register addressDataWidth
- register data-widthresetValue
- register reset valueresetMask
- register reset maskresetMode
- register reset mode, values can be: synchronous, asynchronousresetLevel
- reset level: 0/1hexIfOffset
- hex string ofifOffset
hexAddress
- hex string ofaddress
hexResetValue
- hex string ofresetValue
hexResetMask
- hex string ofresetMask
access
- combination of iAccess and xAccess as: ‘xAccess:iAccess’, iAccess/xAccess can be: R,W,RW,RS,WS,RSWSsortedBits()
- all bit-field list, sorted by offset in descending orderiterWholeBits()
- all bit-field list, including blank bits, use reg.isblank to determine whether it’s a blank bit
- memory property
isMemory
- always TrueSize
- memory sizehexSize
- hex string ofSize
- bitfield property
Name
- bitfield nameOffset
- bitfield offsetWidth
- bitfield widthReserved
- reserved status, can be: reserved, unreservediAccess
- internal access instancexAccess
- external access instanceresetValue
- bitfield reset valueresetMask
- bitfield reset maskhigh
- bitfield high bitlow
- bitfield low bitslice
- string of ‘high
:low
’enums
- bit enumeration list
- bitfield-enum property
Name
- enum nameValue
- enum value
example1:
% for reg in registers:
${reg.hexOffset}: ${reg.Name}
>> ${reg.RegType} - ${reg.hexResetValue} - ${reg.hexResetMask} - ${reg.access}
% endfor