Carry a 64-bit manager's reads over a 32-bit bus. Send twice the beats, merge them back with the worse response, and put narrow reads in the right half.
Hardware context: A width converter between a 64-bit manager and a 32-bit memory. Implement the read path of a downsizer that splits full-width requests and merges the beats back with the worse response.
Lesson P2.19 ran a downsizer on the bench. This is its read side, built by you. A 64-bit manager reads through it from a 32-bit memory whose word at address A holds A.
Write module rd_down. A read of 8-byte beats cannot cross the narrow bus, so send twice as many 4-byte beats. Merge each pair back into one 8-byte beat, the lower address in lanes 0 to 3. Give the merged beat the worse of its two responses.
A read of 4, 2 or 1 bytes per beat already fits. Pass it unchanged and put each 32-bit beat in the half of the 64-bit word its address names. Handle one read at a time.
The fixture checks the request the memory takes and every beat the manager receives. It stalls both sides, and its error region can start in the middle of a beat.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
n_reads | 4 | input of each check |
Full specification
module rd_down (
input logic clk,
input logic rst_n, // active low, asynchronous assert
// the 64-bit manager side: read address and read data (INCR bursts only)
input logic [3:0] arid,
input logic [31:0] araddr, // aligned to the transfer size
input logic [7:0] arlen, // up to 127 for 8-byte beats
input logic [2:0] arsize, // 0 to 3
input logic arvalid,
output logic arready,
output logic [3:0] rid,
output logic [63:0] rdata,
output logic [1:0] rresp,
output logic rlast,
output logic rvalid,
input logic rready,
// the 32-bit memory side
output logic [3:0] s_arid,
output logic [31:0] s_araddr,
output logic [7:0] s_arlen,
output logic [2:0] s_arsize,
output logic s_arvalid,
input logic s_arready,
input logic [3:0] s_rid,
input logic [31:0] s_rdata,
input logic [1:0] s_rresp,
input logic s_rlast,
input logic s_rvalid,
output logic s_rready
);
// your downsizer
endmodule
| Request from the manager | Request to the memory | Each beat back to the manager |
|---|---|---|
| AxSIZE 3, AxLEN n | AxSIZE 2, AxLEN 2n + 1, same address and ID | two memory beats as {second, first}. The response is the worse of the two: DECERR, then SLVERR, then OKAY. RLAST comes with the last pair. |
| AxSIZE 0 to 2 | unchanged | the 32-bit beat in lanes 4-7 if bit 2 of its address is 1, else in lanes 0-3. The other half is 0, and the response is its own. |
The address of narrow beat k is ARADDR + k x 2^ARSIZE; every address is aligned to its size. The memory answers SLVERR with data 0 for every word at or above an error address.
The result is {reads_ok[7:0], beats[15:0], bad[7:0], ar_bad[7:0], hold[7:0]}. bad counts beats with the wrong ID, data, response or RLAST. ar_bad counts memory requests with AxSIZE above 2 or different bytes. hold counts beats changed while waiting for RREADY.
Examples
Example 1
One 8-byte Beat- Input
ID 1: 1 beat of 8 bytes from 0x100 memory: word at A holds A, SLVERR from 0xffffffff; RREADY 16'hffff, memory ARREADY 16'hffff
- Output
reads_ok = 1, beats = 1, bad = 0, ar_bad = 0, hold = 0
The memory takes AxSIZE 2 and AxLEN 1 and sends 00000100 then 00000104. The manager gets 00000104_00000100 with OKAY and RLAST.
Example 2
An Error in the Upper Half- Input
ID 7: 2 beats of 8 bytes from 0x500 memory: word at A holds A, SLVERR from 0x50c; RREADY 16'hffff, memory ARREADY 16'hffff
- Output
reads_ok = 1, beats = 2, bad = 0, ar_bad = 0, hold = 0
The second 8-byte beat covers 0x508 to 0x50f. Its lower half is OKAY and its upper half SLVERR, so the merged beat is SLVERR with 0 in lanes 4-7.
Example 3
Narrow Reads- Input
ID 3: 1 beat of 4 bytes from 0x300; ID 3: 1 beat of 4 bytes from 0x304; ID 4: 4 beats of 4 bytes from 0x308 memory: word at A holds A, SLVERR from 0xffffffff; RREADY 16'hffff, memory ARREADY 16'hffff
- Output
reads_ok = 3, beats = 6, bad = 0, ar_bad = 0, hold = 0
A 4-byte read of 0x304 lands in lanes 4-7; one of 0x300 lands in lanes 0-3. The memory request passes unchanged.
Constraints and Contract
- Keep the module name and the ports. Every burst is INCR.
- The fixture drives its signals after each edge and samples yours just before the next one.
- Do not reach outside your ports.
Hints
Hint 1
Remember whether the read is full width, its address and size, and a beat counter.
Hint 2
For a full-width read, keep the first 32-bit beat and its response, and emit the 64-bit beat when the second arrives.
Hint 3
For a narrow read, the beat address decides the half. Count beats from 0, starting at ARADDR.
What the grader checks: Your downsizer runs twelve read lists, full width and narrow, with stalls on both sides and a 64-beat burst. Error regions start in either half of a beat. Every memory request and every beat is checked. Passing shows the read path is right on these lists.
12 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 1 steps and the final capstone