hwt.serializer package¶
This package contains serializers. Purpose of serializer class is to convert hwt representations of designed architecture to hdlConvertorAst to convert it to target language (VHDL/Verilog/SystemC…+xdc/ucf/…).
Rather than using serializer classes manually it is recommended to use hwt.synthesizer.utils.to_rtl()
The serialization process is usually a destructive operation as parts of AST can be rewritten to fit target language.
Subpackages¶
Submodules¶
hwt.serializer.exceptions module¶
-
exception
hwt.serializer.exceptions.
UnsupportedEventOpErr
[source]¶ Bases:
hwt.serializer.exceptions.SerializerException
Target HDL can not use event operator in this context, it usually has to be replaced by correct expression of sensitivity list
hwt.serializer.ip_packager module¶
-
class
hwt.serializer.ip_packager.
IpPackager
(topUnit: hwt.synthesizer.unit.Unit, name: str = None, extra_files: List[str] = [], serializer_cls=<class 'hwt.serializer.vhdl.Vhdl2008Serializer'>, target_platform=<hwt.synthesizer.dummyPlatform.DummyPlatform object>)[source]¶ Bases:
ipCorePackager.packager.IpCorePackager
IP-core packager
Summary: Packs HDL, constraint and other files to IP-Core package for distribution and simple integration -
__init__
(topUnit: hwt.synthesizer.unit.Unit, name: str = None, extra_files: List[str] = [], serializer_cls=<class 'hwt.serializer.vhdl.Vhdl2008Serializer'>, target_platform=<hwt.synthesizer.dummyPlatform.DummyPlatform object>)[source]¶ Parameters: - topObj –
hwt.synthesizer.unit.Unit
instance of top component - name – optional name of top
- extra_files – list of extra HDL/constrain file names for files which should be distributed in this IP-core (*.v - verilog, *.sv,*.svh -system verilog, *.vhd - vhdl, *.xdc - XDC)
- serializer – serializer which specifies target HDL language
- target_platform – specifies properties of target platform, like available resources, vendor, etc.
- topObj –
-
getInterfaceLogicalName
(intf: hwt.synthesizer.interface.Interface)[source]¶ See: doc of method on parent class
-
getInterfacePhysicalName
(intf: hwt.synthesizer.interface.Interface)[source]¶ See: doc of method on parent class
-
getInterfaceType
(intf: hwt.synthesizer.interface.Interface) → hwt.hdl.types.hdlType.HdlType[source]¶ See: doc of method on parent class
-
getObjDebugName
(obj: Union[hwt.synthesizer.interface.Interface, hwt.synthesizer.unit.Unit, hwt.synthesizer.param.Param]) → str[source]¶ See: doc of method on parent class
-
getTypeWidth
(dtype: hwt.hdl.types.hdlType.HdlType, do_eval=False) → Tuple[int, Union[int, hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal], bool][source]¶ See: doc of method on parent class
-
getVectorFromType
(dtype) → Union[bool, None, Tuple[int, int]][source]¶ See: doc of method on parent class
-
paramToIpValue
(idPrefix: str, g: hdlConvertorAst.hdlAst._defs.HdlIdDef, resolve) → ipCorePackager.otherXmlObjs.Value[source]¶
-
serializeType
(hdlType: hwt.hdl.types.hdlType.HdlType) → str[source]¶ See: doc of method on parent class
-
-
class
hwt.serializer.ip_packager.
ToHdlAstVivadoTclExpr
(name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Bases:
hwt.serializer.vhdl.serializer.ToHdlAstVhdl2008
-
_id
= <HdlValueId id>¶
-
_spirit_decode
= <HdlValueId spirit:decode>¶
-
hwt.serializer.mode module¶
Serializer mode specifies if hdl objects derived from parent unit should be serialized to target HDL or not
use serialize* methods to specify serialization mode for unit class
@serializeExclude
class MyUnit(Unit):
# ...
pass
-
hwt.serializer.mode.
_serializeExclude_eval
(parentUnit, priv)[source]¶ Always decide not to serialize obj
Parameters: priv – private data for this function first unit of this class Returns: tuple (do serialize this object, next priv, replacement unit)
-
hwt.serializer.mode.
_serializeOnce_eval
(parentUnit, priv)[source]¶ Decide to serialize only first obj of it’s class
Parameters: priv – private data for this function (first object with class == obj.__class__) Returns: tuple (do serialize this object, next priv, replacement unit) where priv is private data for this function (first object with class == obj.__class__)
hwt.serializer.serializer_config module¶
-
class
hwt.serializer.serializer_config.
DummySerializerConfig
[source]¶ Bases:
object
The serializer which does not do any additional code transformations and does not produce any output. It is used to generate just internal representation of RTL code.
-
TO_CONSTRAINTS
= None¶
-
TO_HDL
= None¶
-
TO_HDL_AST
¶
-
fileExtension
= None¶
-
hwt.serializer.serializer_filter module¶
-
class
hwt.serializer.serializer_filter.
SerializerFilter
[source]¶ Bases:
object
Base class for filters used to exclude some
hwt.synthesizer.unit.Unit
instances from target HDL (in order to prevent code duplication, archetype colisions etc.)This base implementation keeps track about others objects and calls _serializeDecision on the
hwt.synthesizer.unit.Unit
instance to decide if instance should be excluded.-
do_serialize
(unit: hwt.synthesizer.unit.Unit) → Tuple[bool, Optional[hwt.synthesizer.unit.Unit]][source]¶ Decide if this unit should be serialized or not eventually fix name to fit same already serialized unit
Parameters: - obj – object to serialize
- serializedClasses – dict {unitCls : unitobj}
- serializedConfiguredUnits – (unitCls, paramsValues) : unitObj where paramsValues are named tuple name:value
-
-
class
hwt.serializer.serializer_filter.
SerializerFilterAll
[source]¶ Bases:
hwt.serializer.serializer_filter.SerializerFilter
Ignore any serialization constraints and dump everything
-
do_serialize
(unit: hwt.synthesizer.unit.Unit) → bool[source]¶ Decide if this unit should be serialized or not eventually fix name to fit same already serialized unit
Parameters: - obj – object to serialize
- serializedClasses – dict {unitCls : unitobj}
- serializedConfiguredUnits – (unitCls, paramsValues) : unitObj where paramsValues are named tuple name:value
-
-
class
hwt.serializer.serializer_filter.
SerializerFilterDoNotExclude
[source]¶ Bases:
hwt.serializer.serializer_filter.SerializerFilter
Use all serialization specifications except @serializeExclude Usefull when it is requred to dump all components for sim etc.
-
do_serialize
(unit: hwt.synthesizer.unit.Unit) → bool[source]¶ Decide if this unit should be serialized or not eventually fix name to fit same already serialized unit
Parameters: - obj – object to serialize
- serializedClasses – dict {unitCls : unitobj}
- serializedConfiguredUnits – (unitCls, paramsValues) : unitObj where paramsValues are named tuple name:value
-
hwt.serializer.store_manager module¶
-
class
hwt.serializer.store_manager.
SaveToFilesFlat
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, root: str, _filter: Optional[hwt.serializer.serializer_filter.SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Bases:
hwt.serializer.store_manager.StoreManager
Store all produced code to a single directory, file per component.
-
__init__
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, root: str, _filter: Optional[hwt.serializer.serializer_filter.SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
hwt.serializer.store_manager.
SaveToSingleFiles
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, root: str, name: str, _filter: Optional[hwt.serializer.serializer_filter.SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Bases:
hwt.serializer.store_manager.StoreManager
Store all produced code to a single directory, all component source code to single file and all constrains to single file.
-
__init__
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, root: str, name: str, _filter: Optional[hwt.serializer.serializer_filter.SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
hwt.serializer.store_manager.
SaveToStream
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, stream: _io.StringIO, _filter: Optional[hwt.serializer.serializer_filter.SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Bases:
hwt.serializer.store_manager.StoreManager
Store all produced code to an output stream
-
__init__
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, stream: _io.StringIO, _filter: Optional[hwt.serializer.serializer_filter.SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
hwt.serializer.store_manager.
StoreManager
(serializer_cls: hwt.serializer.serializer_config.DummySerializerConfig, _filter: Type[SerializerFilter] = None, name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]¶ Bases:
object
A base class for an objects which manage how the output of the serialization is stored by serializer_cls