1
0
Fork 0
2023-fpga-computer/src/sap1/memory.v

28 lines
338 B
Coq
Raw Permalink Normal View History

2023-01-04 02:26:45 +00:00
module memory(
input clk,
input rst,
2023-01-04 02:26:45 +00:00
input load,
input[7:0] bus,
output[7:0] out
2023-01-04 02:26:45 +00:00
);
initial begin
$readmemh("program.bin", ram);
end
reg[3:0] mar;
2023-01-04 02:26:45 +00:00
reg[7:0] ram[0:15];
always @(posedge clk, posedge rst) begin
if (rst) begin
mar <= 4'b0;
end else if (load) begin
2023-01-04 02:26:45 +00:00
mar <= bus[3:0];
end
end
assign out = ram[mar];
2023-01-04 02:26:45 +00:00
endmodule