2022-11-26 10:44:00 +00:00
|
|
|
`timescale 1ns / 1ps
|
|
|
|
|
|
|
|
// N = Bit width
|
2022-11-27 06:30:54 +00:00
|
|
|
module InstructionMemory #(
|
|
|
|
parameter N = 32,
|
2022-12-20 05:19:32 +00:00
|
|
|
parameter N_INSTR = 32,
|
|
|
|
parameter BYTE_WIDTH = 8
|
2022-11-27 06:30:54 +00:00
|
|
|
)
|
2022-11-26 10:44:00 +00:00
|
|
|
(
|
|
|
|
input logic[N-1:0] addr,
|
|
|
|
output logic[N-1:0] instr
|
2022-11-27 06:30:54 +00:00
|
|
|
);
|
2022-12-20 05:19:32 +00:00
|
|
|
logic[BYTE_WIDTH-1:0] mem [N_INSTR*BYTE_WIDTH-1:0];
|
2022-11-27 06:30:54 +00:00
|
|
|
|
2022-12-20 05:19:32 +00:00
|
|
|
always_comb begin
|
|
|
|
instr = {mem[addr + 'd0],
|
|
|
|
mem[addr + 'd1],
|
|
|
|
mem[addr + 'd2],
|
|
|
|
mem[addr + 'd3]};
|
|
|
|
end
|
|
|
|
|
|
|
|
initial $readmemh("rv32fw.mem", mem);
|
2022-11-26 10:44:00 +00:00
|
|
|
endmodule
|