Skip to content

Instantly share code, notes, and snippets.

@cfelton
Last active August 29, 2015 14:00
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/11246585 to your computer and use it in GitHub Desktop.
Save cfelton/11246585 to your computer and use it in GitHub Desktop.
MyHDL Slice Signal Example
from random import randint
from myhdl import *
def m_random_assign(clock, reset, xb):
Xc = randint(0, 1)
print(type(xb), xb)
@always_seq(clock.posedge, reset=reset)
def rtl():
xb.next = Xc
return rtl
def m_top(clock, reset, x):
g = [m_random_assign(clock, reset, x(ii))
for ii in range(len(x))]
return g
clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True)
x = Signal(intbv(0)[16:])
tbdut = m_top(clock, reset, x)
@instance
def tbstim():
reset.next = not reset.active
for ii in range(10):
clock.next = True
yield delay(3)
clock.next = False
print(x)
Simulation((tbdut, tbstim,)).run()
toVHDL(m_top, clock, reset, x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment