Skip to content

Commit

Permalink
Update linker test gold output
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Feb 6, 2019
1 parent b8fe80b commit 805c6f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 137 deletions.
1 change: 1 addition & 0 deletions magma/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import difflib


def check_files_equal(callee_file, file1_name, file2_name):
"""
Check if file1 == file2 where file1 and file2 are in the same path as
Expand Down
128 changes: 0 additions & 128 deletions tests/test_coreir/gold/linker_test0.json
Original file line number Diff line number Diff line change
@@ -1,133 +1,5 @@
{"top":"global.LinkerTest0",
"namespaces":{
"commonlib":{
"generators":{
"FifoMem":{
"typegen":"commonlib.FifoMemType",
"genparams":{"depth":"Int", "width":"Int"},
"defaultgenargs":{"depth":["Int",1024], "width":["Int",16]}
},
"LinebufferMem":{
"typegen":"commonlib.LinebufferMemType",
"genparams":{"depth":"Int", "width":"Int"},
"defaultgenargs":{"depth":["Int",1024], "width":["Int",16]}
},
"MAD":{
"typegen":"coreir.ternary",
"genparams":{"width":"Int"}
},
"Ram":{
"typegen":"commonlib.RamType",
"genparams":{"depth":"Int", "width":"Int"}
},
"abs":{
"typegen":"coreir.unary",
"genparams":{"width":"Int"}
},
"absd":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
},
"bitopn":{
"typegen":"commonlib.bitopN_type",
"genparams":{"N":"Int", "operator":"String"}
},
"const_array":{
"typegen":"coreir.constArrayTG",
"genparams":{"type":"CoreIRType", "value":"Int"},
"defaultgenargs":{"value":["Int",0]}
},
"counter":{
"typegen":"commonlib.counter_type",
"genparams":{"inc":"Int", "max":"Int", "min":"Int", "width":"Int"}
},
"deserializer":{
"typegen":"commonlib.deserializer_type",
"genparams":{"rate":"Int", "width":"Int"}
},
"div":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
},
"linebuffer":{
"typegen":"commonlib.lb_type",
"genparams":{"has_valid":"Bool", "image_type":"CoreIRType", "input_type":"CoreIRType", "output_type":"CoreIRType"},
"defaultgenargs":{"has_valid":["Bool",false]}
},
"linebuffer_recursive":{
"typegen":"commonlib.lb_recursive_type",
"genparams":{"has_valid":"Bool", "image_type":"CoreIRType", "input_type":"CoreIRType", "is_last_lb":"Bool", "output_type":"CoreIRType"}
},
"lutN":{
"typegen":"commonlib.lutNType",
"genparams":{"N":"Int"}
},
"muxn":{
"typegen":"commonlib.muxN_type",
"genparams":{"N":"Int", "width":"Int"}
},
"opn":{
"typegen":"commonlib.opN_type",
"genparams":{"N":"Int", "operator":"String", "width":"Int"}
},
"reg_array":{
"typegen":"coreir.regArrayTG",
"genparams":{"has_clr":"Bool", "has_en":"Bool", "has_rst":"Bool", "init":"Int", "type":"CoreIRType"},
"defaultgenargs":{"has_clr":["Bool",false], "has_en":["Bool",false], "has_rst":["Bool",false], "init":["Int",0]}
},
"sclamp":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
},
"serializer":{
"typegen":"commonlib.serializer_type",
"genparams":{"rate":"Int", "width":"Int"}
},
"smax":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"},
"modules":[
[{"width":["Int",16]},{
"type":["Record",[
["in0",["Array",16,"BitIn"]],
["in1",["Array",16,"BitIn"]],
["out",["Array",16,"Bit"]]
]]
}]
]
},
"smin":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
},
"uclamp":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
},
"umax":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
},
"umin":{
"typegen":"coreir.binary",
"genparams":{"width":"Int"}
}
},
"typegens":{
"FifoMemType":[{"depth":"Int", "width":"Int"},"implicit"],
"LinebufferMemType":[{"depth":"Int", "width":"Int"},"implicit"],
"RamType":[{"depth":"Int", "width":"Int"},"implicit"],
"bitopN_type":[{"N":"Int", "operator":"String"},"implicit"],
"counter_type":[{"inc":"Int", "max":"Int", "min":"Int", "width":"Int"},"implicit"],
"deserializer_type":[{"rate":"Int", "width":"Int"},"implicit"],
"lb_recursive_type":[{"has_valid":"Bool", "image_type":"CoreIRType", "input_type":"CoreIRType", "is_last_lb":"Bool", "output_type":"CoreIRType"},"implicit"],
"lb_type":[{"has_valid":"Bool", "image_type":"CoreIRType", "input_type":"CoreIRType", "output_type":"CoreIRType"},"implicit"],
"lutNType":[{"N":"Int"},"implicit"],
"muxN_type":[{"N":"Int", "width":"Int"},"implicit"],
"opN_type":[{"N":"Int", "operator":"String", "width":"Int"},"implicit"],
"serializer_type":[{"rate":"Int", "width":"Int"},"implicit"]
}
},
"global":{
"modules":{
"LinkerTest0":{
Expand Down
23 changes: 14 additions & 9 deletions tests/test_coreir/test_linking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import magma as m
from magma.frontend.coreir_ import coreir_typegen, DeclareCoreIRGenerator
from magma.testing import check_files_equal

# def smax_type_gen(context, values):
# width = values['width'].value
Expand All @@ -10,12 +11,13 @@
# "out": context.Array(width, context.Bit())
# })


@coreir_typegen
def smax_type_gen(width : int):
def smax_type_gen(width: int):
return Tuple(
in0 = m.Array(width, m.In(m.Bit)),
in1 = m.Array(width, m.In(m.BitIn)),
out = m.Array(width, m.In(m.Bit))
in0=m.Array(width, m.In(m.Bit)),
in1=m.Array(width, m.In(m.BitIn)),
out=m.Array(width, m.In(m.Bit))
)


Expand All @@ -25,7 +27,9 @@ def test_declare_generator():

class LinkerTest(m.Circuit):
name = "LinkerTest0"
IO = ["I0", m.In(m.Bits(width)), "I1", m.In(m.Bits(width)), "O", m.Out(m.Bits(width))]
IO = ["I0", m.In(m.Bits(width)), "I1", m.In(m.Bits(width)),
"O", m.Out(m.Bits(width))]

@classmethod
def definition(self):
Smax = DefineSmax(width=width)
Expand All @@ -35,7 +39,8 @@ def definition(self):
m.wire(self.O, smax.out)

dir_path = os.path.dirname(os.path.realpath(__file__))
m.compile(os.path.join(dir_path, "build/linker_test0"), LinkerTest, output="coreir")
with open(os.path.join(dir_path, "build/linker_test0.json"), "r") as actual:
with open(os.path.join(dir_path, "gold/linker_test0.json"), "r") as expected:
assert actual.read() == expected.read()
m.compile(os.path.join(dir_path, "build/linker_test0"), LinkerTest,
output="coreir")

assert check_files_equal(__file__, "build/linker_test0.json",
"gold/linker_test0.json")

0 comments on commit 805c6f3

Please sign in to comment.