Function rsim::processor::isa_mods::vector::replace_bits[][src]

pub fn replace_bits(original: u128, new_data: u128, bits: Range<usize>) -> u128

Function that replaces the bits of a value in a specific range with the bits at the bottom of a new value. The Range is expected in Verilog-style, i.e. all-inclusive unlike typical usages of Range. Panics if new_data has 1s outside of the range specified by bits

assert_eq!(
    replace_bits(0, 0xf, 12..15),
    0xf000
);
assert_eq!(
    replace_bits(0xffff_ffff, 0b1011, 28..31),
    0xbfff_ffff
);