Skip to content

Commit 20e781d

Browse files
wkkunakgugala
authored andcommitted
tests: Add option to verify CSRs after boot into stdby ctrl
Signed-off-by: Wiktoria Kuna <[email protected]>
1 parent 3c23175 commit 20e781d

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

verification/cocotb/top/lib_i3c_top/boot.py

Lines changed: 45 additions & 3 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, verify=False):
5656
"""
5757
Boot sequence model should match the description in "Boot and Initialization" chapter of the documentation.
5858
@@ -79,7 +79,7 @@ async def boot_init(tb: I3CTopTestInterface, timings=None):
7979
await setup_hci_thresholds(tb)
8080

8181
# Start the device
82-
await umbrella_stby_init(tb)
82+
await umbrella_stby_init(tb, verify)
8383

8484

8585
async def check_version(tb):
@@ -193,7 +193,7 @@ async def define_supported_ccc(tb):
193193
pass
194194

195195

196-
async def umbrella_stby_init(tb):
196+
async def umbrella_stby_init(tb, verify=False):
197197
"""
198198
Set the BCR bits and the DCR value in register STBY_CR_DEVICE_CHAR.
199199
@@ -253,6 +253,48 @@ async def umbrella_stby_init(tb):
253253
# 1,
254254
# )
255255

256+
# Check if CSRs have been set properly
257+
if verify:
258+
mode = await tb.read_csr_field(
259+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_CONTROL.base_addr,
260+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_CONTROL.STBY_CR_ENABLE_INIT,
261+
)
262+
assert mode == 2
263+
264+
# Set static address and valid
265+
static_addr = await tb.read_csr_field(
266+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.base_addr,
267+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.STATIC_ADDR,
268+
)
269+
assert static_addr == 0x5A
270+
271+
static_addr_valid = await tb.read_csr_field(
272+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.base_addr,
273+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_DEVICE_ADDR.STATIC_ADDR_VALID,
274+
)
275+
assert static_addr_valid == 0x1
276+
277+
# Set static address and valid for virtual device
278+
virt_static_addr = await tb.read_csr_field(
279+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.base_addr,
280+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.VIRT_STATIC_ADDR,
281+
)
282+
assert virt_static_addr == 0x5B
283+
284+
virt_static_addr_valid = await tb.read_csr_field(
285+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.base_addr,
286+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_VIRT_DEVICE_ADDR.VIRT_STATIC_ADDR_VALID,
287+
0x1,
288+
)
289+
assert virt_static_addr_valid == 0x1
290+
291+
# Enable Target Interface
292+
tgt_en = await tb.read_csr_field(
293+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_CONTROL.base_addr,
294+
tb.reg_map.I3C_EC.STDBYCTRLMODE.STBY_CR_CONTROL.TARGET_XACT_ENABLE,
295+
)
296+
assert tgt_en == 1
297+
256298

257299
async def tti_init(tb):
258300
"""

verification/cocotb/top/lib_i3c_top/test_i3c_target.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def runCocotb(*args, **kwargs):
3737
return wrapper
3838

3939

40-
async def test_setup(dut, fclk=100.0, fbus=12.5):
40+
async def test_setup(dut, fclk=100.0, fbus=12.5, verify_boot=True):
4141
"""
4242
Sets up controller, target models and top-level core interface
4343
"""
@@ -81,7 +81,7 @@ async def test_setup(dut, fclk=100.0, fbus=12.5):
8181
for k, v in timings.items():
8282
dut._log.info(f"{k} = {v}")
8383

84-
await boot_init(tb, timings)
84+
await boot_init(tb, timings, verify_boot)
8585

8686
# Set TTI queues thresholds
8787
await tb.write_csr_field(
@@ -287,7 +287,7 @@ async def test_i3c_target_ibi(dut):
287287
"""
288288

289289
# Setup
290-
i3c_controller, i3c_target, tb = await test_setup(dut)
290+
i3c_controller, i3c_target, tb = await test_setup(dut, verify_boot=True)
291291

292292
target = i3c_controller.add_target(TARGET_ADDRESS)
293293
target.set_bcr_fields(ibi_req_capable=True, ibi_payload=True)
@@ -376,7 +376,7 @@ async def test_i3c_target_ibi_retry(dut):
376376
"""
377377

378378
# Setup
379-
i3c_controller, i3c_target, tb = await test_setup(dut)
379+
i3c_controller, i3c_target, tb = await test_setup(dut, verify_boot=True)
380380

381381
# Enable indefinite IBI retries
382382
# TTI.CONTROL.IBI_EN = 1
@@ -452,7 +452,7 @@ async def test_i3c_target_ibi_data(dut):
452452
"""
453453

454454
# Setup
455-
i3c_controller, i3c_target, tb = await test_setup(dut)
455+
i3c_controller, i3c_target, tb = await test_setup(dut, verify_boot=True)
456456

457457
target = i3c_controller.add_target(TARGET_ADDRESS)
458458
target.set_bcr_fields(ibi_req_capable=True, ibi_payload=True)

0 commit comments

Comments
 (0)