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

Subversion Repositories cdc_ufifo

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 AlexRayne
module graycntr (gray, clk, inc, rst_n, gnext);
2
 
3
parameter lpm_width = 4;
4
 
5
output [lpm_width-1:0] gray;
6
output [lpm_width-1:0] gnext;
7
input clk, inc, rst_n;
8
reg [lpm_width-1:0] gnext, gray, bnext, bin;
9
 
10
integer i;
11
always @(posedge clk or negedge rst_n)
12
    if (!rst_n)
13
        gray <= 0;
14
    else if (inc)
15
        gray <= gnext;
16
 
17
always @(gray or inc) begin
18
    for (i=0; i<lpm_width; i=i+1)
19
        bin[i] = ^(gray>>i);
20
    bnext = bin+1'b1;
21
    gnext = (bnext>>1) ^ bnext;
22
end
23
 
24
endmodule

powered by: WebSVN 2.1.0

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