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. SHARC Processor Characteristics Number Representations When = BUT 2 *2 != 4 M. R. Smith, Electrical and Computer Engineering University of Calgary, Alberta, Canada ucalgary.ca

2 To tackled Number Representations are varied
Make sure you understand them Can solve many coding errors by recognizing improper use of number representations SHARC default number representation for integers is not what is expected. Understanding Number Representations allows for extra speed in that 1 in 1000 situation 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

3 Number Representations
Number representations are important. This is a talk about the number representations on the Analog Devices ADSP SHARC Processor has “C-like” syntax for assembly code Both single cycle integer and float operations 32-bit registers (integer and float) For more information see the article Smith, M. R., "Quirks and SHARCs -- Issues in programming the Analog Devices SHARC processor. When = 2 but != 4", Circuit Cellar, March 2001. 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

4 Recap -- Bit patterns in memory
Bit values stored in memory Can represent what you like hash table, ascii characters, signed and unsigned integer numbers (various precisions), floating point numbers etc. Certain number representations more easily supported by the processor for various operations than others. On SHARC bit integers and FP, also 40-bit FP (extended FP). 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

5 Example -- Eight Bit Values
Unsigned 8-bit integers Range , resolution 1 e.g. 0x00 = 0, 0x10 = 16, 0x7F = 127 0x80 = 128, 0x81 = 129, 0x90 = ????, 0xC0 = ???? 0xF0 = ????, 0xFE = 254, 0xFF = 255 Signed 8-bit integers -- 2’s complement Range -128 to + 127, resolution 1 e.g. 0x00 = 0, 0x10 = +16, 0x7F = +127 0x80 = -128, 0x81 = = -127, 0x90 = ??? 0xF0 = ????, 0xFE = -2, 0xFF = -1 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

6 Floating Point in Binary Representation
20 (decimal) = 0x14 hex = % (binary) = % Normalize binary -- express as %1.frac * 2N % = % * 24 6 = % = % * 22 Sign = 0 Fraction part = Biased Exponent = 129 = % Stored as FP Number etc 0x40C = 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

7 Display Program Code -- Float
32-bit registers 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

8 Code displayed in Mixed Mode
No such instruction as F4 = Only R4 = WARNING --- F4 = 2 is the same as R4 = 2 and is DIFFERENT F4 = 2.0 Note how FP looks like VERY LARGE integer 32 bit registers 40 bit display Ultra High precision FP 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

9 Need to learn to recognize
What do “integers” look like when they are displayed as “floats” What do “floats” look like when displayed as “integers” Happens when you pass a pointer to the start of an array and then treat the array incorrectly I consider the following a BUG IN ASSEMBLER F4 = 6 is actually the same as F4 = 3 * 10-45 FN = value does not exist -- only RN = value Make sure that you add the decimal point!!!! var array_of_FLOATS[] = { 2.8, 3, 3.2, 3.4}; NOT INTENDED AS A VERY SMALL VALUE 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

10 Display Program Code -- Integer
32 BIT registers Top 32 bits means something Note how integers look like VERY SMALL floats -- note also wrong values 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

11 Unexpected default integer representation
68k processor Default operations Signed and unsigned integer representation 21k processor / Blackfin / TigerSHARC Signed and unsigned integer representation of “fractional” values Signed and unsigned integer “need to be switched on” See difference in multiplication 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

12 Code displayed in Mixed Mode Q9 – What happens with Blackfin
5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

13 Proper Integer Coding sequence
5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

14 Bit meaning in 8-bit signed fractional number
^ ACTS AS IF “BINARY POINT” HERE Binary Pattern % = -1 * * * * * * * * 2-7 Decimal Calculation = ( 0x93 / 128) = ( 0x80 + 0x13 ) / = ( ) / 128 = / 128 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

15 Signed fractional Integer interpreted with a binary point just after the sign bit Using 32-bit values Smallest value -1.0 Largest almost = = ^-31 Steps (accuracy) 2^-31 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

16 68k equivalence -- 8-bit example
Standard number format Range -128 to + 127, resolution 1 0x0A+ 0x01 = 0x0B % % = % In any given DSP algorithm it could be useful to scale input values so that we have an alternative number format where binary point is effectively placed between bit #3 and #4 Range -8 to 7 7/8, resolution 1/8 0xA0 + 0x10 = 0xB0 (Means 0xA.0, 0x1.0, 0xB.0) % % = % Addition supported in both number formats 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

17 68k equivalence -- 8-bit example
Standard number format Range -128 to + 127, resolution 1 0x0A * 0x01 = 0x0A % * % = % Alternative number format where binary point is placed between bit #3 and #4 Range -8 to 7 7/8, resolution 1/8 0xA.0 * 0x1.0 = 0x?? % * % = % Must now adjust by >> 8 to get correct answer. When SHARC in SSF format, the scaling occurs automatically 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

18 Equivalent decimal calculation
As done in grade 6 * Perform 75 * 125 then adjust for 5 decimal places. -9375 then adjust to give 68k multiplication was 0xA.0 * 0x1.0 Perform 0xA0 * 0x10 then adjust for hex places 0xA00 then adjust to give 0xA.00 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

19 Displayed as “signed fractional”
5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

20 SHARC DIVISION APPEARS WEIRD TOO
5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

21 Actual SHARC division operations Note the parallel instructions
5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

22 Division is slow Integer division on 68K -- 70 cycles
60000 / 3 takes 70 cycles 60000 / 2 takes 70 cycles Integer shift takes much less 60000 / 2 = >> 1 ASR #1, D0 (with D0 = 60000) takes 4 cycles ASHIFT D0 BY -1 takes 1 cycle Can we find an equivalent operation for floating point scaling (by 2, 4, 8, 16 etc.)? 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

23 Signed Fractional -- ASHIFT of integer
Works here but that’s cheating since SF format is an floating point interpretation of an integer format 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

24 Binary Pattern of TRUE floats
SIGN BIT EXPONENT BITS FRACTIONAL BITS Floating point division is often SLOW DIVIDE BY 2, 4, 8, 16 fast with integers CAN ALSO MAKE FAST WITH FLOATS If you understand number representations 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

25 Fast scaling -- Floats as Integers
Differ in value by 4.0 Differ in BEXP by 2 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

26 Complete Fast Scaling 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

27 Nothing but a party trick!
F8 = ; F0 = 4.0; F1 = F0 * F8; F2 = 2.0; F3 = F3 * F8; F4 = 0.0; F5 = F4 * F8; Since this processor has single cycle multiply operation R8 = -4; F0 = 4.0; F1 = SCALEB F0 BY R8; F2 = 2.0; F3 = SCALEB F2 BY R8; F4 = 0.0; F5 = SCALEB F4 BY R8; Works just like our code Advantage – this is a COMPUTE operation and NOT a MAC operation 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --

28 Learnt today Number Representations are varied
Make sure you understand them Can solve many coding errors by recognizing improper use of number representations -- Limitation in SHARC assembler for F4 = Signed Fractional is default SHARC integer representation Understanding Number Representations allows for that 1 in 1000 situation when somebody at a party likes to play with DSP processors. 5/1/2019 Number Representations -- SHARC ADSP21061 Copyright M. Smith --


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