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. ENCM415 Review with New – Lec. 2 Compare 68K CISC and ADSP-BF533 DSP processor doing Lab. 2 (Exam Quality) M. R. Smith, University of Calgary, Alberta,
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 2 / 20 To be tackled zProgrammers model zLab. 2 – Task 4 yActivateBoard(long int); yResetPIT(unsigned char *, unsigned char, unsigned char); yunsigned char Quit(unsigned char *, unsigned char, unsigned char); yunsigned char ReadPIT(unsigned char *, unsigned char); yWritePIT(unsigned char *, unsigned char, unsigned char); yunsigned char OppositeClocks(unsigned char *, unsigned char, unsigned char, unsigned char);
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 3 / 20 Blackfin -- Programmer’s Model z8 DATA REGISTERS (R0 -- R7) y32 bit -- accessible as 8, 16, 32 bits yAccess very similar to 68K – 16 bits in each register R0.H and R0.L y1.15 Format (signed fractional – integer with floating point features) – also 2’s complement z6 ADDRESS REGISTERS(P0 – P5) y32 bit in size although address bus size is smaller z1 FRAME POINTER(FP (P6?)) z1 STACK POINTER(SP (P7?)) z16 DSP DAG REGISTERS(I0-3, B0-3, L0-3, M0-3) z2 HIGH PRECISION MATHEMATICAL ACCUMULATORS (ACC0 – ACC1) z1 PROGRAM COUNTERPC
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 4 / 20 Lab. 2 – main.c #define BASE1 (unsigned char *) 0x20000 #define QUITMASK 0x1 #define CLOCK1MASK 0x2 #define CLOCK2MASK 0x4 long int main(void) { unsigned char temp; ActivateBoard(REALBOARD); ResetPIT(BASE2, 0xFF, 0x00); while (Quit(BASE2, PORTB, QUITMASK)); while (Quit(BASE2, PORTB, QUITMASK)) { if (OppositClocks(BASE2, PORTB, CLOCK1MASK, CLOCK2MASK) { temp = ReadPIT(BASE2, PORTB); WritePIT(BASE2, PORTA, temp); } }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 5 / 20 void ResetPIT( uchar*, uchar, uchar);.section instruction_rom.EXPORT _ResetPIT INPAR_PBDDR SET 12 INPAR_PADDR SET 8 INPAR_pt SET 4 ; R.A. SET 0 _ResetPIT: MOVE.L INPAR_pt(SP), A0 MOVE.B #0x00, PGCR(A0) MOVE.B #0x80, PACR(A0) MOVE.B #0x80, PBCR(A0) MOVE.L INPAR_PADDR(SP), D1 MOVE.B D1, PADDR(A0) MOVE.L INPAR_PBDDR(SP), D1 MOVE.B D1, PBDDR(A0) RTS #include “pitnames.h” void ResetPIT( unsigned char* pt, unsigned char PADDRvalue. unsigned PBDDRvalue) { 0x00 -> PGCR 0x80 -> PACR 0x80 -> PBCR INPAR2 -> PADDR INPAR3 -> PBDDR }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 6 / 20 void ResetPIT( uchar*, uchar, uchar);.section instruction_rom.EXPORT _ResetPIT INPAR_PBDDR SET 12 INPAR_PADDR SET 8 INPAR_pt SET 4 ; R.A. SET 0 _ResetPIT: MOVE.L INPAR_pt(SP), A0 MOVE.B #0x00, PGCR(A0) MOVE.B #0x80, PACR(A0) MOVE.B #0x80, PBCR(A0) MOVE.L INPAR_PADDR(SP), D1 MOVE.B D1, PADDR(A0) MOVE.L INPAR_PBDDR(SP), D1 MOVE.B D1, PBDDR(A0) RTS.section program;.GLOBAL _ResetPIT; // INPAR_PBDDR is R2 // INPAR_PADDR is R1 // INPAR_pt is R0 // R.A. Is RETS _ResetPIT: P0 = R0; R0 = 0; // or R0.L = 0 (Z); B[P0 + PGCR] = R0; R0 = 0x80; B[P0 + PACR] = R0; B[P0 + PBCR] = R0; B[P0 + PADDR] = R1; B[P0 + PBDDR] = R2; RTS;
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 7 / 20 Lab. 2 – main.c #define BASE1 (unsigned char *) 0x20000 #define QUITMASK 0x1 #define CLOCK1MASK 0x2 #define CLOCK2MASK 0x4 long int main(void) { unsigned char temp; ActivateBoard(REALBOARD); ResetPIT(BASE2, 0xFF, 0x00); while (Quit(BASE2, PORTB, QUITMASK)); while (Quit(BASE2, PORTB, QUITMASK)) { if (OppositClocks(BASE2, PORTB, CLOCK1MASK, CLOCK2MASK) { temp = ReadPIT(BASE2, PORTB); WritePIT(BASE2, PORTA, temp); } }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 8 / 20 Quit(uchar *, uchar, uchar) unsigned char Quit(unsigned char * base, unsigned char whichport, unsigned char mask) { unsigned char temp; temp = mask & ReadPIT(base, whichport); if (temp = = 0) return 1; else return 0; } 3 INPARS – relative to FP -- frame pointer 2 OUTPARS – relative to SP – stack pointer
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 9 / 20 New instruction 68K using A6 as frame pointer LINK A6, #-FRAMESIZE --SP make space on the stack A6 pushed onto stack at M[SP] SP A6 SP = SP – FRAMESIZE INVERSE – UNLINK A6 BLACKFIN Dedicated FP LINK FRAMESIZE --SP make space on the stack RETS pushed onto stack at M[SP] --SP make space on the stack FP pushed onto stack at M[SP] SP -> FP SP = SP – FRAMESIZE INVERSE -- UNLINK
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 10 / 20 Stack Frames 68K ; INPAR4 SET 20 INPAR3 SET 16 INPAR2 SET 12 INPAR1 SET 8 ; RA SET 4 SAVEFP SET 0 Various saved registers and variables ; OUTPAR4 SET 12 ; OUTPAR3 SET 8 OUTPAR2 SET 4 OUTPAR1 SET 0 BLACKFIN #define INPAR4 20 Required #define INPAR3 16 Required but in R2 #define INPAR2 12 Required but in R1 #define INPAR1 8 Required but in R0 #define SAVEDRETS 4 #define SAVEFP 0 Various saved registers and variables #define OUTPAR4 20 Required #define OUTPAR3 16 Required but in R2 #define OUTPAR2 12 Required but in R1 #define OUTPAR1 8 Required but in R0
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 11 / 20 void Quit(uchar *, uchar, uchar).section instruction_rom.EXPORT _Quit INPAR_mask SET 16 INPAR_port SET 12 INPAR_pt SET 8 ; R.A. SET 4 – relative to FP OUTPAR_port SET 4 OUTPAR_pt SET 0 – relative to SP _QUIT: LINK A6, #-8 – room for 2 outpars MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _ReadPIT MOVE.B #0, D1 AND.B INPAR_mask(FP), D0 ONE LINE MISSING – WHAT? BNE DONE MOVE.B #1, D1 DONE: MOVE.B D1, D0 RTS unsigned char Quit(unsigned char * base, unsigned char whichport, unsigned char mask) { unsigned char temp; temp = mask & ReadPIT(base, whichport); if (temp = = 0) return 1; else return 0; }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 12 / 20 void Quit(uchar *, uchar, uchar).section instruction_rom.EXPORT _Quit INPAR_mask SET INPAR_port SET 12 INPAR_pt SET 8 ; R.A. SET 4 – relative to FP OUTPAR_port SET 4 OUTPAR_pt SET 0 – relative to SP _QUIT: LINK A6, #-8 – room for 2 outpars MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _ReadPIT MOVE.B #0, D1 AND.B INPAR_mask(FP), D0 BNE DONE MOVE.B #1, D1 DONE: MOVE.B D1, D0 MISSING????? RTS.section program;.GLOBAL _Quit #define INPAR4 20 #define INPAR_mask 16 #define INPAR_port 12 #define INPAR_pt 8 ; R.A. – relative to FP #define OUTPAR_port 4 #define OUTPAR_pt 0 – relative to SP _QUIT: LINK 16; – room for 4 outpars // Don’t need INPARs again // INPAR_pt is R0 is OUTPAR_pt // INPAR_port is R1 is OUTPAR_port Call _ReadPIT R1 = R0 & R3; R0 = 0; CC = R1 == 0; IF !CC JUMP DONE; R0 = 1; MISSING 1 KEY LINE! DONE: RTS;
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 13 / 20 Lab. 2 – main.c #define BASE1 (unsigned char *) 0x20000 #define QUITMASK 0x1 #define CLOCK1MASK 0x2 #define CLOCK2MASK 0x4 long int main(void) { unsigned char temp; ActivateBoard(REALBOARD); ResetPIT(BASE2, 0xFF, 0x00); while (Quit(BASE2, PORTB, QUITMASK)); while (Quit(BASE2, PORTB, QUITMASK)) { if (OppositClocks(BASE2, PORTB, CLOCK1MASK, CLOCK2MASK) { temp = ReadPIT(BASE2, PORTB); WritePIT(BASE2, PORTA, temp); } }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 14 / 20 Pop Quiz – ReadPIT(uchar *, uchar);.section instruction_rom.EXPORT _ReadPIT INPAR_port set 12 INPAR_pt set 8 _ReadPIT: LINK A6 #0 MOVE.L INPAR_pt(FP), A0 MOVE.L INPAR_pt(FP), D0 NOW COMPLETE.section.______ _ReadPIT _____ INPAR_port 12 (in R1) _____ INPAR_pt set 8 (in R2) _ReadPIT: LINK 0 NOW COMPLETE
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 15 / 20 Pop Quiz – WritePIT(uchar *, uchar, uchar);.section instruction_rom.EXPORT _WritePIT NOW COMPLETE
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 16 / 20 Lab. 2 – main.c #define BASE1 (unsigned char *) 0x20000 #define QUITMASK 0x1 #define CLOCK1MASK 0x2 #define CLOCK2MASK 0x4 long int main(void) { unsigned char temp; ActivateBoard(REALBOARD); ResetPIT(BASE2, 0xFF, 0x00); while (Quit(BASE2, PORTB, QUITMASK)); while (Quit(BASE2, PORTB, QUITMASK)) { if (OppositClocks(BASE2, PORTB, CLOCK1MASK, CLOCK2MASK) { temp = ReadPIT(BASE2, PORTB); WritePIT(BASE2, PORTA, temp); } }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 17 / 20 void Opposite(uchar *, uchar, uchar, uchar).section instruction_rom.EXPORT _Opposite INPAR_mask2 SET 20 INPAR_mask1 SET 16 INPAR_port SET 12 INPAR_pt SET 8 ; R.A. SET 4 – relative to FP SAVED2 SET 8 OUTPAR_port SET 4 OUTPAR_pt SET 0 – relative to SP _Opposite: LINK A6, #-12 – room for 2 outpars + 1 reg MOVE.L D2, SAVED2(SP) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _ReadPIT unsigned char Opposite( unsigned char * base, unsigned char whichport, unsigned char mask1, unsigned char mask2) { unsigned char temp; unsigned char value = 0; temp = mask & ReadPIT(base, whichport); if (!(temp & mask1) && (temp & mask2) ) value =1; if ((temp & mask1) && !(temp & mask2) ) value =1; return value; }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 18 / 20 void Opposite(uchar *, uchar, uchar, uchar) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _ReadPIT MOVE.B D0, D1; copies MOVE.B D0, D2 AND.B INPAR_mask1(FP), D1 ERROR.L AND.B INPAR_mask2(FP), D2 ERROR.L MOVE.B #0, D0 BETTER CMP.B #0, D1 BNE is_high CMP.B #0, D2 BEQ DONE ; BOTH LOW return 0 MOVE.B #1, D0 ; else return 1 BRA DONE Is_high: CMP.B #0, D2 BNE DONE; BOTH HIGH return 0 MOVE.B #1, D0 DONE:MOVE.L SAVED2(SP), D2 UNLINK A6 RTS unsigned char Opposite( unsigned char * base, unsigned char whichport, unsigned char mask1, unsigned char mask2) { unsigned char temp; unsigned char value = 0; temp = mask & ReadPIT(base, whichport); if (!(temp & mask1) && (temp & mask2) ) value =1; if ((temp & mask1) && !(temp & mask2) ) value =1; return value; }
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 19 / 20 void Opposite(uchar *, uchar, uchar, uchar).section instruction_rom BLACKFIN CODE.EXPORT _Opposite INPAR_mask2 SET 20 INPAR_mask1 SET 16 INPAR_port SET 12 INPAR_pt SET 8 ; R.A. SET 4 – relative to FP SAVED2 SET 8 OUTPAR_port SET 4 OUTPAR_pt SET 0 – relative to SP _Opposite: LINK A6, #-12 – room for 2 outpars + 1 reg MOVE.L D2, SAVED2(SP) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _ReadPIT
6/1/2015 Comparing Blackfin and 68K Copyright M. Smith 20 / 20 void Opposite(uchar *, uchar, uchar, uchar) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _ReadPIT MOVE.B D0, D1; copies MOVE.B D0, D2 MOVE.L INPAR_mask1(FP), D0 AND.B D0, D1 MOVE.L INPAR_mask2(FP), D0 AND.B D0, D2 CORRECTED MOVE.B #0, D0 CMP.B #0, D1 BNE is_high CMP.B #0, D2 BEQ DONE ; BOTH LOW return 0 MOVE.B #1, D0 ; else return 1 BRA DONE Is_high: CMP.B #0, D2 BNE DONE; BOTH HIGH return 0 MOVE.B #1, D0 DONE:MOVE.L SAVED2(SP), D2 UNLINK A6 RTS CONVERT TO BLACKFIN