Skip to content

Instantly share code, notes, and snippets.

@cfelton
Last active August 29, 2015 14:27
Show Gist options
  • Save cfelton/950a0dcfb8bcd683686b to your computer and use it in GitHub Desktop.
Save cfelton/950a0dcfb8bcd683686b to your computer and use it in GitHub Desktop.
list of interface conversion example
me = 0
class Interface:
def __init__(self):
self.x = Signal(bool(0))
self.y = Signal(bool(0))
def mod_with_interface(intf):
global me
xi = me
@always(intf.clock.posedge)
def rtl():
intf.y.next = (x + xi) & 1
me += 1
return rtl
def list_of_interfaces_top(clock, x, y, number_of_modules=120):
loi = [Interface() for _ in range(number_of_modules)]
mods = []
for ii, intf in enumerate(loi):
if ii == 0:
intf.x = x
elif ii == number_of_modules-1:
intf.y = y
else:
intf.x = loi[ii-1].x
intf.clock = clock
mods += [mod_with_interface(intf)]
return mods
clock = Signal(bool(0))
x, y = [Signal(bool(0)) for _ in range(2)]
toVerilog(list_of_interfaces_top, clock, x, y)
me = 0
class Interface:
def __init__(self):
self.x = Signal(bool(0))
self.y = Signal(bool(0))
def mod_with_interface(intf):
global me
xi = me
@always(intf.clock.posedge)
def rtl():
intf.y.next = (x + xi) & 1
me += 1
return [rtl]
def list_of_interfaces_top(clock, x, y, number_of_modules=120):
loi = [Interface() for _ in range(number_of_modules)]
mods = []
for ii, intf in enumerate(loi):
if ii == 0:
intf.x = x
elif ii == number_of_modules-1:
intf.y = y
else:
intf.x = loi[ii-1].x
intf.clock = clock
mods += mod_with_interface(intf)
return mods
clock = Signal(bool(0))
x, y = [Signal(bool(0)) for _ in range(2)]
toVerilog(list_of_interfaces_top, clock, x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment