A trace buffer that works in simulation turns into thousands of flip-flops on an FPGA. Change it so the FPGA tools put it in a block RAM, without changing what it does for words that were written.
Hardware context: The ECP5 build of ap_soc's digital chip (Yosys, nextpnr), no board. A trace buffer that fits block RAM.
An FPGA prototype is hard to see into, so teams add trace buffers. A trace buffer is a small memory that records signals for a debugger to read back. This one holds 256 words of 16 bits, written on one port and read on another, one clock after the address.
It was written as an ASIC simulation model. On the FPGA flow it does not become block RAM: the synthesis tool builds it from flip-flops. Find what the model asks for that a block RAM cannot do. Fix trace_buf so it maps to block RAM and keeps its behaviour for every word that was written.
Your module is simulated, then synthesized with the site's iCE40 flow, synth_ice40 in the pinned Yosys. The grader counts flip-flops outside the memory blocks. The budget is 64. The reference uses 42 and one block RAM; the model as given uses 4,112 flip-flops and none.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 4 | input of each check |
Full specification
module trace_buf(input logic clk, resetn, we, input logic [7:0] waddr, input logic [15:0] wdata,
input logic [7:0] raddr, output logic [15:0] rdata);
...
endmodule
| Edge | Inputs before it | After it |
|---|---|---|
| k | we = 1, waddr, wdata | the word is stored |
| k | raddr = A | rdata = the word last written to A |
A word that was never written may read as anything after reset. The site's synthesis service has a generic flow and an iCE40 flow. The lesson's build of ap_soc used ECP5 and nextpnr, which problems here do not run.
Examples
Example 1
Eight Words, Read Back in Order- Input
8 writes, 8 reads
- Output
mismatches = 0, xor_read = 0xd218
Every word comes back one edge after its address.
Example 2
Read Back in Another Order- Input
12 writes, 12 reads
- Output
mismatches = 0, xor_read = 0xf3a8
The order of the reads does not matter.
Example 3
The Top and Bottom Words- Input
3 writes, 3 reads
- Output
mismatches = 0, xor_read = 0x6eef
The first, the last and a middle address.
Constraints and Contract
- Keep the module name and the ports. resetn stays an input, even if you no longer need it.
- rdata shows the word one rising edge after raddr.
- At most 64 flip-flops outside block RAM on the iCE40 flow.
Hints
Hint 1
What must a block RAM's read look like: combinational, or registered on the clock?
Hint 2
Which line of the model asks for something a block RAM cannot do?
Hint 3
Words never written are free to read as anything.
What the grader checks: Five scripts write words and read them back one edge after the address. Then synthesis on the iCE40 flow counts flip-flops outside block RAM against the budget. Words never written are not read, so their value is not graded.
The submitted design must synthesize with 0 latches and no combinational loop. It must use at most 64 cells; a result equal to the limit passes. Counts come from the pinned open-source synthesis flow. They are proxies for logic size and depth, not physical area or timing.
5 checks on Icarus Verilog + Yosys · server. 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 problems on this path