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:
- dt
DataType Data type configuration used for generated VHDL.
- vhdl_2008bool, default: False
Enable VHDL-2008 specific output where applicable.
- dt
- 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:
- arch
Architecture 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.tomlconfiguration file for the VHDL Language Server alongside the generated VHDL files.- **kwargs
Optional VHDL code-generation settings. For info, see Notes.
- arch
Notes
Recognised keyword arguments, grouped by the component they affect:
Top-level / architecture
- io_registers
bool, defaultFalse Insert registers on all top-level I/O ports. Equivalent to setting both
input_registerandoutput_register.- input_register
bool, defaultFalse Insert registers on the top-level input ports only.
- output_register
bool, defaultFalse Insert registers on the top-level output ports only.
- multiplexer_control_registered
bool, defaultFalse Register multiplexer control signals in generated top-level.
- enable_pin
bool, defaultTrue Whether to include an enable pin on the top-level entity.
- interface
StreamInterface, optional Select synchronous I/O (default), AXI4-Stream, or Avalon-ST, FIFO sizing, clock mode, and whether the core may stall.
- stream_inputs, stream_outputs
dict, 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_control
bool, defaultTrue Generate a shared schedule-indexed control ROM in the top-level architecture instead of distributed control generation.
- pipeline_control
bool, defaultFalse 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_backend
strordict[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_registers
dict[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_cycle
dict Clock cycle inside an operation at which each control signal becomes available.
- pipeline_pe_control
bool, defaultFalse Register PE control signals after generation.
Memories (RAM)
- output_sync
bool, defaultTrue Place output registers after memory read.
- external_schedule_counter
bool, defaultTrue Use an external schedule counter signal. Ignored when centralize_control is
Truesince no counter is needed.- std_logic_vector
bool, defaultFalse Use
std_logic_vectordata instead ofsigned/unsigned.- pipeline_mem_control
bool, defaultFalse Register memory control signals after generation.
External memory I/O
MemoryReadandMemoryWritegenerate 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>_addressand<pe>_memory_<index>_enableoutputs, 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_counter
bool, defaultTrue Use an external schedule counter signal.
- std_logic_vector
bool, defaultFalse Use
std_logic_vectordata.- pipeline_output_mux
bool, defaultFalse Register the output multiplexer select signal.
- pipeline_back_edge_mux
bool, defaultFalse 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.tomlconfiguration file for the VHDL Language Server.- Parameters:
- arch
Architecture 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".
- arch