elasticai.creator.hdl_generator.protocols#

Protocol definitions for HDL abstraction.

This module defines the protocols (interfaces) that all HDL implementations must follow. Using Protocol classes allows for structural subtyping (duck typing with type checking).

Module Contents#

Classes#

HDLSignal

Protocol for HDL signals/wires.

HDLInstance

Protocol for HDL module/entity instances.

Template

HDLTemplateDirector

Protocol for HDL template directors.

API#

class elasticai.creator.hdl_generator.protocols.HDLSignal[source]#

Bases: typing.Protocol

Protocol for HDL signals/wires.

Represents either a VHDL signal or a Verilog wire.

abstract property name: str#

The name of the signal/wire.

abstractmethod define() collections.abc.Iterator[str][source]#

Generate HDL code lines to define this signal/wire.

abstractmethod make_instance_specific(instance: str) elasticai.creator.hdl_generator.protocols.HDLSignal[source]#

Create a signal/wire with an instance-specific name.

Args: instance: The instance name to append to the signal name.

Returns: A new signal with the modified name.

class elasticai.creator.hdl_generator.protocols.HDLInstance[source]#

Bases: typing.Protocol

Protocol for HDL module/entity instances.

Represents either a VHDL entity instance or a Verilog module instance.

abstract property name: str#

The instance name.

abstract property implementation: str#

The name of the module/entity being instantiated.

abstractmethod define_signals() collections.abc.Iterator[str][source]#

Generate HDL code lines to define all signals/wires used by this instance.

abstractmethod instantiate() collections.abc.Iterator[str][source]#

Generate HDL code lines to instantiate this module/entity.

class elasticai.creator.hdl_generator.protocols.Template[source]#

Bases: typing.Protocol

abstractmethod substitute(mapping: dict[str, Any] = {}, /, **kwds: Any) str[source]#
class elasticai.creator.hdl_generator.protocols.HDLTemplateDirector[source]#

Bases: typing.Protocol

Protocol for HDL template directors.

Provides a builder interface for creating HDL templates from prototype code.

abstractmethod set_prototype(prototype: str) elasticai.creator.hdl_generator.protocols.HDLTemplateDirector[source]#

Set the prototype HDL code to use as a template base.

Args: prototype: The HDL code to convert into a template.

Returns: Self for method chaining.

abstractmethod add_parameter(name: str) elasticai.creator.hdl_generator.protocols.HDLTemplateDirector[source]#

Add a template parameter (generic/parameter).

Args: name: The name of the parameter to make templatable.

Returns: Self for method chaining.

abstractmethod build() elasticai.creator.hdl_generator.protocols.Template[source]#

Build the final template.

Returns: A string.Template that can be used to generate code.