hwt/hdl/types/arrayCast.py
def getBits_from_array(array, wordWidth, start, end,
                       reinterpretElmToType=None):
    """
    Gets value of bits between selected range from memory

    :param start: bit address of start of bit of bits
    :param end: bit address of first bit behind bits
    :return: instance of BitsVal (derived from SimBits type) which contains
        copy of selected bits
    """
    inPartOffset = 0
    value = Bits(end - start, None).fromPy(None)

    while start != end:
        assert start < end, (start, end)

        dataWordIndex = start // wordWidth

        v = array[dataWordIndex]
        if reinterpretElmToType is not None:
            v = v._reinterpret_cast(reinterpretElmToType)

        endOfWord = (dataWordIndex + 1) * wordWidth
        width = min(end, endOfWord) - start
        offset = start % wordWidth

        val = selectBitRange(v.val, offset, width)
        vldMask = selectBitRange(v.vldMask, offset, width)
        updateTime = v.updateTime

        m = mask(width)
        value.val |= (val & m) << inPartOffset
        value.vldMask |= (vldMask & m) << inPartOffset
        value.updateMask = max(value.updateTime, updateTime)

        inPartOffset += width
        start += width

    return value
def getBits_from_array(array, wordWidth, start, end,
                       reinterpretElmToType=None):
    inPartOffset = 0
    value = Bits(end - start, None).fromPy(None)

    while start != end:
        assert start < end, (start, end)

        dataWordIndex = start // wordWidth

        v = array[dataWordIndex]
        if reinterpretElmToType is not None:
            v = v._reinterpret_cast(reinterpretElmToType)

        endOfWord = (dataWordIndex + 1) * wordWidth
        width = min(end, endOfWord) - start
        offset = start % wordWidth

        val = selectBitRange(v.val, offset, width)
        vldMask = selectBitRange(v.vldMask, offset, width)
        updateTime = v.updateTime

        m = mask(width)
        value.val |= (val & m) << inPartOffset
        value.vldMask |= (vldMask & m) << inPartOffset
        value.updateMask = max(value.updateTime, updateTime)

        inPartOffset += width
        start += width

    return value
def getBits_from_array ( array , wordWidth , start , end , reinterpretElmToType = None ) : inPartOffset = 0 value = Bits ( end - start , None ) . fromPy ( None ) while start != end : assert start < end , ( start , end ) dataWordIndex = start // wordWidth v = array [ dataWordIndex ] if reinterpretElmToType is not None : v = v . _reinterpret_cast ( reinterpretElmToType ) endOfWord = ( dataWordIndex + 1 ) * wordWidth width = min ( end , endOfWord ) - start offset = start % wordWidth val = selectBitRange ( v . val , offset , width ) vldMask = selectBitRange ( v . vldMask , offset , width ) updateTime = v . updateTime m = mask ( width ) value . val |= ( val & m ) << inPartOffset value . vldMask |= ( vldMask & m ) << inPartOffset value . updateMask = max ( value . updateTime , updateTime ) inPartOffset += width start += width return value
Gets value of bits between selected range from memory

    :param start: bit address of start of bit of bits
    :param end: bit address of first bit behind bits
    :return: instance of BitsVal (derived from SimBits type) which contains
        copy of selected bits
Gets value of bits between selected range from memory