prim_updown_counter

Count up or down with saturation, clear, set, and commit.

RESET_VALUE can be nonzero so a down-counter need not start at 0. incr_en_i and decr_en_i together do not count; either alone steps by step_i. clear_i takes priority over set_i, which takes priority over counting. commit_i freezes cnt_after_commit_o into count_o; without it the next value stays speculative, so clear_i and set_i also take effect only with commit_i.

Parameters

Table 1. Parameters
NameTypeDefaultDescription
WIDTHint16Counter width.
RESET_VALUElogic [WIDTH-1:0]'0Value loaded on reset or clear_i; may be nonzero when the counter is used as a down-counter.

Ports

Table 2. Ports
NameDirectionTypeDescription
clk_iinputCounter clock.
rst_niinputActive-low reset, sampled synchronously; loads RESET_VALUE.
clear_iinputLoads RESET_VALUE when committed.
set_iinputLoads set_cnt_i when committed.
set_cnt_iinputctr_tValue loaded when set_i is high.
incr_en_iinputCounts up by step_i.
decr_en_iinputCounts down by step_i.
step_iinputctr_tIncrement or decrement step when enabled.
commit_iinputCommits the pending next value.
count_ooutputctr_tCurrent committed counter state.
cnt_after_commit_ooutputctr_tNext counter state if commit_i is taken.
err_ooutputlogicHardening error output; tied to 0.