-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.sv
56 lines (45 loc) · 751 Bytes
/
sync.sv
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
//These are synchronizers required for bringing asynchronous signals into the FPGA
//synchronizer with no reset (for switches/buttons)
module sync (
input logic Clk, SW,
output logic q
);
always_ff @ (posedge Clk)
begin
q <= SW;
end
endmodule
//synchronizer with reset to 0 (d_ff)
module sync_r0 (
input logic Clk, reset, SW,
output logic q
);
//initial
//begin
// q <= 1'b0;
//end
always_ff @ (posedge Clk or posedge reset)
begin
if (reset)
q <= 1'b0;
else
q <= SW;
end
endmodule
//synchronizer with reset to 1 (d_ff)
module sync_r1 (
input logic Clk, reset, SW,
output logic q
);
//initial
//begin
// q <= 1'b1;
//end
always_ff @ (posedge Clk or posedge reset)
begin
if (reset)
q <= 1'b1;
else
q <= SW;
end
endmodule