How oddball/ipxact2systemverilog works
Project type and purpose
• This is an open-source CLI tool (Python package) named “ipxact2systemverilog” that ingests IP-XACT XML descriptions of register banks and emits synthesizable HDL packages (SystemVerilog & VHDL) plus documentation formats (RST, Markdown, C headers).
• Key use cases: on-the-fly code generation, integration into CI pipelines, example verification via simple test benches.
File structure
• Top-level directories:
• ipxact2systemverilog/ – core Python package (modules: cli.py, validate.py, ipxact2hdlCommon.py, xml/)
• example/ – sample inputs (XML, INI), expected outputs (docx, h, html, md, pdf, rst, rtf, SV/VHDL packages), and test benches
• Configuration & build:
• setup via pyproject.toml, Makefile (build, compile, sim), .github/workflows/ci.yml
• linting and style: .pep8, .prospector.yaml
• External integrations: uses lxml for XML parsing, docutils for RST, mdutils for Markdown; optional pandoc & Sphinx via Makefile.
README for additional insights
• Describes five CLI entry points: ipxact2systemverilog, ipxact2rst, ipxact2md, ipxact2vhdl, ipxact2c
• Notes XML schema validation, example test bench, CI badge, publishing via Twine.
• Mentions dependencies and optional tools for docs/tests.
Main components & their relationships
a. CLI Frontend
– Five console scripts.
– Parses flags (--srcFile, --destDir).
b. XML Loader & Validator
– xml/* modules + validate.py.
– Uses lxml to parse and validate against XSD.
c. Intermediate Representation (IR)
– ipxact2hdlCommon.py builds an in-memory model of registers, fields, banks.
d. Generator Plugins
– Separate generator modules invoked by cli.py:
• SystemVerilog generator
• VHDL generator
• RST generator
• Markdown generator
• C header generator
– Each consumes IR and writes files to destDir.
e. Output Artifacts
– HDL packages (.sv, .vh, .vhd), documentation (.rst, .md, .html, .pdf, .docx, etc.).
f. Example/Test Harness
– example/tb/*.sv, *.vhd: simple test benches showing package usage.
– Makefile orchestrates build, compile (Modelsim), sim, docs via pandoc/Sphinx.
Architectural patterns and design principles
• Modular plugin pattern: separate generators share a common IR interface.
• Separation of concerns: parsing/validation, model construction, code generation.
• Single responsibility per module.
• CLI-core separation: entry point only handles I/O; core logic is importable.