def test_create_integration_record(self): integration = sdb_component.create_integration_record( information = "test integration", vendor_id = 0x1000000000000000, device_id = 0x00000000) self.assertTrue(integration.is_integration_record())
def test_full_bus_with_integration(self): sm = som.SOM() sm.initialize_root() root = sm.get_root() peripheral = sm.insert_bus() peripheral.set_name("peripheral") memory = sm.insert_bus() memory.set_name("memory") d1 = sdbc.create_device_record(name = "device 1", size = 0x100) d2 = sdbc.create_device_record(name = "device 2", size = 0x100) m1 = sdbc.create_device_record(name = "memory 1", size = 0x10000) m2 = sdbc.create_device_record(name = "memory 2", size = 0x20000) intr = sdbc.create_integration_record("Integration Data", vendor_id = 0x800BEAF15DEADC03, device_id = 0x00000000) peripheral.set_child_spacing(0x0100000000) sm.insert_component(peripheral, intr) sm.insert_component(peripheral, d1) sm.insert_component(peripheral, d2) sm.insert_component(memory, m1) sm.insert_component(memory, m2) rom = generate_rom_image(sm) rom_in = sdbc.convert_rom_to_32bit_buffer(rom) #rom_in = ROM2 #print_sdb_rom(rom_in) sm = parse_rom_image(rom_in) rom_out = generate_rom_image(sm) rom_out = sdbc.convert_rom_to_32bit_buffer(rom_out) #print_sdb_rom(rom_out) #compare_roms(rom_in, rom_out) self.assertEqual(rom_in, rom_out)
def test_get_all_component_as_urns(self): """ Go through all the devices and return a URN that will allow users to obtain a unique reference to a device """ som = self.nsm.som root = som.get_root() c = create_synthesis_record("test", 0, "xilinx", 14.1, "bill") som.insert_component(root, c) c = create_repo_url_record("http://www.example.com") som.insert_component(root, c) c = create_integration_record("integrating is fun") som.insert_component(root, c) urns = self.nsm.get_all_components_as_urns() #print urns self.assertIn("/top", urns) self.assertIn("/top/peripheral", urns) self.assertIn("/top/peripheral/SDB", urns) self.assertIn("/top/peripheral/uart1", urns) self.assertIn("/top/peripheral/gpio1", urns) self.assertIn("/top/memory", urns) self.assertIn("/top/memory/wb_sdram", urns)
def test_get_total_number_of_records(self): self.som.initialize_root() root = self.som.get_root() url = sdbc.create_repo_url_record("http://www.geocities.com") synthesis = sdbc.create_synthesis_record("Synthesis Name", 123, "cool tool", 1.0, "jeff") intr = sdbc.create_integration_record("Integration Data", vendor_id=0x800BEAF15DEADC03, device_id=0x00000000) peripheral = self.som.insert_bus() peripheral.set_name("peripheral") memory = self.som.insert_bus() memory.set_name("memory") self.som.insert_component(root, url) self.som.insert_component(root, synthesis) d1 = sdbc.create_device_record(name="device 1", size=0x100) d2 = sdbc.create_device_record(name="device 2", size=0x100) m1 = sdbc.create_device_record(name="memory 1", size=0x10000) m2 = sdbc.create_device_record(name="memory 2", size=0x20000) peripheral.set_child_spacing(0x0100000000) self.som.insert_component(peripheral, d1) self.som.insert_component(peripheral, d2) self.som.insert_component(peripheral, intr) self.som.insert_component(memory, m1) self.som.insert_component(memory, m2) count = get_total_number_of_records(self.som) print "count: %d" % count
def test_get_total_number_of_records(self): self.som.initialize_root() root = self.som.get_root() url = sdbc.create_repo_url_record("http://www.geocities.com") synthesis = sdbc.create_synthesis_record("Synthesis Name", 123, "cool tool", 1.0, "jeff") intr = sdbc.create_integration_record("Integration Data", vendor_id=0x800BEAF15DEADC03, device_id=0x00000000) peripheral = self.som.insert_bus() peripheral.set_name("peripheral") memory = self.som.insert_bus() memory.set_name("memory") self.som.insert_component(root, url) self.som.insert_component(root, synthesis) d1 = sdbc.create_device_record(name="device 1", size=0x100) d2 = sdbc.create_device_record(name="device 2", size=0x100) m1 = sdbc.create_device_record(name="memory 1", size=0x10000) m2 = sdbc.create_device_record(name="memory 2", size=0x20000) peripheral.set_child_spacing(0x0100000000) self.som.insert_component(peripheral, d1) self.som.insert_component(peripheral, d2) self.som.insert_component(peripheral, intr) self.som.insert_component(memory, m1) self.som.insert_component(memory, m2) count = get_total_number_of_records(self.som) print "count: %d" % count
def test_full_bus_with_integration(self): sm = som.SOM() sm.initialize_root() root = sm.get_root() peripheral = sm.insert_bus() peripheral.set_name("peripheral") memory = sm.insert_bus() memory.set_name("memory") d1 = sdbc.create_device_record(name="device 1", size=0x100) d2 = sdbc.create_device_record(name="device 2", size=0x100) m1 = sdbc.create_device_record(name="memory 1", size=0x10000) m2 = sdbc.create_device_record(name="memory 2", size=0x20000) intr = sdbc.create_integration_record("Integration Data", vendor_id=0x800BEAF15DEADC03, device_id=0x00000000) peripheral.set_child_spacing(0x0100000000) sm.insert_component(peripheral, intr) sm.insert_component(peripheral, d1) sm.insert_component(peripheral, d2) sm.insert_component(memory, m1) sm.insert_component(memory, m2) rom = generate_rom_image(sm) rom_in = sdbc.convert_rom_to_32bit_buffer(rom) #rom_in = ROM2 #print_sdb_rom(rom_in) sm = parse_rom_image(rom_in) rom_out = generate_rom_image(sm) rom_out = sdbc.convert_rom_to_32bit_buffer(rom_out) #print_sdb_rom(rom_out) #compare_roms(rom_in, rom_out) self.assertEqual(rom_in, rom_out)
def test_create_integration_record(self): integration = sdb_component.create_integration_record( information="test integration", vendor_id=0x1000000000000000, device_id=0x00000000) self.assertTrue(integration.is_integration_record())
def test_generate_one_sub_bus_integration_record(self): self.som.initialize_root() root = self.som.get_root() bus = self.som.insert_bus() intr = sdbc.create_integration_record("Integration Data", vendor_id=0x800BEAF15DEADC03, device_id=0x00000000) d = sdbc.create_device_record(name="device 1", size=0x100) self.som.insert_component(bus, d) self.som.insert_component(bus, intr) rom = generate_rom_image(self.som)
def test_generate_one_sub_bus_integration_record(self): self.som.initialize_root() root = self.som.get_root() bus = self.som.insert_bus() intr = sdbc.create_integration_record("Integration Data", vendor_id=0x800BEAF15DEADC03, device_id=0x00000000) d = sdbc.create_device_record(name="device 1", size=0x100) self.som.insert_component(bus, d) self.som.insert_component(bus, intr) rom = generate_rom_image(self.som)
def test_get_device_address(self): address = self.nsm.get_device_address("/top/peripheral/gpio1") som = self.nsm.som root = som.get_root() c = create_synthesis_record("test", 0, "xilinx", 14.1, "bill") som.insert_component(root, c) c = create_repo_url_record("http://www.example.com") som.insert_component(root, c) c = create_integration_record("integrating is fun") som.insert_component(root, c) self.assertEqual(address, long(0x02000000))
def test_get_integration_references(self): peripheral = self.nsm._get_component_from_urn("/top/peripheral") from_urn = "/top/peripheral/gpio1" from_pos = self.nsm.get_device_index_in_bus(from_urn) to_pos = self.nsm.get_device_index_in_bus("/top/peripheral/uart1") data = "from_pos:to_pos" data = "%d:%d,%d" % (from_pos, to_pos, to_pos) c = create_integration_record(data) som = self.nsm.som som.insert_component(peripheral, c) to_urns = self.nsm.get_integration_references(from_urn) #print "To URNs: %s" % str(to_urns) self.assertEqual(to_urns[0], "/top/peripheral/uart1") self.assertEqual(to_urns[1], "/top/peripheral/uart1")
def test_insert_integration_record(self): self.som.initialize_root() root = self.som.get_root() din1 = sdbc.create_device_record(name = "t0", size = 0x10) din2 = sdbc.create_device_record(name = "t1", size = 0x10) din3 = sdbc.create_device_record(name = "t3", size = 0x10) self.som.insert_component(root, din1) self.som.insert_component(root, din2) self.som.insert_component(root, din3) irec = sdbc.create_integration_record( "integration test", vendor_id = 0x00, device_id = 0x00) self.som.insert_component(root, irec, 0) record = self.som.get_component(root, 3) self.assertEqual(record, irec)
def generate_integration_record(slave_tags, slave): SDB_OFFSET = 1 integration_list = slave_tags[slave]["integration"] slave_list = slave_tags.keys() #print "slave list: %s" % str(slave_list) slave_pos = slave_list.index(slave) + SDB_OFFSET integration_buffer = "%d:" % slave_pos #Create an integration buffer for s in integration_list: #print "\tslave: %s" % s pos = int(slave_list.index(s)) + SDB_OFFSET #print "\t\tPosition: %d" % pos integration_buffer += str(pos) if integration_list.index(s) != len(integration_list) - 1: integration_buffer += "," c = sdbc.create_integration_record(information = integration_buffer) return c
def generate_integration_record(slave_tags, slave): SDB_OFFSET = 1 integration_list = slave_tags[slave]["integration"] slave_list = slave_tags.keys() #print "slave list: %s" % str(slave_list) slave_pos = slave_list.index(slave) + SDB_OFFSET integration_buffer = "%d:" % slave_pos #Create an integration buffer for s in integration_list: #print "\tslave: %s" % s pos = int(slave_list.index(s)) + SDB_OFFSET #print "\t\tPosition: %d" % pos integration_buffer += str(pos) if integration_list.index(s) != len(integration_list) - 1: integration_buffer += "," c = sdbc.create_integration_record(information=integration_buffer) return c
def test_generate_one_sub_bus_with_url(self): sm = som.SOM() sm.initialize_root() root = sm.get_root() peripheral = sm.insert_bus() peripheral.set_name("peripheral") memory = sm.insert_bus() memory.set_name("memory") d1 = sdbc.create_device_record(name="device 1", size=0x100) d2 = sdbc.create_device_record(name="device 2", size=0x100) m1 = sdbc.create_device_record(name="memory 1", size=0x10000) m2 = sdbc.create_device_record(name="memory 2", size=0x20000) intr = sdbc.create_integration_record("Integration Data", vendor_id=0x800BEAF15DEADC03, device_id=0x00000000) url = sdbc.create_repo_url_record("http://www.geocities.com") synthesis = sdbc.create_synthesis_record("Synthesis Name", 123, "cool tool", 1.0, "jeff") sm.insert_component(root, url) sm.insert_component(root, synthesis) peripheral.set_child_spacing(0x0100000000) sm.insert_component(peripheral, intr) sm.insert_component(peripheral, d1) sm.insert_component(peripheral, d2) sm.insert_component(memory, m1) sm.insert_component(memory, m2) rom = generate_rom_image(sm) rom_in = sdbc.convert_rom_to_32bit_buffer(rom) #print_sdb(rom) sm = parse_rom_image(rom_in) rom_out = generate_rom_image(sm) rom_out = sdbc.convert_rom_to_32bit_buffer(rom_out) #print_sdb_rom(rom_out) #compare_roms(rom_in, rom_out) self.assertEqual(rom_in, rom_out)
def test_generate_one_sub_bus_with_url(self): sm = som.SOM() sm.initialize_root() root = sm.get_root() peripheral = sm.insert_bus() peripheral.set_name("peripheral") memory = sm.insert_bus() memory.set_name("memory") d1 = sdbc.create_device_record(name = "device 1", size = 0x100) d2 = sdbc.create_device_record(name = "device 2", size = 0x100) m1 = sdbc.create_device_record(name = "memory 1", size = 0x10000) m2 = sdbc.create_device_record(name = "memory 2", size = 0x20000) intr = sdbc.create_integration_record("Integration Data", vendor_id = 0x800BEAF15DEADC03, device_id = 0x00000000) url = sdbc.create_repo_url_record("http://www.geocities.com") synthesis = sdbc.create_synthesis_record("Synthesis Name", 123, "cool tool", 1.0, "jeff") sm.insert_component(root, url) sm.insert_component(root, synthesis) peripheral.set_child_spacing(0x0100000000) sm.insert_component(peripheral, intr) sm.insert_component(peripheral, d1) sm.insert_component(peripheral, d2) sm.insert_component(memory, m1) sm.insert_component(memory, m2) rom = generate_rom_image(sm) rom_in = sdbc.convert_rom_to_32bit_buffer(rom) #print_sdb(rom) sm = parse_rom_image(rom_in) rom_out = generate_rom_image(sm) rom_out = sdbc.convert_rom_to_32bit_buffer(rom_out) #print_sdb_rom(rom_out) #compare_roms(rom_in, rom_out) self.assertEqual(rom_in, rom_out)