Altera_Forum
Honored Contributor
16 years agoClock domain crossing of a gray counter. Any constraints / directives / cells?
I have two unrelated clock domains 50MHz / 133MHz
> reg clk50; > reg clk133; I am implementing a Fifo between two clock domains. and have gray counters crossing the clock domains. > reg [13:0] grayctr133; // e.g. write pointer > reg [13:0] grayctr50; // e.g. readpointer In order to determine whether the fifo is full / empty I have to compare both gray counters so I thought about > reg [13:0] grayctr133_retimed50; > reg[13:0] grayctr50_retimed133; > always @(posedge clk50) begin > grayctr133_retimed50; > emtpy <= (grayctr50 == grayctr133_retimed50) & wasreading; > end My question: 1.) Will this work reliably or would I need double retiming before I could do the comparison? 2,) What is the correct way to tell the Quartus, that timing violations between grayctr133_retimed50 and grayctr133 can be ignored. Are there pragmas, that I can add directly into the RTL or do I have to add statements into the a constraint file / the synthesis script If both is possible, what would you recommend?