Skip to content

Instantly share code, notes, and snippets.

@cfelton
Created May 8, 2014 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfelton/a0dbd2c12070a649bb56 to your computer and use it in GitHub Desktop.
Save cfelton/a0dbd2c12070a649bb56 to your computer and use it in GitHub Desktop.
MyHDL signal delay argument
from myhdl import *
import myhdl_tools as mt
def m_add(a, b, c):
@always_comb
def rtl():
c.next = a and b
return rtl
def test():
a = Signal(bool(0), delay=10)
b = Signal(bool(0), delay=1)
c = Signal(bool(0))
def _test():
tbdut = m_add(a, b, c)
@instance
def tbstim():
yield delay(100)
a.next = True
b.next = True
yield delay(100)
return tbdut, tbstim
g = traceSignals(_test)
Simulation(g).run()
fig,ax = mt.vcd.parse_and_plot('_test.vcd')
fig.savefig('signal_delay.png')
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment