-
Notifications
You must be signed in to change notification settings - Fork 2
/
edge_detect.v
53 lines (41 loc) · 1.19 KB
/
edge_detect.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
49
50
51
52
53
/* ----------------------------------------- *
* Title : Edge Detector *
* Project : Verilog Utility Modules *
* ----------------------------------------- *
* File : edge_detect.v *
* Author : Yigit Suoglu *
* Last Edit : 25/11/2020 *
* Licence : CERN-OHL-W *
* ----------------------------------------- *
* Description : Modules to detect edges *
* ----------------------------------------- */
module det_pos_edge(clk, in, pedge);
input clk, in;
output pedge;
reg [1:0] in_del;
assign pedge = in_del[0] & (~in_del[1]);
always@(posedge clk)
begin
in_del <= {in_del[0], in};
end
endmodule//pos_edge
module det_neg_edge(clk, in, nedge);
input clk, in;
output nedge;
reg [1:0] in_del;
assign nedge = in_del[1] & (~in_del[0]);
always@(posedge clk)
begin
in_del <= {in_del[0], in};
end
endmodule//neg_edge
module det_np_edge(clk, in, npedge);
input clk, in;
output npedge;
reg [1:0] in_del;
assign npedge = in_del[0] ^ in_del[1];
always@(posedge clk)
begin
in_del <= {in_del[0], in};
end
endmodule//pos_edge