diff --git a/crates/rhdl-core/src/bitx/dyn_bit_manip.rs b/crates/rhdl-core/src/bitx/dyn_bit_manip.rs index fef9eb96..25695493 100644 --- a/crates/rhdl-core/src/bitx/dyn_bit_manip.rs +++ b/crates/rhdl-core/src/bitx/dyn_bit_manip.rs @@ -141,16 +141,17 @@ pub fn move_nbits_to_msb(a: &[T], n: usize) -> Vec { [right, left].concat() } +/// Const helper to compute maximum of two usize values. +pub const fn const_max2(a: usize, b: usize) -> usize { + if a > b { a } else { b } +} + #[macro_export] /// Macro to compute the maximum of a list of constant expressions at compile time. macro_rules! const_max { ($x: expr) => ($x); ($x: expr, $($z: expr), +) => ( - if $x > const_max!($($z), +) { - $x - } else { - const_max!($($z), +) - } + $crate::bitx::dyn_bit_manip::const_max2($x, const_max!($($z),+)) ); }