simpleram simplification

This commit is contained in:
David Harris 2022-01-25 18:26:31 +00:00
parent e3136c9a1e
commit a86a9f5c2a
3 changed files with 16 additions and 30 deletions

View File

@ -32,48 +32,36 @@
module simpleram #(parameter BASE=0, RANGE = 65535) ( module simpleram #(parameter BASE=0, RANGE = 65535) (
input logic clk, input logic clk,
input logic HSELRam, input logic [31:0] a,
input logic [31:0] Adr, input logic we,
input logic HWRITE, input logic [`XLEN-1:0] wd,
input logic HREADY, output logic [`XLEN-1:0] rd
input logic [1:0] HTRANS,
input logic [`XLEN-1:0] HWDATA,
output logic [`XLEN-1:0] HREADRam,
output logic HRESPRam, HREADYRam
); );
localparam MemStartAddr = BASE>>(1+`XLEN/32); localparam MemStartAddr = BASE>>(1+`XLEN/32);
localparam MemEndAddr = (RANGE+BASE)>>1+(`XLEN/32); localparam MemEndAddr = (RANGE+BASE)>>1+(`XLEN/32);
logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE+BASE)>>1+(`XLEN/32)]; logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE+BASE)>>1+(`XLEN/32)];
logic [31:0] AD; logic [31:0] ad;
logic [`XLEN-1:0] HREADRam0;
logic prevHREADYRam, risingHREADYRam; flop #(32) areg(clk, a, ad);
logic initTrans;
logic memwrite;
logic [3:0] busycount;
assign initTrans = HREADY & HSELRam & (HTRANS != 2'b00);
flop #(32) Adrreg(clk, Adr, AD);
/* verilator lint_off WIDTH */ /* verilator lint_off WIDTH */
if (`XLEN == 64) begin:ramrw if (`XLEN == 64) begin:ramrw
always_ff @(posedge clk) begin always_ff @(posedge clk) begin
if (HWRITE & |HTRANS) RAM[AD[31:3]] <= #1 HWDATA; if (we) RAM[ad[31:3]] <= #1 wd;
end end
end else begin end else begin
always_ff @(posedge clk) begin:ramrw always_ff @(posedge clk) begin:ramrw
if (HWRITE & |HTRANS) RAM[AD[31:2]] <= #1 HWDATA; if (we) RAM[ad[31:2]] <= #1 wd;
end end
end end
// read // read
if(`XLEN == 64) begin: ramr if(`XLEN == 64) begin: ramr
assign HREADRam = RAM[AD[31:3]]; assign rd = RAM[ad[31:3]];
end else begin end else begin
assign HREADRam = RAM[AD[31:2]]; assign rd = RAM[ad[31:2]];
end end
/* verilator lint_on WIDTH */ /* verilator lint_on WIDTH */

View File

@ -236,10 +236,9 @@ module ifu (
simpleram #( simpleram #(
.BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram ( .BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram (
.clk, .clk,
.HSELRam(1'b1), .Adr(CPUBusy ? PCPF[31:0] : PCNextFMux[31:0]), // mux is also inside $, have to replay address if CPU is stalled. .a(CPUBusy ? PCPF[31:0] : PCNextFMux[31:0]), // mux is also inside $, have to replay address if CPU is stalled.
.HWRITE(1'b0), .HREADY(1'b1), .we(1'b0),
.HTRANS(2'b10), .HWDATA(0), .HREADRam(FinalInstrRawF_FIXME), .wd(0), .rd(FinalInstrRawF_FIXME));
.HRESPRam(), .HREADYRam());
assign FinalInstrRawF = FinalInstrRawF_FIXME[31:0]; assign FinalInstrRawF = FinalInstrRawF_FIXME[31:0];
assign BusStall = 0; assign BusStall = 0;
assign IFUBusRead = 0; assign IFUBusRead = 0;

View File

@ -247,10 +247,9 @@ module lsu (
if (`MEM_DTIM) begin : dtim if (`MEM_DTIM) begin : dtim
simpleram #(.BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram ( simpleram #(.BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram (
.clk, .clk,
.HSELRam(1'b1), .Adr(CPUBusy ? IEUAdrM[31:0] : IEUAdrE[31:0]), .a(CPUBusy ? IEUAdrM[31:0] : IEUAdrE[31:0]),
.HWRITE(LSURWM[0]), .HREADY(1'b1), .we(LSURWM[0]),
.HTRANS(|LSURWM ? 2'b10 : 2'b00), .HWDATA(FinalWriteDataM), .HREADRam(ReadDataWordM), .wd(FinalWriteDataM), .rd(ReadDataWordM));
.HRESPRam(), .HREADYRam());
// since we have a local memory the bus connections are all disabled. // since we have a local memory the bus connections are all disabled.
// There are no peripherals supported. // There are no peripherals supported.