Tutorial on Post Lab. 1 Quiz Practice for parallel operations * 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during your presentation In Slide Show, click on the right mouse button Select “Meeting Minder” Select the “Action Items” tab Type in action items as they come up Click OK to dismiss this box This will automatically create an Action Item slide at the end of your presentation with your points entered. Tutorial on Post Lab. 1 Quiz Practice for parallel operations M. R. Smith, Electrical and Computer Engineering University of Calgary, Canada smithmr @ ucalgary.ca *
Post-Lab 1 Quiz Concept is to re-use all of assignment 2 to avoid rewriting any new code This is a hardware quiz and not a software assignment Re-use all of assignment 2 so that can get oscilloscope operation Reuse all of assignment 2 so that can get temperature gauge 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Assignment 2 – main( ) long int known_array[MAX_LENGTH]; long int array_IN[MAX_LENGTH]; long int array_OUT[MAX_LENGTH]; long int max_amplitude, min_amplitude; long int first_nonzero; int main(void) { ProvideImpulses(known_array, MAX_LENGTH, MAX_AMPLITUDE, DISTANCE_BETWEEN, TRUE); DoIIR(known_array, array_IN, MAXLENGTH]); FindMaxMin(array_IN, MAX_LENGTH, &max_amplitude, &min_amplitude); BinarizeSignal(array_IN, array_OUT, MAX_LENGTH, max_amplitude); first_nonzero = FindFirst(array_OUT, MAX_LENGTH); if (first_nonzero != ALLZEROS) RepositionArray(known_array, array_OUT, MAX_LENGTH, first_nonzero); } 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Oscilloscope – main( ) } int main(void) { for( ; ; ) { ProvideImpulses(known_array, MAX_LENGTH, MAX_AMPLITUDE, DISTANCE_BETWEEN, CODEC); DoIIR(known_array, array_IN, MAXLENGTH]); FindMaxMin(array_IN, MAX_LENGTH, &max_amplitude, &min_amplitude); BinarizeSignal(array_IN, array_OUT, MAX_LENGTH, max_amplitude); first_nonzero = FindFirst(array_OUT, MAX_LENGTH, POSITIVE); if (first_nonzero != ALLZEROS) RepositionArray(known_array, array_OUT, MAX_LENGTH, first_nonzero); KnownLocationForBreakPoint(1); } 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Temperature – main( ) int main(void) { for( ; ; ) { ProvideImpulses(known_array, MAX_LENGTH, MAX_AMPLITUDE, DISTANCE_BETWEEN, CODEC); DoIIR(known_array, array_IN, MAXLENGTH]); FindMaxMin(array_IN, MAX_LENGTH, &max_amplitude, &min_amplitude); BinarizeSignal(array_IN, array_OUT, MAX_LENGTH, max_amplitude); first_nonzero = FindFirst(array_OUT, MAX_LENGTH, POSITIVE); second_nonzero = FindFirst(array_OUT + first_nonzero + 1, MAX_LENGTH, NEGATIVE); third_nonzero = FindFirst(array_OUT + second_nonzero + 1, MAX_LENGTH, POSITIVE); CalculateTemperature(third – second, second – first); KnownLocationForBreakPoint(1); } 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
ProvideImpulses( ) void ProvideImpulses(long int *known_array, long int data_length_required, long int max_amplitude, for (count = 0; count < data_length_required; count++) *temp_pt++ = 0; for (count = 0; count < data_length_required; count += rough_distance_between_impulses) { temp_pt[count] = dummy[which_dummy++]; } for (count = 0; count < data_length_required; count++) { for (decimate = 0; decimate < RATE; decimate++) ReadSource(&chan1_in, &chan2_in); *temp_pt++ = chan1_in; } 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Parallel code tutorial Memory operations and resource allocation 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Code review Sheet -- PSP Need to identify common errors -- CODE REVIEW Constructs to link to “C” Are all declarations at the start of subroutine -- #define etc CONSTANTS, variables, FunctionNames, EXPORT leading underscores, .segment declarations Assembly syntax Self documentating code, clanguage_register_defines.I Missing semicolons -- CODE REVIEW Conditional Delayed Branching properly handled -- DESIGN REVIEW Load/Store Architecture -- DESIGN REVIEW Can’t do R1 = R2 + 4 . Becomes temp = 4; R1 = R2 + temp; Register operations, volatile, order of I and M registers -- CODE REVIEW What is your favourite error to waste time? 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Example of array handling volatile pm int value; // VOLATILE MEANS WHAT void MakeSignal{ float re_array[ ], int num ) { int count; for (count = 0; count < num; count++) { re_array[count] = count + value ; } } THINGS TO WORRY ABOUT DURING TRANSLATION Prologue, Epilogue REVIEW How handle LOAD/STORE architecture How handle for-loop How handle = count operation (int to float conversion) How handle stepping through array -- post modify How handle how handle parameter passing 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Step 4 -- convert the for-loop volatile pm int value; VOLATILE MEANS WHAT void MakeSignal{ register float *re_array, register int num ) { register int count = GARBAGE; register float scratch = GARBAGE; register dm float *arraypt = re_array; count = 0; while (count < num) { scratch = (float) (count + value); *arraypt = scratch; arraypt++; count = count + 1; } } THINGS TO WORRY ABOUT DURING TRANSLATION Prologue, Epilogue REVIEW How handle for-loop -- 68K like -- NOT OPTIMIZED How handle how handle parameter passing 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Step 4A -- convert the for-loop void MakeSignal{ register float *re_array, register int num ) { register int count = GARBAGE; register float scratch = GARBAGE; register dm float *arraypt = re_array; count = num; if (num > 0) do { scratch = (float) (count + value); PROBLEM *arraypt = scratch; ALSO – how handle with HWL arraypt++ } while (--count > 0); } THINGS TO WORRY ABOUT DURING TRANSLATION Prologue, Epilogue REVIEW How handle for-loop -- 68K like -- NOT OPTIMIZED How handle how handle parameter passing 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
#define countR1 scratchR1 #define arraypt scratchDMpt .global _MakeSignal; _MakeSignal: #define countR1 scratchR1 #define arraypt scratchDMpt countR1 = 0; arraypt = re_arrayINPAR1; MR_WHILE: COMP(countR1, numINPAR2); if GT JUMP(PC, MR_ENDLOOP) (DB); nop; nop; #define tempF2 scratchF2 valueR0 = pm(VALUE); // better with scratchPMpt valueR0 = valueR0 + countR1; tempF2 = FLOAT countR0; dm(arraypt, 1) = tempF2; countR1 = countR1 + 1; JUMP(PC, MR_WHILE) (DB); nop; nop; MR_ENDLOOP: 5 magic lines of code for “C” return 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Parallel Put the previous exercise into a resource chart and then optimize MULT ADD DM PM 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Now convert to use hardware loop Place into resource chart and optimize 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca
Parallel Put the previous exercise into a resource chart and then optimize I think the loop can be made equal to 1 instruction MULT ADD DM PM 2/28/2019 ENEL515 -- Translating “C-based” design to 21061 code Copyright smithmr@ucalgary.ca