1
2
3
4
5import isystem.connect as ic
6
7
8winidea_id = ''
9
10def test_soc_ctrl_bus_access_batch():
11 conn_mgr = ic.ConnectionMgr()
12 conn_mgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
13
14 sess_ctrl = ic.CSessionCtrl(conn_mgr)
15 sess_ctrl.begin_reset()
16 soc = sess_ctrl.get_SoC('')
17
18 access_batch = ic.CAccessBatch()
19
20
21 base_ai = ic.SAddressInfo()
22 base_ai.dest_bus(bus_index=0)
23 base_ai.address(address=0xE0000000)
24 access_batch.set_base(base_ai)
25
26
27
32 write_data = ic.ByteVector([1, 2, 3, 4])
33 handle_write = access_batch.write(offset=0x04, data=write_data)
34
35
36
37
38 custom_ai = ic.SAddressInfo()
39 custom_ai.dest_bus(bus_index=0)
40 custom_ai.address(address=0x80000004)
41 write_data = ic.ByteVector([1, 2, 3, 4])
42
43 handle_write_a = access_batch.write_a(address_info=custom_ai, data=write_data)
44
45
46
47
48 cs_ai = ic.SAddressInfo()
49 cs_ai.dest_bus(bus_index=0)
50 cs_ai.address(address=0x80000004)
51 code_store = ic.CCodeStore(conn_mgr)
52 code_store.insert(0x000, ic.ByteVector([0x01, 0x02, 0x03, 0x04]))
53 code_store.insert(0x100, ic.ByteVector([0x7E, 0x57, 0xDA, 0x7A]))
54
55 handle_write_cs_a = access_batch.write_CS_a(address_info=cs_ai,
56 code_store=code_store)
57
58
59
64 handle_read = access_batch.read(offset=0x04, num_MAUs=4)
65
66
67
68
69 custom_ai = ic.SAddressInfo()
70 custom_ai.dest_bus(bus_index=0)
71 custom_ai.address(address=0x80000004)
72 handle_read_a = access_batch.read_a(address_info=custom_ai, num_MAUs=4)
73
74
75
80 data = ic.ByteVector([0x10, 0x22, 0x33, 0xAB])
81 mask = ic.ByteVector([0xFF, 0xF0, 0xFF, 0xFC])
82 handle_poll = access_batch.poll(offset=0x04,
83 data=data,
84 mask=mask,
85 timeout_us=100)
86
87
88
89
90 custom_ai = ic.SAddressInfo()
91 custom_ai.dest_bus(bus_index=0)
92 custom_ai.address(address=0x80000004)
93 data = ic.ByteVector([0x10, 0x22, 0x33, 0xAB])
94 mask = ic.ByteVector([0xFF, 0xF0, 0xFF, 0xFC])
95 handle_poll_a = access_batch.poll_a(address_info=custom_ai,
96 data=data,
97 mask=mask,
98 timeout_us=100)
99
100
101
106 data = ic.ByteVector([0xCC])
107 handle_fill = access_batch.fill(offset=0x04,
108 num_MAUs=0x100,
109 data=data)
110
111
112
113
114 custom_ai = ic.SAddressInfo()
115 custom_ai.dest_bus(bus_index=0)
116 custom_ai.address(address=0x80000004)
117 handle_fill_a = access_batch.fill_a(address_info=custom_ai,
118 num_MAUs=0x100,
119 data=data)
120
121
122
127 handle_ftrig = access_batch.ftrig(n_trig=5)
128
129
130
134 result = soc.access_batch(access_batch)
135
136
137
138
139 item = access_batch.item(handle_write)
140 print('Time: ' + str(item.time_us))
141
142
143 item = access_batch.item(handle_read)
144 data_str = '0x'
145 for data_byte in item.data:
146 data_str += f'{data_byte:02X}'
147 print('Data: ' + data_str)
148
149
150 item = access_batch.item(handle_read)
151 for access_info_index in range(len(item.access_info)):
152 if item.access_info[access_info_index] == ic.ACCESS_FAIL:
153 print(f'Access to MAU at index {access_info_index} failed')
154 else:
155 print(f'Access to MAU at index {access_info_index} OK')
156
157
158 item = access_batch.item(handle_poll)
159 print('Poll duration: ' + str(item.poll_duration_us))
160
161
162 pass
163
164
165if __name__ == '__main__':
166 test_soc_ctrl_bus_access_batch()