Skip to content

Commit 15fe97d

Browse files
committed
Add partial flush tests for DIV path in int_muldiv_shim
The existing partial flush tests only covered the MUL path, but div_flush_inflight/div_flushed tracking is implemented separately. Add test_partial_flush_suppresses_younger_div and test_partial_flush_keeps_older_div to close the gap.
1 parent b075bf5 commit 15fe97d

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

verif/cocotb_tests/tomasulo/fu_shims/test_int_muldiv_shim.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,3 +695,72 @@ async def test_partial_flush_keeps_older(dut: Any) -> None:
695695
result["tag"] == rob_tag
696696
), f"tag mismatch: got {result['tag']}, expected {rob_tag}"
697697
assert result["value"] == 42, f"Expected 42, got {result['value']}"
698+
699+
700+
# ============================================================================
701+
# Test 21: Partial flush suppresses younger in-flight DIV
702+
# ============================================================================
703+
@cocotb.test()
704+
async def test_partial_flush_suppresses_younger_div(dut: Any) -> None:
705+
"""Partial flush with flush_tag younger than in-flight DIV suppresses result."""
706+
iface = await setup(dut)
707+
708+
# Issue DIV with rob_tag=10
709+
iface.drive_issue(
710+
valid=True,
711+
rob_tag=10,
712+
op=_op("DIV"),
713+
src1_value=42,
714+
src2_value=7,
715+
)
716+
await RisingEdge(iface.clock)
717+
iface.clear_issue()
718+
719+
# Partial flush: flush_tag=5, head=0 -> tag 10 is younger than 5, gets flushed
720+
iface.drive_partial_flush(flush_tag=5, head_tag=0)
721+
await RisingEdge(iface.clock)
722+
iface.clear_partial_flush()
723+
await FallingEdge(iface.clock)
724+
725+
# Wait for divider to finish; result should be suppressed
726+
for _ in range(MAX_LATENCY):
727+
await RisingEdge(iface.clock)
728+
await FallingEdge(iface.clock)
729+
result = iface.read_div_fu_complete()
730+
assert (
731+
result["valid"] is False
732+
), "DIV result should be suppressed after partial flush of younger tag"
733+
734+
735+
# ============================================================================
736+
# Test 22: Partial flush keeps older in-flight DIV
737+
# ============================================================================
738+
@cocotb.test()
739+
async def test_partial_flush_keeps_older_div(dut: Any) -> None:
740+
"""Partial flush with flush_tag older than in-flight DIV keeps result."""
741+
iface = await setup(dut)
742+
743+
# Issue DIV with rob_tag=3
744+
rob_tag = 3
745+
iface.drive_issue(
746+
valid=True,
747+
rob_tag=rob_tag,
748+
op=_op("DIV"),
749+
src1_value=42,
750+
src2_value=7,
751+
)
752+
await RisingEdge(iface.clock)
753+
iface.clear_issue()
754+
755+
# Partial flush: flush_tag=10, head=0 -> tag 3 is older than 10, not flushed
756+
iface.drive_partial_flush(flush_tag=10, head_tag=0)
757+
await RisingEdge(iface.clock)
758+
iface.clear_partial_flush()
759+
760+
# Result should still appear
761+
result = await wait_for_div_complete(iface)
762+
assert result["valid"], "DIV result should NOT be suppressed (tag is older)"
763+
assert (
764+
result["tag"] == rob_tag
765+
), f"tag mismatch: got {result['tag']}, expected {rob_tag}"
766+
assert result["value"] == 6, f"Expected 6, got {result['value']}"

0 commit comments

Comments
 (0)