elasticai.creator.ir2verilog.templates#
Module Contents#
Classes#
Director for building verilog templates. |
|
API#
- class elasticai.creator.ir2verilog.templates.TemplateDirector[source]#
Director for building verilog templates.
Most methods correspond to verilog language constructs. Building the final template can be expensive! Typically you only want to do this once. E.g.:
from string import Template from elasticai.creator.ir2verilog import type_handler, Code, TemplateDirector, Implementation class _ExplodingTemplate: def substitute(self, params): raise RuntimeError("Template not initialized!") _template = None @type_handler def fir_filter(impl: Implementation) -> Code: global _template if _template is None: _template = ( TemplateDirector() .define_scoped_switch("USE_EXT_WEIGHTS", False) .define_scoped_switch("USE_EXT_MAC", False) .parameter("BITWIDTH") .parameter("LENGTH") .localparam("FILT_COEFFS") .localparam("NUM_MULT_UNIT") .add_module_name() .set_prototype(res.read_text(package_path, "verilog/filter_fir_full.v")) .build() ) return _template.substitute(impl.attributes)
Initialization
- define_scoped_switch(name: str, default: bool) Self[source]#
Add a switch for a define that is scoped to the module name.
The switch will be prefixed with the value that users provide as
module_nameto the render call.- Parameters:
name – String with name of the switch/define name
default – Setting switch for defining output state (True=set, False=undefine)