Skip to content

Instantly share code, notes, and snippets.

@LIMPIX31
Created February 15, 2026 13:48
Show Gist options
  • Select an option

  • Save LIMPIX31/f33475238d7f2d6c99d6e65b6e1d761f to your computer and use it in GitHub Desktop.

Select an option

Save LIMPIX31/f33475238d7f2d6c99d6e65b6e1d761f to your computer and use it in GitHub Desktop.
PI Filter for DPLL
module pi_filter #
( parameter DW = 10
, parameter KP = 4
, parameter KI = 6
)
( input logic clk
, input logic rst
, input logic i_valid
, output logic o_valid
, input logic signed [DW-1:0] i
, output logic signed [DW-1:0] o
);
logic signed [DW-1:0] acc;
always_ff @(posedge clk) begin
if (rst) begin
acc <= 0;
o <= 0;
end else if (i_valid) begin
acc <= acc + i;
o <= (acc >>> KI) + (i >>> KP);
end
end
always_ff @(posedge clk) begin
o_valid <= i_valid;
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment