Skip to content

Commit

Permalink
[rtl, prim] Add 'commit' functionality to prim_count
Browse files Browse the repository at this point in the history
When the new `commit_i` input is enabled (via the 'EnableCommit'
parameter) changes to the count will only occur if `commit_i` is set.
Crucially the `cnt_next_o` output is unaffected by the commit. That
provides you with the next counter state, if the commit occurs.

Signed-off-by: Greg Chadwick <[email protected]>
  • Loading branch information
GregAC committed Jan 26, 2024
1 parent 5200790 commit c721c51
Show file tree
Hide file tree
Showing 43 changed files with 146 additions and 88 deletions.
3 changes: 2 additions & 1 deletion hw/ip/clkmgr/rtl/clkmgr_trans.sv
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ module clkmgr_trans
.incr_en_i(mubi4_test_true_strict(idle[0]) & ~idle_valid),
.decr_en_i(1'b0),
.step_i(IdleCntWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(idle_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/csrng/rtl/csrng_cmd_stage.sv
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ module csrng_cmd_stage import csrng_pkg::*; #(
.incr_en_i(1'b0),
.decr_en_i(cmd_gen_cnt_dec), // Count down.
.step_i(GenBitsCntrWidth'(1)),
.commit_i(1'b1),
.cnt_o(cmd_gen_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cmd_gen_cnt_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/csrng/rtl/csrng_ctr_drbg_gen.sv
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ module csrng_ctr_drbg_gen import csrng_pkg::*; #(
.incr_en_i(v_ctr_inc), // count up
.decr_en_i(1'b0),
.step_i(CtrLen'(1)),
.commit_i(1'b1),
.cnt_o(v_ctr),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(ctr_drbg_gen_v_ctr_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/csrng/rtl/csrng_ctr_drbg_upd.sv
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ module csrng_ctr_drbg_upd #(
.incr_en_i(v_ctr_inc), // count up
.decr_en_i(1'b0),
.step_i(CtrLen'(1)),
.commit_i(1'b1),
.cnt_o(v_ctr),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(ctr_drbg_upd_v_ctr_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/edn/rtl/edn_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,9 @@ module edn_core import edn_pkg::*;
.incr_en_i(1'b0),
.decr_en_i(send_gencmd && cmd_sent), // count down
.step_i(RegWidth'(1)),
.commit_i(1'b1),
.cnt_o(max_reqs_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(max_reqs_cnt_err)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_adaptp_ht.sv
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ module entropy_src_adaptp_ht #(
.incr_en_i(entropy_bit_vld_i),
.decr_en_i(1'b0),
.step_i(RegWidth'(entropy_bit_i[sh])),
.commit_i(1'b1),
.cnt_o(test_cnt[sh]),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(test_cnt_err[sh])
);
end : gen_cntrs
Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_bucket_ht.sv
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ module entropy_src_bucket_ht #(
.incr_en_i(bin_incr[i]),
.decr_en_i(1'b0),
.step_i(RegWidth'(1)),
.commit_i(1'b1),
.cnt_o(bin_cntr[i]),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(bin_cntr_err[i])
);
assign bin_cnt_exceeds_thresh[i] = (bin_cntr[i] > thresh_i);
Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_cntr_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ module entropy_src_cntr_reg #(
.incr_en_i(event_i && (~counter_value != '0)),
.decr_en_i(1'b0),
.step_i(RegWidth'(1)),
.commit_i(1'b1),
.cnt_o(counter_value),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,9 @@ module entropy_src_core import entropy_src_pkg::*; #(
.incr_en_i(health_test_esbus_vld),
.decr_en_i(1'b0),
.step_i(HalfRegWidth'(1)),
.commit_i(1'b1),
.cnt_o(window_cntr),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(window_cntr_err)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_markov_ht.sv
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ module entropy_src_markov_ht #(
.incr_en_i(samples_no_match_pulse[sh]),
.decr_en_i(1'b0),
.step_i(RegWidth'(1)),
.commit_i(1'b1),
.cnt_o(pair_cntr[sh]),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(pair_cntr_err[sh])
);
end : gen_cntrs
Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_repcnt_ht.sv
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ module entropy_src_repcnt_ht #(
.incr_en_i(samples_match_pulse[sh]),
.decr_en_i(1'b0),
.step_i(RegWidth'(1)),
.commit_i(1'b1),
.cnt_o(rep_cntr[sh]),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(rep_cntr_err[sh])
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/entropy_src/rtl/entropy_src_repcnts_ht.sv
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ module entropy_src_repcnts_ht #(
.incr_en_i(samples_match_pulse),
.decr_en_i(1'b0),
.step_i(RegWidth'(1)),
.commit_i(1'b1),
.cnt_o(rep_cntr),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(rep_cntr_err)
);

Expand Down
15 changes: 10 additions & 5 deletions hw/ip/flash_ctrl/rtl/flash_ctrl_lcmgr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ module flash_ctrl_lcmgr
.incr_en_i(seed_cnt_en),
.decr_en_i(1'b0),
.step_i(SeedCntWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(seed_cnt_q),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(seed_cnt_err_d)
);

Expand All @@ -216,8 +217,9 @@ module flash_ctrl_lcmgr
.incr_en_i(addr_cnt_en),
.decr_en_i(1'b0),
.step_i(SeedRdsWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(addr_cnt_q),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(addr_cnt_err_d)
);

Expand Down Expand Up @@ -623,8 +625,9 @@ module flash_ctrl_lcmgr
.incr_en_i(page_cnt_incr),
.decr_en_i(1'b0),
.step_i(PageCntWidth'(1)),
.commit_i(1'b1),
.cnt_o(page_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(page_err_d)
);

Expand All @@ -641,8 +644,9 @@ module flash_ctrl_lcmgr
.incr_en_i(word_cnt_incr),
.decr_en_i(1'b0),
.step_i(WordCntWidth'(MaxRmaProgBurst)),
.commit_i(1'b1),
.cnt_o(word_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(word_err_d)
);

Expand All @@ -659,8 +663,9 @@ module flash_ctrl_lcmgr
.incr_en_i(rma_wipe_idx_incr),
.decr_en_i(1'b0),
.step_i(WipeIdxWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(rma_wipe_idx),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(rma_idx_err_d)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/flash_ctrl/rtl/flash_ctrl_prog.sv
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ module flash_ctrl_prog import flash_ctrl_pkg::*; (
.incr_en_i(data_rd_o),
.decr_en_i(1'b0),
.step_i(12'h1),
.commit_i(1'b1),
.cnt_o(cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/flash_ctrl/rtl/flash_ctrl_rd.sv
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ module flash_ctrl_rd import flash_ctrl_pkg::*; (
.incr_en_i(data_wr_o),
.decr_en_i(1'b0),
.step_i(12'h1),
.commit_i(1'b1),
.cnt_o(cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/flash_ctrl/rtl/flash_phy_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ module flash_phy_core
.incr_en_i(host_gnt && !host_req_done_o && (host_outstanding <= RspOrderDepth)),
.decr_en_i(!host_gnt && host_req_done_o && |host_outstanding),
.step_i(OutstandingRdWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(host_outstanding),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/keymgr/rtl/keymgr_ctrl.sv
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ module keymgr_ctrl
.incr_en_i(op_update | random_req),
.decr_en_i(1'b0),
.step_i(CntWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/keymgr/rtl/keymgr_kmac_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ module keymgr_kmac_if import keymgr_pkg::*;(
.incr_en_i(1'b0),
.decr_en_i(cnt_en),
.step_i(CntWidth'(1'b1)),
.commit_i(1'b1),
.cnt_o(cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/keymgr/rtl/keymgr_reseed_ctrl.sv
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ module keymgr_reseed_ctrl import keymgr_pkg::*; (
.incr_en_i(cnt_en),
.decr_en_i(1'b0),
.step_i(16'h1),
.commit_i(1'b1),
.cnt_o(reseed_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/kmac/rtl/keccak_round.sv
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ module keccak_round
.incr_en_i(inc_rnd_num),
.decr_en_i(1'b0),
.step_i(RndW'(1)),
.commit_i(1'b1),
.cnt_o(round),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(round_count_error_o)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/kmac/rtl/kmac_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ module kmac_core
.incr_en_i(inc_keyidx),
.decr_en_i(1'b0),
.step_i(sha3_pkg::KeccakMsgAddrW'(1)),
.commit_i(1'b1),
.cnt_o(key_index),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(key_index_error_o)
);

Expand Down
6 changes: 4 additions & 2 deletions hw/ip/kmac/rtl/kmac_entropy.sv
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ module kmac_entropy
.incr_en_i(hash_cnt_en),
.decr_en_i(1'b0),
.step_i(HashCntW'(1)),
.commit_i(1'b1),
.cnt_o(hash_cnt_o),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(hash_count_error)
);

Expand Down Expand Up @@ -384,8 +385,9 @@ module kmac_entropy
.incr_en_i(|lfsr_seed_en),
.decr_en_i(1'b0),
.step_i(SeedIdxWidth'(1)),
.commit_i(1'b1),
.cnt_o(seed_idx),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(seed_idx_count_error)
);

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/kmac/rtl/sha3pad.sv
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ module sha3pad
.incr_en_i(inc_sentmsg),
.decr_en_i(1'b0),
.step_i(KeccakCountW'(1)),
.commit_i(1'b1),
.cnt_o(sent_message),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(msg_count_error_o)
);

Expand Down
19 changes: 10 additions & 9 deletions hw/ip/otbn/rtl/otbn_loop_controller.sv
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,16 @@ module otbn_loop_controller
) u_loop_count (
.clk_i,
.rst_ni,
.clr_i (state_reset_i),
.set_i (loop_count_set),
.set_cnt_i (new_loop.loop_iterations),
.incr_en_i (1'b0),
.decr_en_i (loop_count_dec), // count down
.step_i (32'd1),
.cnt_o (loop_counters[i_count]),
.cnt_next_o(),
.err_o (loop_counter_err[i_count])
.clr_i (state_reset_i),
.set_i (loop_count_set),
.set_cnt_i (new_loop.loop_iterations),
.incr_en_i (1'b0),
.decr_en_i (loop_count_dec), // count down
.step_i (32'd1),
.commit_i (1'b1),
.cnt_o (loop_counters[i_count]),
.cnt_after_commit_o(),
.err_o (loop_counter_err[i_count])
);

assign loop_counter_err_d[i_count] = loop_counter_err_q[i_count] | loop_counter_err[i_count];
Expand Down
19 changes: 10 additions & 9 deletions hw/ip/otbn/rtl/otbn_stack.sv
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ module otbn_stack
) u_stack_wr_ptr (
.clk_i,
.rst_ni,
.clr_i (clear_i),
.set_i (1'b0),
.set_cnt_i ('0),
.incr_en_i (stack_write),
.decr_en_i (stack_read),
.step_i ((StackDepthW+1)'(1'b1)),
.cnt_o (stack_wr_ptr),
.cnt_next_o (next_stack_wr_ptr),
.err_o (cnt_err)
.clr_i (clear_i),
.set_i (1'b0),
.set_cnt_i ('0),
.incr_en_i (stack_write),
.decr_en_i (stack_read),
.step_i ((StackDepthW+1)'(1'b1)),
.commit_i (1'b1),
.cnt_o (stack_wr_ptr),
.cnt_after_commit_o (next_stack_wr_ptr),
.err_o (cnt_err)
);

assign cnt_err_d = cnt_err_q | cnt_err;
Expand Down
3 changes: 2 additions & 1 deletion hw/ip/otp_ctrl/rtl/otp_ctrl_dai.sv
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,9 @@ module otp_ctrl_dai
.incr_en_i(cnt_en),
.decr_en_i(1'b0),
.step_i(CntWidth'(1)),
.commit_i(1'b1),
.cnt_o(cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(cnt_err)
);

Expand Down
6 changes: 4 additions & 2 deletions hw/ip/otp_ctrl/rtl/otp_ctrl_kdi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ module otp_ctrl_kdi
.incr_en_i(seed_cnt_en),
.decr_en_i(1'b0),
.step_i(CntWidth'(1)),
.commit_i(1'b1),
.cnt_o(seed_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(seed_cnt_err)
);

Expand All @@ -242,8 +243,9 @@ module otp_ctrl_kdi
.incr_en_i(entropy_cnt_en),
.decr_en_i(1'b0),
.step_i(CntWidth'(1)),
.commit_i(1'b1),
.cnt_o(entropy_cnt),
.cnt_next_o(),
.cnt_after_commit_o(),
.err_o(entropy_cnt_err)
);

Expand Down
Loading

0 comments on commit c721c51

Please sign in to comment.