I have an fpga project that uses synchronous flushes (I prefer synchronous flushes to asynchronous flushes for reasons discussed elsewhere). I have four different clock domains in the design, and I use one button to generate my reset signal, which, of course, is completely asynchronous to everything (except for my finger). I reject the button signal in each of the four clock domains in order to generate synchronous drops for four domains from the same source. My debounce module basically calculates N clock cycles of the reset button. If more than N cycles have passed with reset, then I generate my reset signal (the code for this module is inserted below).
The first question is, are there better ways to generate reset (s) than this method?
The second (more interesting question): when I look at the deadline reports (using xilinx tools), I see that all limit signals are related to reset. For example, the limit path from the reset generator (debouncer) to some register of the state of the machine state. The reset signals are very high (they relate to everything in their clock domains). I am a little surprised, although my speed is limited to reset. I find that I am limited to something like 8.5 nS where ~ 50% is routed and ~ 50% is the logic. Any suggestions on how to make this a little better? How do you feel about synchronous reset generation in fpga projects?
Here is the code to generate reset. Note that the reset signal is akin to debut output (for example, when I create an instance of the module, the debounced output is reset for this particular synchronization domain).
module button_debouncer( // Outputs debounced, // Inputs clk, button ); parameter WIDTH = 1; parameter NUM_CLKS_HIGH = 12000000; parameter log2_NUM_CLKS = 24; input clk; input [WIDTH-1:0] button; output [WIDTH-1:0] debounced; reg [WIDTH-1:0] b1, b2; reg [log2_NUM_CLKS-1:0] counter; always @(posedge clk) begin b1 <= button; b2 <= b1; end always @(posedge clk) begin if(~b2) counter <= 0; else if(counter < {log2_NUM_CLKS{1'b1}}) counter <= counter + 1; end
Doov source share