2 `define BRAM_ADDR_WIDTH 8
3 `define BRAM_DATA_WIDTH `DATAWIDTH
4 `define BRAM_NAME dcache_bram
8 read_addr_r, read_addr_a_, read_addr_d,
9 read_data_r_, read_data_a, read_data_d_,
10 write_addr_r, write_addr_a_, write_addr_d,
11 write_data_r, write_data_a_, write_data_d,
12 write_done_r_, write_done_a, write_done_d_
16 `input(read_addr_r, read_addr_a, read_addr_a_, [(`DATAWIDTH-1):0], read_addr_d)
17 `output(read_data_r, read_data_r_, read_data_a, [(`DATAWIDTH-1):0], read_data_d_)
18 `defreg(read_data_d_, [(`DATAWIDTH-1):0], read_data_d)
22 reg have_read; initial have_read = 0;
23 reg read_pending; initial read_pending = 0;
24 assign bram_read_address = read_addr_d;
26 always @(posedge clk) begin
27 `include "cache_write.inc"
29 if (read_pending) begin
32 read_data_d <= bram_read_data;
33 end else if (have_read) begin
34 `onwrite(read_data_r, read_data_a)
38 `onread(read_addr_r, read_addr_a)
39 // ======= Careful with the timing here! =====================
40 // We MUST capture bram_read_data on the very next clock since
41 // read_addr_d is free to change after the next clock
42 // ===========================================================