hdl_registers.generator.c package


hdl_registers.generator.c.header module

class hdl_registers.generator.c.header.CHeaderGenerator(register_list: RegisterList, output_folder: Path, file_name: str | None = None)

Bases: RegisterCodeGenerator, RegisterCodeGeneratorHelpers

Generate a C code header with register information.

There is no unit test of this class that checks the generated code. It is instead functionally tested in the file test_register_compilation.py. That test generates C code from an example register set, compiles it and performs some run-time assertions in a C program. That test is considered more meaningful and exhaustive than a unit test would be.

COMMENT_START: str = '//'
__init__(register_list: RegisterList, output_folder: Path, file_name: str | None = None)

For argument description, please see the super class.


file_name – Optionally specify an explicit result file name. If not specified, the name will be derived from the name of the register list.

get_code(**kwargs: Any) str

Get a complete C header with all constants and all registers.

property output_file: Path

Result will be placed in this file.