Presentation is loading. Please wait.

Presentation is loading. Please wait.

This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.

Similar presentations


Presentation on theme: "This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during."— Presentation transcript:

1 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,

2 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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);

3 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 3 / 20 Blackfin -- Programmer’s Model z8 DATA REGISTERS (R0 -- R7) y32 bit -- accessible as 8, 16, 32 bits yAccess very similar to 68K – 2 @ 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

4 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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); } }

5 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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;

7 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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); } }

8 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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

9 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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

10 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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

11 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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; }

12 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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;

13 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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); } }

14 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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

15 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 15 / 20 Pop Quiz – WritePIT(uchar *, uchar, uchar);.section instruction_rom.EXPORT _WritePIT NOW COMPLETE

16 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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); } }

17 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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; }

18 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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; }

19 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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

20 6/1/2015 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca 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


Download ppt "This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during."

Similar presentations


Ads by Google