beepo/tests/spmem.v

28 lines
578 B
Coq
Raw Normal View History

2023-11-17 02:02:40 -06:00
module spMem(
output [7:0] dout,
input clk,
input oce,
input ce,
input reset,
input wre,
input [15:0] ad,
input [7:0] din
);
// gets replaced with the memory for the program to run
$$insert_mem$$
reg [15:0] r_ad_prev = 0;
reg [7:0] r_out;
assign dout = r_out;
always @(negedge clk) begin
// one full clock cycle before being fetched
2023-11-21 05:08:22 -06:00
if (r_ad_prev == ad) begin
if (wre == 1) mem[ad*8+:8] = din;
r_out <= mem[ad*8+:8];
end
2023-11-17 02:02:40 -06:00
else r_ad_prev = ad;
end
endmodule