-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsram.v
More file actions
28 lines (25 loc) · 754 Bytes
/
sram.v
File metadata and controls
28 lines (25 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module sram #(parameter ADDR_WIDTH=8, DATA_WIDTH=8, DEPTH=256, MEMFILE="") (
input wire i_clk,
input wire [ADDR_WIDTH-1:0] i_addr,
input wire i_write,
input wire [DATA_WIDTH-1:0] i_data,
output reg [DATA_WIDTH-1:0] o_data
);
reg [DATA_WIDTH-1:0] memory_array [0:DEPTH-1];
initial begin
if (MEMFILE > 0)
begin
$display("Loading memory init file '" + MEMFILE + "' into array.");
$readmemh(MEMFILE, memory_array);
end
end
always @ (posedge i_clk)
begin
if(i_write) begin
memory_array[i_addr] <= i_data;
end
else begin
o_data <= memory_array[i_addr];
end
end
endmodule