From 6f0cbe5d5b3acd551c65e1af72bb7e34fba389cb Mon Sep 17 00:00:00 2001 From: Ankita Navadiya Date: Thu, 23 Apr 2026 01:55:08 +0000 Subject: [PATCH 1/4] I3C buse_timers.sv Coverage Gaps #200 Internal-tag: [#96240] Signed-off-by: Ankita Navadiya --- verification/cocotb/noxfile.py | 2 + .../cocotb/top/lib_i3c_top/test_bus_idle.py | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 verification/cocotb/top/lib_i3c_top/test_bus_idle.py diff --git a/verification/cocotb/noxfile.py b/verification/cocotb/noxfile.py index d45c868cb..4fd815064 100644 --- a/verification/cocotb/noxfile.py +++ b/verification/cocotb/noxfile.py @@ -312,6 +312,7 @@ def i2c_target_fsm_verify(session, test_group, test_name, coverage, simulator): "test_ibi_multi_queue", "test_te_errors", "test_tsco_violation", + "test_bus_idle", ], ) @nox.parametrize("coverage", coverage_types) @@ -339,6 +340,7 @@ def i3c_ahb_verify(session, test_group, test_name, coverage, simulator): "test_ibi_multi_queue", "test_te_errors", "test_tsco_violation", + "test_bus_idle", ], ) @nox.parametrize("coverage", coverage_types) diff --git a/verification/cocotb/top/lib_i3c_top/test_bus_idle.py b/verification/cocotb/top/lib_i3c_top/test_bus_idle.py new file mode 100644 index 000000000..7e9e6862b --- /dev/null +++ b/verification/cocotb/top/lib_i3c_top/test_bus_idle.py @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: Apache-2.0 + +import logging +import cocotb +from cocotb.triggers import ClockCycles, Timer +from boot import boot_init +from i3c_controller_fixed import I3cControllerFixed as I3cController +from interface import I3CTopTestInterface +from common import log_seed + +async def test_setup(dut): + cocotb.log.setLevel(logging.DEBUG) + log_seed(dut) + i3c_controller = I3cController( + sda_i=dut.bus_sda, sda_o=dut.sda_sim_ctrl_i, + scl_i=dut.bus_scl, scl_o=dut.scl_sim_ctrl_i, + debug_state_o=None, speed=12.5e6, + ) + i3c_controller.monitor_enable.clear() + await i3c_controller.monitor_idle.wait() + dut.sda_sim_target_i.value = 1 + dut.scl_sim_target_i.value = 1 + dut.peripheral_reset_done_i.value = 0 + tb = I3CTopTestInterface(dut) + await tb.setup(fclk=333.0) + await ClockCycles(tb.clk, 50) + await boot_init(tb, fclk=333.0) + return i3c_controller, tb + +@cocotb.test() +async def test_bus_idle_coverage(dut): + """ + Coverage: bus_idle_o is toggled and reset_counter = 0 and bus_idle_o = 1. + """ + i3c_controller, tb = await test_setup(dut) + + # 1. Generate a manual STOP condition to start the bus timers + # (The timer requires a STOP detection edge to restart its internal counters) + dut._log.info("Generating STOP condition (SDA 0->1 while SCL=1) to start bus timers") + i3c_controller.scl = 1 + i3c_controller.sda = 0 + await Timer(2, "us") + i3c_controller.sda = 1 # STOP edge + await Timer(2, "us") + + # 2. Wait > 200us for T_IDLE. This forces bus_idle_o to toggle 0 -> 1. + dut._log.info("Waiting 210us for bus_idle_o to assert") + await Timer(210, "us") + + # 3. Generate a manual START condition to break the idle state (1 -> 0 toggle) + dut._log.info("Generating START condition (SDA 1->0 while SCL=1) to deassert bus_idle_o") + i3c_controller.sda = 0 + await Timer(2, "us") + + await tb.teardown() \ No newline at end of file From 7f00458818089eaa2c0f50568033394ad570461f Mon Sep 17 00:00:00 2001 From: Robert Szczepanski Date: Wed, 6 May 2026 14:12:17 +0200 Subject: [PATCH 2/4] Add i3c_bus_idle.py to AHB and AXI test suites Internal-tag: [#96240] --- verification/cocotb/noxfile.py | 1 + verification/cocotb/top/i3c_ahb/test_bus_idle.py | 1 + verification/cocotb/top/i3c_axi/test_bus_idle.py | 1 + 3 files changed, 3 insertions(+) create mode 120000 verification/cocotb/top/i3c_ahb/test_bus_idle.py create mode 120000 verification/cocotb/top/i3c_axi/test_bus_idle.py diff --git a/verification/cocotb/noxfile.py b/verification/cocotb/noxfile.py index 4fd815064..b4e1ebbc6 100644 --- a/verification/cocotb/noxfile.py +++ b/verification/cocotb/noxfile.py @@ -532,6 +532,7 @@ def recovery_pec_verify(session, test_group, test_name, coverage, simulator): "test_ibi_multi_queue", "test_te_errors", "test_tsco_violation", + "test_bus_idle", ], ) @nox.parametrize("coverage", coverage_types) diff --git a/verification/cocotb/top/i3c_ahb/test_bus_idle.py b/verification/cocotb/top/i3c_ahb/test_bus_idle.py new file mode 120000 index 000000000..943f955d7 --- /dev/null +++ b/verification/cocotb/top/i3c_ahb/test_bus_idle.py @@ -0,0 +1 @@ +verification/cocotb/top/lib_i3c_top/test_bus_idle.py \ No newline at end of file diff --git a/verification/cocotb/top/i3c_axi/test_bus_idle.py b/verification/cocotb/top/i3c_axi/test_bus_idle.py new file mode 120000 index 000000000..943f955d7 --- /dev/null +++ b/verification/cocotb/top/i3c_axi/test_bus_idle.py @@ -0,0 +1 @@ +verification/cocotb/top/lib_i3c_top/test_bus_idle.py \ No newline at end of file From 4f18c35833496bfdce5edfbc76455d3076f08b26 Mon Sep 17 00:00:00 2001 From: Robert Szczepanski Date: Wed, 6 May 2026 16:26:38 +0200 Subject: [PATCH 3/4] Add bus_idle test to testplan Internal-tag: [#96240] --- verification/testplan/source-maps.yml | 3 ++- verification/testplan/top/target.hjson | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/verification/testplan/source-maps.yml b/verification/testplan/source-maps.yml index b118514a6..df0ddf98f 100644 --- a/verification/testplan/source-maps.yml +++ b/verification/testplan/source-maps.yml @@ -39,7 +39,8 @@ testplans: testpoints: - name: "^(.*)$" source: ".*verification/cocotb/top/lib_i3c_top/test_i3c_target.py" - cocotb_xml: ".*verification/cocotb/top/i3c_axi/test_i3c_target(_[0-9]+)?.xml" + # test_bus_idle here is for bus_idle_coverage + cocotb_xml: ".*verification/cocotb/top/i3c_axi/test_(i3c_target|bus_idle)(_[0-9]+)?.xml" - name: 'Recovery mode tests' testpoints: - name: "^(.*)$" diff --git a/verification/testplan/top/target.hjson b/verification/testplan/top/target.hjson index 3070268b9..dffd974a7 100644 --- a/verification/testplan/top/target.hjson +++ b/verification/testplan/top/target.hjson @@ -357,5 +357,15 @@ tests: [""] tags: ["top"] } + { + name: bus_idle + desc: + ''' + Generate STOP condition, wait for over 200us and ensure the target entered idle state. Then + generate START condition and ensure target left idle state. + ''' + tests: ["bus_idle"] + tags: ["top"] + } ] } From db97597aa87eaed5381f18fe5d70d84e84b650e5 Mon Sep 17 00:00:00 2001 From: Robert Szczepanski Date: Wed, 6 May 2026 16:26:52 +0200 Subject: [PATCH 4/4] Add actual checks to bus_idle test Internal-tag: [#96240] --- .../cocotb/top/lib_i3c_top/test_bus_idle.py | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/verification/cocotb/top/lib_i3c_top/test_bus_idle.py b/verification/cocotb/top/lib_i3c_top/test_bus_idle.py index 7e9e6862b..de108fff4 100644 --- a/verification/cocotb/top/lib_i3c_top/test_bus_idle.py +++ b/verification/cocotb/top/lib_i3c_top/test_bus_idle.py @@ -8,6 +8,13 @@ from interface import I3CTopTestInterface from common import log_seed + +_BUS_IDLE_PATH = ( + "xi3c_wrapper.i3c.xcontroller.xcontroller_standby" + ".xcontroller_standby_i3c.xbus_timers.bus_idle_o" +) + + async def test_setup(dut): cocotb.log.setLevel(logging.DEBUG) log_seed(dut) @@ -27,13 +34,15 @@ async def test_setup(dut): await boot_init(tb, fclk=333.0) return i3c_controller, tb + @cocotb.test() -async def test_bus_idle_coverage(dut): +async def test_bus_idle(dut): """ - Coverage: bus_idle_o is toggled and reset_counter = 0 and bus_idle_o = 1. + Ensures target enters and leaves bus idle state after certain delays. """ i3c_controller, tb = await test_setup(dut) - + bus_idle_sig = getattr(dut, _BUS_IDLE_PATH) + # 1. Generate a manual STOP condition to start the bus timers # (The timer requires a STOP detection edge to restart its internal counters) 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): await Timer(2, "us") i3c_controller.sda = 1 # STOP edge await Timer(2, "us") - + # 2. Wait > 200us for T_IDLE. This forces bus_idle_o to toggle 0 -> 1. dut._log.info("Waiting 210us for bus_idle_o to assert") await Timer(210, "us") - + assert bus_idle_sig.value == 1, "Target should be in bus idle state" + # 3. Generate a manual START condition to break the idle state (1 -> 0 toggle) dut._log.info("Generating START condition (SDA 1->0 while SCL=1) to deassert bus_idle_o") i3c_controller.sda = 0 await Timer(2, "us") - - await tb.teardown() \ No newline at end of file + assert bus_idle_sig.value == 0, "Target should not be in bus idle state" + + await tb.teardown()