コード例 #1
0
    def test_physical_netlist_convert(self):
        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])
        netlist_capnp = phys_netlist.convert_to_capnp(interchange)

        self.round_read_write_message('physical', netlist_capnp)
コード例 #2
0
    def test_physical_netlist_rapidyaml(self):
        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])
        netlist_capnp = phys_netlist.convert_to_capnp(interchange)

        self.round_trip_rapidyaml('phys', netlist_capnp)
コード例 #3
0
    def test_device_rapidyaml(self):
        return
        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])

        with open(
                os.path.join(os.environ['DEVICE_RESOURCE_PATH'],
                             phys_netlist.part + '.device'), 'rb') as f:
            dev_message = interchange.read_device_resources_raw(f)

        self.round_trip_rapidyaml('device', dev_message)
コード例 #4
0
    def test_physical_netlist(self):
        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])

        with tempfile.NamedTemporaryFile('w+b') as f:
            netlist_capnp = phys_netlist.convert_to_capnp(interchange)
            write_capnp_file(netlist_capnp, f)
            f.seek(0)
            read_phys_netlist = PhysicalNetlist.read_from_capnp(f, interchange)

        self.assertEqual(len(phys_netlist.placements),
                         len(read_phys_netlist.placements))
コード例 #5
0
    def test_simple_placement(self):
        netlist = example_logical_netlist()
        cells = create_constraint_cells_from_netlist(
            netlist, filtered_out={'GND', 'VCC'})

        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])

        with open(
                os.path.join(os.environ['DEVICE_RESOURCE_PATH'],
                             phys_netlist.part + '.device'), 'rb') as f:
            dev_message = interchange.read_device_resources_raw(f)

        dev_message = dev_message.as_builder()

        path = os.path.join(__dir__, 'data', 'series7_constraints.yaml')
        with open(path, 'rb') as f:
            patch_capnp(dev_message, ['constraints'], 'yaml', f)

        device = DeviceResources(dev_message)

        allowed_sites = {
            'IOB_X0Y0',
            'IOB_X0Y1',
            'IOB_X0Y2',
            'SLICE_X0Y0',
            'BUFGCTRL_X0Y0',
        }

        model, placement_oracle, placements = make_problem_from_device(
            device, allowed_sites)

        solver = model.build_sat(placements, cells, placement_oracle)
        clauses = solver.prepare_for_sat()

        with Solver() as sat:
            for clause in clauses:
                sat.add_clause(clause)

            solved = sat.solve()
            self.assertTrue(solved)
コード例 #6
0
    def setUp(self):
        schema = get_schema(os.environ['INTERCHANGE_SCHEMA_PATH'], 'device',
                            'Device.Constraints')
        path = os.path.join(__dir__, 'data', 'series7_constraints.yaml')
        with open(path, 'rb') as f:
            constraints = read_format(schema, 'yaml', f)

        self.model = Constraints()
        self.model.read_constraints(constraints)

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])
        phys_netlist = example_physical_netlist()
        with open(
                os.path.join(os.environ['DEVICE_RESOURCE_PATH'],
                             phys_netlist.part + '.device'), 'rb') as f:
            device = interchange.read_device_resources(f)

        self.placement_oracle = PlacementOracle()
        self.placement_oracle.add_sites_from_device(device)
コード例 #7
0
    def test_check_routing_tree_and_stitch_segments(self):
        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])

        with open(
                os.path.join(os.environ['DEVICE_RESOURCE_PATH'],
                             phys_netlist.part + '.device'), 'rb') as f:
            device_resources = interchange.read_device_resources(f)

        phys_netlist.check_physical_nets(device_resources)
        before_stitch = phys_netlist.get_normalized_tuple_tree(
            device_resources)
        phys_netlist.stitch_physical_nets(device_resources)
        after_stitch = phys_netlist.get_normalized_tuple_tree(device_resources)
        phys_netlist.stitch_physical_nets(device_resources, flatten=True)
        after_stitch_from_flat = phys_netlist.get_normalized_tuple_tree(
            device_resources)

        self.assertEqual(len(before_stitch), len(after_stitch))
        self.assertEqual(len(before_stitch), len(after_stitch_from_flat))

        bad_nets = set()
        for net in before_stitch:
            if before_stitch[net] != after_stitch[net]:
                bad_nets.add(net)
                print(net)
                pprint.pprint(before_stitch[net])
                pprint.pprint(after_stitch[net])

            if before_stitch[net] != after_stitch_from_flat[net]:
                bad_nets.add(net)
                print(net)
                pprint.pprint(before_stitch[net])
                pprint.pprint(after_stitch_from_flat[net])

        self.assertEqual(set(), bad_nets)
コード例 #8
0
    def test_patch_series7_constraints(self):
        phys_netlist = example_physical_netlist()

        interchange = Interchange(
            schema_directory=os.environ['INTERCHANGE_SCHEMA_PATH'])

        with open(
                os.path.join(os.environ['DEVICE_RESOURCE_PATH'],
                             phys_netlist.part + '.device'), 'rb') as f:
            dev_message = interchange.read_device_resources_raw(f)

        dev_message = dev_message.as_builder()

        path = os.path.join(__dir__, 'data', 'series7_constraints.yaml')
        with open(path, 'rb') as f:
            patch_capnp(dev_message, ['constraints'], 'yaml', f)

        schema = get_schema(os.environ['INTERCHANGE_SCHEMA_PATH'], 'device',
                            'Device.Constraints')
        with open(path, 'rb') as f:
            series7 = read_format(schema, 'yaml', f)

        compare_capnp(self, series7, dev_message.constraints)