hdl_registers.generator.vhdl package

Subpackages

Submodules

hdl_registers.generator.vhdl.record_package module

class hdl_registers.generator.vhdl.record_package.VhdlRecordPackageGenerator(register_list: RegisterList, output_folder: Path)

Bases: VhdlGeneratorCommon

Generate a VHDL package with register record types containing natively-typed members for each register field. See the VHDL code generator article for usage details.

  • For each register, plain or in array, a record with natively-typed members for each register field.

  • For each register array, a correctly-ranged array of records for the registers in that array.

  • Combined record with all the registers and register arrays. One each for registers in the up direction and in the down direction.

  • Constants with default values for all of the above types.

  • Conversion functions to/from std_logic_vector representation for all of the above types.

The generated VHDL file needs also the generated package from VhdlRegisterPackageGenerator.

SHORT_DESCRIPTION = 'VHDL record package'
create(**kwargs: Any) Path

See super class for API details.

Overloaded here because this package file shall only be created if the register list actually has any registers.

get_code(**kwargs: Any) str

Get a complete VHDL package with register record types.

property output_file: Path

Result will be placed in this file.

hdl_registers.generator.vhdl.register_package module

class hdl_registers.generator.vhdl.register_package.VhdlRegisterPackageGenerator(register_list: RegisterList, output_folder: Path)

Bases: VhdlGeneratorCommon

Generate a base VHDL package with basic register information. See the VHDL code generator article for usage details.

  • For each register constant, the value as a native VHDL constant.

  • For each register, the index within the register map.

  • For each field in each register

    • Register bit index range definitions.

    • Native VHDL type corresponding to the field type.

    • Conversion of a field value to/from SLV.

Also produces a register map constant, mapping indexes to modes, suitable for use with axi_lite_reg_file.vhd or VhdlAxiLiteWrapperGenerator.

SHORT_DESCRIPTION = 'VHDL register package'
get_code(**kwargs: Any) str

Get a complete VHDL package with register and constant information.

property output_file: Path

Result will be placed in this file.

hdl_registers.generator.vhdl.reserved_keywords module

hdl_registers.generator.vhdl.vhdl_generator_common module

class hdl_registers.generator.vhdl.vhdl_generator_common.VhdlGeneratorCommon(register_list: RegisterList, output_folder: Path)

Bases: RegisterCodeGenerator

Common methods for generation of VHDL code.

COMMENT_START: str = '--'
field_to_slv(field: RegisterField, field_name: str, value: str) str

Get a VHDL snippet that converts a value of the given field to SLV. Via e.g. a function call or a cast.

Parameters:
  • field – The field.

  • field_name – The field’s qualified name.

  • value – The name of the variable/constant that holds the field’s natively typed value.

static field_to_slv_function_name(field: RegisterField, field_name: str) str

Name of the function that converts the field’s native VHDL representation to SLV.

Parameters:
  • field – A field.

  • field_name – The field’s qualified name.

field_type_name(register: Register, field: RegisterField, register_array: RegisterArray | None = None) str

Get the native VHDL type name that will represent the value of the supplied field.

has_any_hardware_accessible_register(direction: HardwareAccessDirection) bool

Return True if the register list contains at least one register, plain or in array, with a mode where hardware accesses the value in the given direction.

has_any_software_accessible_register(direction: SoftwareAccessDirection) bool

Return True if the register list contains any register, plain or in array, that is software-accessible in the given direction.

iterate_hardware_accessible_array_registers(register_array: RegisterArray, direction: HardwareAccessDirection) Iterator[Register]

Iterate all registers in the register array that are hardware-accessible in the given direction.

iterate_hardware_accessible_plain_registers(direction: HardwareAccessDirection) Iterator[Register]

Iterate all plain registers in the register list that are hardware-accessible in the given direction.

iterate_hardware_accessible_register_arrays(direction: HardwareAccessDirection) Iterator[RegisterArray]

Iterate all register arrays in the register list that contain at least one register that is hardware-accessible in the given direction.

iterate_hardware_accessible_registers(direction: HardwareAccessDirection) Iterator[tuple[Register, RegisterArray | None]]

Iterate all registers in the register list, plain or in array, that are hardware-accessible in the given direction.

iterate_software_accessible_array_registers(register_array: RegisterArray, direction: SoftwareAccessDirection) Iterator[Register]

Iterate all registers in the register array that are software-accessible in the given direction.

iterate_software_accessible_plain_registers(direction: SoftwareAccessDirection) Iterator[Register]

Iterate all plain registers in the register list that are software-accessible in the given direction.

iterate_software_accessible_register_arrays(direction: SoftwareAccessDirection) Iterator[RegisterArray]

Iterate all register arrays in the register list that contain at least one register that is software-accessible in the given direction.

iterate_software_accessible_registers(direction: SoftwareAccessDirection) Iterator[tuple[Register, RegisterArray | None]]

Iterate all registers in the register list, plain or in array, that are software-accessible in the given direction.