Skip to content

Base Module

Base Hardware Module.

BaseMod defines the base interface which is common to all hardware modules.

BaseMod

Bases: NamedObject

Hardware Module.

Parameters:

Name Type Description Default
parent BaseMod

Parent Module. None by default for top module.

None
name str

Instance name. Required if parent is provided.

None

Other Parameters:

Name Type Description
title str

Title

descr str

Description

comment str

Comment

paramdict dict

Parameter values for this instance.

doc property

doc

Documentation.

basename property

basename

Base Name.

modname abstractmethod property

modname

Module Name.

topmodname abstractmethod property

topmodname

Top Module Name.

libname abstractmethod property

libname

Library Name.

qualname cached property

qualname

Qualified Name (Library Name + Module Name).

basequalnames cached property

basequalnames

Qualified Name (Library Name + Module Name) of Base Modules.

hiername property

hiername

Hierarchical Name.

is_tb abstractmethod property

is_tb

Determine if module belongs to Testbench or Design.

path property

path

Path.

inst property

inst

Path String.

assigns cached property

assigns

Assignments.

parser cached property

parser

Expression Parser.

parents property

parents

Parents.

flipflops property

flipflops

Flip Flops.

muxes property

muxes

Iterate over all Multiplexer.

is_locked property

is_locked

Return If Module Is Already Completed And Locked For Modification.

Locking is done by the build process automatically and MUST NOT be done earlier or later. Use a different module type or enumeration or struct type, if you have issues with locking.

get_modref classmethod

get_modref()

Python Class Reference.

get_basemodrefs classmethod

get_basemodrefs()

Python Class Reference.

build_top classmethod

build_top(**kwargs)

Build Top Instance.

Return module as top module.

add_param

add_param(arg, name=None, title=None, descr=None, comment=None, ifdef=None, exist_ok=False)

Add Module Parameter (:any:Param).

Parameters:

Name Type Description Default
arg BaseType | Param

Type or Parameter

required
name str | None

Name. Mandatory if arg is a Type.

None

Other Parameters:

Name Type Description
title str | None

Full Spoken Name.

descr str | None

Documentation Description.

comment str | None

Source Code Comment.

ifdef str | None

IFDEF pragma

exist_ok bool

Do not complain about already existing item

add_const

add_const(arg, name=None, title=None, descr=None, comment=None, ifdef=None, exist_ok=False)

Add Module Internal Constant (:any:Const).

Parameters:

Name Type Description Default
arg BaseType | Const

Type or Parameter

required
name str | None

Name. Mandatory if arg is a Type.

None

Other Parameters:

Name Type Description
title str | None

Full Spoken Name.

descr str | None

Documentation Description.

comment str | None

Source Code Comment.

ifdef str | None

IFDEF pragma

exist_ok bool

Do not complain about already existing item

add_type_consts

add_type_consts(type_, exist_ok=False, only=None, name=None, item_suffix='e')

Add description of type_ as local parameters.

Parameters:

Name Type Description Default
type_

Type to be described.

required

Other Parameters:

Name Type Description
exist_ok bool

Do not complain, if parameter already exists.

name str

Name of the local parameter. Base on type_ name by default.

only str

Limit parameters to these listed in here, separated by ';'

item_suffix str

Enumeration Suffix.

add_port

add_port(type_, name, direction=None, title=None, descr=None, comment=None, ifdef=None, route=None)

Add Module Port (:any:Port).

Parameters:

Name Type Description Default
type_ BaseType

Type.

required
name str

Name.

required

Other Parameters:

Name Type Description
direction Direction | None

Signal Direction. Automatically detected if name ends with '_i', '_o', '_io'.

title str | None

Full Spoken Name.

descr str | None

Documentation Description.

comment str | None

Source Code Comment. Default is 'title'

ifdef str | None

IFDEF mapping

route Routeables | None

Routes (iterable or string separated by ';')

add_signal

add_signal(type_, name, direction=FWD, title=None, descr=None, comment=None, ifdef=None, route=None)

Add Module Internal Signal (:any:Signal).

Parameters:

Name Type Description Default
type_ BaseType

Type.

required
name str

Name.

required

Other Parameters:

Name Type Description
direction Orientation

Signal Direction. Automatically detected if name ends with '_i', '_o', '_io'.

title str | None

Full Spoken Name.

descr str | None

Documentation Description.

comment str | None

Source Code Comment. Default is 'title'

ifdef str | None

IFDEF mapping

route Routeables | None

Routes (iterable or string separated by ';')

add_port_or_signal

add_port_or_signal(type_, name, direction=None, title=None, descr=None, comment=None, ifdef=None, route=None)

Add Module Port (:any:Port) or Signal (:any:Signal) depending on name.

Parameters:

Name Type Description Default
type_ BaseType

Type.

required
name str

Name.

required

Other Parameters:

Name Type Description
direction Direction | None

Signal Direction. Automatically detected if name ends with '_i', '_o', '_io'.

title str | None

Full Spoken Name.

descr str | None

Documentation Description.

comment str | None

Source Code Comment. Default is 'title'

ifdef str | None

IFDEF mapping

route Routeables | None

Routes (iterable or string separated by ';')

set_parent

set_parent(parent)

Set Parent.

Do not use this method, until you really really really know what you do.

assign

assign(target, source, cast=False, overwrite=False)

Assign target to source.

The assignment is done without routing.

Parameters:

Name Type Description Default
target Parseable

Target to be driven. Must be known within this module.

required
source Parseable | Note

Source driving target. Must be known within this module.

required

Other Parameters:

Name Type Description
cast bool

Cast. False by default.

overwrite bool

Overwrite existing assignment.

filter_ (str, Callable)

Target names or function to filter target identifiers.

add_inst

add_inst(inst)

Add Submodule inst.

Parameters:

Name Type Description Default
inst BaseMod

Instance.

required

get_inst

get_inst(inst_or_name)

Get Module Instance.

set_instcon

set_instcon(inst, port, expr, cast=False, overwrite=False)

Connect port of inst to expr without routing.

The assignment is done without routing.

Parameters:

Name Type Description Default
inst Union[BaseMod, str]

Module Instance

required
port Parseable

Port to be connected. Must be known within module instance.

required
expr Parseable

Expression. Must be known within this module.

required

Other Parameters:

Name Type Description
cast bool

Cast. False by default.

overwrite bool

Overwrite existing assignment.

get_instcons

get_instcons(inst)

Retrieve All Instance Connections Of inst.

add_flipflop

add_flipflop(type_, name, clk, rst_an, nxt=None, rst=None, ena=None, route=None)

Add Module Internal Flip-Flop.

Parameters:

Name Type Description Default
type_ BaseType

Type.

required
name str

Name.

required
clk Parseable

Clock. Module Clock by default.

required
rst_an Parseable

Reset. Module Reset by default.

required

Other Parameters:

Name Type Description
nxt Parseable | None

Next Value. Basename of name with _nxt_s by default.

rst Parseable | None

Synchronous Reset.

ena Parseable | None

Enable Condition.

route Routeables | None

Routing of flip-flop output.

add_mux

add_mux(name, title=None, descr=None, comment=None)

Add Multiplexer with name And Return It For Filling.

Parameters:

Name Type Description Default
name str

Name.

required

Other Parameters:

Name Type Description
title str

Full Spoken Name.

descr str

Documentation Description.

comment str

Source Code Comment.

See :any:Mux.set() how to fill the multiplexer and the example above.

get_mux

get_mux(mux)

Get Multiplexer.

lock

lock()

Lock.

Locking is done via this method by the build process automatically and MUST NOT be done earlier or later. Use a different module type or enumeration or struct type, if you have issues with locking.

check_lock

check_lock()

Check if module is locked for modifications.

con

con(port, source)

Connect port to dest.

route

route(target, source)

Route source to target within the actual module.

get_overview

get_overview()

Return brief module overview.

Router

Bases: Object

The One And Only Router.

add

add(tpath, spath)

Add route from source to tpath.

flush

flush()

Create Pending Routes.

__create

__create(rpath, cpath)

Create cpath based on rpath.