ENCM 415 Review with New Lec 2 Compare

  • Slides: 20
Download presentation
ENCM 415 Review with New – Lec. 2 Compare 68 K CISC and ADSP-BF

ENCM 415 Review with New – Lec. 2 Compare 68 K CISC and ADSP-BF 533 DSP processor doing Lab. 2 (Exam Quality) M. R. Smith, University of Calgary, Alberta,

To be tackled z Programmers model z Lab. 2 – Task 4 y. Activate.

To be tackled z Programmers model z Lab. 2 – Task 4 y. Activate. Board(long int); y. Reset. PIT(unsigned char *, unsigned char); yunsigned char Quit(unsigned char *, unsigned char); yunsigned char Read. PIT(unsigned char *, unsigned char); y. Write. PIT(unsigned char *, unsigned char); yunsigned char Opposite. Clocks(unsigned char *, unsigned char, unsigned char); 12/14/2021 Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 2

Blackfin -- Programmer’s Model z 8 DATA REGISTERS (R 0 -- R 7) y

Blackfin -- Programmer’s Model z 8 DATA REGISTERS (R 0 -- R 7) y 32 bit -- accessible as 8, 16, 32 bits y. Access very similar to 68 K – 2 @ 16 bits in each register R 0. H and R 0. L y 1. 15 Format (signed fractional – integer with floating point features) – also 2’s complement z 6 ADDRESS REGISTERS (P 0 – P 5) y 32 bit in size although address bus size is smaller z 1 FRAME POINTER (FP (P 6? )) z 1 STACK POINTER (SP (P 7? )) z 16 DSP DAG REGISTERS (I 0 -3, B 0 -3, L 0 -3, M 0 -3) z 2 HIGH PRECISION MATHEMATICAL ACCUMULATORS (ACC 0 – ACC 1) Comparing Blackfin and 68 K z 1 PROGRAMCopyright COUNTER PC 12/14/2021 M. Smith smithmr@ucalgary. ca 3

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000 #define QUITMASK 0 x 1 #define CLOCK 1 MASK 0 x 2 #define CLOCK 2 MASK 0 x 4 long int main(void) { unsigned char temp; Activate. Board(REALBOARD); Reset. PIT(BASE 2, 0 x. FF, 0 x 00); while (Quit(BASE 2, PORTB, QUITMASK)) { if (Opposit. Clocks(BASE 2, PORTB, CLOCK 1 MASK, CLOCK 2 MASK) { temp = Read. PIT(BASE 2, PORTB); Write. PIT(BASE 2, PORTA, temp); } } } Comparing Blackfin and 68 K 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca 4

void Reset. PIT( uchar*, uchar); . section instruction_rom. EXPORT _Reset. PIT INPAR_PBDDR SET 12

void Reset. PIT( uchar*, uchar); . section instruction_rom. EXPORT _Reset. PIT INPAR_PBDDR SET 12 INPAR_PADDR SET 8 INPAR_pt SET 4 ; R. A. SET 0 _Reset. PIT: MOVE. L INPAR_pt(SP), A 0 MOVE. B #0 x 00, PGCR(A 0) MOVE. B #0 x 80, PACR(A 0) MOVE. B #0 x 80, PBCR(A 0) MOVE. L INPAR_PADDR(SP), D 1 MOVE. B D 1, PADDR(A 0) MOVE. L INPAR_PBDDR(SP), D 1 MOVE. B D 1, PBDDR(A 0) RTS 12/14/2021 #include “pitnames. h” void Reset. PIT( unsigned char* pt, unsigned char PADDRvalue. unsigned PBDDRvalue) { 0 x 00 -> PGCR 0 x 80 -> PACR 0 x 80 -> PBCR INPAR 2 -> PADDR INPAR 3 -> PBDDR } Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 5

void Reset. PIT( uchar*, uchar); . section instruction_rom. EXPORT _Reset. PIT INPAR_PBDDR SET 12

void Reset. PIT( uchar*, uchar); . section instruction_rom. EXPORT _Reset. PIT INPAR_PBDDR SET 12 INPAR_PADDR SET 8 INPAR_pt SET 4 ; R. A. SET 0 _Reset. PIT: MOVE. L INPAR_pt(SP), A 0 MOVE. B #0 x 00, PGCR(A 0) MOVE. B #0 x 80, PACR(A 0) MOVE. B #0 x 80, PBCR(A 0) MOVE. L INPAR_PADDR(SP), D 1 MOVE. B D 1, PADDR(A 0) MOVE. L INPAR_PBDDR(SP), D 1 MOVE. B D 1, PBDDR(A 0) RTS 12/14/2021 . section program; . GLOBAL _Reset. PIT; // INPAR_PBDDR is R 2 // INPAR_PADDR is R 1 // INPAR_pt is R 0 // R. A. Is RETS _Reset. PIT: P 0 = R 0; R 0 = 0; // or R 0. L = 0 (Z); B[P 0 + PGCR] = R 0; R 0 = 0 x 80; B[P 0 + PACR] = R 0; B[P 0 + PBCR] = R 0; B[P 0 + PADDR] = R 1; B[P 0 + PBDDR] = R 2; RTS; Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 6

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000 #define QUITMASK 0 x 1 #define CLOCK 1 MASK 0 x 2 #define CLOCK 2 MASK 0 x 4 long int main(void) { unsigned char temp; Activate. Board(REALBOARD); Reset. PIT(BASE 2, 0 x. FF, 0 x 00); while (Quit(BASE 2, PORTB, QUITMASK)) { if (Opposit. Clocks(BASE 2, PORTB, CLOCK 1 MASK, CLOCK 2 MASK) { temp = Read. PIT(BASE 2, PORTB); Write. PIT(BASE 2, PORTA, temp); } } } Comparing Blackfin and 68 K 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca 7

Quit(uchar *, uchar) unsigned char Quit(unsigned char * base, unsigned char whichport, unsigned char

Quit(uchar *, uchar) unsigned char Quit(unsigned char * base, unsigned char whichport, unsigned char mask) { unsigned char temp; temp = mask & Read. PIT(base, whichport); if (temp = = 0) return 1; else return 0; } 3 INPARS – relative to FP -- frame pointer 2 OUTPARS – relative to SP – stack pointer 12/14/2021 Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 8

New instruction 68 K using A 6 as frame pointer LINK A 6, #-FRAMESIZE

New instruction 68 K using A 6 as frame pointer LINK A 6, #-FRAMESIZE --SP make space on the stack A 6 pushed onto stack at M[SP] SP A 6 SP = SP – FRAMESIZE INVERSE – UNLINK A 6 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 12/14/2021 Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 9

Stack Frames 68 K ; INPAR 4 SET 20 INPAR 3 SET 16 INPAR

Stack Frames 68 K ; INPAR 4 SET 20 INPAR 3 SET 16 INPAR 2 SET 12 INPAR 1 SET 8 ; RA SET 4 SAVEFP SET 0 BLACKFIN #define INPAR 4 20 Required #define INPAR 3 16 Required but in R 2 #define INPAR 2 12 Required but in R 1 #define INPAR 1 8 Required but in R 0 #define SAVEDRETS 4 #define SAVEFP 0 Various saved registers and variables #define OUTPAR 4 20 Required ; OUTPAR 4 SET 12 #define OUTPAR 3 16 Required but in R 2 ; OUTPAR 3 SET 8 #define OUTPAR 2 12 Required but in R 1 OUTPAR 2 SET 4 #define OUTPAR 1 8 Required but in R 0 OUTPAR 1 SET 0 12/14/2021 Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 10

void Quit(uchar *, uchar). section instruction_rom. EXPORT _Quit INPAR_mask SET 16 INPAR_port SET 12

void Quit(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 A 6, #-8 – room for 2 outpars unsigned char Quit(unsigned char * base, unsigned char whichport, unsigned char mask) { unsigned char temp; temp = mask & Read. PIT(base, whichport); if (temp = = 0) return 1; else return 0; MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) } JSR _Read. PIT MOVE. B #0, D 1 AND. B INPAR_mask(FP), D 0 ONE LINE MISSING – WHAT? BNE DONE MOVE. B #1, D 1 Comparing Blackfin and 68 K DONE: MOVE. B D 1, D 0 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca RTS 11

void Quit(uchar *, uchar) . section program; . section instruction_rom. GLOBAL _Quit. EXPORT _Quit

void Quit(uchar *, uchar) . section program; . section instruction_rom. GLOBAL _Quit. EXPORT _Quit #define INPAR 4 20 INPAR_mask SET #define INPAR_mask 16 INPAR_port SET 12 #define INPAR_port 12 INPAR_pt SET 8 #define INPAR_pt 8 ; R. A. SET 4 – relative to FP ; R. A. – relative to FP OUTPAR_port SET 4 #define OUTPAR_port 4 OUTPAR_pt SET 0 – relative to SP #define OUTPAR_pt 0 – relative to SP _QUIT: LINK A 6, #-8 – room for 2 outpars LINK 16; – room for 4 outpars // Don’t need INPARs again MOVE INPAR_pt(FP), OUTPAR_pt(SP) // INPAR_pt is R 0 is OUTPAR_pt MOVE INPAR_port(FP), OUTPAR_port(SP) // INPAR_port is R 1 is OUTPAR_port JSR _Read. PIT Call _Read. PIT MOVE. B #0, D 1 R 1 = R 0 & R 3; AND. B INPAR_mask(FP), D 0 R 0 = 0; BNE DONE CC = R 1 == 0; MOVE. B #1, D 1 IF !CC JUMP DONE; Comparing Blackfin and. R 0 68 K= 1; DONE: MOVE. B D 1, D 0 MISSING? ? ? MISSING 1 KEY LINE! 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca 12 RTS DONE: RTS;

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000 #define QUITMASK 0 x 1 #define CLOCK 1 MASK 0 x 2 #define CLOCK 2 MASK 0 x 4 long int main(void) { unsigned char temp; Activate. Board(REALBOARD); Reset. PIT(BASE 2, 0 x. FF, 0 x 00); while (Quit(BASE 2, PORTB, QUITMASK)) { if (Opposit. Clocks(BASE 2, PORTB, CLOCK 1 MASK, CLOCK 2 MASK) { temp = Read. PIT(BASE 2, PORTB); Write. PIT(BASE 2, PORTA, temp); } } } Comparing Blackfin and 68 K 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca 13

Pop Quiz – Read. PIT(uchar *, uchar); . section instruction_rom. EXPORT _Read. PIT INPAR_port

Pop Quiz – Read. PIT(uchar *, uchar); . section instruction_rom. EXPORT _Read. PIT INPAR_port set 12 INPAR_pt set 8 _Read. PIT: LINK A 6 #0 MOVE. L INPAR_pt(FP), A 0 MOVE. L INPAR_pt(FP), D 0 NOW COMPLETE 12/14/2021 . section. ______ _Read. PIT _____ INPAR_port 12 (in R 1) _____ INPAR_pt set 8 (in R 2) _Read. PIT: LINK 0 NOW COMPLETE Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 14

Pop Quiz – Write. PIT(uchar *, uchar); . section instruction_rom. EXPORT _Write. PIT NOW

Pop Quiz – Write. PIT(uchar *, uchar); . section instruction_rom. EXPORT _Write. PIT NOW COMPLETE 12/14/2021 NOW COMPLETE Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca 15

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000

Lab. 2 – main. c #define BASE 1 (unsigned char *) 0 x 20000 #define QUITMASK 0 x 1 #define CLOCK 1 MASK 0 x 2 #define CLOCK 2 MASK 0 x 4 long int main(void) { unsigned char temp; Activate. Board(REALBOARD); Reset. PIT(BASE 2, 0 x. FF, 0 x 00); while (Quit(BASE 2, PORTB, QUITMASK)) { if (Opposit. Clocks(BASE 2, PORTB, CLOCK 1 MASK, CLOCK 2 MASK) { temp = Read. PIT(BASE 2, PORTB); Write. PIT(BASE 2, PORTA, temp); } } } Comparing Blackfin and 68 K 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca 16

void Opposite(uchar *, uchar, uchar). section instruction_rom. EXPORT _Opposite unsigned char Opposite( unsigned char

void Opposite(uchar *, uchar, uchar). section instruction_rom. EXPORT _Opposite unsigned char Opposite( unsigned char * base, INPAR_mask 2 SET 20 unsigned char whichport, INPAR_mask 1 SET 16 unsigned char mask 1, INPAR_port SET 12 unsigned char mask 2) { INPAR_pt SET 8 ; R. A. SET 4 – relative to FP unsigned char temp; SAVED 2 SET 8 unsigned char value = 0; OUTPAR_port SET 4 temp = mask & OUTPAR_pt SET 0 – relative to SP Read. PIT(base, whichport); _Opposite: LINK A 6, #-12 – room for 2 outpars + 1 reg if (!(temp & mask 1) MOVE. L D 2, SAVED 2(SP) && (temp & mask 2) ) MOVE INPAR_pt(FP), OUTPAR_pt(SP) value =1; MOVE INPAR_port(FP), OUTPAR_port(SP) if ((temp & mask 1) JSR _Read. PIT && !(temp & mask 2) ) value =1; Comparing Blackfin and 68 K return value; 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca 17 }

void Opposite(uchar *, uchar, uchar) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _Read. PIT

void Opposite(uchar *, uchar, uchar) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _Read. PIT MOVE. B D 0, D 1 ; copies MOVE. B D 0, D 2 AND. B INPAR_mask 1(FP), D 1 ERROR. L AND. B INPAR_mask 2(FP), D 2 ERROR. L MOVE. B #0, D 0 BETTER CMP. B #0, D 1 BNE is_high CMP. B #0, D 2 BEQ DONE ; BOTH LOW return 0 MOVE. B #1, D 0 ; else return 1 BRA DONE Is_high: CMP. B #0, D 2 BNE DONE ; BOTH HIGH return 0 MOVE. B #1, D 0 unsigned char Opposite( unsigned char * base, unsigned char whichport, unsigned char mask 1, unsigned char mask 2) { unsigned char temp; unsigned char value = 0; temp = mask & Read. PIT(base, whichport); if (!(temp & mask 1) && (temp & mask 2) ) value =1; if ((temp & mask 1) && !(temp & mask 2) ) value =1; return value; DONE: MOVE. L SAVED 2(SP), D 2 Comparing Blackfin and 68 K UNLINK A 6 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca } RTS 18

void Opposite(uchar *, uchar, uchar). section instruction_rom. EXPORT _Opposite INPAR_mask 2 SET 20 INPAR_mask

void Opposite(uchar *, uchar, uchar). section instruction_rom. EXPORT _Opposite INPAR_mask 2 SET 20 INPAR_mask 1 SET 16 INPAR_port SET 12 INPAR_pt SET 8 ; R. A. SET 4 – relative to FP SAVED 2 SET 8 OUTPAR_port SET 4 OUTPAR_pt SET 0 – relative to SP _Opposite: LINK A 6, #-12 – room for 2 outpars + 1 reg MOVE. L D 2, SAVED 2(SP) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _Read. PIT 12/14/2021 Comparing Blackfin and 68 K Copyright M. Smith smithmr@ucalgary. ca BLACKFIN CODE 19

void Opposite(uchar *, uchar, uchar) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _Read. PIT

void Opposite(uchar *, uchar, uchar) MOVE INPAR_pt(FP), OUTPAR_pt(SP) MOVE INPAR_port(FP), OUTPAR_port(SP) JSR _Read. PIT MOVE. B D 0, D 1 ; copies MOVE. B D 0, D 2 MOVE. L INPAR_mask 1(FP), D 0 AND. B D 0, D 1 MOVE. L INPAR_mask 2(FP), D 0 AND. B D 0, D 2 CORRECTED MOVE. B #0, D 0 CMP. B #0, D 1 BNE is_high CMP. B #0, D 2 BEQ DONE ; BOTH LOW return 0 MOVE. B #1, D 0 ; else return 1 BRA DONE CONVERT TO BLACKFIN Is_high: CMP. B #0, D 2 BNE DONE ; BOTH HIGH return 0 MOVE. B #1, D 0 DONE: MOVE. L SAVED 2(SP), D 2 Comparing Blackfin and 68 K UNLINK A 6 12/14/2021 Copyright M. Smith smithmr@ucalgary. ca RTS 20