Skip to content

Commit f816f37

Browse files
committed
add from_u128 for BitSignal
1 parent 154560d commit f816f37

File tree

1 file changed

+10
-0
lines changed
  • substrate/src/verification/simulation

1 file changed

+10
-0
lines changed

substrate/src/verification/simulation/bits.rs

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ impl BitSignal {
4949
Self { bits }
5050
}
5151

52+
pub fn from_u128(mut value: u128, width: usize) -> Self {
53+
assert!(width <= 128);
54+
let mut bits = BitVec::with_capacity(width);
55+
for _ in 0..width {
56+
bits.push(value & 1 != 0);
57+
value >>= 1;
58+
}
59+
Self { bits }
60+
}
61+
5262
#[inline]
5363
pub fn ones(width: usize) -> Self {
5464
Self {

0 commit comments

Comments
 (0)