-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemo.v
More file actions
39 lines (37 loc) · 852 Bytes
/
memo.v
File metadata and controls
39 lines (37 loc) · 852 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
29
30
31
32
33
34
35
36
37
38
39
module mem
(input wire [0:7] din,input wire [0:9] add,input wire wr,en,clk,output reg [0:7] dout);
reg [0:7] memo [0:1023];
always @ (posedge clk)
begin
if(en)
begin
if(wr)
begin
memo[add] <= din;
end
else
dout<=memo[add];
end
end
endmodule // mem
module tg
(output reg [0:7] din,output reg [0:9] add,output reg wr,en,clk,input wire [0:7] dout);
initial begin
$monitor($time,,,,"din=%b add=%b wr=%b en=%b clk=%b dout=%b",din,add,wr,en,clk,dout);
clk=0;
din=43;
add=32;
en=1;
#1 wr=1;
#2 wr=0;
#1 $finish;
end
always #1 clk=~clk;
endmodule // tg
module wb;
wire [0:7] din,dout;
wire [0:9] add;
wire wr,en,clk;
mem mem1(din,add,wr,en,clk,dout);
tg tg1(din,add,wr,en,clk,dout);
endmodule // wb