Presentation is loading. Please wait.

Presentation is loading. Please wait.

M. Smith, Electrical and Computer Engineering,

Similar presentations


Presentation on theme: "M. Smith, Electrical and Computer Engineering,"— Presentation transcript:

1 Offline investigation of Audio Channel Modeling Laboratory FM-Stereo Demodulation
M. Smith, Electrical and Computer Engineering, University of Calgary, Canada ucalgary.ca

2 Modeling an audio channel using an ADSP21061 processor
11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

3 ENEL515 Post Lab. 0 Quiz YOU’LL NEED HEADPHONES
Test out VisualDSP software environment using “OFFLINE_SOURCE_DEMO.exe” -- get from ENCM515 Web Test out VisualDSP hardware environment using “LOCAL_SOURCE_DEMO.exe” -- get from ENCM515 Web YOU’LL NEED HEADPHONES Start/finish work on ‘C’ and assembly code version of FMSTEREO_DEMOD for Post-Lab 0 Quiz. Test Off-Line version using VisualDSP1.0++ and VisualDSP2.0++ 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

4 Files needed for Post Lab 0 Quiz
offline_source21061.dxe -- Demonstration OFFLINE Audio Channel Modeling -- FM Stereo Demodulation and simple IIR filter operations local_source21061.dxe -- Demonstration LOCAL Audio Channel Modeling -- FM Stereo Demodulation codec_source21061.dxe -- Demonstration CODEC Audio Channel Modeling -- FM Stereo Demodulation AudioChannelmain2001.c -- Main driver routine for audio modeling laboratories on ADSP21061 SHARC channelmodels_lab0.c -- Audio Channel Modeling Algorithms for Lab. 0 processdefs.h -- Audio Channel Modeling constants general_library21061Lite.dlb -- Library of utilties needed for CODEC, OFFLINE and ON_LINE sound sources offline_library21061Lite.dlb -- Library needed for OFF-LINE audio channel modeling online_library21061Lite.dlb -- Library needed for LOCAL and CODEC audio channel modeling ADSP 21061interrupts.ldf -- ADSP21061 Architectural Specifications for EZ-LITE SHARC clanguage_register_defines.i -- Changes ADSP21O6X register names to something more readable handout_lab0demo.asm -- Walk through the development of an ADSP assembly language file 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

5 Testing the Audio Channel Modeling hardware environment
Build a directory u:\yourname\encm515\postlab0\debug Download the following files from “Files need for Post Lab1 Quiz” on the ENCM515 web page OFFLINE.dxe -- Demonstration OFFLINE Audio Channel Modeling -- FM Stereo Demodulation and simple IIR filter operations LOCAL.dxe -- Demonstration LOCAL Audio Channel Modeling -- FM Stereo Demodulation CODEC.dxe -- Demonstration CODEC Audio Channel Modeling -- FM Stereo Demodulation Most recent files are dated 28 December watch for updates 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

6 Test -- VisualDSP VisualDSP -- Select CONTROL plus DEBUG button in the top menu (ladybird) From session list select ADSP ADSP-2106x simulator ADSP 2106x family and Activate Click OK on File could not be found window as we are not using the default executable name (test.dxe) associated with the Visual DSP project Download OFFLINE_SOURCE.dxe file from postlab0\ debug directory We now need to display the input and output files associated with this executable Select View | Debug Windows | Plot Browse and Add the following arrays to the Plot window using Memory DM, count 768, stride 1, data int for each array input_array -- will show square source when run output_left -- will show filtered FM-demodulated left channel when run (Positive components in this case) output_right-- will show FM-demodulated right channel when run (Negative components in this case) 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

7 Files used in every lab. 2001main.c
Activates the sound sources and audio channel modeling -- Change only ProcessSound() channelmodels.c and fasterchannelmodels.asm The algorithms used in the audio channel modeling processdefs.h Constants used to define the channel modeling operations -- This are hardcoded into libraries -- don’t change the values ADSP-21061interrupts.ldf 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

8 Main Program MAKE NO CHANGES TO THIS CODE SECTION
#define DELAYUNITS 44 #define IIR_COEFF 0.1 AttachSoundSource(whichsource, DELAYUNITS, IIR_COEFF); // ONLY RETURNS FROM THIS FUNCTION FOR OFF-LINE OPS // For LOCAL-SOURCE and CODEC-SOURCE -- launches interrupts // Only gets here with OFFLINE_SOURCE -- However other sources do equivalent while (ReadSoundSource(&channel_one, &channel_two) != 0){ // Checks if OFFLINE_SOURCE sounds are finished ProcessSound(channel_one, channel_two, &left_channel, &right_channel); WriteSoundSource(left_channel, right_channel); } printf("main() -- While loop has exited for OFFLINE_SOURCE\n"); MAKE NO CHANGES TO THIS CODE SECTION 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

9 Process Sound( ) void ProcessSound(int channel_one, int channel_two, int *left_channel, int *right_channel) { if (sound_source & FM_STEREO) DecodeFMSTEREO(channel_two_strength, &channel_one, &channel_two); if (sound_source & OVERSIMPLEIIR) OverSimpleIIR(/* IIRcoeff */ process_var2, &channel_one, &channel_two); if ((sound_source & LEFT_DELAY) == LEFT_DELAY) { if ((sound_source & MOVEDELAY) == MOVEDELAY) MemoryMove_LeftDelay(process_var1, &channel_one); } // Have finished modifying the channels *left_channel = channel_one; *right_channel = channel_two; 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

10 Key component -- audiochannel.c
#define MAXDELAY 0x80 void MemoryMove_LeftDelay(int process_var1, int *channel_one) { int count; static float left_delayline[MAXDELAY] = {0}; // Insert new value into the back of the FIFO delay line left_delayline[0 + process_var1] = (float) *channel_one; // Grab delayed value from the front of the FIFO delay line *channel_one = (int) left_delayline[0]; // Update the FIFO delay line using inefficient memory moves for (count = 0; count < process_var1; count++) left_delayline[count] = left_delayline[count + 1]; } LOOK AT COMPILER, ALGORITHM AND HARDWARE EFFICIENCIES 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

11 VisualDSP++ 1.0 IIR filter
INPUT_ARRAY -- SQUARE WAVE to RIGHT_OUTPUT -- SQUARE WAVE 0 to LEFT_OUTPUT -- SQUARE WAVE 0 to Which is then low pass filtered Filter operation involves(implied) float to int conversions with the form *new_output = (int) ( (1 - a) * *channel + a * old_output); a = 0.1 * channel -- is the value to be processed *new_output -- is the new filtered value old_output -- is the previous filtered value void OverSimpleIIR(float IIRcoeff, int *channel_one, int *channel_two) { static int oldy = 0; *channel_one = *channel_one * IIRcoeff + oldy * (1 - IIRcoeff); oldy = *channel_one; } 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

12 Test -- VisualDSP Debug -- Select the RUN PROGRAM icon (Small Page with down arrow) Will see -- Version Information, Source information on the screen etc. Since simulating within a complicated DSP processor environment, takes some time to FM demodulate and IIR filter 768 points from the input array. From results can determine -- impulse response, IIR filter time constant etc Original Square Wave to Channel Left -- L+R, Right -- L -- R OFFLINE FM-Stereo Modeling approach Right Channel -- designed as negative components of original signal Left Channel -- designed as positive components of original signal. Simple RC IIR filter applied after FM-demodulation 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

13 ICE hardware --1 TAKE CARE -- THESE ARE VERY EXPENSIVE PROBES -- I want to use them for a number of years! Look at the set-up for Lab. 0 for the care and handling of the ICE hardware 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

14 Test -- hard ware -- 2 VisualDSP -- Select DEBUG button in the top menu (ladybird) From new session list select SummitICE21061 (ADSP-21061) ADSP ADSP-21xxxx JTAG Emulator Click OK on File could not be found window as we are not using the default executable name associated with the Visual DSP project Download OFFLINE_SOURCE.dxe file from lab0\ debug directory to the board. You may have to use the RESET option in the debug window or the RESET button on the evaluation board if the processor is “hung” We now need to display the input and output files associated with this executable Select View | Debug Windows | Plot Browse and Add the following arrays to the Plot window using Memory DM, count 768, stride 1, data int for each array input_array, output_left, output_right Run the program -- should go a lot faster (if you are not still run the simulator by mistake (MFE -- my favourite error)). 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

15 General Lab. Process Develop your DSP algorithms
Test your algorithms in a controlled OFF-LINE environment so you can tell that they work Evaluate IMPULSE or SINEWAVE response for example Evaluate TIMING of the algorithms Evaluate expected output against actual output Once you are getting the expected results in the OFFLINE enviroment then simply “relink” to the on-line_library and try real-time version 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

16 Project file configurations
Offline.dpj file AudioChannelsmain2001.c channelmodels.c or .asm ADSP-21061interrupts.ldf general_library21061.dlb offline_library21061.dlb 2001main.c is compiled using compiler option -D WHICHSOURCE= OFFLINE_SOURCE Once set this option stays set inside this particular .dpj file local.dpj or codec.dpj files 2001main.c channelmodels.c or .asm ADSP-21061interrupts.ldf general_library21061.dlb online_library21061.dlb 2001main.c is compiled using compiler option -D WHICHSOURCE= LOCAL_SOURCE or -D WHICHSOURCE= CODEC_SOURCE Once set this option stays set 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

17 Parameter set in main.c // Set the WHICHSOURCE option as -D WHICHSOURCE=??? as a COMPILER option #if (WHICHSOURCE & OFFLINE_SOURCE) // whichsource = OFFLINE_SOURCE | SQUAREWAVE | MONO | MOVEDELAY | LEFT_DELAY; // whichsource = OFFLINE_SOURCE | SQUAREWAVE | MONO | MOVEDELAY | LEFT_DELAY | OVERSIMPLEIIR; whichsource = OFFLINE_SOURCE | SQUAREWAVE | FM_STEREO | OVERSIMPLEIIR; // whichsource = OFFLINE_SOURCE | SINEWAVE | MONO | MOVEDELAY | LEFT_DELAY; // whichsource = OFFLINE_SOURCE | SINEWAVE | MONO | MOVEDELAY | LEFT_DELAY | OVERSIMPLEIIR; // whichsource = OFFLINE_SOURCE | IMPULSE | MONO | MOVEDELAY | LEFT_DELAY; // whichsource = OFFLINE_SOURCE | IMPULSE | MONO | MOVEDELAY | LEFT_DELAY | OVERSIMPLEIIR; #elif (WHICHSOURCE & LOCAL_SOURCE) // whichsource = LOCAL_SOURCE | MONO; // whichsource = LOCAL_SOURCE | MONO | MOVEDELAY | LEFT_DELAY; // whichsource = LOCAL_SOURCE | STEREO; // whichsource = LOCAL_SOURCE | STEREO | MOVEDELAY | LEFT_DELAY; whichsource = LOCAL_SOURCE | FM_STEREO; // whichsource = LOCAL_SOURCE | FM_STEREO | MOVEDELAY | LEFT_DELAY; #endif 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

18 Building the OFFLINE project
Windows -- Programs | Visual |Environment VisualDSP -- File | New | Project Save as offlinetesting.dpj in postlab0 directory Project Options -- KEY Processor ADSP-21061 Type DSP executable Configuration Debug Compiler Options -- Add -D WHICHSOURCE= OFFLINE_SOURCE Use the + icon to add the five files Force “rebuild all” option and then download to simulator 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

19 Building the LOCAL project
Windows -- Programs | Visual |Environment VisualDSP -- File | New | Project Save as localsource.dpj in postlab0 directory Project Options -- KEY Processor ADSP-21061 Type DSP executable Configuration Debug Compiler Options -- Add -D WHICHSOURCE= LOCAL_SOURCE Use the + icon to add the five files Force “rebuild all” option and then download to “real board” You will need head-phones to hear the sounds Notice that buttons on the board control activity -- read prompts. 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

20 Building the CODEC project
Windows -- Programs | Visual |Environment VisualDSP -- File | New | Project Save as codecsource.dpj in postlab0 directory Project Options -- KEY Processor ADSP-21061 Type DSP executable Configuration Debug Compiler Options -- Add -D WHICHSOURCE= CODEC_SOURCE Use the + icon to add the five files Force “rebuild all” option and download to “real board” You will need head-phones to hear the sounds You will need cable to go from CD to input Notice that buttons on the board control activity -- read prompts. 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

21 Current “audiochannels.c”
#ifndef SMITH_TEST void DecodeFMSTEREO(int channel_two_strength, int *channel_one, int *channel_two) { printf("void DecodeFMSTEREO(int, int *, int *) is developed as part of Pre-Lab 0 Quiz"); printf("\t Try the Smith version by compiling with option -D SMITH_TEST"); exit(0); } #endif Post Lab 0 requires Building and testing the algorithm with “C” version Building your own “assembly” version Comparing assembly code generated by “C” and your own Scheduling the assembly code in MicroSoft Project 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

22 Post Lab. 0 Quiz -- Add “C” -- 1
Add the following “C” code to your project to get your FM stereo demodulation module to work inside channelmodels.c void DecodeFMSTEREO(int channel_two_strength, int *channel_one, int *channel_two) { int temp_one = *channel_one; int temp_two = *channel_two; static int comment = 0; // If Channel Strength is too week then just use channel_one on both channels if (channel_two_strength < 25) *channel_two = *channel_one; else { *channel_one = (temp_one + temp_two) >> 1; *channel_two = (temp_one - temp_two) >> 1; } if (!comment) { printf("Smith DecodeFMStereo() -- FM_STEREO demodulation example"); printf(" Channel_one L + R -- strength %d", channel_one_strength); printf(" Channel_two L - R -- strength %d", channel_two_strength); comment = 1; 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

23 Post Lab. 0 Quiz -- 2 Remove “C” DecodeFM() link to new file lab0handout.asm
#include <def21060.h> #include "clanguage_register_defines.i" // void DecodeFMSTEREO(int channel_two_strength, int *channel_one, int *channel_two); .segment/dm seg_dmda; .var comment = 0; // static int comment = 0; .endseg; .segment/pm seg_pmco; .global _DecodeFMSTEREO; _DecodeFMSTEREO: // void DecodeFMSTEREO( #define strengthR4 INPAR1 // int temp_one = *channel_one; #define temp_oneR1 scratchR1 scratchDMpt = INPAR2; // Example code temp_oneR1 = dm(zeroDM, scratchDMpt); // Example code 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

24 Post Lab. 0 Quiz -- 3 Replace “C” with lab0handout.asm
// int temp_two = *channel_two; #define temp_twoR2 scratchR2 ???? Your turn ???? // If Channel Strength is too week then just use channel_one on both channels // if (channel_two_strength < 25) *channel_two = *channel_one; // else { // *channel_one = (temp_one + temp_two) >> 1; // *channel_two = (temp_one - temp_two) >> 1; // } // Rewrite in simpler RISC life format // Take into account can't compare to constant directly 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

25 Additional hints There are some additional hints suggested in the rest of the “lab0handout.asm” file 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

26 ENCM515 Post Lab. 0 Quiz Test out VisualDSP software environment using “OFFLINE_SOURCE_DEMO.exe” -- get from ENCM515 Web Test out VisualDSP hardware environment using “LOCAL_SOURCE_DEMO.exe” -- get from ENCM515 Web You’ll need head phones Build a Visual DSP project -- OFF_LINE source -- your own version (in C) of FMSTEREO_DEMODULATION Start/finish work on assembly code version of FMSTEREO_DEMOD for Post-Lab 0 Quiz. 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

27 Post Lab. 0 Quiz -- 4 Replace “C” with lab0handout.asm
// constant = 25; // Compare channel_two_strength with constant // if greater or equal go to ELSE_CODE (watch delayed jump) // otherwise fall through to IF_CODE // IF_CODE: *channel_two = *channel_one; // JUMP ALWAYS TO END_IF (watch delayed jump) // ELSE_CODE // temp = temp_one + temp_two; // *channel_one = temp >> 1; // temp = temp_one - temp_two; // *channel_two = temp >> 1; // END_IF 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

28 Post Lab. 0 Quiz -- 5 Replace “C” with lab0handout.asm
// constant = 25; Which scratch register has become available? #define constantR0 retvalueR0 // Example code constantR0 = 25 // Compare channel_two_strength with constant ???? // if greater or equal go to ELSE_CODE (watch delayed jump) // otherwise fall through to IF_CODE IF GE JUMP(PC, ELSE_CODE)(DB); // Example code NOP; // Example code // IF_CODE: *channel_two = *channel_one; // Can translate this as *channel_two = temp_one // Need to use INPAR3 to specify destination address IF_CODE: // Example code scratchDMpt = INPAR3; // Example code // JUMP ALWAYS TO END_IF (watch delayed jump) 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

29 Post Lab. 0 Quiz -- 6 Replace “C” with lab0handout.asm
// ELSE_CODE // temp = temp_one + temp_two; // *channel_one = temp >> 1; // temp = temp_one - temp_two; // *channel_two = temp >> 1; ELSE_CODE: // Example code #define tempR0 retvalueR0 // Example code ???? etc // END_IF END_IF: 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

30 Post Lab. 0 Quiz -- 7 Replace “C” with lab0handout.asm
// The following code for printf( ) is easier handled by swinging back into "C" // Note that the processor architecture has been modified to allow more efficient // for use with "C-language" -- CJUMP instruction modifies R2 // I7 used as CTOPstack pointer -- this is not the same as SP which is part of BRANCH LOGIC // I6 used as FP (frame pointer) // BIG WARNING -- Note that this code is at the end of the subroutine so that // it no longer matters that INPAR1, INPAR2 and INPAR3 may be destroyed during // a call to another subroutine // if (!comment) { #define commentR1 scratchR1 commentR1 = dm(comment); // Remember RISC architecture commentR1 = pass commentR1; // Set the ALU flags for testing // !comment means comment != 0 -- A PSP GOTCHA! // NOTE -- NOT pass(commentR1) -- A PSP GOTCHA! IF NE JUMP(PC, END_PRINTF) (DB); // Watch the delayed instructions NOP; 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

31 Post Lab. 0 Quiz -- 8 Replace “C” with lab0handout.asm
// The following code for printf( ) is easier handled by swinging back into "C" IF_PRINTF: // comment = 1; // Remember RISC architecture commentR1 = 1; // Can't put a 1 directly to memory dm(comment) = commentR1; // SwitchBack2C(channel_two_strength) dm(CTOPstack, minus1DM) = INPAR1;// Push INPAR1 onto "C" stack C_OUTPAR1 // Note that this is not the same as OUTPAR1 for a non-”C”call (R4) .extern _SwitchBack2C; cjump _SwitchBack2C (DB); // Warning cjump also causes R2 <- FP (I6) dm(CTOPstack,minus1DM) = r2; // Warning -- this is not expected R2 dm(CTOPstack,minus1DM) = pc;// This is ADSP21061 "C-langauge" JSR // Note that two parameters are pulled from the "C" stack during the "C-return" modify(CTOPstack, plus1DM); // Destroy what might be left of C_OUTPAR1 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --

32 Post Lab. 0 Quiz -- 9 Replace “C” with lab0handout.asm
// Handling a series of printf( ) is best handled in "C" -- However this is what it would like // Note that would have to hand-translate the format statement into ascii values // printf("Smith DecodeFMStereo() -- FM_STEREO demodulation example"); scratchR1 = FORMAT1_LABEL; // Starting address of printf format dm(CTOPstack,minus1DM) = scratchR1; // Not that is not the stack controlled by SP .extern _printf; cjump _printf (DB); // Warning cjump also causes R2 <- FP (I6) dm(CTOPstack,minus1DM) = r2; // Warning -- this is not R2 dm(CTOPstack,minus1DM) = pc; // This is "C-langauge" JSR modify(CTOPstack,plus1DM); // Note that only one parameter left on the "C" stack END_PRINTF: scratchPMpt =dm(-1,FP); // } -- Return to "C" code jump (plus1PM,scratchPMpt) (DB); nop; RFRAME; .endseg; .section/dm seg_dmda; //DATA FORMAT1_LABEL: .var FORMAT1_STRING[ ] =83,109,105,116,104,32,68,101,99,111,100,101,70,77,83,116, 101,114,101,111,40,41,32,45,45,32,70,77,95,83,84,69 etc 11/15/2018 ENCM Post Lab. 0 Hardware Details Copyright M. Smith --


Download ppt "M. Smith, Electrical and Computer Engineering,"

Similar presentations


Ads by Google