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

Subversion Repositories cdc_ufifo

[/] [cdc_ufifo/] [trunk/] [graycntr.v] - Rev 2

Compare with Previous | Blame | View Log

module graycntr (gray, clk, inc, rst_n, gnext);
 
parameter lpm_width = 4;
 
output [lpm_width-1:0] gray;
output [lpm_width-1:0] gnext;
input clk, inc, rst_n;
reg [lpm_width-1:0] gnext, gray, bnext, bin;
 
integer i;
always @(posedge clk or negedge rst_n)
    if (!rst_n) 
        gray <= 0;
    else if (inc)
        gray <= gnext;
 
always @(gray or inc) begin
    for (i=0; i<lpm_width; i=i+1)
        bin[i] = ^(gray>>i);
    bnext = bin+1'b1;
    gnext = (bnext>>1) ^ bnext;
end
 
endmodule

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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