diff --git a/fast-servo/pid_err_sig_pipeline.patch b/fast-servo/pid_err_sig_pipeline.patch new file mode 100644 index 0000000..4e09e27 --- /dev/null +++ b/fast-servo/pid_err_sig_pipeline.patch @@ -0,0 +1,19 @@ +diff --git a/gateware/logic/pid.py b/gateware/logic/pid.py +index e737577..f1a4096 100644 +--- a/gateware/logic/pid.py ++++ b/gateware/logic/pid.py +@@ -43,10 +43,12 @@ class PID(Module, AutoCSR): + self.comb += [setpoint_signed.eq(self.setpoint.storage)] + + self.error = Signal((self.width + 1, True)) ++ error_reg = Signal((self.width + 1, True)) ++ self.sync += self.error.eq(error_reg) + + self.comb += [ +- If(self.running, self.error.eq(self.input - self.setpoint.storage)).Else( +- self.error.eq(0) ++ If(self.running, error_reg.eq(self.input - self.setpoint.storage)).Else( ++ error_reg.eq(0) + ) + ] + diff --git a/flake.nix b/flake.nix index f3d89b0..80c0b46 100644 --- a/flake.nix +++ b/flake.nix @@ -169,6 +169,7 @@ fast-servo/iir_pipeline.patch fast-servo/linien_module_pipeline.patch fast-servo/pid_pipeline.patch + fast-servo/pid_err_sig_pipeline.patch ]; nativeBuildInputs = [ (pkgs.python3.withPackages(ps: [