Skip to content

Commit

Permalink
Add nesting test
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Aug 30, 2018
1 parent 29f2d34 commit bc5b9a1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_coreir/gold/test_nesting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{"top":"global.bar",
"namespaces":{
"global":{
"modules":{
"Foo":{
"type":["Record",[
["ifc",["Record",[["I","BitIn"],["O","Bit"]]]]
]],
"connections":[
["self.ifc.O","self.ifc.I"]
]
},
"bar":{
"type":["Record",[
["I",["Record",[["x",["Record",[["a","BitIn"],["b","BitIn"]]]],["y",["Record",[["a","Bit"],["b","Bit"]]]],["z",["Record",[["a","BitIn"],["b","Bit"]]]]]]]
]],
"instances":{
"inst0":{
"modref":"global.Foo"
},
"inst1":{
"modref":"global.Foo"
},
"inst2":{
"modref":"global.Foo"
}
},
"connections":[
["self.I.x.a","inst0.ifc.I"],
["self.I.y.a","inst0.ifc.O"],
["self.I.x.b","inst1.ifc.I"],
["self.I.y.b","inst1.ifc.O"],
["self.I.z.a","inst2.ifc.I"],
["self.I.z.b","inst2.ifc.O"]
]
}
}
}
}
}
19 changes: 19 additions & 0 deletions tests/test_coreir/test_coreir_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,24 @@ def test_multi_direction_tuple_instance_bulk():
assert check_files_equal(__file__, f"build/test_multi_direction_tuple_instance_bulk.json",
f"gold/test_multi_direction_tuple_instance.json")

def test_nesting():
bar = m.DefineCircuit("bar", "I", m.Tuple(x=m.In(m.Tuple(a=m.Bit, b=m.Bit)),
y=m.Out(m.Tuple(a=m.Bit, b=m.Bit)),
z=m.Tuple(a=m.In(m.Bit), b=m.Out(m.Bit))))
foo = def_foo()
foo_inst0 = foo()
foo_inst1 = foo()
foo_inst2 = foo()
m.wire(foo_inst0.ifc.I, bar.I.x.a)
m.wire(foo_inst0.ifc.O, bar.I.y.a)
m.wire(foo_inst1.ifc.I, bar.I.x.b)
m.wire(foo_inst1.ifc.O, bar.I.y.b)
m.wire(foo_inst2.ifc.I, bar.I.z.a)
m.wire(foo_inst2.ifc.O, bar.I.z.b)
m.EndCircuit()
m.compile("build/test_nesting", bar, output="coreir")
assert check_files_equal(__file__, f"build/test_nesting.json",
f"gold/test_nesting.json")

if __name__ == "__main__":
test_multi_direction_tuple()

0 comments on commit bc5b9a1

Please sign in to comment.