-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRAM.v
More file actions
24 lines (21 loc) · 684 Bytes
/
RAM.v
File metadata and controls
24 lines (21 loc) · 684 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
`timescale 1ns / 1ps
module RAM #( parameter DATA_WIDTH = 8, ADDRESS_WIDTH = 8, DEPTH = 256, MEMFILE = "") (
input wire clk,
input wire wEn,
input wire [ADDRESS_WIDTH-1:0] addr,
input wire [DATA_WIDTH-1:0] dataIn,
output reg [DATA_WIDTH-1:0] dataOut);
reg[DATA_WIDTH-1:0] MemoryArray[0:DEPTH-1];
initial begin
if(MEMFILE > 0) begin
$readmemh(MEMFILE, MemoryArray);
end
end
always @(posedge clk) begin
if(wEn) begin
MemoryArray[addr] <= dataIn;
end else begin
dataOut <= MemoryArray[addr];
end
end
endmodule