Skip to content

Commit 380d308

Browse files
robertszczepanskikgugala
authored andcommitted
Adjust Recovery test to improved register descriptions
1 parent 77e96f9 commit 380d308

File tree

10 files changed

+291
-208
lines changed

10 files changed

+291
-208
lines changed

verification/cocotb/block/bus_tx/test_bus_tx.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ async def setup_test(dut, timings=None, scl_clk_ratio=SCL_CLK_RATIO):
3838

3939
if timings is None:
4040
timings = {
41-
"t_r": 2,
42-
"t_f": 2,
41+
"t_r": 2,
42+
"t_f": 2,
4343
"t_su": 5,
4444
"t_hd": 5,
4545
}
@@ -73,7 +73,7 @@ async def assert_drive_start(dut, sda_value):
7373
await RisingEdge(dut.clk_i)
7474
await ReadOnly()
7575

76-
t_r = int(dut.t_r_i.value)
76+
t_r = int(dut.t_r_i.value)
7777
t_su = int(dut.t_su_dat_i.value)
7878
if (t_r + t_su) == 0:
7979
# SDA should be driven 1 cycle after SCL negedge
@@ -122,6 +122,7 @@ async def send_bit(dut, value):
122122
assert dut.tx_idle_o.value == 0
123123
await RisingEdge(dut.clk_i)
124124

125+
125126
async def send_byte(dut, data):
126127
for i in range(8):
127128
bit = ((data << i) & 0x80) != 0
@@ -137,15 +138,15 @@ async def test_bit_tx_negedge(dut, value, timings, ratio):
137138
timings = None
138139
elif timings == "1":
139140
timings = {
140-
"t_r": 1,
141-
"t_f": 1,
141+
"t_r": 1,
142+
"t_f": 1,
142143
"t_su": 1,
143144
"t_hd": 1,
144145
}
145146
elif timings == "0":
146147
timings = {
147-
"t_r": 0,
148-
"t_f": 0,
148+
"t_r": 0,
149+
"t_f": 0,
149150
"t_su": 0,
150151
"t_hd": 0,
151152
}

verification/cocotb/block/ctrl_edge_detector/test_edge_detector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
from cocotb.handle import SimHandleBase
88
from cocotb.triggers import ClockCycles, RisingEdge
99

10+
1011
async def setup(dut):
1112
"""
1213
Sets up a base for testing
1314
"""
1415

1516
cocotb.log.setLevel("INFO")
1617

17-
dut.trigger.value = 0
18-
dut.line.value = 0
18+
dut.trigger.value = 0
19+
dut.line.value = 0
1920

2021
clock = Clock(dut.clk_i, 2, units="ns")
2122
cocotb.start_soon(clock.start())
@@ -65,7 +66,7 @@ async def test_pretrigger_with_delay(dut: SimHandleBase):
6566
cycles = await count_cycles(clk, dut.detect)
6667

6768
# Check cycle count
68-
assert cycles == DELAY+1
69+
assert cycles == DELAY + 1
6970

7071

7172
@cocotb.test()

verification/cocotb/block/ctrl_i3c_bus_monitor/test_i3c_bus_monitor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import cocotb
77
from cocotb.clock import Clock
88
from cocotb.handle import SimHandleBase
9-
from cocotb.triggers import ClockCycles, RisingEdge, ReadOnly
9+
from cocotb.triggers import ClockCycles, ReadOnly, RisingEdge
1010

1111

1212
async def setup(dut):
@@ -45,6 +45,7 @@ def create_default_controller(dut: SimHandleBase) -> I3cController:
4545
speed=12.5e6,
4646
)
4747

48+
4849
@cocotb.test()
4950
async def test_bus_monitor_hdr_exit(dut: SimHandleBase):
5051
"""

verification/cocotb/common/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def or_null(d, idx):
267267

268268
byte_idx += 4
269269

270+
270271
def format_ibi_data(mdb, data):
271272
"""
272273
Given MDB and a list of data bytes (can be empty) prepare a sequence of
@@ -309,4 +310,3 @@ async def get_interrupt_status(tb):
309310
intrs[key] = state
310311

311312
return intrs
312-

verification/cocotb/noxfile.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ def _verify(session, test_group, test_type, test_name, coverage=None, simulator=
4343
"COCOTB_RESULTS_FILE=" + test.filenames["xml"],
4444
]
4545
if simulator == "verilator":
46-
plusargs.extend([
47-
"+verilator+rand+reset+2",
48-
f"+verilator+seed+{seed}",
49-
])
46+
plusargs.extend(
47+
[
48+
"+verilator+rand+reset+2",
49+
f"+verilator+seed+{seed}",
50+
]
51+
)
5052
if coverage:
5153
args.append("COVERAGE_TYPE=" + coverage)
5254

verification/cocotb/top/lib_i3c_top/boot.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def common_procedure(tb: I3CTopTestInterface):
5252
return core_config
5353

5454

55-
async def boot_init(tb: I3CTopTestInterface, timings = None):
55+
async def boot_init(tb: I3CTopTestInterface, timings=None):
5656
"""
5757
Boot sequence model should match the description in "Boot and Initialization" chapter of the documentation.
5858
@@ -65,20 +65,16 @@ async def boot_init(tb: I3CTopTestInterface, timings = None):
6565
# Timing configuration. When none set all to zeros
6666
if timings is None:
6767
timings = {
68-
"T_R": 0,
69-
"T_F": 0,
68+
"T_R": 0,
69+
"T_F": 0,
7070
"T_HD_DAT": 0,
7171
"T_SU_DAT": 0,
7272
}
7373

74-
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_R_REG.base_addr,
75-
timings["T_R"])
76-
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_F_REG.base_addr,
77-
timings["T_F"])
78-
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_HD_DAT_REG.base_addr,
79-
timings["T_HD_DAT"])
80-
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_SU_DAT_REG.base_addr,
81-
timings["T_SU_DAT"])
74+
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_R_REG.base_addr, timings["T_R"])
75+
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_F_REG.base_addr, timings["T_F"])
76+
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_HD_DAT_REG.base_addr, timings["T_HD_DAT"])
77+
await _write_csr(tb, tb.reg_map.I3C_EC.SOCMGMTIF.T_SU_DAT_REG.base_addr, timings["T_SU_DAT"])
8278

8379
await setup_hci_thresholds(tb)
8480

@@ -235,7 +231,7 @@ async def umbrella_stby_init(tb):
235231
await tb.write_csr_field(
236232
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.base_addr,
237233
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.VIRT_STATIC_ADDR,
238-
0x5b,
234+
0x5B,
239235
)
240236
await tb.write_csr_field(
241237
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.base_addr,

verification/cocotb/top/lib_i3c_top/test_ccc.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ async def test_ccc_setdasa(dut):
9898
)
9999
dynamic_address_reg_addr = tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.base_addr
100100
dynamic_address_reg_value = tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.DYNAMIC_ADDR
101-
virtual_dynamic_address_reg_addr = tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.base_addr
102-
virtual_dynamic_address_reg_value = tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.VIRT_DYNAMIC_ADDR
101+
virtual_dynamic_address_reg_addr = (
102+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.base_addr
103+
)
104+
virtual_dynamic_address_reg_value = (
105+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.VIRT_DYNAMIC_ADDR
106+
)
103107
dynamic_address_reg_valid = (
104108
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.DYNAMIC_ADDR_VALID
105109
)
@@ -110,14 +114,18 @@ async def test_ccc_setdasa(dut):
110114
dynamic_address_valid = await tb.read_csr_field(
111115
dynamic_address_reg_addr, dynamic_address_reg_valid
112116
)
113-
virt_dynamic_address = await tb.read_csr_field(virtual_dynamic_address_reg_addr, virtual_dynamic_address_reg_value)
117+
virt_dynamic_address = await tb.read_csr_field(
118+
virtual_dynamic_address_reg_addr, virtual_dynamic_address_reg_value
119+
)
114120
virt_dynamic_address_valid = await tb.read_csr_field(
115121
virtual_dynamic_address_reg_addr, virtual_dynamic_address_reg_valid
116122
)
117123
assert dynamic_address == DYNAMIC_ADDR, "Unexpected DYNAMIC ADDRESS read from the CSR"
118124
assert dynamic_address_valid == 1, "New DYNAMIC ADDRESS is not set as valid"
119125

120-
assert virt_dynamic_address == VIRT_DYNAMIC_ADDR, "Unexpected VIRT DYNAMIC ADDRESS read from the CSR"
126+
assert (
127+
virt_dynamic_address == VIRT_DYNAMIC_ADDR
128+
), "Unexpected VIRT DYNAMIC ADDRESS read from the CSR"
121129
assert virt_dynamic_address_valid == 1, "New VIRT DYNAMIC ADDRESS is not set as valid"
122130

123131

@@ -220,9 +228,7 @@ async def test_ccc_getmrl(dut):
220228
i3c_controller, _, tb = await test_setup(dut)
221229
await ClockCycles(tb.clk, 50)
222230

223-
responses = await i3c_controller.i3c_ccc_read(
224-
ccc=command, addr=TGT_ADR, count=3
225-
)
231+
responses = await i3c_controller.i3c_ccc_read(ccc=command, addr=TGT_ADR, count=3)
226232
[mrl_msb, mrl_lsb, ibi_payload_size] = responses[0][1]
227233

228234
mrl = (mrl_msb << 8) | mrl_lsb
@@ -500,9 +506,9 @@ async def test_ccc_direct_multiple_wr(dut):
500506

501507
cccs = [
502508
(TGT_ADR - 1, (0x00, 0xA0)),
503-
(TGT_ADR, (0x00, 0xA1)),
504-
(TGT_ADR, (0x00, 0xA2)),
505-
(TGT_ADR + 2, (0x00, 0xA3)), # TGT_ADR + 1 is set as virtual target static address
509+
(TGT_ADR, (0x00, 0xA1)),
510+
(TGT_ADR, (0x00, 0xA2)),
511+
(TGT_ADR + 2, (0x00, 0xA3)), # TGT_ADR + 1 is set as virtual target static address
506512
]
507513

508514
# Send CCCs
@@ -537,8 +543,9 @@ async def test_ccc_direct_multiple_rd(dut):
537543
await ClockCycles(tb.clk, 50)
538544

539545
# Set MWL in the target
540-
acks = await i3c_controller.i3c_ccc_write(ccc=CCC.DIRECT.SETMWL,
541-
directed_data=[(TGT_ADR, (0x00, 0x55))])
546+
acks = await i3c_controller.i3c_ccc_write(
547+
ccc=CCC.DIRECT.SETMWL, directed_data=[(TGT_ADR, (0x00, 0x55))]
548+
)
542549
if acks != [True]:
543550
dut._log.error("Initial SETMWL failed")
544551
assert False
@@ -547,8 +554,7 @@ async def test_ccc_direct_multiple_rd(dut):
547554

548555
# Issue multiple directed GETMWL
549556
addrs = [TGT_ADR - 1, TGT_ADR, TGT_ADR, TGT_ADR + 2]
550-
responses = await i3c_controller.i3c_ccc_read(ccc=CCC.DIRECT.GETMWL,
551-
addr=addrs, count=2)
557+
responses = await i3c_controller.i3c_ccc_read(ccc=CCC.DIRECT.GETMWL, addr=addrs, count=2)
552558

553559
# Check ACKs
554560
acks = [r[0] for r in responses]

0 commit comments

Comments
 (0)