elasticai.creator.ir2vhdl#

Package Contents#

Classes#

Ir2Vhdl

Edge

Signal

Instance

Represents an entity that we can/want instantiate.

Implementation

InstanceFactory

Automatically creates Instances from VhdlNodes based on their type field.

LogicSignal

LogicVectorSignal

NullDefinedLogicSignal

PluginLoader

Plugin loader for ir2vhdl translation.

PluginSpec

PortMap

Shape

VhdlNode

Extending ir.core.Node to a vhdl specific node.

EntityTemplateParameter

Find the entity in vhdl code and make its name available as a template paramter.

ValueTemplateParameter

Find a value definition and make it settable via a template parameter.

EntityTemplateDirector

Functions#

edge

vhdl_node

Convenience method for creating new vhdl nodes.

Data#

API#

class elasticai.creator.ir2vhdl.Ir2Vhdl[source]#

Bases: elasticai.creator.ir.LoweringPass[elasticai.creator.ir2vhdl.ir2vhdl.Implementation, elasticai.creator.ir2vhdl.ir2vhdl.Code]

register_static(name: str, fn: collections.abc.Callable[[], str]) None[source]#
__call__(args: collections.abc.Iterable[elasticai.creator.ir2vhdl.ir2vhdl.Implementation]) Iterator[elasticai.creator.ir2vhdl.ir2vhdl.Code][source]#
class elasticai.creator.ir2vhdl.Edge(src: str, dst: str, data: dict[str, elasticai.creator.ir.base.Attribute])[source]#

Bases: elasticai.creator.ir.Edge

src_dst_indices: tuple[tuple[int, int] | tuple[str, str], ...]#

None

__hash__() int[source]#
elasticai.creator.ir2vhdl.Code: TypeAlias#

None

class elasticai.creator.ir2vhdl.Signal[source]#

Bases: abc.ABC

types: set[type[elasticai.creator.ir2vhdl.ir2vhdl.Signal]]#

‘set(…)’

abstract define() Iterator[str][source]#
abstract property name: str#
classmethod from_code(code: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
abstract classmethod can_create_from_code(code: str) bool[source]#
classmethod register_type(t: type[elasticai.creator.ir2vhdl.ir2vhdl.Signal]) None[source]#
abstract make_instance_specific(instance: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
class elasticai.creator.ir2vhdl.Instance(node: elasticai.creator.ir2vhdl.ir2vhdl.VhdlNode, generic_map: dict[str, str], port_map: dict[str, elasticai.creator.ir2vhdl.ir2vhdl.Signal])[source]#

Represents an entity that we can/want instantiate.

The aggregates all the knowledge that is necessary to instantiate and use the corresponding entity programmatically, when generating vhdl code.

Initialization

property input_shape: elasticai.creator.ir2vhdl.ir2vhdl.Shape#
property output_shape: elasticai.creator.ir2vhdl.ir2vhdl.Shape#
property name: str#
property implementation: str#
define_signals() Iterator[str][source]#
instantiate() Iterator[str][source]#
class elasticai.creator.ir2vhdl.Implementation(*, name: str | None = None, type: str | None = None, node_fn=VhdlNode, edge_fn=Edge, data: dict[str, Any] | None = None, attributes: dict[str, Any] | None = None, graph: elasticai.creator.graph.BaseGraph | None = None)[source]#

Bases: elasticai.creator.ir.Implementation[elasticai.creator.ir2vhdl.ir2vhdl.N, elasticai.creator.ir2vhdl.ir2vhdl.E]

name: str#

None

type: str#

None

class elasticai.creator.ir2vhdl.InstanceFactory[source]#

Bases: elasticai.creator.function_utils.KeyedFunctionDispatcher[elasticai.creator.ir2vhdl.ir2vhdl.VhdlNode, elasticai.creator.ir2vhdl.ir2vhdl.Instance]

Automatically creates Instances from VhdlNodes based on their type field.

Initialization

class elasticai.creator.ir2vhdl.LogicSignal(name: str)[source]#

Bases: elasticai.creator.ir2vhdl.ir2vhdl.Signal

define() Iterator[str][source]#
property name: str#
classmethod can_create_from_code(code: str) bool[source]#
classmethod from_code(code: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
make_instance_specific(instance: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
__eq__(other: object) bool[source]#
class elasticai.creator.ir2vhdl.LogicVectorSignal(name: str, width: int)[source]#

Bases: elasticai.creator.ir2vhdl.ir2vhdl.Signal

define() Iterator[str][source]#
property name: str#
property width: int#
classmethod can_create_from_code(code: str) bool[source]#
classmethod from_code(code: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
make_instance_specific(instance: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
__eq__(other) bool[source]#
class elasticai.creator.ir2vhdl.NullDefinedLogicSignal(name)[source]#

Bases: elasticai.creator.ir2vhdl.ir2vhdl.Signal

define() Iterator[str][source]#
property name: str#
classmethod can_create_from_code(code: str) bool[source]#
classmethod from_code(code: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
make_instance_specific(instance: str) elasticai.creator.ir2vhdl.ir2vhdl.Signal[source]#
class elasticai.creator.ir2vhdl.PluginLoader(lowering: elasticai.creator.ir2vhdl.ir2vhdl.Ir2Vhdl)[source]#

Bases: elasticai.creator.plugin.PluginLoader[elasticai.creator.ir2vhdl.ir2vhdl.Ir2Vhdl]

Plugin loader for ir2vhdl translation.

Initialization

load_from_package(package: str) None[source]#
class elasticai.creator.ir2vhdl.PluginSpec[source]#

Bases: elasticai.creator.plugin.PluginSpec

generated: tuple[str, ...]#

None

static_files: tuple[str, ...]#

None

elasticai.creator.ir2vhdl.PluginSymbol: TypeAlias[source]#

None

class elasticai.creator.ir2vhdl.PortMap(map: dict[str, elasticai.creator.ir2vhdl.ir2vhdl.Signal])[source]#

Initialization

as_dict() dict[str, str][source]#
classmethod from_dict(data: dict[str, str]) elasticai.creator.ir2vhdl.ir2vhdl.PortMap[source]#
__eq__(other: object) bool[source]#
class elasticai.creator.ir2vhdl.Shape(*values: int)[source]#

Initialization

values are interpreted as one of the following:

  • width

  • depth, width

  • depth, width, height

Usually width is kernel_size, depth is channels

classmethod from_tuple(values: elasticai.creator.ir2vhdl.ir2vhdl.ShapeTuple | list[int]) elasticai.creator.ir2vhdl.ir2vhdl.Shape[source]#
to_tuple() elasticai.creator.ir2vhdl.ir2vhdl.ShapeTuple[source]#
to_list() list[int][source]#
__getitem__(item)[source]#
size() int[source]#
ndim() int[source]#
property depth: int#
__eq__(other)[source]#
property width: int#
property height: int#
__repr__() str[source]#
elasticai.creator.ir2vhdl.ShapeTuple: TypeAlias#

None

elasticai.creator.ir2vhdl.TypeHandlerFn: TypeAlias#

None

class elasticai.creator.ir2vhdl.VhdlNode(name: str, data: dict[str, elasticai.creator.ir.base.Attribute])[source]#

Bases: elasticai.creator.ir.Node

Extending ir.core.Node to a vhdl specific node.

VhdlNode contains all knowledge that we need to create and use an instance of a vhdl entity. However, this becomes a little bit complicated because vhdl differentiates between the entity and the architecture of a component. The entity is similar to an interface while the architecture is similar to the implementation. However, to instantiate components, we need to know both names.

Attributes:

implementation:: The name of the implementation will be used to derive the architecture name. E.g., if the implementation is "adder", we will instantiate the entity work.adder(rtl). CAUTION: This behaviour is subject to change. Future versions might require the full entity name

Initialization

implementation: str#

None

input_shape: elasticai.creator.ir.RequiredField[list[int], elasticai.creator.ir2vhdl.ir2vhdl.Shape]#

‘ShapeField(…)’

output_shape: elasticai.creator.ir.RequiredField[list[int], elasticai.creator.ir2vhdl.ir2vhdl.Shape]#

‘ShapeField(…)’

elasticai.creator.ir2vhdl.edge(src: str, dst: str, src_dst_indices: collections.abc.Iterable[tuple[int, int]] | tuple[str, str]) elasticai.creator.ir2vhdl.ir2vhdl.Edge[source]#
elasticai.creator.ir2vhdl.type_handler#

‘FunctionDecorator(…)’

elasticai.creator.ir2vhdl.type_handler_iterable#

‘FunctionDecorator(…)’

elasticai.creator.ir2vhdl.vhdl_node(name: str, type: str, implementation: str, input_shape: elasticai.creator.ir2vhdl.ir2vhdl.Shape | elasticai.creator.ir2vhdl.ir2vhdl.ShapeTuple, output_shape: elasticai.creator.ir2vhdl.ir2vhdl.Shape | elasticai.creator.ir2vhdl.ir2vhdl.ShapeTuple, attributes: dict | None = None) elasticai.creator.ir2vhdl.ir2vhdl.VhdlNode[source]#

Convenience method for creating new vhdl nodes.

class elasticai.creator.ir2vhdl.EntityTemplateParameter[source]#

Bases: elasticai.creator.template.AnalysingTemplateParameter

Find the entity in vhdl code and make its name available as a template paramter.

Assumes that there is only one entity in the provided prototype.

NOTE: Will only replace occurences where name is followed and preceded by a non-word character, ie. for an entity named 'skeleton' the occurence 'architecture rtl of skeleton is' will be replaced by 'architecture rtl of $entity is' but the occurences 'skeleton_pkg', 'skeleton;', 'skeleton-' or skeleton. will remain unaltered. IMPORTANT: This detail is likely to change in the future.

Initialization

analyse(m: dict[str, str]) None[source]#
replace(m: dict[str, str]) str[source]#
class elasticai.creator.ir2vhdl.ValueTemplateParameter(name: str)[source]#

Bases: elasticai.creator.template.TemplateParameter

Find a value definition and make it settable via a template parameter.

Searches for vhdl value definitions of the form identifier : type or identifier : type := and transforms them into identifier : type := $identifier.

Essentially allows to replace generics as well as variable or signal initializations.

Initialization

replace(match: dict[str, str]) str[source]#
class elasticai.creator.ir2vhdl.EntityTemplateDirector[source]#

Initialization

set_prototype(prototype: str) elasticai.creator.ir2vhdl.vhdl_template.EntityTemplateDirector[source]#
add_generic(name: str) elasticai.creator.ir2vhdl.vhdl_template.EntityTemplateDirector[source]#
build() string.Template[source]#