Project Correlation based GPS System_milestone 2

advertisement
ECE 6276 Final
Project
Correlation based GPS
System
Milestone 2
Team 4:
Alex Cunningham
Phillip Marks
Andrew D. Falendysz
Meghashyam Adoni
Goals
• Our goal is to use a correlator bank to determine which GPS
satellite(s) are available at a given location.
• To design a high-sensitivity, fast acquisition system to
provide accurate identification of weak GPS signals. The
extra processing power will be used to integrate weak
signals to the point where they can be used to provide a
position or timing solution.
System Block Diagram
Read New Code
Demodulated
Input
N
Shift Register
Correlator
Chip
Clk
> Threshold
Y
Shift
Register
Code
PRN Code
Detect
Header
C Code Reference Design
int main(int argc, char ** argv)
{
// Load Data
//cout << "Using shift register" << endl;
// data will cycle the encoded message continuously
// shift existing data in shift_reg
for (int i = CA_CODE_SIZE-1; i> 0; i--)
{
shift_reg[i] = shift_reg[i-1];
}
// prep buffers
// move CA code into an int buffer
float ca_code[CA_CODE_SIZE];
for (int i = 0; i < CA_CODE_SIZE; i++)
{
ca_code[i] = (float) cacode.get();
}
// shift into the current register
shift_reg[0] = new_data;
// clear shift register - possibly optional step
float shift_reg[CA_CODE_SIZE];
// load encoded data into a buffer that can be circled
float* encoded_msg = new float[DATA_CYCLE_SIZE];
for (int i = 0; i < DATA_CYCLE_SIZE; i++)
{
encoded_msg[i] = (float) encoded.get();
}
// a pointer to use with the circular buffer
float * encoded_msg_ptr = encoded_msg +INPUT_OFFSET;
// while waiting on a lock
cout << "Looking for lock..." << endl;
bool haslock = false;
while (!haslock)
{
// load a new piece of data
//cout << "Load more data" << endl;
float new_data = (float) *encoded_msg_ptr;
// perform circular buffering on dataset
if (encoded_msg_ptr = encoded_msg+CA_CODE_SIZE-1)
encoded_msg_ptr = encoded_msg;
else
encoded_msg_ptr++;
// perform correlation
//cout << "Performing correlation" << endl;
float power;
cout << "correlating..." << endl;
correlator(shift_reg, ca_code, &power, CA_CODE_SIZE);
// if threshold is high enough - break out of loop to acquire lock
//cout << "checking for lock" << endl;
cout << " correlation: " << power << endl;
if (power > 0.5)
haslock = true;
}
cout << "Lock found!" << endl;
delete[] encoded_msg;
cout << "Freeded Encode" << endl;
return 0;
}
Conversion to Catapult C
• All code and libraries have been modified by
using AC Datatypes.
• Catapult C FFT library has been used in lieu of
fftw library used in the C implementation.
• Loops have been identified and labeled for
optimization.
• Problems arose with initial implementation
• New algorithm is proposed
Test Vectors
• A test-bench file has been created with the
appropriate test vectors. (CA code and test
message at the moment)
• These test vectors remain the same as in the
previous C implementation.
• Binary data files:
– C/A Code (128 Bytes)
– NAV Message (38 Bytes)
– NAV Message Modulated with C/A Code (434
kB)
Initial Catapult C Implementation
• Top Level
#pragma hls_design_top
void my_gps (ac_channel<real_sample> &data_input, // sample data
code_type cacode[CA_CODE_SIZE],
// C/A code for the particular satellite
bool *lock_out, // output for test whether a lock was found
lag_type *lag_out) // time delay in signal for alignment with C/A code
{
static gps_correlator filter_1();
filter_1.test_for_lock(data_input, cacode, lock_out, lag_out);
}
Initial Catapult C Implementation
// initialize variables
max = 0;
cur_lag = 0;
static CComplex< real_sample > cSinCosRom[64] = {
#include "SinCos_256.tab"
};
// create fft engines
FFT_type fft(cSinCosRom);
IFFT_type ifft(cSinCosRom);
// shift in new data
SHIFT:for(int z=(CA_CODE_SIZE-1);z>=0;z--)
{
data[z] = (z==0) ? CComplex<real_sample>(data_input.read()) : data[z-1] ;
}
FFT_type::MemoryType data_fft(data);
// convert code to complex array
LOAD:for(int z=0;z < CA_CODE_SIZE; z++)
{
code[z] = CComplex<real_sample>(cacode[z]);
}
FFT_type::MemoryType code_fft(code);
// perform in-place FFT of input
fft.Run(data_fft, 8);
// perform FFT of code
fft.Run(code_fft, 8);
// conjugate and multiply
CONJ:for(int ii=0; ii<CA_CODE_SIZE; ii++)
{
corr[ii] = CComplex<real_sample>(
data[ii].Re() * code[ii].Re() + data[ii].Im() * code[ii].Im(),
data[ii].Re() * code[ii].Im() - data[ii].Im() * code[ii].Re());
}
IFFT_type::MemoryType corr_time(corr);
// inverse FFT
//FFTSimple<SIZE_LOG, real_sample, real_sample, false>(corr);
//IFFT_type ifft(cSinCosRom);
ifft.Run(corr_time, 8); // check that this is a good number
// find max power and location of max power
MAX:for(int ii=0; ii<CA_CODE_SIZE; ii++)
{
if (corr[ii].Re() > max)
{
max = corr[ii].Re();
cur_lag = ii;
}
}
// load answers into results
if (max > MIN_POWER_THRESH)
{
*lag_out = cur_lag;
*lock_out = true;
}
else
{
*lag_out = 0;
*lock_out = false;
}
Optimization Focus and Plans
• Focus: Area
• Receivers need to be implemented in
parallel, so individual GPS trackers need to
be individually small
• Reduce the number of bits for the FFT algorithm
• Pre-calculate FFT of C/A code to remove
optimizations from the main function
• Ensure that only one FFT module is created
• Unrolling load and maximum-finding loops
Coding Issues
• Synthesis engine optimizes out internals of
design
• Very long synthesis times (~20 minutes)
• Doing bit level operations on bytes.
• Not able to make FFT/IFFT a block and take
advantage of hierarchical coding
• This feature isn't available in our version of
Catapult C
• Problems using FFT examples in CatapultC
Coding Issues
• In the end couldn't get actual results
• Need a better algorithm that avoids
complications of using the FFT
• A new algorithm is proposed in the next slides
XNOR Based Correlator
• An XNOR operation on the data and C/A code
along with an accumulator
• Assume data and C/A code are binary signals with
values of 1 and -1
• The XNOR truth table is similar to 'standard' binary
case
• Avoid use of FFT
• Much faster than FFT based method and smaller in
area
• Actually implemented on the data bits
XNOR Based Correlator (Algorithm)
•
•
•
•
•
START
Load C/A code into a bit vector
LOOP:
Shift in a data bit
For each bit in the C/A code and the data vector
calculator XNOR
• Then add result to an accumulator
• Back to LOOP
XNOR Based Correlator
XNOR Based Correlator (Code)
// returns true if code has been found, false otherwise
#pragma hls_design top
bool my_gps(bool data_sample, bool cacode[CODE_SIZE])
{
static correlator corr;
if(corr.init)
{
corr.load_code(cacode);
return false;
}
else
{
return corr.correlate(data_sample);
}
}
XNOR Based Correlator (Code)
// constructor
correlator()
{
// only initializes buffers as necessary
CLEAR_DATA:for(int i = 0; i<CODE_SIZE; i++)
{
data[i] = false;
}
init = true;
}
// initialization function - just copies in the code
void load_code(bool cacode[CODE_SIZE])
{
LOAD_CODE:for(int i = 0; i < CODE_SIZE; i++)
{
code[i] = cacode[i];
}
init = false;
}
//Main Function
bool correlate(bool data_sample)
{
// reset counter
counter = 0;
// load data into shift register
SHIFT:for(int z=(CODE_SIZE-1);z>=0;z--) {
data[z] = (z==0) ? data_sample : data[z-1];
}
// loop over registers and score
ACC:for(int z=0;z<CODE_SIZE;z++) {
counter += (!(code[z] ^ data[z])) ? 1 : -1;
}
// threshold the counter to set output
return counter > DETECT_THRESH;
}
Catapult C Resuts
Variation Name
Optimizations
DefaultParameters
Memory Config
RAM for internal and external
None
35880
35870
319
1.74
FullRegisters
Registers for internal, RAM for input
None
25640
25630
5025
0.32
FullRegistersAndDirectInput Registers for everything
None
25620
25630
5272
0.32
ACCPipelined
ACC Loop pipelined
20530
20520
5043
0.32
Failed:
LoadShiftUnrolled
EverythingUnrolled
MainLoopPipelined
Registers for internal, RAM for input
Latency Time Throughput Time Total Area Slack
New Optimization Focus and Plans
• Focus will remain on area
• Use adder tree or distributed arithmetic to cut
down on area even more
• More unrolling/pipelining of ACC and SHIFT
loops
• Reduce latency
• User doesn’t want to wait for a lock
• Parallel operation
• Use multiple correlators in parallel
References
1.
Global Positioning System Standard Positioning Service Signal Specification, 1995
http://www.navcen.uscg.gov/pubs/gps/sigspec/gpssps1.pdf
2.
Peter H. Dana, 1992 http://www.colorado.edu/geography/gcraft/notes/gps/gps.html
3.
Fast Acquisition, high sensitivity GPS receiver, Inventor: Norman F. Krasner, Assignee:
Snaptrack, No. 6289041, Issued: Sep 11, 2001
4.
Parallel correlator for global positioning system receiver, Inventors: Glen W. Brooksby,
Gerald J. Michon, Jerome J. Tiemann, Assignee: General Electric Company, No. 5579014,
Issued: Nov 26, 1996
5.
Method and apparatus for computing signal correlation, Inventor: Charles Abraham et al,
Assignee: Global Locate, Inc, No. 6606346, Issued: Aug 12, 2003
6.
Multiplexed digital correlator, Inventor: Lawrence M. Leibowitz, Assignee: The United States
of America as represented by the Secretary of the Navy, No. 4660164, Issued: Apr 21,
1987
7.
Fast algorithms for digital signal processing / Richard E. Blahut. Reading, Mass. : AddisonWesley Pub. Co., c1985.
8.
Global Positioning System Overview
http://www.colorado.edu/geography/gcraft/notes/gps/gif/bitsanim.gif
9.
Efficient Correlation over a sliding window, Inventor Paul W. Dent, Eric Wang, Assignee:
Ericsson Inc, No. 5931893, Issued: Aug. 3rd 1999
Download