Follow two read-modify-write sequences through one SRAM port, and find what the lock costs and saves.
Hardware context: Two managers sharing one SRAM port through a round-robin arbiter with a lock. Debugging a shared counter on a multi-manager bus
This capture comes from the lab of lesson S4.13. The counter in SRAM starts at 7. The cpu adds 2 and the dma adds 30. Both raise HMASTLOCK for their read and their write. The arbiter is round robin, and the cpu wins the first tie.
This worksheet uses named constants. The first three entries show how to record your decisions.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Edge | Waiting, cpu | Waiting, dma | HMASTLOCK, cpu | HMASTLOCK, dma | Port locked by | Served at this edge | Counter before the edge |
|---|---|---|---|---|---|---|---|
| 0 | none | none | 0 | 0 | nobody | nobody | 7 |
| 1 | none | none | 1 | 1 | nobody | nobody | 7 |
| 2 | READ | READ | 1 | 1 | nobody | cpu READ 7 | 7 |
| 3 | none | READ | 1 | 1 | cpu | nobody | 7 |
| 4 | WRITE | READ | 1 | 1 | cpu | cpu WRITE 9 | 7 |
| 5 | none | READ | 0 | 1 | cpu | nobody | 9 |
| 6 | none | READ | 0 | 1 | nobody | dma READ 9 | 9 |
| 7 | none | none | 0 | 1 | dma | nobody | 9 |
| 8 | none | WRITE | 0 | 1 | dma | dma WRITE 39 | 9 |
| 9 | none | none | 0 | 0 | dma | nobody | 39 |
| 10 | none | none | 0 | 0 | nobody | nobody | 39 |
Each row is what one rising clock edge sees. A request waits in the input stage until the port serves it. The port is locked after a served transfer with HMASTLOCK at 1. It is unlocked after a cycle in which the manager that holds it shows HMASTLOCK at 0. Enter edges and values as plain numbers.
| Entry | Your decision |
|---|---|
| CPU_READ_EDGE | Edge that serves the read of the cpu. |
| CPU_READ_VALUE | Value that the cpu reads. |
| FIRST_LOCKED | First edge that sees the port locked. |
| CPU_WRITE_EDGE | Edge that serves the write of the cpu. |
| CPU_WRITE_VALUE | Value that the cpu writes. |
| DMA_WAITS | Number of edges that see the read of the dma waiting and do not serve it. |
| UNLOCK_SEEN | Edge that sees the HMASTLOCK of the cpu at 0 while the port is still locked. |
| DMA_READ_EDGE | Edge that serves the read of the dma. |
| DMA_READ_VALUE | Value that the dma reads. |
| DMA_WRITE_VALUE | Value that the dma writes. |
| RACE_RESULT | Value of the counter at the end if neither manager raised HMASTLOCK. The reads are then served at edges 2 and 3, and the writes at edges 4 and 5. |
| LOCKED_RESULT | What does the counter hold at the end if the dma adds N in place of 30, with both managers locking as in the capture? |
Examples
Example 1
CPU READ EDGE- Input
Edge that serves the read of the cpu.
- Output
matches = 1
Edge 2 has both reads waiting. The cpu wins the first tie.
Example 2
CPU READ VALUE- Input
Value that the cpu reads.
- Output
matches = 1
The counter is 7 before edge 2.
Example 3
FIRST LOCKED- Input
First edge that sees the port locked.
- Output
matches = 1
The read served at edge 2 had HMASTLOCK at 1, so the port is locked from then on.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For LOCKED_RESULT, enter a constant expression using N. Only this entry changes with the parameter. The supported integer range is 0 through 31, inclusive.
Hints
Hint 1
Find the edge that serves its read and the edge that serves its write.
Hint 2
The port is locked from the edge after a served locked transfer. It opens one cycle after HMASTLOCK falls.
Hint 3
Without the lock the two reads come first. Both managers then add to the same old value.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
12 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 problem on this path