ad_edge_detect: Add a flop to output, reset is active high

main
Istvan Csomortani 2015-12-14 15:40:29 +02:00
parent f4e3523390
commit 29a0f27cd1
1 changed files with 15 additions and 9 deletions

View File

@ -57,7 +57,7 @@ module ad_edge_detect (
localparam ANY_EDGE = 2; localparam ANY_EDGE = 2;
input clk; input clk;
input rstn; input rst;
input in; input in;
output out; output out;
@ -65,8 +65,10 @@ module ad_edge_detect (
reg ff_m1 = 0; reg ff_m1 = 0;
reg ff_m2 = 0; reg ff_m2 = 0;
reg out = 0;
always @(posedge clk) begin always @(posedge clk) begin
if (rstn == 1) begin if (rst == 1) begin
ff_m1 <= 0; ff_m1 <= 0;
ff_m2 <= 0; ff_m2 <= 0;
end else begin end else begin
@ -75,15 +77,19 @@ module ad_edge_detect (
end end
end end
generate always @(posedge clk) begin
if (EDGE == POS_EDGE) begin if (rst == 1) begin
assign out = ff_m1 & ~ff_m2; out <= 1'b0;
end else if (EDGE == NEG_EDGE) begin
assign out = ~ff_m1 & ff_m2;
end else begin end else begin
assign out = ff_m1 ^ ff_m2; if (EDGE == POS_EDGE) begin
out <= ff_m1 & ~ff_m2;
end else if (EDGE == NEG_EDGE) begin
out <= ~ff_m1 & ff_m2;
end else begin
out <= ff_m1 ^ ff_m2;
end
end
end end
endgenerate
endmodule endmodule