ENCM515 Take Home Quiz of ______(Print Name)

Lab. Section Lab. Station Discussed in class – 21th January, 2002. Tutorial planned (if needed) – 30th January, 2002Hand-in at start (11 a.m.) of FRIDAY 1st February, 2002 ENCM515 class (No late exams!)

Hand in this exam stapled in front
of any additional pages you prepare

In the space below hand write and sign a “Statement of Authenticity” indicating that the answers provided to this exam are your work and that you have followed University regulations regarding plagiarism, and have applied the Smith 30-minute rule when asking for help.

Signed: ______Date ______

To cut down on the amount of marking associated with this exam, not all questions will necessarily be marked by the T.A.’s.

Basically – two components of the take home quiz – you are to handle these independently.

1) Implement OFFLINE and ONLINE versions of the FM-STEREO demodulation functions in conjunction with the audio-modeling algorithms written in “C”. Print out the plots associated the OFFLINE versions running. Demonstrate the ON-LINE version during the labs.

2) Compare and contrast the 21k code timing associated with the assembly code generated by non-optimized and optimised “C” code. Profile the code using the simulator and compare your results to the values determined by the simulator.
Q1. Briefly explain the 30 minute rule which I expect to be observed when you are assisting other students, or are being assisted by other students, during this take home exam and during the laboratory.

Q2. Consider the following “C” code10 marks

float input_array[ ] = {6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0};

float CalculateSum(float *input_array) {

float sum1 = 0;

float sum2 = 0;

int count;// Yes the compiler will accept this mix

for (count = 0; count < 8; count++)

sum1 = sum1 + input_array[count];

for (count = 0; count < 8; count++)

sum2 = sum2 + *input_array++;

return(sum1 – sum2);

}

Translate this code into SHARC assembly code using just scratch registers and don’t bother to parallelize the instructions. DON’T put your code through the “C” compiler as you will not be able to use the “C” compiler during quizzes and exams.

Why wouldn’t the following code produce the correct result (sum1 – sum2 = 0)?2 marks

for (count = 0; count < 8; count++)

sum2 = sum2 + *input_array++;

for (count = 0; count < 8; count++)

sum1 = sum1 + input_array[count];

Why wouldn’t the following code compile? 2 marks

float CalculateSum(void) {

float input_array[ ] = {6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0};

float sum2 = 0;

int count;

for (count = 0; count < 8; count++)

sum2 = sum2 + *input_array++;

return(sum2);

}

Q2. There is a “tutorial” exercise associated with Lab. 0 to hand-convert the program

void DecodeFMSTEREO(int channel_two_strength, int *channel_one, int *channel_two) into assembly code. The file handout_lab0demo.asm can be downloaded from the ENCM515 web. Complete this exercise and test it using OFFLINE_SOURCE.

Provide the documented code

Display the plots of the “input”, “left” and “right” output channels of the DSP algorithm

with the FM_STEREO demodulation activated and not-activated. 20 marks

If your surname begins with the initials A – M use this code in the following exercise

#define MAXDELAY 0x80

void MemoryMove_LeftDelay(int process_var1, int *channel_one) {

int count;

static int left_delayline[MAXDELAY] = {0};

// Insert new value into the back of the FIFO delay line

left_delayline[0 + process_var1] = *channel_one;

// Grab delayed value from the front of the FIFO delay line

*channel_one = 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];

}

If your surname begins with the initials N -- Z use this code in the following exercise (You may need to fix the initializations ‘a little” if treating this as “c” rather than “C++”

#define MAXDELAY 0x80

void MemoryMove_LeftDelay(int process_var1, int *channel_one) {

int count;

static int left_delayline[MAXDELAY] = {0};

int *scatchpt = left_delayline;// int *scratchpt = &left_delayline[0];

int *pt = &left_delayline[1];/

// Insert new value into the back of the FIFO delay line

*(scratchpt + process_var1) = *channel_one;

// Grab delayed value from the front of the FIFO delay line

*channel_one = *scratchpt;

// Update the FIFO delay line using inefficient memory moves

for (count = 0; count < process_var1; count++)

*scratchpt++ = *pt++;

}

Q3. Hand convert the code (using hardware and software loop control) – get it to work rather than being “the best code in the world”. Compare your code to that generated by “C” and “C+” compilers (you may need to change the file extensions and compiler options) with and without optimisations. Get somebody who did the other code version to provide you with their analysis. Discuss (3 or 4 pages – no B. G. O’s please – also include tables and code printouts.

You are looking for the following issues, amongst others

  • Relative efficiencies of your code relative to the compiler’s.
  • Relative efficiencies of the coding approaches.
  • Comparison of type of instructions used.
  • Name mangling issues associated with “C” and “C+” compiler usage – need to know if linking “C/C++” to assembly code
  • Register usage, stack operations.
  • Errors spotted in your code when compared to the compiler

20 marks