-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday2_DFF.sv
More file actions
65 lines (47 loc) · 1.04 KB
/
day2_DFF.sv
File metadata and controls
65 lines (47 loc) · 1.04 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
// Different DFF
module day2 (
input logic clk,
input logic reset,
input logic d_i,
output logic q_norst_o,
output logic q_syncrst_o,
output logic q_asyncrst_o
);
// Asyn including reset and clk, Sync ONLY includes clk.
//Async reset FF
always_ff @(posedge clk or posedge reset) begin
if(reset) q_asyncrst_o <= 1'b0;
else q_asyncrst_o <= d_i;
end
//Sync reset FF
always_ff @(posedge clk) begin
if(reset) q_syncrst_o <= 1'b0;
else q_syncrst_o <= d_i;
end
//No reset
always_ff @(posedge clk) begin
q_norst_o <= d_i;
end
endmodule
module tb;
logic clk;
logic reset;
logic d_i;
logic q_norst_o;
logic q_syncrst_o;
logic q_asyncrst_o;
day2 rtl (.*);
always #2 clk = !clk;
always #2 d_i = $urandom;
initial begin
$dumpfile("dump.vcd");
$dumpvars;
end
initial begin
reset=1; clk=0; d_i=1'b1;
@(posedge clk)
reset=0;
#30;
$finish;
end
endmodule