Configuration file
Corsair uses simple flat INI configuration file called csrconfig
. It is used for the two things:
to pass global parameters to corsair
to specify all generation targets with their attributes
Example of csrconfig is below:
[globcfg]
data_width = 32
address_width = 16
register_reset = sync_pos
[v_module]
path = regs.v
interface = axil
generator = Verilog
[c_header]
path = regs.h
generator = CHeader
It has one special section globcfg
for global parameters, and one or many sections for generation targets.
globcfg section
Global parameters available:
Parameter |
Default value |
Description |
|||
---|---|---|---|---|---|
|
0 |
Register map base address in global address map |
|||
|
32 |
Width of all data buses and registers |
|||
|
16 |
Address bus width (capacity of the register map) |
|||
|
|
Flip-flop reset style |
|||
|
Synchronous active high reset |
||||
|
Synchronous active low reset |
||||
|
Asynchronous active high reset |
||||
|
Asynchronous active low reset |
||||
|
|
Address auto increment mode, if no address is provided for a register |
|||
|
Address auto increment mode is disabled |
||||
|
Enable address auto increment with value based on |
||||
|
Enable address auto increment with provided number of bytes, e.g 4 |
||||
|
|
Check for address alignment of registers. |
|||
|
No check of address alignment |
||||
|
Enable check of address alignment based on |
||||
|
Enable check of address alignment based on provided number of bytes, e.g 4 |
||||
|
|
Force case for all the names (regsiters, bit fields, enums) |
|||
|
Names used as they are |
||||
|
Force names to have lowercase |
||||
|
Force names to have uppercase |
You can omit any of this in your csrconfig
file - default value will be used.
You also can add your own parameters and access them inside your custom flow the same way as standart ones. This is valid config:
[globcfg]
data_width = 32
address_width = 16
register_reset = sync_pos
foo = bar
Target sections
Target section defines file generator and specify its parameters. Generator is a Python class that produces some output based on input arguments. Usually, one target section - one output file.
Few simple rules to remember:
target name should be unique
targets without
generator
parameter is ignored
Parameter generator
can be defined in the two ways. To use built-in generator:
[target]
generator = Verilog
Or to use custom created one:
[target]
generator = custom_generator.py::MyCustomGenerator
If you are interesting in expanding corsair functionality, there is the example of how to build your own generator and use it with corsair CLI.
Generators
Corsair provides many built-in generators:
Generator |
Description |
---|---|
|
Dump register map to a JSON file |
|
Dump register map to a YAML file |
|
Dump register map to a text file |
|
Create Verilog file with register map |
|
Create VHDL file with register map |
|
Create Verilog header file with register map defines |
|
Create C header file with register map define |
|
Create SystemVerilog package with register map parameters |
|
Create documentation for a register map in Markdown |
|
Create documentation for a register map in AsciiDoc |
|
Create Python file with register map |
There are even more generators but these ones are normally don’t used in csrconfig
file -
they are helpfull for creating custom generators or other development tasks:
Generator |
Description |
---|---|
|
Base generator class |
|
Basic class for rendering Jinja2 templates |
|
Basic class for rendering register images with wavedrom |
|
Create Verilog file with bridge to Local Bus |
|
Create Vhdl file with bridge to Local Bus |
Note
These parameters in csrconfig
file are nothing but arguments for the class constructor.
If parameter is not provided - default value will be used.
Please note that the tables below were created mannualy, while data in Generators API page was collected automaticaly.
As these things are exactrly the same information just in different forms, please refer to API if you have any doubts.
Json
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
Yaml
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
Txt
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
Verilog
Parameter |
Default |
Description |
|
---|---|---|---|
|
|
Path to the output file |
|
|
0 |
Numeric value to return if wrong address was read |
|
|
|
Register map bus protocol |
|
|
AXI4-Lite |
||
|
Avalon-MM |
||
|
APB4 |
||
|
Custom LocalBus interface |
Vhdl
Parameter |
Default |
Description |
|
---|---|---|---|
|
|
Path to the output file |
|
|
0 |
Numeric value to return if wrong address was read |
|
|
|
Register map bus protocol |
|
|
AXI4-Lite |
||
|
Avalon-MM |
||
|
APB4 |
||
|
Custom LocalBus interface |
VerilogHeader
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
|
|
Prefix for all defines. If empty, output file name will be used. |
CHeader
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
|
|
Prefix for all defines. If empty, output file name will be used. |
SystemVerilogPackage
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
|
|
Prefix for the all parameters. If empty, output file name will be used. |
Markdown
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
|
|
Document title |
|
|
Enable generating images for bit fields of a register |
|
|
Path to directory where all images will be saved |
|
|
Enable generating table with register access modes explained |
Asciidoc
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |
|
|
Document title |
|
|
Enable generating images for bit fields of a register |
|
|
Path to directory where all images will be saved |
|
|
Enable generating table with register access modes explained |
Python
Parameter |
Default |
Description |
---|---|---|
|
|
Path to the output file |