HDL Generation

Generation of HDL code.

One code printer is currently available:

  • VhdlPrinter — generates a VHDL implementation of an architecture.

VhdlPrinter

class b_asic.code_printer.vhdl.vhdl_printer.VhdlPrinter(dt: DataType, vhdl_2008: bool = False)

Generate VHDL source files for an Architecture.

Parameters:
dtDataType

Data type configuration used for generated VHDL.

vhdl_2008bool, default: False

Enable VHDL-2008 specific output where applicable.

get_compile_order(arch: Architecture) → list[str]

Return the file names for the VHDL code describing the provided architecture.

Parameters:
arch

Architecture instance used to determine the compile order of the generated VHDL files.

print(arch: Architecture, *, path: str | Path = PosixPath('.'), vhdl_ls: bool = False, **kwargs) → None

Write VHDL files for an Architecture.

Parameters:
archArchitecture

Architecture instance to generate code for.

pathstr | Path, optional

Output directory. Defaults to the current directory.

vhdl_lsbool, default False

Also write a vhdl_ls.toml configuration file for the VHDL Language Server alongside the generated VHDL files.

**kwargs

Optional VHDL code-generation settings. For info, see Notes.

Notes

Recognised keyword arguments, grouped by the component they affect:

Top-level / architecture

io_registersbool, default False

Insert registers on all top-level I/O ports. Equivalent to setting both input_register and output_register.

input_registerbool, default False

Insert registers on the top-level input ports only.

output_registerbool, default False

Insert registers on the top-level output ports only.

multiplexer_control_registeredbool, default False

Register multiplexer control signals in generated top-level.

enable_pinbool, default True

Whether to include an enable pin on the top-level entity.

interfaceStreamInterface, optional

Select synchronous I/O (default), AXI4-Stream, or Avalon-ST, FIFO sizing, clock mode, and whether the core may stall.

stream_inputs, stream_outputsdict, optional

Map physical stream names to lists of input/output PE entity names. Scheduled transfers from grouped resources share one FIFO in schedule order. Unlisted resources get their own stream.

centralize_controlbool, default True

Generate a shared schedule-indexed control ROM in the top-level architecture instead of distributed control generation.

pipeline_controlbool, default False

Register all outputs of the centralized control ROM. Component control pipeline options must agree with this setting when supplied. This option requires centralized control.

Processing elements

fp_backendstr or dict[str, str]

Floating-point IP backend to use. Pass a string to apply the same backend to every PE, or a {entity_name: backend} dict to select on a per-PE basis.

pe_registersdict[str, tuple[int, int]]

Register split (pre, post) inserted around the operator of a PE. Keys are either the PE entity name or the PE type name.

control_cycledict

Clock cycle inside an operation at which each control signal becomes available.

pipeline_pe_controlbool, default False

Register PE control signals after generation.

Memories (RAM)

output_syncbool, default True

Place output registers after memory read.

external_schedule_counterbool, default True

Use an external schedule counter signal. Ignored when centralize_control is True since no counter is needed.

std_logic_vectorbool, default False

Use std_logic_vector data instead of signed/unsigned.

pipeline_mem_controlbool, default False

Register memory control signals after generation.

External memory I/O

MemoryRead and MemoryWrite generate one interface per memory name used by a PE. Names are sorted and numbered from zero; the generated PE comments record the mapping. Each interface has <pe>_memory_<index>_address and <pe>_memory_<index>_enable outputs, and data ports following the normal I/O naming convention. Address widths use the largest address on that interface, with a minimum of one bit. Enables are low during reset, disabled cycles, and cycles without an access. Read requests occur at operation start; data is expected at start plus read latency. The latency belongs to the external memory; no additional PE or top-level I/O registers are inserted in these interfaces.

Memories (register-based)

external_schedule_counterbool, default True

Use an external schedule counter signal.

std_logic_vectorbool, default False

Use std_logic_vector data.

pipeline_output_muxbool, default False

Register the output multiplexer select signal.

pipeline_back_edge_muxbool, default False

Register the back-edge multiplexer select signal.

print_vhdl_ls_toml(arch: Architecture, *, path: str | Path = PosixPath('.'), lib_name: str = 'lib') → None

Write a vhdl_ls.toml configuration file for the VHDL Language Server.

Parameters:
archArchitecture

Architecture instance used to determine the file list.

pathstr | Path, optional

Output directory (same directory where VHDL files were written). Defaults to the current directory.

lib_namestr, optional

Library name used in the toml file. Defaults to "lib".

Internals