prim_clk_counter

Count clk_i edges while a reference window on refclk_i is open.

Close the window on refclk_cnt_done_i and make clk_cnt_o valid; the counter restarts from zero at each window end and saturates at all ones. test_mode_i swaps scan_rst_ni onto the reset path. cnt_en_i must be high for the counter to run; it crosses from refclk_i to clk_i through a 4-phase handshake, and refclk_cnt_done_i through a toggle pulse synchronizer.

Parameters

Table 1. Parameters
NameTypeDefaultDescription
WIDTHint unsigned24Counter width.

Ports

Table 2. Ports
NameDirectionTypeDescription
refclk_iinputlogicReference clock for the measurement window.
refclk_cnt_done_iinputlogicSingle-cycle pulse on refclk_i that ends each window.
refclk_rst_niinputlogicActive-low reset for the refclk_i-side logic and both CDC source sides.
clk_iinputlogicClock under measurement.
rst_niinputlogicActive-low reset for the clk_i domain; asserts asynchronously, deasserts after four clk_i cycles.
test_mode_iinputlogicSelects scan_rst_ni on the reset mux.
scan_rst_niinputlogicDFT scan reset, active-low.
cnt_en_iinputlogicEnables counting; in the refclk_i domain. Low clears the count and clk_cnt_valid_o.
clk_cnt_ooutputlogic [WIDTH-1:0]clk_i cycles counted in the last closed window.
clk_cnt_valid_ooutputlogicclk_cnt_o is valid after the window closes.