From 8ccc61f9fae80ff1eeb70bf14e996c61df1fd890 Mon Sep 17 00:00:00 2001 From: Marcel Lauwerijssen Date: Thu, 25 Nov 2004 11:09:45 +0000 Subject: Further preparations for splitting up the audio I/O component and FFT component into 2 separate clockdomains. --- FFT_Test/fft.hcc | 158 ++++++++++++++++++++++++++++++---------------------- FFT_Test/fft.hch | 8 ++- FFT_Test/runfft.hcc | 33 +++++------ 3 files changed, 112 insertions(+), 87 deletions(-) diff --git a/FFT_Test/fft.hcc b/FFT_Test/fft.hcc index 93f4d62..30feb98 100644 --- a/FFT_Test/fft.hcc +++ b/FFT_Test/fft.hcc @@ -1,19 +1,37 @@ +/*! \file eventhandler.hcc + * + * \section generic This modules coordinates all events. Thus for example + * when the mousehandler registers a 'click' we coordinate + * the actions that follow that click. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author M. Lauwerijssen + * \date 20041110 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041110: M. Lauwerijssen\n Initial version + * + ********************************************************************/ #define PAL_TARGET_CLOCK_RATE 50000000 +/******** System Includes *************/ #include #include "pal_master.hch" +/******** Application Includes ********/ #include "audio.hch" #include "weights_256.hch" #include "configuration.hch" #include "debug.hch" #include "xilinxmult.hch" -#define HARDWARE_MULTIPLY 1 -#define PERFORM_FFT_CALCULATION 1 /* Define two multi-port RAMs for FFT calculation; one for real and one for imaginary values * Extra block RAM settings are defined to make sure read and write actions can be performed * within one clock-cycle. - * Left out extra settings on new board the clock changes TODO !!!! */ #if HARDWARE_MULTIPLY mpram @@ -44,19 +62,16 @@ mpram ram signed 7 eq_settings[16] = {0,2,4,7,10,13,16,19,22,26,30,35,41,48,55,63}; -/**************************************************************** -* Function: multiply * -* * -* Arguments * -* x,y signed variables * -* * -* Description * -* Just a multiplier. But by doing this in a function the * -* FPGA space needed is reduced. * -* * -* Return Values * -* The result after multiplication * -****************************************************************/ +/*! \fn macro proc multiply(result, op_a, op_b); + * \brief + * + * \param result variable containing the result of the multiply procedure + * \param op_a integer value to be multiplied. + * \param op_b integer value to be multiplied. + * + * \return Procedure returns through variable. + * \retval signed 36 + */ macro proc multiply(result, op_a, op_b) { #if HARDWARE_MULTIPLY @@ -80,8 +95,8 @@ extern chan unsigned 1 AudioInReady; /* Create a dual port RAM */ -mpram DualPortRam AudioIn with {block = "BlockRAM"}; -mpram DualPortRam AudioOut with {block = "BlockRAM"}; +mpram DualPortInputRam AudioIn with {block = "BlockRAM"}; +mpram DualPortOutputRam AudioOut with {block = "BlockRAM"}; #if HARDWARE_MULTIPLY signed 18 *audioptr_in1,*audioptr_in2,*audioptr_in3,*audioptr_in4; @@ -104,8 +119,11 @@ void main (void) FFTRun (); } -/* - * Runs the FFT +/*! \fn macro proc FFTRun(); + * \brief + * + * \return Never returns + * \retval void */ static macro proc FFTRun () { @@ -164,18 +182,18 @@ static macro proc FFTRun () } -/************************************************************************ -* Function: calculate_fft * -* * -* Arguments * -* select_inverse Boolean that indicates FFT or iFFT calculation * -* * -* Description * -* This routine performs the Fast Fourier Transform for * -* calculation of the frequency spectrum * -* * -* Cost: 12391 cycles * -************************************************************************/ +/*! \fn void calculate_fft(unsigned 1 select_inverse) + * \brief + * + * \param unsigned 1 select_inverse determines if a FFT or iFFT has to be calculated + * + * \return nothing + * \retval void + * + * \cost 12391 cycles + * + * \desc This routine performs the Fast Fourier Transform for calculation of the frequency spectrum + */ void calculate_fft(unsigned 1 select_inverse) { unsigned 4 level; @@ -316,20 +334,19 @@ void calculate_fft(unsigned 1 select_inverse) } } -/******************************************************************* -* Function: perform_fft * -* * -* Arguments * -* pcm_audio Pointer to the array containing the audio data * -* * -* Description * -* This routine obtains the audio data from the audio I/O * -* component and copies this data to local arrays for * -* calculating purposes, and calls the FFT algorithm. * -* * -* Cost: 259 cycles (excl. the calculate FFT function) * -* * -*******************************************************************/ +/*! \fn void perform_fft(signed 18 *pcm_audio) + * \brief + * + * \param signed 18 *pcm_audio pointer to array containg the audio data + * + * \return nothing + * \retval void + * + * \cost 258 cycles (excl. the calculate FFT function) + * + * \desc This routine obtains the audio data from the audio I/O component and copies this + * \desc data to local arrays for calculating purposes, and calls the FFT algorithm. + */ #if HARDWARE_MULTIPLY void perform_fft(signed 18 *pcm_audio) #else @@ -382,27 +399,21 @@ void perform_fft(signed 16 *pcm_audio) } -/******************************************************************* -* Function: perform_ifft * -* * -* Arguments * -* modified_audio Pointer to the array containing the audio data * -* * -* ifft_info Pointer to the ifft_info array containing the * -* modified waveform data for display purposes* -* * -* * -* Description * -* This routine calls the ifft algorithm and after completing that* -* it obtains the modified audio data and copies that to the * -* output arrays of the audio I/O component. Besides that it * -* also fills the array used by the display routine for * -* displaying the waveform . * -* * -* * -* Cost: 259 cycles (excl. the calculate FFT function) * -* * -*******************************************************************/ +/*! \fn void perform_ifft(signed 18 *modified_audio, unsigned 6 *ifft_info) + * \brief + * + * \param signed 18 *modified_audio pointer to array containg the audio data + * \param unsigned 6 *ifft_info Pointer to the ifft_info array containing the modified waveform data for display purposes + * + * \return nothing + * \retval void + * + * \cost 258 cycles (excl. the calculate iFFT function) + * + * \desc This routine calls the ifft algorithm and after completing that it obtains the + * \desc modified audio data and copies that to the output arrays of the audio I/O component. + * \desc Besides that it also fills the array used by the display routine for displaying the waveform. + */ #if HARDWARE_MULTIPLY void perform_ifft(signed 18 *modified_audio, unsigned 6 *ifft_info) #else @@ -469,6 +480,19 @@ void perform_ifft(signed 16 *modified_audio, unsigned 6 *ifft_info) } while(k); } +/*! \fn void equalize_audio(audiodata_t *audiodata) + * \brief + * + * \param audiodata_t *audiodata pointer to the audiodata struct, containing the eq_info, etc. + * + * \return nothing + * \retval void + * + * \cost 3844 cycles (Maximum) + * + * \desc This routine equalizes the frequencies derived by the FFT calculation, + * \desc according to the settings of the equalizer bars. + */ /******************************************************************* * Function: equalize_audio * * * diff --git a/FFT_Test/fft.hch b/FFT_Test/fft.hch index e44e32b..a9a46a5 100644 --- a/FFT_Test/fft.hch +++ b/FFT_Test/fft.hch @@ -7,8 +7,14 @@ void perform_ifft(signed 16 *modified_audio ,unsigned 6 *ifft_info); #endif void equalize_audio(audiodata_t *audiodata); -mpram DualPortRam +mpram DualPortInputRam { ram signed 18 audio_io[256]; ram signed 18 fft[256]; }; + +mpram DualPortOutputRam +{ + ram signed 18 audio_io[128]; + ram signed 18 fft[128]; +}; diff --git a/FFT_Test/runfft.hcc b/FFT_Test/runfft.hcc index 0c1c371..25a019a 100644 --- a/FFT_Test/runfft.hcc +++ b/FFT_Test/runfft.hcc @@ -25,9 +25,7 @@ #include "configuration.hch" #if USE_RUNFFT -#include "audio.hch" #include "fft.hch" - #include "debug.hch" /* @@ -35,12 +33,8 @@ */ static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE; -//EQ settings for the FFT -ram unsigned 4 EQ_info[128] with { block = "BlockRAM"}; -//EQ settings received from the display - -extern mpram DualPortRam AudioIn; -extern mpram DualPortRam AudioOut; +extern mpram DualPortInputRam AudioIn; +extern mpram DualPortOutputRam AudioOut; extern chan unsigned 1 AudioOutReady; chan unsigned 1 AudioInReady; @@ -58,24 +52,25 @@ signed 16 *audioptr_out1,*audioptr_out2; #endif -/* - * FFT routine +/*! \fn macro proc audio_main(AUDIOIN, AUDIOOUT); + * \brief + * + * \param AUDIOIN Handle to audio-input + * \param AUDIOOUT Handle to audio-output + * + * \return Never Returns. + * \retval void */ macro proc audio_main(AUDIOIN, AUDIOOUT) { - signed 18 sample; unsigned 6 sample_count; - unsigned 8 i,cycle; - unsigned 4 eqinfo; - unsigned 1 FFT_Sync, first; + unsigned 1 FFT_Sync; macro expr OW = PalAudioOutGetMaxDataWidthCT (); macro expr IW = PalAudioInGetMaxDataWidthCT (); signed LeftNew, RightNew; signed Output_sample; - ram unsigned 6 input[64]; - //pointers for double and quadruple buffering: audioptr_in1 = &AudioIn.audio_io[0]; audioptr_in2 = &AudioIn.audio_io[64]; @@ -88,7 +83,7 @@ macro proc audio_main(AUDIOIN, AUDIOOUT) FFT_Sync=0; par { - for(;;) + for(;;)//Notify FFT loop. { if (FFT_Sync) //if 64 samples are read from ADC... { @@ -112,7 +107,7 @@ par delay; } - for(sample_count=0;;)//store the samples in the inputbuffer + for(sample_count=0;;)//Audiosampling loop { if (!FFT_Sync) { @@ -143,7 +138,7 @@ par delay; } } - for(;;) + for(;;)//Audio output-loop { PalAudioOutWrite(AUDIOOUT,(signed OW)(Output_sample @ 0),(signed OW)(Output_sample @ 0)); } -- cgit v0.12