Skip to content

Commit a0a6a5d

Browse files
Add actual checks to bus_idle test
Internal-tag: [#96240]
1 parent 85ccb9d commit a0a6a5d

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

verification/cocotb/top/lib_i3c_top/test_bus_idle.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
from interface import I3CTopTestInterface
99
from common import log_seed
1010

11+
12+
_BUS_IDLE_PATH = (
13+
"xi3c_wrapper.i3c.xcontroller.xcontroller_standby"
14+
".xcontroller_standby_i3c.xbus_timers.bus_idle_o"
15+
)
16+
17+
1118
async def test_setup(dut):
1219
cocotb.log.setLevel(logging.DEBUG)
1320
log_seed(dut)
@@ -27,13 +34,15 @@ async def test_setup(dut):
2734
await boot_init(tb, fclk=333.0)
2835
return i3c_controller, tb
2936

37+
3038
@cocotb.test()
31-
async def test_bus_idle_coverage(dut):
39+
async def test_bus_idle(dut):
3240
"""
33-
Coverage: bus_idle_o is toggled and reset_counter = 0 and bus_idle_o = 1.
41+
Ensures target enters and leaves bus idle state after certain delays.
3442
"""
3543
i3c_controller, tb = await test_setup(dut)
36-
44+
bus_idle_sig = getattr(dut, _BUS_IDLE_PATH)
45+
3746
# 1. Generate a manual STOP condition to start the bus timers
3847
# (The timer requires a STOP detection edge to restart its internal counters)
3948
dut._log.info("Generating STOP condition (SDA 0->1 while SCL=1) to start bus timers")
@@ -42,14 +51,16 @@ async def test_bus_idle_coverage(dut):
4251
await Timer(2, "us")
4352
i3c_controller.sda = 1 # STOP edge
4453
await Timer(2, "us")
45-
54+
4655
# 2. Wait > 200us for T_IDLE. This forces bus_idle_o to toggle 0 -> 1.
4756
dut._log.info("Waiting 210us for bus_idle_o to assert")
4857
await Timer(210, "us")
49-
58+
assert bus_idle_sig.value == 1, "Target should be in bus idle state"
59+
5060
# 3. Generate a manual START condition to break the idle state (1 -> 0 toggle)
5161
dut._log.info("Generating START condition (SDA 1->0 while SCL=1) to deassert bus_idle_o")
5262
i3c_controller.sda = 0
5363
await Timer(2, "us")
54-
55-
await tb.teardown()
64+
assert bus_idle_sig.value == 0, "Target should not be in bus idle state"
65+
66+
await tb.teardown()

0 commit comments

Comments
 (0)