Skip to content

Commit

Permalink
[delta_counter] Attach reset properly to overflow FF
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
FrancescoConti authored Aug 28, 2024
1 parent a66efbd commit 0823a77
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/delta_counter.sv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ 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

Check warning on line 41 in src/delta_counter.sv

View workflow job for this annotation

GitHub Actions / Verilog Sources

[verible-verilog-lint] reported by reviewdog 🐶 Remove trailing spaces. [Style: trailing-spaces] [no-trailing-spaces] Raw Output: message:"Remove trailing spaces. [Style: trailing-spaces] [no-trailing-spaces]" location:{path:"./src/delta_counter.sv" range:{start:{line:41 column:1}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:41 column:1} end:{line:42}} text:"\n"}
always_comb begin
overflow_d = overflow_q;
if (clear_i || load_i) begin
Expand Down

0 comments on commit 0823a77

Please sign in to comment.