def round_read_write_message(self, schema, message): schema_dir = os.environ['INTERCHANGE_SCHEMA_PATH'] schema = get_schema(schema_dir, schema) for format1 in FORMATS: f = io.BytesIO() write_format(message, format1, f) f.seek(0) message_out = read_format(schema, format1, f) compare_capnp(self, message, message_out) for format2 in FORMATS: f2 = io.BytesIO() write_format(message_out, format2, f2) f2.seek(0) message_out2 = read_format(schema, format2, f2) compare_capnp(self, message, message_out2) compare_capnp(self, message_out, message_out2)
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)
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)
def test_parse_ecp5_constraints(self): schema = get_schema(os.environ['INTERCHANGE_SCHEMA_PATH'], 'device', 'Device.Constraints') path = os.path.join(__dir__, 'data', 'ecp5_constraints.yaml') with open(path, 'rb') as f: _ = read_format(schema, 'yaml', f)