verilog-apple-one/rtl/ram.v

28 lines
500 B
Coq
Raw Normal View History

2018-01-26 13:21:05 +00:00
module ram(
input clk,
input [12:0] address,
input w_en,
input [7:0] din,
output reg [7:0] dout
);
`ifdef YOSYS
parameter RAM_FILENAME = "../../roms/ram.hex";
`else
parameter RAM_FILENAME = "../roms/ram.hex";
`endif
reg [7:0] ram_data[0:8191];
2018-01-26 13:21:05 +00:00
initial
$readmemh(RAM_FILENAME, ram_data, 0, 8191);
2018-01-26 13:21:05 +00:00
always @(posedge clk)
begin
dout <= ram_data[address];
if (w_en) ram_data[address] <= din;
2018-01-26 13:21:05 +00:00
end
endmodule