import isystem.connect as ic
winidea_id = ''
def test_soc_ctrl_bus_access_batch():
conn_mgr = ic.ConnectionMgr()
conn_mgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
sess_ctrl = ic.CSessionCtrl(conn_mgr)
sess_ctrl.begin_reset()
soc = sess_ctrl.get_SoC('')
access_batch = ic.CAccessBatch()
base_ai = ic.SAddressInfo()
base_ai.dest_bus(bus_index=0)
base_ai.address(address=0xE0000000)
access_batch.set_base(base_ai)
write_data = ic.ByteVector([1, 2, 3, 4])
handle_write = access_batch.write(offset=0x04, data=write_data)
custom_ai = ic.SAddressInfo()
custom_ai.dest_bus(bus_index=0)
custom_ai.address(address=0x80000004)
write_data = ic.ByteVector([1, 2, 3, 4])
handle_write_a = access_batch.write_a(address_info=custom_ai, data=write_data)
cs_ai = ic.SAddressInfo()
cs_ai.dest_bus(bus_index=0)
cs_ai.address(address=0x80000004)
code_store = ic.CCodeStore(conn_mgr)
code_store.insert(0x000, ic.ByteVector([0x01, 0x02, 0x03, 0x04]))
code_store.insert(0x100, ic.ByteVector([0x7E, 0x57, 0xDA, 0x7A]))
handle_write_cs_a = access_batch.write_CS_a(address_info=cs_ai,
code_store=code_store)
handle_read = access_batch.read(offset=0x04, num_MAUs=4)
custom_ai = ic.SAddressInfo()
custom_ai.dest_bus(bus_index=0)
custom_ai.address(address=0x80000004)
handle_read_a = access_batch.read_a(address_info=custom_ai, num_MAUs=4)
data = ic.ByteVector([0x10, 0x22, 0x33, 0xAB])
mask = ic.ByteVector([0xFF, 0xF0, 0xFF, 0xFC])
handle_poll = access_batch.poll(offset=0x04,
data=data,
mask=mask,
timeout_us=100)
custom_ai = ic.SAddressInfo()
custom_ai.dest_bus(bus_index=0)
custom_ai.address(address=0x80000004)
data = ic.ByteVector([0x10, 0x22, 0x33, 0xAB])
mask = ic.ByteVector([0xFF, 0xF0, 0xFF, 0xFC])
handle_poll_a = access_batch.poll_a(address_info=custom_ai,
data=data,
mask=mask,
timeout_us=100)
data = ic.ByteVector([0xCC])
handle_fill = access_batch.fill(offset=0x04,
num_MAUs=0x100,
data=data)
custom_ai = ic.SAddressInfo()
custom_ai.dest_bus(bus_index=0)
custom_ai.address(address=0x80000004)
handle_fill_a = access_batch.fill_a(address_info=custom_ai,
num_MAUs=0x100,
data=data)
handle_ftrig = access_batch.ftrig(n_trig=5)
result = soc.access_batch(access_batch)
if result == ic.CAccessBatch.EAccessBatchResult_OK:
print('Access batch OK')
else:
print(f'Access batch failed with error: {result}')
item = access_batch.item(handle_write)
print('Time: ' + str(item.time_us))
item = access_batch.item(handle_read)
data_str = '0x'
for data_byte in item.data:
data_str += f'{data_byte:02X}'
print('Data: ' + data_str)
item = access_batch.item(handle_read)
for access_info_index in range(len(item.access_info)):
if item.access_info[access_info_index] == ic.ACCESS_FAIL:
print(f'Access to MAU at index {access_info_index} failed')
else:
print(f'Access to MAU at index {access_info_index} OK')
item = access_batch.item(handle_poll)
print('Poll duration: ' + str(item.poll_duration_us))
item = access_batch.item(handle_read)
print('Read duration: ' + str(item.memory_access_duration))
pass
if __name__ == '__main__':
test_soc_ctrl_bus_access_batch()