2 * This file is based on "Asynchronous FIFO" by Alex Claros F.,
3 * itself based on the article "Asynchronous FIFO in Virtex-II FPGAs"
7 module asfifo_graycounter #(
10 output reg [width-1:0] gray_count,
16 reg [width-1:0] binary_count;
18 always @(posedge clk, posedge rst) begin
20 binary_count <= {width{1'b0}} + 1;
21 gray_count <= {width{1'b0}};
23 binary_count <= binary_count + 1;
24 gray_count <= {binary_count[width-1],
25 binary_count[width-2:0] ^ binary_count[width-1:1]};