peakrdl-mnrs (1.2.4)
Installation
pip install --index-url peakrdl-mnrs
About this package
peakrdl exporter using templates to generate addrmap and regfile headers from systemrdl
peakrdl_mnrs - The MINRES peakrdl exporter
peakrdl_mnrs is a peakrdl exporter that supports generation of source and header files from SystemRDL using jinja templates.
It allows generation of register header files, Address Map header files and Module source and header skeletons by default.
Custom Templates can also be supplied.
Table of Contents
Installation
To install this package from source simply run the following command in the root directory:
pip install .
When using vscode to create a venv (Ctrl + Shift + P: Python: Create Environment) the package will be installed automatically and this step can be skipped.
peakrdl_mnrs is now also installable using pip. Instructions can be found here.
Usage
Example:
peakrdl mnrs --regfiles -o output test/test_addrmap.rdl
This runs the generator to create the regfile header files. The generated files of the default templates can now be inspected in the output directory.
To get an overview of all possible options (peakrdl and mnrs):
peakrdl mnrs -h
When it comes to behavior originating from peakrdl, refer to the peakrdl documentation.
Features
The Peakrdl Compiler requires addrmaps to be supplied as input. To generate regfile headers from rdl-files without one the supplied mnrs_gen
script can be used. If needed it wraps the regfile(s) and then calls peakrdl with the appropriate exporter settings.
By default, the exporter does not modify files if the content does not change. This behavior can be changed by using the --overwrite
option.
Generated skeleteons (--module_header
and --module_source
) will never be overwritten, even when using the --overwrite
option.
Custom templates can be supplied using the --template
option.
Using --template
together with --addrmap
will cause the addrmap node to be accessible inside the template with the name "node". Note that this does not affect the name of the generated file, it will still be called <addrmap_instance_name>.h.
Using --template
together with --regfiles
will iterate over all regfile nodes in the given addrmap, causing generation of a single file for each node using the supplied template. The root regfile node will be accessible inside the template under the "regfile_node" name. Similar to above, the generated file will be called <regfile_instance_name>_regs.h.
Currently names cannot be supplied when using templates.
Working with this package
When working with the package it is easiest to install it in editable mode. Make sure pip and setuptools are up to date:
pip install --upgrade pip
pip install --upgrade setuptools
Then install this package:
pip install -e
To see the (possible) parameters of nodes when writing custom templates, it is easiest to set a breakpoint in the export(...)
function in exporter.py
. The addressmap node and its properties are visible as self.top_node
and the regfiles in the regfile_nodes
variable. Note that children of nodes with their full properties (such as their size) are only made available using the node.children()
function and are not found in the children
property.
(Custom) functions inside the templates can be accessed using filters. Besides the standard ones, filters (and tests) can be made accessible using the schema in generator.py
and the register_helpers(...)
function.
Publishing the package
The following is now deprecated as the package is automatically published if the version changes.
Create a .pypirc file according to the gitea documentation, it is best practice to generate a SHH-key in gitea as a password (User -> Settings -> SSH- /GPG-keys).
Then publish the package like this:
pip install build twine
python -m build
python -m twine upload --repository gitea dist/*
The package can now be installed using
pip install --extra-index-url https://git.minres.com/api/packages/Tools/pypi/simple peakrdl-mnrs