Skip to content

treewide: Make FFs clearable#314

Open
niwis wants to merge 8 commits into
v2-devfrom
nw/clr-v2
Open

treewide: Make FFs clearable#314
niwis wants to merge 8 commits into
v2-devfrom
nw/clr-v2

Conversation

@niwis

@niwis niwis commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Add an active-high synchronous clear clr_i to all modules, clearing all FFS to their reset value (analogous to rst_ni). Streamline the codebase by consistently using register macros for sequential logic.

Design principles:

  • clr_i shall clear all FFs, similar to rst_ni.
  • Every sequential module shall have a clr_i.
  • Consequently, if a module already has a functional clear that clears all FFs, rename that port to clr_i. If a an existing functional clear only clears a subset of FFs, rename that port to something distinctively else and add clr_i.

The previous stream_arbiter wrapper is now redundant and replaced by the previous stream_arbiter_flushable.

Sequential modules where no synchronous clear was added:

  • cdc_*
  • clk_*
  • edge_propagator*
  • isochronous_*
  • rstgen*

Add an active-high synchronous clear `clr_i` to the building-block modules,
clearing all flip-flops to their reset values (a synchronous counterpart to
the asynchronous `rst_ni`). Hand-written reset blocks are converted to the
`FFARNC`/`FFLARNC` clearable register macros.

Re-application of the original treewide change onto the v2-dev naming
(cc_ prefix, renamed parameters/types). Modules that already had a functional
clear which clears all FFs are renamed to `clr_i`; where a functional clear
covers only part of the state (cc_max_counter, cc_exp_backoff,
cc_serial_deglitch) it is kept alongside a separate general `clr_i`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@niwis niwis added this to the v2.0 milestone Jun 4, 2026
@niwis niwis added the v2 label Jun 4, 2026
@niwis niwis self-assigned this Jun 4, 2026
@niwis niwis marked this pull request as ready for review June 5, 2026 15:36
@niwis niwis requested a review from phsauter June 5, 2026 15:37

@phsauter phsauter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some cleanup to explain the difference between clr and other signals and to unify the comments a bit more. Should be easily doable by LLM.

Additionally the Readme needs updating:

  • cc_stream_arbiter_flushable is removed
  • rst_ni and clr_i need to be mentioned and their purpose explained
  • The use of the FF macros should be mentioned in the Readme.

Comment thread src/cc_counter.sv
input logic clk_i,
input logic rst_ni,
input logic clear_i, // synchronous clear
input logic clr_i, // synchronous clear

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are at it, could you make sure the comments here are consistent? Here it is lower case, in cb_filter it is uppercase. I think all modules should have a comment for each clock, the reset and the synchronous clear.
Active high is assumed but not stated, the resets active low is stated, where applicable (eg credit_counter) an additional bit of comment after a semicolon is useful.

Comment thread src/cc_fifo.sv
)(
input logic clk_i, // Clock
input logic rst_ni, // Asynchronous reset active low
input logic clr_i, // synchronous clear

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between clr_i and flush_i (the former clears the elements in the fifo to zero as well as clearing the pointers, which might have a slight energy penalty) should be stated since it is hard to understand without looking at the code.

Comment thread src/cc_stream_fifo.sv
) (
input logic clk_i, // Clock
input logic rst_ni, // Asynchronous reset active low
input logic clr_i, // Synchronous clear

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again state difference between clr and flush in comment.

) (
input logic clk_i, // Clock
input logic rst_ni, // Asynchronous reset active low
input logic clr_i, // Synchronous clear

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again state difference between clr and flush in comment.

) (
input logic clk_i ,
input logic rst_ni ,
input logic clr_i ,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again state difference between clr and flush in comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants