Skip to content

Commit b08e21f

Browse files
riscv multi cycle design bram dmem needed manual pipeline regs around it for correct timing paths
1 parent 073cd7e commit b08e21f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/risc-v/mem_decl.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,20 @@ riscv_dmem_out_t riscv_dmem(
328328
riscv_dmem_ram_out_t ram_out = riscv_dmem_ram(mem_rw_word_index,
329329
wr_word, wr_word_byte_ens, 1);
330330
uint32_t mem_rd_data = ram_out.rd_data0;
331+
#ifdef RISCV_DMEM_1_CYCLE
332+
// Manually delay signals to align with 1 cycle read data delay of dmem
333+
#ifdef RISCV_DMEM_NO_AUTOPIPELINE
334+
static riscv_mmio_mod_out_t mem_map_out_reg;
335+
static uint2_t byte_mux_sel_reg;
336+
static uint1_t rd_byte_ens_reg[4];
337+
riscv_mmio_mod_out_t mem_map_out_next = mem_map_out;
338+
uint2_t byte_mux_sel_next = byte_mux_sel;
339+
uint1_t rd_byte_ens_next[4] = rd_byte_ens;
340+
mem_map_out = mem_map_out_reg;
341+
byte_mux_sel = byte_mux_sel_reg;
342+
rd_byte_ens = rd_byte_ens_reg;
343+
#endif
344+
#endif
331345

332346
// Determine output memory read data
333347
// Mem map read comes from memory map module not RAM memory
@@ -356,5 +370,14 @@ riscv_dmem_out_t riscv_dmem(
356370
// Final mem rd data assignment to output
357371
mem_out.rd_data = mem_rd_data;
358372

373+
// Manual pipeline regs next signal
374+
#ifdef RISCV_DMEM_1_CYCLE
375+
#ifdef RISCV_DMEM_NO_AUTOPIPELINE
376+
mem_map_out_reg = mem_map_out_next;
377+
byte_mux_sel_reg = byte_mux_sel_next;
378+
rd_byte_ens_reg = rd_byte_ens_next;
379+
#endif
380+
#endif
381+
359382
return mem_out;
360383
}

0 commit comments

Comments
 (0)