Last active
June 2, 2016 12:28
-
-
Save cfelton/17bfc798550aa9ed8e04 to your computer and use it in GitHub Desktop.
A template for MyHDL testbenchds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import myhdl | |
from myhdl import Signal, intbv, instance, delay, StopSimulation | |
def testbench_template(args=None): | |
# any code to extract argument for what is desired to be tested | |
# instantiate all signals and interface | |
@myhdl.block | |
def bench_template(): | |
# use an embedded function, then all the testbench signals | |
# can be traced as well as the DUT | |
tbdut = design_under_test() | |
@always(delay(5)) | |
def tbclk(): | |
clock.next = not clock | |
@instance | |
def tbstim(): | |
# put all the testbench stimulus here | |
yeild delay(100) | |
raise StopSimulation | |
return tbdut, tbclk, tbstim | |
# use arguments to determine if trace or not | |
inst = bench_template() | |
inst.sim_config(trace=True) | |
inst.sim_run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment