(num_bits: int, v_in: BV)
Ensure given bv is num_bits bits long by either zero extending or truncating.
Ensure given bv is num_bits bits long by either zero extending or truncating.
Ensure given bv is num_bits bits long by either zero extending or truncating .
def _adjust_value_size(num_bits: int, v_in: BV) -> BV:
        """
        Ensure given bv is num_bits bits long by either zero extending or truncating.
        """
        if v_in.size() > num_bits:
            v_out = v_in[num_bits-1:0]
            l.debug('Truncating value %s (%d bits) to %s (%d bits)',
                    v_in,
                    v_in.size(),
                    v_out,
                    num_bits)
            return v_out
        elif v_in.size() < num_bits:
            v_out = v_in.zero_extend(num_bits-v_in.size())
            l.debug('Extending value %s (%d bits) to %s (%d bits)',
                    v_in,
                    v_in.size(),
                    v_out,
                    num_bits)
            return v_out
        else:
            return v_in
def _adjust_value_size ( num_bits : int , v_in : BV ) -> BV : if v_in . size ( ) > num_bits : v_out = v_in [ num_bits - 1 : 0 ] l . debug ( 'Truncating value %s (%d bits) to %s (%d bits)' , v_in , v_in . size ( ) , v_out , num_bits ) return v_out elif v_in . size ( ) < num_bits : v_out = v_in . zero_extend ( num_bits - v_in . size ( ) ) l . debug ( 'Extending value %s (%d bits) to %s (%d bits)' , v_in , v_in . size ( ) , v_out , num_bits ) return v_out else : return v_in