soc/picorv32/common/boot_load.py
def read_verilog_hex(fName):
    '''
    Read a verilog .hex file with 32 bit words.
    Returns a bytearray with the data, ready to be flashed into
    picoRV32 memory
    '''
    binBuffer = bytearray(2**16 * 4)
    currentWordAddr = 0
    with open(fName) as f:
        for hexLine in f:
            hexLine = hexLine.strip()
            if hexLine.startswith('\\'):
                continue
            if hexLine.startswith('@'):
                currentWordAddr = int(hexLine[1:], 16)
                print(hexLine)
                continue
            tempWord = int(hexLine, 16)
            binBuffer[currentWordAddr * 4 + 3] = (tempWord >> 24) & 0xFF
            binBuffer[currentWordAddr * 4 + 2] = (tempWord >> 16) & 0xFF
            binBuffer[currentWordAddr * 4 + 1] = (tempWord >> 8) & 0xFF
            binBuffer[currentWordAddr * 4 + 0] = (tempWord >> 0) & 0xFF
            currentWordAddr += 1
    return binBuffer[0: currentWordAddr * 4]

    Read a verilog .hex file with 32 bit words.
    Returns a bytearray with the data, ready to be flashed into
    picoRV32 memory
    
Read a verilog .hex file with 32 bit words.
Returns a bytearray with the data, ready to be flashed into
picoRV32 memory
Read a verilog . hex file with 32 bit words . Returns a bytearray with the data ready to be flashed into picoRV32 memory
def read_verilog_hex(fName):
    binBuffer = bytearray(2**16 * 4)
    currentWordAddr = 0
    with open(fName) as f:
        for hexLine in f:
            hexLine = hexLine.strip()
            if hexLine.startswith('\\'):
                continue
            if hexLine.startswith('@'):
                currentWordAddr = int(hexLine[1:], 16)
                print(hexLine)
                continue
            tempWord = int(hexLine, 16)
            binBuffer[currentWordAddr * 4 + 3] = (tempWord >> 24) & 0xFF
            binBuffer[currentWordAddr * 4 + 2] = (tempWord >> 16) & 0xFF
            binBuffer[currentWordAddr * 4 + 1] = (tempWord >> 8) & 0xFF
            binBuffer[currentWordAddr * 4 + 0] = (tempWord >> 0) & 0xFF
            currentWordAddr += 1
    return binBuffer[0: currentWordAddr * 4]
def read_verilog_hex ( fName ) : binBuffer = bytearray ( 2 ** 16 * 4 ) currentWordAddr = 0 with open ( fName ) as f : for hexLine in f : hexLine = hexLine . strip ( ) if hexLine . startswith ( '\\' ) : continue if hexLine . startswith ( '@' ) : currentWordAddr = int ( hexLine [ 1 : ] , 16 ) print ( hexLine ) continue tempWord = int ( hexLine , 16 ) binBuffer [ currentWordAddr * 4 + 3 ] = ( tempWord >> 24 ) & 0xFF binBuffer [ currentWordAddr * 4 + 2 ] = ( tempWord >> 16 ) & 0xFF binBuffer [ currentWordAddr * 4 + 1 ] = ( tempWord >> 8 ) & 0xFF binBuffer [ currentWordAddr * 4 + 0 ] = ( tempWord >> 0 ) & 0xFF currentWordAddr += 1 return binBuffer [ 0 : currentWordAddr * 4 ]
Read a verilog .hex file with 32 bit words.
Read a verilog . hex file with 32 bit words .
'''
    Read a verilog .hex file with 32 bit words.
    Returns a bytearray with the data, ready to be flashed into
    picoRV32 memory
    '''
fName