import numpy as np from test_fft.register_addresses_fft_test import * from __main__ import RMAPPlugin0 def getWaveFromRecord( cwf, bufferSize, offset, column ): yVector = cwf[(0+offset):(bufferSize+offset), column] return yVector def sineWave( bufferSize, nbPeriod, amplitude): deltaX = nbPeriod * 2 * np.pi / bufferSize xVector = np.arange( bufferSize ) * deltaX yVector = np.int16( amplitude * np.sin( xVector ) ) return yVector def continuous( bufferSize, value ): tmpVector = np.empty( bufferSize ) tmpVector.fill( value ) yVector = np.int16( tmpVector ) return yVector def step( bufferSize, value ): tmpVector = np.empty( bufferSize ) for k in range( bufferSize / 2 ): tmpVector[ bufferSize / 2 + k ] = value yVector = np.int16( tmpVector ) return yVector def dirac( bufferSize, value ): tmpVector = np.zeros( bufferSize ) tmpVector[0] = value yVector = np.int16( tmpVector ) return yVector def generateDataToWrite( bufferSize, wfrm0, wfrm1 ): dataVector = [] for k in range(bufferSize): dataVector.append( ( (np.int16(wfrm1[k]) & 0xffff ) << 16) | (np.int16(wfrm0[k]) & 0xffff ) ) return dataVector def print_reg_fft( ): fft_reg = RMAPPlugin0.Read( address_CTRL, 1) out_ren = (fft_reg[0] & 0x0000001f) out_reuse = (fft_reg[0] & 0x000003e0) >> 5 out_locked = (fft_reg[0] & 0x00007c00) >> 10 MEM_IN_SM_Full = (fft_reg[0] & 0x000f8000) >> 15 MEM_IN_SM_Empty = (fft_reg[0] & 0x01f00000) >> 20 print "out_ren = " + bin( out_ren ) \ + ", out_reuse = " + bin( out_reuse ) \ + ", out_locked = " + bin( out_locked ) \ + ", MEM_IN_SM_Full = " + bin( MEM_IN_SM_Full ) \ + ", MEM_IN_SM_Empty = " + bin( MEM_IN_SM_Empty ) RMAPPlugin0.ProcessPendingEvents() def convertToSigned16Bits( dataToConvert ): dataInInt16 = np.int16( dataToConvert ) if dataInInt16 < 32768: val = dataInInt16 else: val = dataInInt16 - 65536 return val def convertVectorToSigned16Bits( bufferSize, dataBuffer ): dataBufferConverted = np.zeros( bufferSize ) for k in range( bufferSize ): dataBufferConverted[k] = convertToSigned16Bits( dataBuffer[k] ) return dataBufferConverted def convertToSigned8Bits( dataToConvert ): dataInInt16 = np.int8( dataToConvert ) if dataInInt16 < 8: val = dataInInt16 else: val = dataInInt16 - 16 return val