Skip to content

Commit

Permalink
delta_counter: Attach reset properly to overflow FF (#228)
Browse files Browse the repository at this point in the history
* [delta_counter] Attach reset properly to overflow FF

In the previous version of the code, the flip-flop was described non-idiomatically, using a ternary operator to implement the asynchronous reset. Some synthesis tools do not properly interpret this as a reset, resulting in gates being inserted on the reset network, which is undesirable.

* Update delta_counter.sv

Make the linter happy
  • Loading branch information
FrancescoConti authored Aug 29, 2024
1 parent a66efbd commit 10dac0f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/delta_counter.sv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ module delta_counter #(
logic [WIDTH:0] counter_q, counter_d;
if (STICKY_OVERFLOW) begin : gen_sticky_overflow
logic overflow_d, overflow_q;
always_ff @(posedge clk_i or negedge rst_ni) overflow_q <= ~rst_ni ? 1'b0 : overflow_d;

always_ff @(posedge clk_i or negedge rst_ni)
begin
if(rst_ni) begin
overflow_q <= 1'b0;
end else begin
overflow_q <= overflow_d;
end
end

always_comb begin
overflow_d = overflow_q;
if (clear_i || load_i) begin
Expand Down

0 comments on commit 10dac0f

Please sign in to comment.