Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.

Slides:



Advertisements
Similar presentations
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
Advertisements

1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
Over-view of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 3 – New instruction recap Tutorial.
Assignment Overview Thermal oscillator One of the ENCM415 Laboratory 2 items Oscillator out GND +5V.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Lab. 1 – Earlier Tasks. Needed by both application and demonstration lab. streams For more details – see the Lab. 1 web-site There will be a 20 min prelab-quiz.
6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 1 Temperature Sensor Laboratory 2 Part 2 – Developing.
Building a simple loop using Blackfin assembly code M. Smith, Electrical and Computer Engineering, University of Calgary, Canada.
Developing a bicycle speed-o-meter Part 2 A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
Over-view of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab.
Review of Blackfin Syntax Moves and Adds 1) What we already know and have to remember to apply 2) What we need to learn.
Lab. 1 – Task 1 to 4 details For more details – see the Lab. 1 web-site There will be a 20 min prelab-quiz (based on Assignment 1 and 2) at the start of.
Over-view of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab.
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Laboratory 1 – ENCM415 Familiarization with the Analog Devices’ VisualDSP++ Integrated Development Environment.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
Just enough information to program a Blackfin Familiarization assignment for the Analog Devices’ VisualDSP++ Integrated Development Environment.
Blackfin BF533 EZ-KIT Control The O in I/O
Developing a bicycle speed-o-meter Midterm Review.
Programmable Logic Controllers
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 9/19/2015 Review of 50% OF ENCM369 in 50 minutes1.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
Blackfin Array Handling Part 2 Moving an array between locations int * MoveASM( int foo[ ], int fee[ ], int N);
Over-view of Lab. 1 See the Lab. 1 web-site and later lecture notes for more details.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
Generating “Rectify( )” Test driven development approach to TigerSHARC assembly code production Assembly code examples Part 1 of 3.
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system Manual control of RC car.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
Lab. 1 – Required Tasks. For more details – see the Lab. 1 web-site.
Over-view of Lab. 1 See the Lab. 1 web-site and the lecture notes for more details.
Multi-threaded projects Services and Drivers Alternate ways of doing Labs 1, 2, 3 and 4.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
A first attempt at learning about optimizing the TigerSHARC code TigerSHARC assembly syntax.
Building a simple loop using Blackfin assembly code If you can handle the while-loop correctly in assembly code on any processor, then most of the other.
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 2/26/2016 Review of 50% OF ENCM369 in 50 minutes1.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 3/3/2016 Review of 50% OF ENCM369 in 50 minutes1.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Over-view of Lab. 1 See the Lab. 1 web-site and latter lecture notes for more details.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
See the Lab. 1 web-site and later lecture notes for more details
Developing a bicycle speed-o-meter
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Assembly Language Review
Assembly Language Review
Phillipa Gill SCI 199 Y Tutorial Sept. 14, 2009 Phillipa Gill
See the Lab. 1 web-site and later lecture notes for more details
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Developing a bicycle speed-o-meter
Developing a bicycle speed-o-meter
Blackfin BF533 EZ-KIT Control The O in I/O
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.
Developing a bicycle speed-o-meter
Developing a bicycle speed-o-meter Part 2
Chapter 6 Programming the basic computer
A first attempt at learning about optimizing the TigerSHARC code
Let’s use a PUSH-Button!
Blackfin Syntax Moves and Adds
Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
Presentation transcript:

Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult part of the course.

Essentially all the instructions you ever need to know on ANY processor. assignment = add (+), subtract (-) bitwise AND (&), bit wise OR (|) Shift values left and right (arithmetic and logical) store a value to memory retrieve, read, load a value from memory Handle 8-bit, 16-bit and 32-bit DATA values do an if statement and then (conditionally jump) Call a function, return from a function 2 /18

Basic assembly code operations on Blackfin processor -- ADD Place a 1 into register R0 Place a 2 into register R1 Add the values and store in R3 and return the value to a C / C++ program.section program;.global AddASM; AddAsm: R0 = 1; R1 = 2; R3 = R1 + R2; // Note typo – WHERE, WHERE? R0 = R3;// C++ REQUIREMENT TO RETURN VALUE IN R0 AddAsm.END: RTS;// Expect Result is 3 3 /18 MODIFIED SLIDE – R0 Requqirements for C / ASM interface

Basic assembly code operations on Blackfin processor -- SUB Place a 1 into register R0 Place a 2 into register R1 Subtract R0 from R1 and store in R3 and return the value to a C / C++ program.section program;.global SubASM; SubAsm: R0 = 1; R1 = 2; R3 = R1 – R0; R0 = R3;// C++ REQUIREMENT, RETURN VALUE IN R0 SubAsm.END: RTS;// Expect Result is 1 4 /18

UNPLANNED HIDDEN ERROR YOU CAN’T USE R4 Place a 1 into register R0 Place a 2 into register R1 Subtract R0 from R1 and store in R4 and return the value to a C / C++ program.section program;.global SubASM; SubAsm: R0 = 1; R1 = 2; R4 = R1 – R0; // OTHER C CODE IS USING R4 R0 = R4;// C++ REQUIREMENT TO RETURN VALUE IN R0 SubAsm.END: RTS;// Expect Result is 1 5 /18 NEW SLIDE

CORRECTED CODE FOR USING R4 (NO-VOLATILE) REGISTER.section program;.global SubASM; SubAsm: [--SP] = R4;// SAVE THE VALUE THE OTHER C CODE USES // IMPORTANT --SP NOT SP- - // PRE-DECREMENT SP THEN USE IT R0 = 1; R1 = 2; R4 = R1 – R0; // OKAY TO USE R4 R0 = R4;// C++ REQUIREMENT TO RETURN VALUE IN R0 // IMPORTANT SP++ NOT ++SP // USE SP THEN INCREMENT SP R4 = [SP++]; // SAVE THE VALUE THE OTHER C CODE USES SubAsm.END: RTS;// Expect Result is 1 6 /18 NEW SLIDE

Embedded UnitTest TEST FORMAT AddASM( ) does the following Place a 1 into register R0, Place a 2 into register R1 Adds the values and store in R3 and return the values (3) to a C / C++ program in R0 SubASM( ) does the following Place a 1 into register R0, Place a 2 into register R1 Subtracts R0 from R1 and store in R3 and return the value to a C / C++ program in R0 extern “C” int AddASM( void); TEST(AddASM) { int expectedValue = 3; CHECK_VALUES(expectedValue, AddASM( ) ); } extern “C” int SubASM( void); TEST(SubASM) { int expectedValue = 1; CHECK_VALUES(expectedValue, SubASM( ) ); } 7 /18 MODIFIED SLIDE – AddASM( ) and SubASM( )

Basic assembly code operations on Blackfin processor -- AND Place a 1 into register R0 Place a 3 into register R1 AND the values and store in R3 and return the value to a C / C++ program.section program;.global AndASM; AndAsm: R0 = 1; R0 (last 8 bits) = b R1 = 3; R1 (last 8 bits) = b R3 = R1 & R0; R3 (last 8 bits) = b???? ???? R0 = R3;// C++ REQUIREMENT FOR RETURN VALUE AndAsm.END: RTS;// Expect Result is 1 & 3 = ????? 8 /18 MODIFIED SLIDE – R0 and R1 bit values

Introduce the Blackfin GPIO register Input / Output Interface to the outside world Memory mapped 16-bit register 9 /18 BIT 0 Name FIO_FLAG_D defined in MODIFIED SLIDE – Interface mentioned

Read the 16 bit value in the Blackfin GPIO data register and return value to “C++” Switch values, thermal sensor values Non self-documented code (poor for getting marks) #include.section program;.global ReadGPIO; ReadGPIO : #define FLAG_MEMORY_LOCATION 0xFFC00700 P0.L = lo(FLAG_MEMORY_LOCATION); P0.H = hi(FLAG_MEMORY_LOCATION); R3 = W[P0] (Z); // Read 16-bit value, // Extend with 0’s to 32-bits and store in 32 bit register // Easier code to remember how to use (and less likely to make a typo) P0.L = lo(FIO_FLAG_D); P0.H = hi(FIO_FLAG_D); R3 = W[P0] (Z); // Read 16-bit bit pattern value and zero extend it as it is not a number R0 = R3;// C++ REQUIREMENT TO RETURN VALUE IN R0 ReadGPIO.END: RTS;// Expect Result is ????? 10 /18 MODIFIED SLIDE – How GPIO lines used Blackfin manual information

Return ONLY bit 11 of Blackfin GPIO data register (SW3) and return value to “C++” Non self-documented code (poor for getting marks) #include.section program;.global ReadGPIOBit; ReadGPIOBit : // Easier code to remember how to use (and less likely to make a typo) P0.L = lo(FIO_FLAG_D); P0.H = hi(FIO_FLAG_D); R3 = W[P0] (Z); // Read 16-bit value, // Extend with 0’s to 32-bits and store in 32 bit register // Turn all bits but bit 11 into zero #define BIT11MASK 0x0800 // Binary pattern R2 = BIT11MASK; R0 = R3 & R2;// C++ REQUIREMENT TO RETURN VALUE IN R0 ReadGPIOBit.END: RTS;// Expect Result is 0x0800 if button SW3 pressed otherwise 0 11 /18

Return ONLY if bit 11 of Blackfin GPIO data register (SW3) is set (DEMONSTRATE LOOP) Non self-documented code (poor for getting marks) #include.section program;.global ReturnOnBit11; ReturnOnBit11 : // Easier code to remember how to use (and less likely to make a typo) P0.L = lo(FIO_FLAG_D); P0.H = hi(FIO_FLAG_D); R3 = W[P0] (Z); // Read 16-bit value, // Extend with 0’s to 32-bits and store in 32 bit register // Turn all bits but bit 11 into zero #define BIT11MASK 0x0800 // Binary pattern (BIT 11 IS SET) R2 = BIT11MASK; R1 = R3 & R2;// Changed register name to R1 CC = R1 == R2;// CC condition code SET to 1 if R1 == R2 (bit 11 set) and 0 otherwise IF CC JUMP ReturnOnBit11; ReturnOnBit11.END: RTS; 12 /18 MODIFIED SLIDE

Return a 1 if bit 11 of Blackfin GPIO data register (SW3) is set and return 0 otherwise Non self-documented code (poor for getting marks) #include.section program;.global Return1OnBit11; Return1OnBit11 : // Easier code to remember how to use (and less likely to make a typo) P0.L = lo(FIO_FLAG_D); P0.H = hi(FIO_FLAG_D); R3 = W[P0] (Z); // Read 16-bit value, // Extend with 0’s to 32-bits and store in 32 bit register // Turn all bits but bit 11 into zero #define BIT11MASK 0x08000 // Binary pattern R2 = BIT11MASK; R1 = R3 & R2;// C++ REQUIREMENT CC = R1 == R2;// CC condition code 1 if R1 == R2 (bit 11 set) and 0 otherwise IF !CC R0 = 0;// If condition not true, return a 0 (in R0) IF CC R0 = 1; // If condition not true, return a 1 (in R0) // Is this syntax really possible?Write simple code to check Return1OnBit11.END: RTS; 13 /18

Add a trial.asm file to Familiarization Lab. code to test the syntax 14 /18

This changed syntax is possible if CC reg = reg but stupid in this situation 15 /18 MODIFIED SLIDE

This code assembles – but is it correct? (meaning gives the correct answer)? Read Chapter 10 of programming manual 16 /18

Tutorial Exercise 17 /18 Switches 0, 1, 2 and 3 are connected to pins 8, 9, 10, and 11 respectively Pins 0 to 7 are connected to the Blackfin video channel (input) Pins 12 to 15 are connected to ????

Tutorial Write a Blackfin assembly language routine that does not return until Switch 1 is up (set, 1), switch 2 is down (clear, 0) and switch 4 is set. Part of the code to store commands for the operation of the radio controlled car. 18 /18

Burglar alarm 19 /18 Light 1 Light 2 Light 1 Sensor connected to SW3 input GPIO line Light 2 sensor connected to SW1 input GPIO line Light sensor output is 1 if there is light shining on the sensor. Write a Blackfin Assembly Subroutine that waits until somebody leaves or enters the room, and then returns the value 1 or 2 depending on how many people leave the room at the same time ROOM

Subroutine to call Return1onBit11( ) and store result in memory #include.section L1_data;.byte2 _result;.section program;.extern Return1OnBit11;// Code in another file.global NewFunction; NewFunction: LINK 16; CALL Return1OnBit11;// Returns value in R0 ALWAYS P0.l = lo(_result); P0.h = hi(_result); // value returned in R0 by convention W[P0] = R0; UNLINK; NewFunction.END: RTS; 20 /18

This code looks the same – but is the difference between a B grade and a D grade and many hours wasted in the lab. #include.section L1_data;.byte2 _result;.section program;.extern Return1OnBit11;// Code in another file.global NewFunction; NewFunction: LINK 16; P0.l = lo(_result); P0.h = hi(_result); CALL Return1OnBit11;// Returns value in R0 ALWAYS //P0.l = lo(_result); P0.h = hi(_result); // value returned in R0 by convention W[P0] = R0; UNLINK; NewFunction.END: RTS; 21 /18 WHY DOES THIS CODE FAIL?

Essentially all the instructions you ever need to know on a processor. assignment = add (+), subtract (-) bitwise and (&), bit wise or (|) Shift values left and right (arithmetic and logical) store a value to memory retrieve, read, load a value from memory Handle 8-bit, 16-bit and 32-bit DATA values do an if statement and then (conditionally jump) Call a function, return from a function 22 /18