Count the page hits, the page misses and the clock cycles of eight reads on a two-bank SDRAM with the open-page policy.
Hardware context: An SDRAM controller for a display driver that fetches two pixels per request and refreshes the memory. Count page hits, page misses and cycles for a stream of reads over two banks.
A memory controller keeps the last row of each bank open. A read of that row is a page hit and needs only READ. Any other read must open its row first, and a read of a different row must also close the old one.
This is an Implement problem with no logic to write. You follow a stream of eight reads by hand and fill in the constants. They are the hits, the misses, the reads into an idle bank and the total number of cycles.
The memory has two banks. Each bank has its own row buffer, so each bank can keep one row open. Both banks start with no open row.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
constant | 8 | input of each check |
Full specification
| Case | Commands | Cycles |
|---|---|---|
| Page hit: the row is open in its bank | READ | CL = 3 |
| Cold: no row is open in that bank | ACTIVATE, READ | tRCD + CL = 3 + 3 |
| Page miss: another row is open in that bank | PRECHARGE, ACTIVATE, READ | tRP + tRCD + CL = 2 + 3 + 3 |
The reads run one after the other. The cycles of a read count from its first command to its data. After a read, its row stays open in its bank.
| Read | Bank | Row |
|---|---|---|
| 1 | 0 | 5 |
| 2 | 0 | 5 |
| 3 | 1 | 2 |
| 4 | 0 | 7 |
| 5 | 1 | 2 |
| 6 | 0 | 5 |
| 7 | 1 | 9 |
| 8 | 0 | 5 |
A worked example with three reads, all in bank 0: row 1, row 1, row 4. The first read is cold: 6 cycles. The second is a hit: 3 cycles. The third is a miss: 8 cycles. That is 1 hit, 1 miss and 17 cycles, already in the starter.
// answer: your counts, as constants.
module answer (
output logic [7:0] warmup_hits,
output logic [7:0] warmup_misses,
output logic [7:0] warmup_cycles,
output logic [7:0] hits,
output logic [7:0] misses,
output logic [7:0] cold,
output logic [7:0] total_cycles
);
// the worked example of the brief: three reads in bank 0
assign warmup_hits = 8'd1;
assign warmup_misses = 8'd1;
assign warmup_cycles = 8'd17;
// the stream of eight reads
assign hits = 8'd0; // reads that find their row open
assign misses = 8'd0; // reads that find another row open in their bank
assign cold = 8'd0; // reads that find no row open in their bank
assign total_cycles = 8'd0; // the sum of the cycles of all eight reads
endmodule
Examples
Example 1
Hits in the Worked Example- Input
bank 0: row 1, row 1, row 4
- Output
warmup_hits = 1
Read 2 finds row 1 still open in bank 0. It is the only hit of the three reads.
Example 2
Misses in the Worked Example- Input
bank 0: row 1, row 1, row 4
- Output
warmup_misses = 1
Read 3 wants row 4 while row 1 is open in the same bank. It must close row 1 first: one miss. Read 1 found no open row, so it is cold, not a miss.
Example 3
Cycles of the Worked Example- Input
bank 0: row 1, row 1, row 4
- Output
warmup_cycles = 17
Cold, hit, miss: 6 + 3 + 8 = 17 cycles. The stream of eight reads is checked the same way, one constant at a time.
Constraints and Contract
- Keep the module name answer and its seven outputs.
- Each output is a whole number from 0 to 255. The three outputs of the worked example are already right.
Hints
Hint 1
Make a small table with one line per read. Keep two notes beside it: the open row of bank 0 and the open row of bank 1.
Hint 2
A read in bank 1 does not change the open row of bank 0. Look only at the note of the bank that the read uses.
Hint 3
Every read is exactly one of hit, miss or cold, so the three counts add up to 8. Then multiply each count by its cycles and add.
What the grader checks: The seven constants are compared with a model of the open-page policy written in JavaScript. The first three are the worked example of the brief. Refresh, writes and reads that overlap in time are outside this problem.
7 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 steps and the final capstone