python -m pytest tests/unit/ -vThe existing end-to-end test (test_sv_c_path.py) requires a simulator
(verilator, vcs, or vsim) and is skipped automatically if none is
available.
- Generator -- Create
src/ml_hpi/gen/gen_<lang>.pysubclassingGenerator. Implementgenerate(outdir) -> list[Path]. - Type map -- Add a
<lang>_type()static method toGeneratoringen_base.pycovering all ml-hpi scalar types. - Parser -- Create
src/ml_hpi/parse/parse_<lang>.pysubclassingParser. Implementparse(source) -> MlHpiDoc. - Reverse type map -- Add a
<LANG>_TYPE_TO_MLdict toparse_base.py. - Tests -- Create
tests/unit/test_gen_<lang>.pyandtests/unit/test_parse_<lang>.py. Add the language to the parametrized round-trip test intests/unit/test_roundtrip.py. - CLI -- Register the generator and parser in
src/ml_hpi/__main__.py. - Exports -- Add the new classes to
gen/__init__.pyandparse/__init__.py. - Documentation -- Add
docs/bindings/<lang>.rstand include it indocs/language_bindings.rst.
When adding a new scalar type (e.g. float32):
- Add the type to every forward map in
gen_base.py(sv_type,c_type,cpp_type,python_type,pss_type). - Add the reverse mapping to every reverse map in
parse_base.py(SV_TYPE_TO_ML,CPP_TYPE_TO_ML,PSS_TYPE_TO_ML,PYTHON_CTYPES_TO_ML). - Update
pss_scalar_to_ml()if the PSS representation requires programmatic handling. - Add the type to
ALL_TYPESintests/unit/test_type_maps.py. - Update every generator to handle the new type (most will work automatically via the type map).
- Update every parser to handle the new type.
- Add the type to the mapping tables in
docs/ml_hpi.mdand eachdocs/bindings/*.rstpage. - Update the JSON schema (
schema/ml-hpi.schema.json) if it enumerates valid types.
- Python source uses
from __future__ import annotationsfor modern type hint syntax. - Generator and parser modules follow the naming convention
gen_<lang>.pyandparse_<lang>.py. - Each generator class is named
Gen<Lang>(e.g.GenPSS,GenCpp). Each parser class is namedParse<Lang>(e.g.ParseSV,ParseCpp). - Test files mirror source file names:
test_gen_<lang>.py,test_parse_<lang>.py. - Use
StringIOfor building generated output incrementally. - Group interfaces by package prefix (
Interface.pkg()) when generating one output file per package.