forked from nand2mario/nestang
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdpram.v
38 lines (32 loc) · 763 Bytes
/
dpram.v
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
29
30
31
32
33
34
35
36
37
38
module dpram #(
parameter widthad_a,
parameter width_a = 8
) (
input [widthad_a-1:0] address_a,
input [widthad_a-1:0] address_b,
input clock_a,
input clock_b,
input [width_a-1:0] data_a,
input [width_a-1:0] data_b,
input wren_a,
input wren_b,
input [width_a/8-1:0] byteena_a,
input [width_a/8-1:0] byteena_b,
output reg [width_a-1:0] q_a,
output reg [width_a-1:0] q_b
);
localparam SIZE = 1 << widthad_a;
reg [width_a-1:0] mem [0:SIZE-1];
always @(posedge clock_a) begin
if (wren_a)
mem[address_a] <= data_a;
else
q_a <= mem[address_a];
end
always @(posedge clock_b) begin
if (wren_b)
mem[address_b] <= data_b;
else
q_b <= mem[address_b];
end
endmodule