예제 #1
0
 def test_wire_outside(self):
     search = list(
         sdn.get_cables(
             self.netlist.top_instance.reference.cables[0].wires[0],
             selection="OUTSIDE"))
     self.assertEqual(len(search), 1)
     self.assertEqual(search[0].name, "middle_cable")
예제 #2
0
    def compare_definition(self, definition_orig, definition_composer, check_identifier=True):
        if check_identifier:
            assert self.get_identifier(definition_orig) == self.get_identifier(definition_composer), \
                "Definitions do not have the same identifier"
            assert self.get_original_identifier(definition_orig) == self.get_original_identifier(definition_composer), \
                "Definitions do not have the same original identifier"

        assert len(definition_orig.ports) == len(definition_composer.ports), \
            "Definitions do not have the same number of ports"
        # for orig_port, composer_port in zip(definition_orig.ports, definition_composer.ports):
        #     self.compare_ports(orig_port, composer_port)
        # do a smarter compare
        for orig_port in definition_orig.ports:
            if orig_port.name == None:
                #ports with no name are not compared
                print("WARNING: ports with name == None exist and are not compared")
                continue
            else:
                patterns = orig_port.name
            composer_port = next(sdn.get_ports(definition_composer, patterns))
            self.compare_ports(orig_port, composer_port)

        assert len(definition_orig.cables) == len(definition_composer.cables), \
            "Definitions do not have the same number of cables"
        
        for orig_cable in definition_orig.cables:
            if orig_cable.name == None:
                #ports with no name are not compared
                print("WARNING: cables with name == None exist and are not compared")
                continue
            else:
                patterns = orig_cable.name
            composer_cable = next(sdn.get_cables(definition_composer, patterns))
            self.compare_cables(orig_cable, composer_cable)

        assert len(definition_orig.children) == len(definition_composer.children), \
            "Definitions do not have the same number of instances"
        # for orig_instance, composer_cable in zip(definition_orig.children, definition_composer.children):
        #     self.compare_instances(orig_instance, composer_cable)
        for orig_instance in definition_orig.children:
            if orig_instance.name == None:
                #ports with no name are not compared
                print("WARNING: children with name == None exist and are not compared")
                continue
            else:
                if orig_instance.name.startswith("SDN_Assignment_"):
                    #skip assignment statements for now
                    continue
                else:
                    patterns = orig_instance.name
            try:
                composer_instance = next(sdn.get_instances(definition_composer, patterns))
            except Exception:
                import pdb; pdb.set_trace()
            self.compare_instances(orig_instance, composer_instance)
        
        #compare assignemnt statements
        pattern = "SDN_Assignment_*"
        composer_generator = sdn.get_instances(definition_composer, pattern)
        orig_generator = sdn.get_instances(definition_orig, pattern)
        #i just need to make sure that they both contain the same number of each width assignment
        composer_dict = dict()
        orig_dict = dict()
        
        ci = next(composer_generator, None)
        while ci is not None:
            num = ci.name.split("_")[3]
            if num in composer_dict:
                composer_dict[num] += 1
            else:
                composer_dict[num] = 1
            ci = next(composer_generator, None)
        
        oi = next(orig_generator, None)
        while oi is not None:
            num = oi.name.split("_")[3]
            if num in orig_dict:
                orig_dict[num] +=1
            else:
                orig_dict[num] = 1
            oi = next(orig_generator, None)

        for k in composer_dict.keys():
            assert k in orig_dict and orig_dict[k] == composer_dict[k], "there are a different number of "+ str(k) + " width assignment"
예제 #3
0
 def test_collection(self):
     definition = sdn.Definition()
     cable = definition.create_cable()
     cable.name = "MY_CABLE"
     cables = list(sdn.get_cables([definition, definition]))
     self.assertEqual(len(cables), 1)
예제 #4
0
 def test_absolute_name_from_relative_reference(self):
     search = next(sdn.get_cables(self.middle_inst, "middle_cable"))
     self.assertEqual(search, self.middle_inst.reference.cables[0])
예제 #5
0
 def test_wires_all(self):
     search = list(
         sdn.get_cables(
             self.netlist.top_instance.reference.cables[0].wires[0],
             selection="ALL"))
     self.assertEqual(len(search), 3)
예제 #6
0
 def test_wire_inside(self):
     search = list(
         sdn.get_cables(
             self.netlist.top_instance.reference.cables[0].wires[0]))
     self.assertEqual(len(search), 1)
     self.assertEqual(search[0].name, "top_cable")
예제 #7
0
 def test_outer_pin(self):
     search = list(sdn.get_cables(self.middle_inst.pins, selection="ALL"))
     self.assertEqual(len(search), 3)
예제 #8
0
 def test_port(self):
     port = self.netlist.top_instance.reference.ports[0]
     search = list(sdn.get_cables(port))
     self.assertEqual(len(search), 1)
     self.assertEqual(port.pins[0].wire.cable, search[0])
예제 #9
0
 def test_href_to_cable_all(self):
     href = next(sdn.get_hcables(self.middle_inst))
     search = list(sdn.get_cables(href, selection="ALL"))
     self.assertEqual(len(search), 3)
예제 #10
0
 def test_href_to_cable(self):
     href = next(sdn.get_hcables(self.middle_inst))
     search = next(sdn.get_cables(href))
     self.assertEqual(href.item, search)
예제 #11
0
 def test_select_all(self):
     middle_def = self.middle_inst.reference
     search = list(sdn.get_cables(middle_def, selection="ALL"))
     self.assertEqual(len(search), 3)