Skip to content

Commit

Permalink
Merge 69e8228 into 473a925
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Oct 7, 2019
2 parents 473a925 + 69e8228 commit 81f8fbb
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_type/test_tuple.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import magma as m
from magma import *

def test_pair():
Expand Down Expand Up @@ -127,3 +128,46 @@ def test_val():
assert isinstance(b, BitType)
assert str(b) == 'a.x'


def test_nested():
# Test for https://github.com/phanrahan/magma/issues/445
def hierIO():
dictIO = {
"baseIO": baseIO(),
"ctr": m.In(m.Bit)
}
return m.Tuple(**dictIO)

def DefineCtrModule():
class ctrModule(m.Circuit):
name = "ctr_module"
IO = ["ctr",m.In(m.Bit)]
return ctrModule

def baseIO():
dictIO = {
"in0":m.In(m.Bit),
"out0":m.Out(m.Bit)
}
return m.Tuple(**dictIO)

def DefineBaseModule():
class baseModule(m.Circuit):
name = "base_module"
IO = ["baseIO",baseIO()]
return baseModule

def DefineHier():
class HierModule(m.Circuit):
name = "hier_module"
IO = ["hier", hierIO()]
@classmethod
def definition(io):
baseM = DefineBaseModule()()
ctrM = DefineCtrModule()()
m.wire(baseM.baseIO,io.hier.baseIO)
m.wire(ctrM.ctr,io.hier.ctr)
return HierModule

baseMH = DefineHier()
m.compile("build/baseMH", baseMH, output="coreir-verilog")

0 comments on commit 81f8fbb

Please sign in to comment.