Skip to content

Commit ca0b534

Browse files
kgugalarobertszczepanski
authored andcommitted
test_recovery: perform transactions to virtual static address
Signed-off-by: Karol Gugala <kgugala@antmicro.com>
1 parent 5e21a0c commit ca0b534

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

verification/cocotb/top/lib_i3c_top/test_recovery.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from interface import I3CTopTestInterface
1414

1515
import cocotb
16+
from cocotb.regression import TestFactory
1617
from cocotb.triggers import ClockCycles, Combine, Event, RisingEdge, Timer
1718

1819
STATIC_ADDR = 0x5A
@@ -408,15 +409,17 @@ async def test_virtual_overwrite(dut):
408409
await tb.teardown()
409410

410411

411-
@cocotb.test()
412-
async def test_virtual_write(dut):
412+
async def test_virtual_write(dut, use_static_addr=False):
413413
"""
414-
Tests CSR write(s) using the recovery protocol using the virtual address
414+
Tests CSR write(s) using the recovery protocol using the virtual address.
415+
Parameterized over static vs. dynamic virtual device address.
415416
"""
416417

417418
# Initialize
418419
i3c_controller, i3c_target, tb, recovery = await initialize(dut)
419420

421+
virt_addr = VIRT_STATIC_ADDR if use_static_addr else VIRT_DYNAMIC_ADDR
422+
420423
# exit recovery mode
421424
status = 0x2
422425
await tb.write_csr(
@@ -428,14 +431,15 @@ async def test_virtual_write(dut):
428431
await i3c_controller.i3c_ccc_write(
429432
ccc=CCC.DIRECT.SETDASA, directed_data=[(STATIC_ADDR, [DYNAMIC_ADDR << 1])]
430433
)
431-
# set virtual device dynamic address
432-
await i3c_controller.i3c_ccc_write(
433-
ccc=CCC.DIRECT.SETDASA, directed_data=[(VIRT_STATIC_ADDR, [VIRT_DYNAMIC_ADDR << 1])]
434-
)
434+
if not use_static_addr:
435+
# set virtual device dynamic address
436+
await i3c_controller.i3c_ccc_write(
437+
ccc=CCC.DIRECT.SETDASA, directed_data=[(VIRT_STATIC_ADDR, [VIRT_DYNAMIC_ADDR << 1])]
438+
)
435439

436440
# Write to the RESET CSR (one word)
437441
await recovery.command_write(
438-
VIRT_DYNAMIC_ADDR, I3cRecoveryInterface.Command.DEVICE_RESET, [0xAA, 0xBB, 0xCC]
442+
virt_addr, I3cRecoveryInterface.Command.DEVICE_RESET, [0xAA, 0xBB, 0xCC]
439443
)
440444

441445
# Wait & read the CSR from the AHB/AXI side
@@ -449,7 +453,7 @@ async def test_virtual_write(dut):
449453

450454
# read back device reset
451455
i3c_data, pec_ok = await recovery.command_read(
452-
VIRT_DYNAMIC_ADDR, I3cRecoveryInterface.Command.DEVICE_RESET
456+
virt_addr, I3cRecoveryInterface.Command.DEVICE_RESET
453457
)
454458

455459
# Check
@@ -489,7 +493,7 @@ async def test_virtual_write(dut):
489493
# Write to the FIFO_CTRL CSR (two words)
490494
# This write should not pass because the device is not set to recovery mode
491495
await recovery.command_write(
492-
VIRT_DYNAMIC_ADDR,
496+
virt_addr,
493497
I3cRecoveryInterface.Command.INDIRECT_FIFO_CTRL,
494498
[0xAA, 0xBB, 0xCC, 0xDD, 0x11, 0x22],
495499
)
@@ -519,6 +523,11 @@ async def test_virtual_write(dut):
519523
await tb.teardown()
520524

521525

526+
_tf_virtual_write = TestFactory(test_function=test_virtual_write)
527+
_tf_virtual_write.add_option("use_static_addr", [False, True])
528+
_tf_virtual_write.generate_tests()
529+
530+
522531
@cocotb.test()
523532
async def test_chained_ri_and_ccc_commands(dut):
524533
"""

0 commit comments

Comments
 (0)