From ab7e3d229bebcfae3dbeda4a5442a377eb6e1e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Mon, 1 Feb 2021 14:44:53 +0100 Subject: [PATCH] rpll: clean up asserts --- dsp/src/rpll.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dsp/src/rpll.rs b/dsp/src/rpll.rs index 79a2b30..108464e 100644 --- a/dsp/src/rpll.rs +++ b/dsp/src/rpll.rs @@ -49,7 +49,7 @@ impl RPLL { shift_frequency: u8, shift_phase: u8, ) -> (i32, u32) { - debug_assert!(shift_frequency > self.dt2); + debug_assert!(shift_frequency >= self.dt2); debug_assert!(shift_phase >= self.dt2); // Advance phase self.y = self.y.wrapping_add(self.f as i32); @@ -122,6 +122,10 @@ mod test { } fn run(&mut self, n: usize) -> (Vec, Vec) { + assert!(self.period >= 1 << self.dt2); + assert!(self.period < 1 << self.shift_frequency); + assert!(self.period < 1 << self.shift_phase + 1); + let mut y = Vec::::new(); let mut f = Vec::::new(); for _ in 0..n { @@ -162,10 +166,6 @@ mod test { } fn measure(&mut self, n: usize, limits: [f32; 4]) { - assert!(self.period >= 1 << self.dt2); - assert!(self.dt2 <= self.shift_frequency); - assert!(self.period < 1 << self.shift_frequency); - assert!(self.period < 1 << self.shift_frequency + 1); let t_settle = (1 << self.shift_frequency - self.dt2 + 4) + (1 << self.shift_phase - self.dt2 + 4); self.run(t_settle); @@ -190,7 +190,7 @@ mod test { print!("{:.2e} ", rel); assert!( rel <= 1., - "idx {}, have |{}| > want {}", + "idx {}, have |{:.2e}| > limit {:.2e}", i, m[i], limits[i]