-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdutmem1.v
48 lines (39 loc) · 878 Bytes
/
dutmem1.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
39
40
41
42
43
44
45
46
47
48
//
// Created by : Harris Zhu
// Filename : dutmem0.v
// Author : Harris Zhu
// Created On : 2016-11-15 23:37
// Last Modified :
// Update Count : 2016-11-15 23:37
// Tags :
// Description :
// Conclusion :
//
//=======================================================================
module dutmem1(clk, rstn, ce, we, addr, din, dout);
parameter DWIDTH = 32;
parameter AWIDTH = 10;
parameter DEPTH = (1<<AWIDTH);
input clk, rstn;
input ce, we;
input [AWIDTH-1:0] addr;
input [DWIDTH-1:0] din;
output [DWIDTH-1:0] dout;
reg [DWIDTH-1:0] do_r;
reg [DWIDTH-1:0] mem [0:DEPTH-1];
always @(posedge clk)
begin
if(ce && we)
begin
mem[addr] <= din;
end
end
always @(posedge clk)
begin
if(ce && !we)
begin
do_r <= mem[addr];
end
end
assign dout = do_r;
endmodule