forked from ashishrana160796/verilog-starter-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncAndSyncDFlipFlop.v
More file actions
82 lines (75 loc) · 1.48 KB
/
AsyncAndSyncDFlipFlop.v
File metadata and controls
82 lines (75 loc) · 1.48 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
module sync_async(in1,in2,out1,out2,reset,clock);
input in1;
input in2;
output out1;
output out2;
input reset;
input clock;
reg out1,out2;
// Synchronous : Depend on clock.
always @(posedge clock)
begin
if(reset)
out1=0;
else
out1=in1;
end
// Asynchronous : Independent of clock.
always @(posedge clock or reset)
begin
if(reset)
out2=0;
else
out2=in2;
end
endmodule
module test;
integer i;
reg in1,in2,reset,clock;
wire out1,out2;
sync_async a1(in1,in2,out1,out2,reset,clock);
initial
begin
$dumpfile("vcd/SyncAndAsyncDFlipFlop.vcd");
$dumpvars(0,test);
$display("in1 in2 out1 out2 reset clock");
$monitor("%b %b %b %b %b %b ",in1,in2,out1,out2,reset,clock);
in1= 0;
in2=0;
reset=0;
#10
in1= 0;
in2=1;
reset=0;
#10
in1 = 1;
in2=0;
reset=0;
#10
in1=1;
in2=1;
reset=0;
#10
in1= 0;
in2=0;
reset=1;
#10
in1= 0;
in2=1;
reset=1;
#10
in1 = 1;
in2=0;
reset=1;
#10
in1=1;
in2=1;
reset=1;
$finish;
end
initial begin
clock = 0;
for(i=0;i<20;i=i+1)
#4 clock = ~clock;
end
endmodule