hdl_registers.generator.c package

Submodules

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

Generate a C header. See the C code generator article for usage details.

The header will contain:

  • Constant values for all register constants.

  • Enumeration types for all Enumeration fields.

  • A struct type with all registers as members, which can be memory mapped directly.

  • For each register, #define constants with the index and address of the register.

  • For each field in each register, #define constants with the bit shift, bit mask and inverse bit mask of the field.

COMMENT_START: str = '//'
DEFAULT_INDENTATION_LEVEL: int = 0
SHORT_DESCRIPTION = 'C header'
__init__(register_list: RegisterList, output_folder: Path, file_name: str | None = None)

For argument description, please see the super class.

Parameters:

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.

hdl_registers.generator.c.reserved_keywords module