Skip to content

Commit

Permalink
add BitSignal::from_u128_padded (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulk29 authored Oct 7, 2024
1 parent 5c16cf5 commit ad168b2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions substrate/src/verification/simulation/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ impl BitSignal {
Self { bits }
}

#[inline]
pub fn from_u128(mut value: u128, width: usize) -> Self {
assert!(width <= 128);
Self::from_u128_padded(value, width)
}

pub fn from_u128_padded(mut value: u128, width: usize) -> Self {
let mut bits = BitVec::with_capacity(width);
for _ in 0..width {
bits.push(value & 1 != 0);
Expand Down

0 comments on commit ad168b2

Please sign in to comment.