diff options
author | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2024-05-23 08:29:19 +0200 |
---|---|---|
committer | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2024-05-23 08:29:19 +0200 |
commit | eb163582941af4b3fac8daf00665e1b704fd7c23 (patch) | |
tree | 651d8e799a404d0270467c137159b93615b2929a | |
parent | 6a9573628b3c7e537bd273a483be9abcfa2ee429 (diff) | |
download | riscv_cpu-eb163582941af4b3fac8daf00665e1b704fd7c23.tar.gz riscv_cpu-eb163582941af4b3fac8daf00665e1b704fd7c23.zip |
reverted mem size
-rw-r--r-- | rtl/src/cpu.v | 2 | ||||
-rw-r--r-- | rtl/src/ram.v | 35 | ||||
-rw-r--r-- | rtl/src/rom.v | 18 |
3 files changed, 6 insertions, 49 deletions
diff --git a/rtl/src/cpu.v b/rtl/src/cpu.v index a1ccf78..a373e72 100644 --- a/rtl/src/cpu.v +++ b/rtl/src/cpu.v @@ -80,7 +80,7 @@ mem_addr_src_mux mem_addr_src_mux ( ); memory_interface memory_interface ( - .clk(clk), + .clk(~clk), .rstn(rstn), .we(mem_we), .addr(mem_addr), diff --git a/rtl/src/ram.v b/rtl/src/ram.v index 323bbdd..fc1dc21 100644 --- a/rtl/src/ram.v +++ b/rtl/src/ram.v @@ -18,39 +18,10 @@ module ram #( //(* RAM_STYLE="BLOCK" *) reg [31:0] mem [0:SIZE-1]; -wire [31:0] rd_w; -wire [15:0] rd_h; -wire [7:0] rd_b; -assign rd_w = mem[addr >> 2]; -assign rd_h = (mem[addr >> 2] >> (addr[1] * 16)) & 32'hFFFF; -assign rd_b = (mem[addr >> 2] >> (addr[1:0] * 8)) & 32'hFF; -always @(negedge clk) begin - if (we) begin - case (size) - FUNCT3_LS_W: mem[addr >> 2] <= wd; - FUNCT3_LS_H: - case (addr[1]) - 1'b0: mem[addr >> 2][15:0] <= wd[15:0]; - 1'b1: mem[addr >> 2][31:16] <= wd[15:0]; - endcase - FUNCT3_LS_B: - case (addr[1:0]) - 2'b00: mem[addr >> 2][7:0] <= wd[7:0]; - 2'b01: mem[addr >> 2][15:8] <= wd[7:0]; - 2'b10: mem[addr >> 2][23:16] <= wd[7:0]; - 2'b11: mem[addr >> 2][32:24] <= wd[7:0]; - endcase - endcase - end - case (size) - FUNCT3_LS_W: rd <= rd_w; - FUNCT3_LS_H: rd <= { {16{rd_h[15]}}, rd_h }; - FUNCT3_LS_B: rd <= { {24{rd_b[7]}}, rd_b }; - FUNCT3_LS_HU: rd <= rd_b; - FUNCT3_LS_BU: rd <= rd_h; - default: rd <= rd_w; - endcase +always @(posedge clk) begin + if (we) mem[addr >> 2] <= wd; + rd <= mem[addr >> 2]; end endmodule diff --git a/rtl/src/rom.v b/rtl/src/rom.v index 6cb9a92..bca7ba8 100644 --- a/rtl/src/rom.v +++ b/rtl/src/rom.v @@ -22,22 +22,8 @@ initial begin $readmemh(ROM_FILE, mem, 0, SIZE-1); end -wire [31:0] rd_w; -wire [15:0] rd_h; -wire [7:0] rd_b; -assign rd_w = mem[addr >> 2]; -assign rd_h = (mem[addr >> 2] >> (addr[1] * 16)) & 32'hFFFF; -assign rd_b = (mem[addr >> 2] >> (addr[1:0] * 8)) & 32'hFF; - -always @ (negedge clk) begin - case (size) - FUNCT3_LS_W: rd <= rd_w; - FUNCT3_LS_H: rd <= { {16{rd_h[15]}}, rd_h }; - FUNCT3_LS_B: rd <= { {24{rd_b[7]}}, rd_b }; - FUNCT3_LS_HU: rd <= rd_b; - FUNCT3_LS_BU: rd <= rd_h; - default: rd <= rd_w; - endcase +always @ (posedge clk) begin + rd <= mem[addr >> 2]; end endmodule |