Skip to content

Module Testbench

Testbench Module.

ATbMod

Bases: BaseMod

Testbench Module.

Attributes:

Name Type Description
filelists ModFileLists

File Lists.

dut_mods tuple[Any, ...]

Testbench is limited to these kind of modules.

title str

Title.

dut BaseMod

Module Under Test.

parent BaseMod | None

Parent.

Create testbench for dut.

The TopModRef and load() function allow to wrap any design module with a testbench.

Module Testbench Examples

Example:

>>> import ucdp as u
>>> class MyMod(u.AMod):
...
...     def _build(self):
...         self.add_port(u.UintType(4), "data_i")
...         self.add_port(u.UintType(4), "data_o")
...
>>> class OtherMod(u.AMod):
...
...     def _build(self):
...         self.add_port(u.UintType(4), "data_i")
...         self.add_port(u.UintType(4), "data_o")
...
>>> class GenTbMod(u.ATbMod):
...
...     def _build(self):
...         # Build testbench for self.dut here
...         pass
...
...     @staticmethod
...     def build_dut():
...         return MyMod()

>>> tb = GenTbMod()
>>> tb
<ucdp.modtb.GenTbMod(inst='gen_tb_my', libname='ucdp', modname='gen_tb_my', dut=<ucdp.modtb.MyMod(...)>)>
>>> tb.dut
<ucdp.modtb.MyMod(inst='my', libname='ucdp', modname='my')>
>>> tb = GenTbMod(OtherMod())
>>> tb
<ucdp.modtb.GenTbMod(inst='gen_tb_other', libname='ucdp', modname='...', dut=<ucdp.modtb.OtherMod(...)>)>
>>> tb.dut
<ucdp.modtb.OtherMod(inst='other', libname='ucdp', modname='other')>

TopModRef and load() handle that gracefully and allow pairing of testbench and dut on command line and in configuration files.

filelists class-attribute

filelists = ()

File Lists.

dut_mods class-attribute

dut_mods = ()

Testbench is limited to these kind of modules.

modname property

modname

Module Name.

topmodname property

topmodname

Top Module Name.

libname property

libname

Library Name.

is_tb property

is_tb

Determine if module belongs to Testbench or Design.

build_tb classmethod

build_tb(dut, **kwargs)

Build Testbench.

build_dut classmethod

build_dut(**kwargs)

Build DUT.

search_duts classmethod

search_duts(mod)

Iterate over topmod and return modules which can be tested by this testbench.

search_dut_topmodrefs classmethod

search_dut_topmodrefs(mod)

Iterate over topmod and return TopModRef for modules which can be tested by this testbench.

get_tests

get_tests()

Yield Tests to be run on design.

model_post_init

model_post_init(__context)

Run Build.

AGenericTbMod

Bases: ATbMod

A Generic Testbench which adapts to dut.