VisualDSP++ and Test Driven Development What happened last lecture?

Slides:



Advertisements
Similar presentations
TigerSHARC processor and evaluation board Different capabilities Different functionality.
Advertisements

6/2/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
Software and Hardware Circular Buffer Operations First presented in ENCM There are 3 earlier lectures that are useful for midterm review. M. R.
Lab. 2 Overview 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have that knowledge?
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter.
VisualDSP++ and Test Driven Development Prelaboratory assignment information.
TigerSHARC processor General Overview. 6/28/2015 TigerSHARC processor, M. Smith, ECE, University of Calgary, Canada 2 Concepts tackled Introduction to.
Laboratory 1 – ENCM415 Familiarization with the Analog Devices’ VisualDSP++ Integrated Development Environment.
Just enough information to program a Blackfin Familiarization assignment for the Analog Devices’ VisualDSP++ Integrated Development Environment.
Understand Application Lifecycle Management
Blackfin Array Handling Part 2 Moving an array between locations int * MoveASM( int foo[ ], int fee[ ], int N);
Humboldt University Berlin, University of Novi Sad, University of Plovdiv, University of Skopje, University of Belgrade, University of Niš, University.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 3 Understanding the memory pipeline issues.
Averaging Filter Comparing performance of C++ and ‘our’ ASM Example of program development on SHARC using C++ and assembly Planned for Tuesday 7 rd October.
TigerSHARC Laboratory Setting up the HPP-ICE environment ICT 318 / 320 Running versions of the Audio-talk-through program.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 2 Understanding the pipeline.
Generating “Rectify( )” Test driven development approach to TigerSHARC assembly code production Assembly code examples Part 1 of 3.
Lab. 4 Demonstrating and understanding multi-processor boot TigerSHARC multi-processor system.
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);
Mistakes, Errors and Defects. 12/7/2015Mistakes, Errors, Defects, Copyright M. Smith, ECE, University of Calgary, Canada 2 Basic Concepts  You are building.
12/14/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
A first attempt at learning about optimizing the TigerSHARC code TigerSHARC assembly syntax.
Generating a software loop with memory accesses TigerSHARC assembly syntax.
Software Development.
Memory Management.
FOP: Multi-Screen Apps
UMBC CMSC 104 – Section 01, Fall 2016
Chapter 5- Assembling , Linking, and Executing Programs
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Lab. 2 Overview – Earlier Tasks Prelaboratory T1, T3, T4 and T5
and Executing Programs
Software and Hardware Circular Buffer Operations
TigerSHARC processor General Overview.
Generating the “Rectify” code (C++ and assembly code)
Generating “Rectify( )”
A Play Core Timer Interrupts
Introduction to Test Driven Development
PROGRAMMING METHODOLOGY
Automated Testing Environment
Overview of SHARC processor ADSP Program Flow and other stuff
Trying to avoid pipeline delays
Generating a software loop with memory accesses
Understanding the TigerSHARC ALU pipeline
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
TigerSHARC processor and evaluation board
Lab. 2 – More details – Later tasks
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Understanding the TigerSHARC ALU pipeline
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Using Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Lab. 4 – Part 1 Demonstrating and understanding multi-processor boot
A Play Lab. 2 Task 8 Core Timer Interrupts
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
* M. R. Smith 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint.
Getting serious about “going fast” on the TigerSHARC
General Optimization Issues
Concept of TDD Test Driven Development
Explaining issues with DCremoval( )
General Optimization Issues
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Data Structures & Algorithms
Understanding the TigerSHARC ALU pipeline
Mistakes, Errors and Defects
A first attempt at learning about optimizing the TigerSHARC code
Working with the Compute Block
Lecture 3 More on Flow Control, More on Functions,
A first attempt at learning about optimizing the TigerSHARC code
Building tests and code for a “software radio”
Presentation transcript:

VisualDSP++ and Test Driven Development What happened last lecture? Note – Developing the C++ Rectify code will be part of Familiarization Lab. and Pre-lab 1 Assignments

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Developing software radio on the TigerSHARC Concept of test driven development – An “Agile” software development concept Writing the customer tests Understanding the E-TDD testing framework Writing the CPP rectify code Will be trying these ideas out in the laboratory this afternoon. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Conventional “AM” radio RF STAGE Antenna Pickup AUDIO STAGE Low pass Filter + amplifier Low pass Filter Rectifier Mixer Local Oscillator IF STAGE Audio out 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Software “AM” radio concept RF STAGE Antenna Pickup AUDIO STAGE Low pass Filter + amplifier Low pass Filter Rectifier Mixer Local Oscillator IF STAGE Audio out Most stages handled with high speed software 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

A basic example for the coding practices adopted through the term Going to use the rectification stage of this “soft-radio” as a “code example” all through the course. We may also look at “single-side band modulation” (involves IIR filtering) as a second “code example” followed all though the term. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Customer Requirements Wants to get “product out of the door” as fast as possible Less time spend on development the better, but it has to work Developing in C++ is easier than developing in assembler code, but is it fast enough Risk analysis – take one representative part of the code and explain the differences between the speeds from C++ code (Debug and Release Mode) and assembly code 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Standard testing practice Heavy on documentation TLD Test Last Development 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Test Driven Development Work with customer to check that the tests properly express what the customer wants done. Iterative process with customer “heavily involved” – “Agile” methodology. CUSTOMER DEVELOPER 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Lets apply TDD to rectification issue Overall technique Decide on a particular test action with the customer Write the test(s) Write the simplest possible code to satisfy the test(s) “Refactor” the code to improve “quality” Definition of “quality” is unclear in the literature Ease of “use” or “reuse” of code Reliable to use – “robust” My additional idea – meets speed requirements for the embedded situation See paper handed out for more details 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Files and directories needed TDD and many tests files available on web ENCM515 WEB Rectify Tests – Assign1Tests HalfWaveDebugModeTests.cpp HalfWaveReleaseModeTests.cpp HalfWaveAMSTests.cpp TDD files in E-TDDIncludes dir ActivateTests.cpp TS201_char32_TDDLib_dlb Various TDD_includes.h TDD_Tests1Jan05.h Rectify code developed in Assign1 directory Rectify.h TS201.ldf (loader description file for 1 processor) HalfWaveDebugMode.cpp (float and int code) HalfWaveReleaseMode.cpp (float and int code) HalfWaveIntASM.asm HalfWaveFLoatASM.asm Lab1 Lab1Tests Lab2 Lab2Tests LabX LabXTests 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada E-TDD Test.cpp files have four main components. Many error messages if not present Include Files – cut-and-paste (always the same) TEST_CONNECT (TestFileInfo) TEST(testNAME, testTYPE) NOTE: Tests execute from LAST in file to FIRST. As normally the LAST test is the most recently added test, this is good. You test if new code works and then check (regression test) that you did not break anything LINK_TEST(TestFileInfo, testTYPE) 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Now expand the Customer Tests to do what the customer has requested 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Now expand the Customer Tests to do what the customer has requested E-TDD TEST SYNTAX CHECK( ) – if condition is true XF_CHECK( ) – expected failure meaning you know its wrong and plan to fix later. Passing an XF_CHECK( ) (SUCCESS) is considered a failure. ARRAYS_EQUAL( ) – basically a loop of CHECK( )s. MEASURE_EXECUTION_TIME( ) automatically uses an internal TigerSHARC clock. Value returned in “processor cycles”. REPORT – currently printf( ) 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Note that writing the tests has automatically generated the function interface information Why int* and float* rather than just void as you are passing in the address of the output Design decision – sort of standard with “C” to pass back a pointer to thing being changed 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Floating point version of the Tests Essentially a cut-and-paste version of integer code 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Stage 1 – Compile / Link the tests Obviously the Link is not going to work – as the code for functions HalfWaveRectifyXXX( ) have not been written If obviously going to fail – WB (why bother)? Basically – You are TESTING THE TESTS Are you calling the functions you expect to call. Better handled by doing Code Review first, and then use compiler / linker to CHECK the Code Review did not miss something (PSP – personal software process). C++ can overload function names (done via name mangling). What are the name-mangled names needed for the assembly code? – This stage will show you. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Name mangled names can be seen from linker C++ name as used The name mangled name generated by in C++ code by the C++ compiler in response to function overloading. These are the “assembly code” names 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Next step: Write just enough code to satisfy the linker – C++ stubs 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Write the assembly language stub We lost control of the processors in the debug environment. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Recovery process Don’t lose control – write good code Do incremental builds so you are continually writing and testing code E-TDD encourages this – write a test, then write just enough code to satisfy the tests If you lose control Try selecting each processor (DSPA then DSPB) in processor window. Then select DEBUG | HALT If that fails, then in this order (easier restart process) Exit from E-TDD GUI, Exit from VisualDSP IDDE Power down the board Walk-around your chair twice (or count to 10)  Power up board, then reactivate VisualDSP IDDE and the GUI 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

We “accidentally” pass some tests without writing any code 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Write “just enough code to satisfy” Cpp tests. During design may identify more tests. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Build the code incrementally to satisfy tests See speed change now we Are executing code – but why failures Note what if N < = 0 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Add test to check that works if N <= 0 Do another code review and spot problemS NEW TESTS CHECKING WRONG THING OVER-WRITING EXPECTED RESULTS 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Weird test results 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Weird test results I forgot to add the new code for the pt = NULL if N <= 0, yet some tests pass ASM passes since stub sets pt = NULL before returning I did not do any assembly code – yet the tests act as if the code is working Release code passes ASM code passes Poor test design because we did not set the “result_array[ ]” back to zero FIX THE TEST AS PART OF ASSIGNMENT 1 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Incrementally added the code to HalfWaveReleaseMode( ) Test that past before are now failing Compiler does not know difference between “debug” and “release” mode 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Select file – then right click and select FILE OPTIONS 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Click on “File Specific Settings” and then on COMPILE | General 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Click on ENABLE OPTIMIZATION, Click okay and then rerun the tests 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Note Special marker Compiler optimization FLOATS 927  304 -- THREE FOLD INTS 960  150 – SIX FOLD Why the difference, and can we do better, and do we want to? Note the failures – what are they 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Use GUI to find out Okay – at this point in time – we are expecting that to fail 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Concepts tackled Developing software radio on the TigerSHARC Concept of test driven development – An “Agile” software development concept Writing the customer tests Understanding the E-TDD testing framework Writing the CPP rectify code Will be trying these ideas out in the laboratory this afternoon. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada