Post on 31-Dec-2015
description
04/19/23 1
Developing a multi-thread product -- IntroductionM. Smith
Electrical Engineering, University of Calgary
Smithmr @ ucalgary.ca
04/19/23 2 / 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
04/19/23 3 / 33
References
1) Understanding GPS Principles and Applications, 1996, Elliott D. Kaplan
2) Digital Signal Processing – A Practical Approach, 1993, Emmanuel C. Ifeachor, Barrie W. Jervis
3) ADSP-TS101 TigerSHARC and Blackfin Processor Programming References, Analog Devices
4) Articles submitted to Circuit Cellar magazine by M. Smith, March 2004
04/19/23 4 / 33
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
04/19/23 5 / 33
What is GPS?
Global Positioning System
24 satellite (SV) constellation
Orbits are set-up to give global coverage24 hours a day
Need at least 4 satellites in view to calculate a position
Orbiting 20,000 km from the surface of the Earth in 12 hour cycles
(1)
04/19/23 6 / 33
GPS Positioning Concepts
(1) 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.
04/19/23 7 / 33
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
04/19/23 8 / 33
Determining Time
Use the PRN code to determine time Use time to determine distance to the
satellite distance = speed of light * time
(1)
04/19/23 9 / 33
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
04/19/23 10 / 33
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)
Timing
30,000Complex
operations
1,048,576operations
N-1
(N2)
04/19/23 11 / 33
TigerSHARC -- TS101 and TS201
Low-cost version $45 / chipEvaluation boards $950 eacheducational price
TS101
TS201
04/19/23 12 / 33
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
04/19/23 13 / 33
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
04/19/23 14 / 33
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
04/19/23 15 / 33
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.
04/19/23 16 / 33
VDK set-up for TigerSHARC (3.5)
04/19/23 17 / 33
VDK Setup – Visual DSP 4.0
04/19/23 18 / 33
Adding the Initialization Thread
04/19/23 19 / 33
Making the InitializationThread a Boot-Thread
AutomaticallyGenerated
Thread Code
04/19/23 20 / 33
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
04/19/23 21 / 33
Thread window legend(Right click in thread window to activate)
Running
Sleeping
Status change
Running
Tick (0.05 ms default)
04/19/23 22 / 33
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
04/19/23 23 / 33
Thread code automatically generatedExample after running the code
Problem – the threads have not been created – so they exist but don’t run
04/19/23 24 / 33
Still problems
All threads are launched
But one thread has taken over all the resources of the system
04/19/23 25 / 33
Reason for Problem
Thread is just spinning its wheels
Forgot to add the sleep?
04/19/23 26 / 33
Solution
Thread now all in existence – but free running
Need to add “semaphores” to gain control
04/19/23 27 / 33
Receiver Requirements
On receipt of “Capture Signal” semaphore Clear ReceiverBuffer When receiver buffer is cleared
Grab satellite signals 1, 2 and 3
04/19/23 28 / 33
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);
04/19/23 29 / 33
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?
04/19/23 30 / 33
Adding a semaphore
04/19/23 31 / 33
Method code addedWhy does not anything work?
What do you have to do to get this?
1 line change
04/19/23 32 / 33
Some issues remaining
Blue bar means what? Why is distance between Init ThreadGreen 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?
04/19/23 33 / 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