factorio-riscv/board/parts/rom.sv

24 lines
496 B
Systemverilog
Raw Normal View History

2023-12-29 14:10:10 +00:00
// RISC-V Read only memory
2023-12-29 18:45:02 +00:00
module rom(clk, rd, addr, datar);
2023-12-29 14:10:10 +00:00
input clk;
input reg rd;
input reg [31:0] addr;
output reg [31:0] datar;
2023-12-29 18:45:02 +00:00
parameter SIZE = 'h100;
parameter FILE = "";
reg [31:0] data [0 : SIZE - 1];
2023-12-29 14:10:10 +00:00
always @(posedge clk) begin
if (rd) begin
2023-12-29 18:45:02 +00:00
datar = data[addr];
2023-12-29 14:10:10 +00:00
end else begin
datar = 0;
end
end
2023-12-29 18:45:02 +00:00
initial begin
$readmemh(FILE, data, 0, SIZE - 1);
end
2023-12-29 14:10:10 +00:00
endmodule