1 / 33

Developing a multi-thread product -- Introduction

Developing a multi-thread product -- Introduction. M. Smith Electrical Engineering, University of Calgary Smithmr @ ucalgary.ca. Tackled today. GPS example of a multi-tasking DSP problem What is GPS and how does it fit into Lab. 4? Lab. 4 concepts VisualDSP VDK environment – 1 hour prelab.

Download Presentation

Developing a multi-thread product -- Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing a multi-thread product -- Introduction M. Smith Electrical Engineering, University of Calgary Smithmr @ ucalgary.ca

  2. Tackled today • GPS example of a multi-tasking DSP problem • What is GPS and how does it fit into Lab. 4? • Lab. 4 concepts • VisualDSP VDK environment – 1 hour prelab. • Adding a boot thread • Adding (and then creating) free-running threads • Adding Semaphore so threads communicate

  3. References • Understanding GPS Principles and Applications, 1996, Elliott D. Kaplan • Digital Signal Processing – A Practical Approach, 1993, Emmanuel C. Ifeachor, Barrie W. Jervis • ADSP-TS101 TigerSHARC and Blackfin Processor Programming References, Analog Devices • Articles submitted to Circuit Cellar magazine by M. Smith, March 2004

  4. Introduction • GPS traditionally done with ASIC/Processor combination • Looking at FPGA/DSP combination for low end GPS receivers • Technological interest in software radio • Cheaper, quicker development cycle. • Customizations for special applications • From a talk by Darrell Anklovitch for ENEL619.23

  5. What is GPS? Global Positioning System 24 satellite (SV) constellation Orbiting 20,000 km from the surface of the Earth in 12 hour cycles Orbits are set-up to give global coverage 24 hours a day Need at least 4 satellites in view to calculate a position (1)

  6. GPS Positioning Concepts • For now make 2 assumptions: • We know the distance to each satellite • We know where each satellite is • Require 3 satellites for a 3-D position in this “ideal” scenario • Requires 4 satellites to account for local receiver clock drift. (1)

  7. GPS Signal Structure • Each satellite transmits 2 carrier frequencies referred to as L1 (1575 MHz) and L2 (1227 MHz) • Each carrier frequency is BPSK modulated with a unique PRN (pseudo random number) code • The PRN code on L1 is called CA code (coarse acquisition), The PRN code on L2 is called P code (precise) • CA code takes 1 ms for full PRN transmission at 1MHz chip (bit) rate. P code takes 1.5 s for full PRN transmission at ~10MHz chip rate • Also modulated on each carrier is 50 Hz data that includes the current position of the satellite

  8. Determining Time • Use the PRN code to determine time • Use time to determine distance to the satellite distance = speed of light * time (1)

  9. Algorithms to Find PRN Phase • Time-domain Cross correlation: 1/N∑x1 (n) * x2(n) • Coding equivalent to FIR filter, but need to filter N sets of data, each shifted by one data point • Correlation of perfectly matching signals gives a maximum value • Correlation of 2 random data sequences tends to 0 • PRN code from different satellites are designed to correlate to 0. • Frequency domain correlation: 1/N F-1[X1(k)X2(k)] where F-1 is the inverse Discrete Fourier Transform and the X’s are the Discrete Fourier Transforms of two sequences D

  10. Timing • Frequency Domain 1/N F-1[X1(k)X2(k)] • 1024 point FFT (2 * NLOG2N) • 1024 MULTS (N) • 1024 point INV FFT (NLOG2N) • Time Domain 1/N∑x1 (n) * x2(n) • n = 0 • 1024 MACs (N) • 1024 Phases (N) 30,000 Complex operations N-1 1,048,576 operations (N2)

  11. TigerSHARC -- TS101 and TS201 TS101 TS201 Low-cost version $45 / chip Evaluation boards $950 eacheducational price

  12. Lab. 4 and Take-Home Quiz 4 • Demonstrate developing a multi-threaded environment involving the receiving and analysis of 3 satellite signals • Lab 4 • VDK environment • Use of current assembly FIR code for correlation analysis • Take-home quiz (Done individually) • Use Analog Devices provided FFT code • Develop your own assembly language code using CLU functionality -- XCORRS

  13. Lab. 4 – Parts 1, 2 and 3 – done as pre-laboratory tasks – about 1 hour • Part 1 -- Create an Initialization Thread • Use VDK::Sleep(200) sleep as a work load • Part 2 – Launch (create) Satellite Receiver Tasks as free running tasks • Use VDK::Sleep(X) as a work load • ClearReceiverThread X = 100 • ReceiveSatellite1 X = 10 • ReceiveSatellite2 X = 20 • ReceiveSatellite3 X = 30 • Part 3 – Add semaphores to get satellite tasks running in proper time sequences

  14. Lab. 4 – Continued – details to be added • Part 4 -- Add Satellite Receiver Tasks Payloads • Download payload code from the web – code provided • Part 5 – Generate E-TTD tests for correlation function designed using your existing FIR filter code • Part 6 – Add analysis and reporting threads • Part 7 – adjust task priorities to make realistic and working • Demo and code hand-in with minor write-up

  15. Adding the initialization Thread • Blackfin code (VisualDSP 3.5) can be found at http://www.enel.ucalgary.ca/People/Smith/2005webs/encm515_05/05Labs/05Lab4/04IntroductionVDK.ppt • TigerSHARC VDK • Different implementation for each version of processor (0.1 or 1.0) because of number of available timers on the chips • Slightly different setup between Visual DSP 3.5 and 4.0 because of the silicon differences mentioned above.

  16. VDK set-up for TigerSHARC (3.5)

  17. VDK Setup – Visual DSP 4.0

  18. Adding the Initialization Thread

  19. Making the InitializationThread a Boot-Thread AutomaticallyGeneratedThread Code

  20. Adding a VDK::Sleep(200) work load to the Initialization Thread VDK-Thread activity window can be activated through VIEW | VDK window menu option – you can Zoom into find fine details of certain activitiesWARNINGL If the silicon option are incorrect – only the IDLE thread seen

  21. Thread window legend(Right click in thread window to activate) Running Sleeping Status change Running Tick (0.05 ms default)

  22. Now add the following threads with following VDK::Sleep( ) periods • ReceiverControlThread -- 100 ticks • ReceiverBufferClear -- 10 ticks • Receive1Satellite -- 10 ticks • Receive2Satellite -- 20 ticks • Receive3Satellite -- 30 ticks

  23. Thread code automatically generatedExample after running the code Problem – the threads have not been created – so they exist but don’t run

  24. Still problems All threads are launched But one thread has taken over all the resources of the system

  25. Reason for Problem Thread is just spinning its wheels Forgot to add the sleep?

  26. Solution Thread now all in existence – but free running Need to add “semaphores” to gain control

  27. Receiver Requirements • On receipt of “Capture Signal” semaphore • Clear ReceiverBuffer • When receiver buffer is cleared • Grab satellite signals 1, 2 and 3

  28. Requirements rephrased ReceiverControlThread • VDK::PendSemaphore(kCaptureSignalSTART, 0); • On receipt of “Capture Signal” semaphore • VDK::PostSemaphore(kReceiverBufferClearSTART) • Clear ReceiverBuffer • VDK::PendSemaphore(kReceiverBufferClearDONE, 0); • When receiver buffer is cleared • VDK::PostSemaphore(kReceiver1SatelliteSTART); • VDK::PostSemaphore(kReceiver2SatelliteSTART); • VDK::PostSemaphore(kReceiver3SatelliteSTART); • Grab satellite signals 1, 2 and 3 • VDK::Sleep (200) • VDK::PostSemaphore(kCaptureSignalDONE);

  29. Requirements rephrased • ReceiverBufferClear • VDK::PendSemaphore(ReceiverBufferClearSTART, 0); • VDK::Sleep (10); // Will be replaced by process later • VDK::PostSemaphore(ReceiverBufferClearDONE); • Typical Satellite Thread • VDK::PendSemaphore(ReceiverXSatelliteSTART, 0); • VDK::Sleep (X); // Will be replaced by process later • VDK::PostSemaphore(ReceiverXSatelliteDONE); • What are the syntax errors in the code?

  30. Adding a semaphore

  31. Method code addedWhy does not anything work? What do you have to do to get this? 1 line change

  32. Some issues remaining Blue bar means what? Why is distance between Init Thread Green bar means what? and start of Receiver Control thread Grey bar means what? changing?Yellow arrow means what? Is it a problem that Satellite 3 task finishes after receiver control thread starts to sleep?

  33. Tackled today • GPS example of a multi-tasking DSP problem • What is GPS and how does it fit into Lab. 4? • Lab. 4 concepts • VisualDSP VDK environment – 1 hour prelab. • Adding a boot thread • Adding (and then creating) free-running threads • Adding Semaphore so threads communicate

More Related