OpenCores
URL https://opencores.org/ocsvn/cdc_ufifo/cdc_ufifo/trunk

Subversion Repositories cdc_ufifo

[/] [cdc_ufifo/] [trunk/] [delay_pulse_ff.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 AlexRayne
/*
2
    provides delay on both edges of pulse
3
    1st positive, and 2nd stage negative
4
*/
5
module delay_pulse_ff(d
6
                , clock, enable, clrn
7
                , q
8
                );
9
parameter delay = 1;
10
parameter lpm_width =1;
11
 
12
input wire[lpm_width-1:0] d;
13
output wire[lpm_width-1:0] q;
14
input wire clock, enable, clrn;
15
 
16
generate
17
    if (delay == 0) begin
18
        assign q = d;
19
    end
20
    else begin
21
        reg [lpm_width-1:0] qt_pos [1:delay];
22
        reg [lpm_width-1:0] qt_neg [1:delay];
23
        integer k;
24
 
25
        always @(posedge clock or negedge clrn) begin
26
            if (~clrn)
27
                qt_pos[1] <= 0;
28
            else if (enable)
29
                qt_pos[1] <= d;
30
 
31
            for (k = 1; k < delay; k=k+1) begin : DelayRiseInstance
32
                if (~clrn)
33
                    qt_pos[k+1] <= 0;
34
                else if (enable)
35
                    qt_pos[k+1] <= qt_neg[k];
36
            end
37
        end
38
 
39
        always @(negedge clock or negedge clrn) begin
40
            if (~clrn)
41
                qt_neg[1] <= 0;
42
            else if (enable)
43
                qt_neg[1] <= qt_pos[1];
44
 
45
            for (k = 1; k < delay; k=k+1) begin : DelayFallInstance
46
                if (~clrn)
47
                    qt_neg[k+1] <= 0;
48
                else if (enable)
49
                    qt_neg[k+1] <= qt_pos[k];
50
            end
51
        end
52
 
53
        assign q = qt_neg[delay];
54
    end
55
endgenerate
56
 
57
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.