Skip to content

Instantly share code, notes, and snippets.

@hgomersall
Created April 19, 2016 17:28
Show Gist options
  • Save hgomersall/f2f8fa86438128cc208c60a59701eb87 to your computer and use it in GitHub Desktop.
Save hgomersall/f2f8fa86438128cc208c60a59701eb87 to your computer and use it in GitHub Desktop.
from myhdl import *
class Interface(object):
def __init__(self):
self.foo = Signal(intbv(0)[20:])
self.bar = Signal(intbv(0)[20:])
@block
def Foo(a, b, c, d, e, clock):
if e == True:
@always(clock.posedge)
def instance():
a.next = b
c.next = d
instances = [instance]
else:
@always(clock.posedge)
def instance():
c.next = d
a.foo.next = b.foo
a.bar.next = b.bar
instances = [instance]
return instances
clock = Signal(False)
a = Signal(intbv(0)[10:])
b = Signal(intbv(0)[10:])
#a = Interface()
#b = Interface()
c = Signal(intbv(0)[10:])
d = Signal(intbv(0)[10:])
foo = Foo(a, b, c, d, True, clock)
foo._inferInterface()
print foo.argnames
print foo.argdict
for each in foo.argnames:
print(each, len(foo.argdict[each]))
#foo.convert(hdl='Verilog')
foo.convert(hdl='VHDL')
foo.convert(hdl='VHDL')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment