|
Lab InstructionsPart I – Compiling to the PICIn this part of the lab you are to write a bubble sort routine in C as well as in assembler. You will use the PIC C compiler to compile your C code to assembly and then run the program on the PIC. Your task is to compare the performance of the compiled code against your handwritten code. I expect that you do not get beaten by a brainless compiler… To implement this lab, do the following things:
Compile your C code. Use the command line
prompt to enter (assuming your C file is sort.c):
cc5x –a sort.c Reset the simulation in the IDE and open the File Register Window. If you use an array similar to that in the insertion sort example, you will see that it is located in 0x26 – 0x2F. You need to enter “interesting” data values into this array to make sure that there is something to be sorted. Use the “fill registers” function (right-click in file register window) to enter different data values. You should have 5 different arrays that you are going to sort with the C code and later with your code. One should be the best case, one should be the worst case, and the other three should be somewhat random. Make sure to write down what your values are. After entering the data into the registers, step through the simulation until the program has completed. Use the stopwatch window to count the number of cycles that the sorting took. Record this value for all five arrays. You should see differences between the worst and best case array. Now, write the bubble sort program by hand in assembly. You can use the same memory layout as the C compiler or any other that you find more suitable. You may use any clever tricks to write faster code than the compiler. Just make sure that your program still does bubble sort… Simulate the sorting of the five arrays with your program as you have done in steps 4 and 5. Record the number of cycles that your program takes. For your lab report, show the performance of the C code and your code (e.g., in a table) for all five arrays. Show the data arrays for each experiment. Explain why there is a performance difference (you may show the relevant assembly code lines). Include the C and both assembly files in the report. Part II – Compiling to the DSPIn this part of Lab 5, you will write a simple routine to calculate the dot product of two vectors. The major part of the code is given to you and you just need to add a few lines yourself. The code also contains a vector addition routine that illustrates how to operate on the vectors. You will then compile the code for the TI DSP and simulate its performance for different levels of optimization. For your lab report, you should report the performance and explain the differences based on the assembly code generated by the compiler. You should do the following steps:
DemoFor the demo, you should show the results from Part I and II. You should be able to explain the steps that you have taken and the code that you have written. You should also be able to show that you can use the compilers and the DSP simulator. The demo and quiz will be done individually for this lab. Please sign up with your former team partner for a 30 minute slot (even though it is an individual project). Lab ReportThe lab report should be concise and consist of two parts that include the components mentioned in each section above. Include a brief introduction that discusses the basic concepts of how the code is compiled for the PIC and what the benefits and drawbacks of this approach are. For the DSP part, briefly discuss the DSP architecture and how parallelism can be used to speed up processing. ChallengeFor both parts of the lab, a competition is held. For both competitions, the goal is to write the fastest code:
The winner of each competition receives an extra 10 points for lab 5 (the total of lab 5 cannot exceed 100 points). If there are multiple competitors who achieve the best result, the 10 points will be divided between them (fractions of points are rounded off). If there is a single winner for the PIC competition, he or she may carry the title “ECE354 Master Assembly Crafter.” If there is a single winner for the DSP competition, he or she may carry the title “ECE354 Master Parallelism Exploiter.” If both competitions are won by the same individual, he or she may carry the title “ECE354 Supreme Embedded Coder.” During lab hours, the current best performance should be announced on the blackboard in the lab. All competitors must have their solution’s performance announced on the blackboard by Wednesday 5/12/04 to give others a chance to counter (updates due to code improvements are allowed and encouraged). |
|