Esempio n. 1
0
    def test_small_verilog_compose(self):
        i = 0
        errors = 0
        for ii, filename in enumerate(self.verilog_files):
            with self.subTest(i=ii):
                if os.path.getsize(filename) > 1024 * 10:
                    continue
                if filename.endswith(".zip"):
                    with tempfile.TemporaryDirectory() as tempdirectory:
                        # try:
                        print("*********************" + filename +
                              "*********************")
                        # vp = sdn.parsers.verilog.parser.VerilogParser.from_filename(os.path.join(directory, filename))
                        # netlist = vp.parse()
                        netlist = parsers.parse(filename)
                        composers.compose(
                            netlist,
                            os.path.join(
                                tempdirectory,
                                os.path.basename(filename) + "-spydrnet.v"))
                        #comp.run(netlist,"temp2/"+filename[:len(filename)-6] + "-spydrnet.v")
                        # comp.run(netlist,os.path.join(tempdirectory, filename[:len(filename)-6] + "-spydrnet.v"))
                        i += 1
                        print("pass")
                    # except Exception as identifier:
                    #     print("FAIL")
                    #     print(identifier)
                    #     errors += 1
                else:
                    continue

        print("processed", i, "errors", errors)

        assert errors == 0, "there were errors while parsing and composing files. Please see the output."
Esempio n. 2
0
    def test_simple_compose(self):

        i = 0
        errors = 0
        directory = os.path.join(sdn.base_dir, "support_files",
                                 "verilog_netlists")
        for filename in os.listdir(directory):
            if filename.endswith(".zip"):
                with tempfile.TemporaryDirectory() as tempdirectory:
                    # try:
                    print("*********************" + filename +
                          "*********************")
                    # vp = sdn.parsers.verilog.parser.VerilogParser.from_filename(os.path.join(directory, filename))
                    # netlist = vp.parse()
                    netlist = parsers.parse(os.path.join(directory, filename))
                    composers.compose(
                        netlist,
                        os.path.join(
                            tempdirectory,
                            filename[:len(filename) - 6] + "-spydrnet.v"))
                    #comp.run(netlist,"temp2/"+filename[:len(filename)-6] + "-spydrnet.v")
                    # comp.run(netlist,os.path.join(tempdirectory, filename[:len(filename)-6] + "-spydrnet.v"))
                    i += 1
                    print("pass")
                # except Exception as identifier:
                #     print("FAIL")
                #     print(identifier)
                #     errors += 1
            else:
                continue

        print("processed", i, "errors", errors)

        assert errors == 0, "there were errors while parsing and composing files. Please see the output."
Esempio n. 3
0
 def test_simple_parse(self):
     directory = os.path.join(sdn.base_dir, "support_files",
                              "verilog_netlists", "4bitadder.v.zip")
     #parser = parse#VerilogParser.from_filename(directory)
     netlist = parsers.parse(directory)
     print("hierarchy")
     self.simple_recursive_netlist_visualizer(netlist)
     print("Connectivity")
     self.simple_definition_information_visualizer(netlist)
Esempio n. 4
0
    def test_definition_list_option(self):
        for filename in glob.glob(
                os.path.join(self.dir_of_verilog_netlists,
                             "*4bitadder.v.zip")):
            with tempfile.TemporaryDirectory() as tempdirectory:
                netlist = parsers.parse(filename)
                out_file = os.path.join(
                    tempdirectory,
                    os.path.basename(filename) + "-spydrnet.v")
                composers.compose(netlist, out_file, definition_list=['adder'])

                with open(out_file, "r") as fp:
                    lines = fp.readlines()
                    print(len(lines))
                    m = list(filter(lambda x: x.startswith('module'), lines))
            self.assertGreater(len(m), 0, "Adder module not written")
            self.assertLess(len(m), 2, "Failed to write only definition_list")
            return
        raise AssertionError("Adder design not found " +
                             "definition_list options not tested,")
Esempio n. 5
0
def load_example_netlist_by_name(name):
    assert name in example_netlist_names, "Example netlist not found"
    return parse(os.path.join(base_dir, 'support_files', 'EDIF_netlists', name + ".edf.zip"))