Generators
Generator
- class corsair.generators.Generator(rmap, **args)[source]
Bases:
object
Base generator class.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map object
Jinja2
- class corsair.generators.Jinja2[source]
Bases:
object
Basic class for rendering Jinja2 templates
- render(template, vars, templates_path=None)[source]
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)[source]
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
Wavedrom
Json
- class corsair.generators.Json(rmap=None, path='regs.json', **args)[source]
Bases:
Generator
Dump register map to a JSON file.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- validate()
Validate generator parameters.
Yaml
- class corsair.generators.Yaml(rmap=None, path='regs.yaml', **args)[source]
Bases:
Generator
Dump register map to a YAML file.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- validate()
Validate generator parameters.
Txt
- class corsair.generators.Txt(rmap=None, path='regs.txt', **args)[source]
Bases:
Generator
Dump register map to a text table.
Note: only registers with single bitfield are allowed.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- validate()
Validate generator parameters.
Verilog
- class corsair.generators.Verilog(rmap=None, path='regs.v', read_filler=0, interface='axil', **args)[source]
-
Create Verilog file with register map.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
read_filler (int) – Numeric value to return if wrong address was read
interface (str) – Register map bus protocol. Use one of: axil, apb, amm, lb
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
Vhdl
- class corsair.generators.Vhdl(rmap=None, path='regs.vhd', read_filler=0, interface='axil', **args)[source]
-
Create VHDL file with register map.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
read_filler (int) – Numeric value to return if wrong address was read
interface (str) – Register map bus protocol. Use one of: axil, apb, amm, lb
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
VerilogHeader
- class corsair.generators.VerilogHeader(rmap=None, path='regs.vh', prefix='CSR', **args)[source]
-
Create Verilog header file with register map defines.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
prefix (str) – Prefix for the all defines. If empty output file name will be used.
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
- validate()
Validate generator parameters.
CHeader
- class corsair.generators.CHeader(rmap=None, path='regs.h', prefix='CSR', **args)[source]
-
Create C header file with register map defines.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
prefix (str) – Prefix for the all defines and types. If empty output file name will be used.
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
SystemVerilogPackage
- class corsair.generators.SystemVerilogPackage(rmap=None, path='regs_pkg.sv', prefix='CSR', **args)[source]
-
Create SystemVerilog package with register map parameters.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
prefix (str) – Prefix for the all parameters and types. If empty output file name will be used.
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
- validate()
Validate generator parameters.
Markdown
- class corsair.generators.Markdown(rmap=None, path='regs.md', title='Register map', print_images=True, image_dir='regs_img', print_conventions=True, **args)[source]
Bases:
Generator
,Jinja2
,Wavedrom
Create documentation for a register map in Markdown.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
title (str) – Document title
print_images (bool) – Enable generating images for bit fields of a register
image_dir (str) – Path to directory where all images will be saved
print_conventions (bool) – Enable generating table with register access modes explained
- draw_regs(imgdir, rmap)
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
- validate()
Validate generator parameters.
Asciidoc
- class corsair.generators.Asciidoc(rmap=None, path='regs.adoc', title='Register map', print_images=True, image_dir='regs_img', print_conventions=True, **args)[source]
Bases:
Generator
,Jinja2
,Wavedrom
Create documentation for a register map in AsciiDoc.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
title (str) – Document title
print_images (bool) – Enable generating images for bit fields of a register
image_dir (str) – Path to directory where all images will be saved
print_conventions (bool) – Enable generating table with register access modes explained
- draw_regs(imgdir, rmap)
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
- validate()
Validate generator parameters.
Python
- class corsair.generators.Python(rmap=None, path='regs.py', **args)[source]
-
Create Python file to access register map via some interface.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
- validate()
Validate generator parameters.
LbBridgeVerilog
- class corsair.generators.LbBridgeVerilog(rmap=None, path='axil2lb.v', bridge_type='axil', **args)[source]
-
Create Verilog file with bridge to Local Bus.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
bridge_type (str) – Bridge protocol. Use one of axil, apb, amm.
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used
LbBridgeVhdl
- class corsair.generators.LbBridgeVhdl(rmap=None, path='axil2lb.v', bridge_type='axil', **args)[source]
-
Create VHDL file with bridge to Local Bus.
- Parameters:
rmap (
corsair.RegisterMap
) – Register map objectpath (str) – Path to the output file
bridge_type (str) – Bridge protocol. Use one of axil, apb, amm.
- make_target(name)
Dump class attributes to dictionary that can be used as target for csrconfig generation.
- Parameters:
name – Name of the target
- Returns:
Target dictionary
- render(template, vars, templates_path=None)
Render text with Jinja2.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
templates_path – Path to search templates. If no path provided, then internal templates will be used
- Returns:
String with rendered text
- render_to_file(template, vars, path, templates_path=None)
Render text with Jinja2 and save it to the file.
- Parameters:
template – Jinja2 template filename
vars – Dictionary with variables for Jinja2 rendering
path – Path to the output file
templates_path – Path to search templates. If no path provided, then internal templates will be used