All pastes #942456 Raw Edit

lib_cell_search.h

public text v1 · immutable
·published 2008-03-14 15:11 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <iostream>

#include "ipp.h"
#include "correlation_CUDA.h"

#define UMTS_NORM_CUTOFF_FREQ	(2e6/(256*OSR)/9.75e6)  // ??? *** Check Normalized cut-off frequency, should be in the range (0,0.5).
#define UMTS_RESAMPLE_TAP_LEN	(64)
#define UMTS_UPSAMPLE_RATE		(256*OSR)
#define UMTS_DOWNSAMPLE_RATE	(325)
#define UMTS_UPSAMPLE_PHASE		(0)
#define UMTS_DOWNSAMPLE_PHASE	(0)


#define SAMPLING_RATE		(9750000)                // Number of baseband samples per second.
#define CHIP_RATE			(3840000)
#define OSR					(2.5390625) //325/128 	// Oversampling rate (= samples per chip) in the BB signal
#define N_BASEBAND_SAMP		(int)(16.1*2560*OSR)	// Number of bawseband re-sampled samples >= (15*2560*OSR + N_SAMP_CPICH_CORR)

#define N_SLOTS_PER_FRAME	(15)
#define FRAME_PERIOD_SEC	(0.01)					// Frame duration in seconds
#define SLOT_PERIOD_SEC		(FRAME_PERIOD_SEC/N_SLOTS_PER_FRAME)	// Slot duration in seconds
#define N_SAMP_PER_SLOT		(int)(SLOT_PERIOD_SEC*SAMPLING_RATE)			// Number of samples per slot
#define N_SAMP_PER_FRAME	(N_SAMP_PER_SLOT*N_SLOTS_PER_FRAME)

#define PSCHSize			(int)(256*OSR)				// PSCH length in samples
#define PSCHSpace			(int)(2560*OSR)				// Slot/PSCH spacing in samples

#define N_SAMP_PER_SCR_CODE			(int)(1024*OSR)	// (38400*OSR per frame) Number of resampled samples per scr code available in memory

#define N_SAMP_CPICH_CORR			(int)(1024*OSR)	//(2*2560*OSR) Total length of CPICH correlation in samples, which are broken into parts
#define N_PARTS_CPICH_CORR			(4)				// Number of parts for which CPICH correlation is non-coherently combined
#define N_SAMP_PER_PART_CPICH_CORR	(N_SAMP_CPICH_CORR/N_PARTS_CPICH_CORR)

#define N_CAND_POS_CPICH_CORR		(50)		// (200) Number of candidate positions selected from correlations of 512 p-scr. codes, where
#define N_CAND_PER_SCR_CODE			(10)		// (10)    multiple candidate-positions may correspond to a single P-scr-code

#define N_POS_CPICH_CORR_LONG		(10)		// Number of positions for long-CPICH-correlate in next cell search	(Fast mode)
												// <= N_CAND_POS_CPICH_CORR  [Done at known frame-boundaries]
#define N_SAMP_CPICH_CORR_LONG		(int)(4*2560*OSR)	// Total length of long-CPICH-correlation in samples (broken into parts) 
#define N_PARTS_CPICH_CORR_LONG		(8)			// Number of parts for which long CPICH-correlation is non-coherently combined
#define N_SAMP_PER_PART_CPICH_CORR_LONG	(N_SAMP_CPICH_CORR_LONG/N_PARTS_CPICH_CORR_LONG)

#define N_SAMP_MAX_CORR_SPREAD		(5)			// Number of samples correlation is spread on each side


//==========================================================================================
// Class - Cell Search Candidate
//==========================================================================================
class cellSearchCandidate {
  public:
	int scrCodeNum, idxFrameStarts, corrSpreadInSamples;   // corr spread = {0,1,2,3,4,5}
	__int64 timeFrameStarts;  // In micro frames (10^8 micro frames/sec)
	double cpichCorrRMS, sigRMS;  // cpichCorrRMS: CPICH amplitude, sigRMS: RMS of received baseband signal

    void set_values (int code_num, int idx_frStarts, __int64 time_frStarts);
};

void Alpha_cell_search(Ipp32fc *BBsig, int len_BBsig, __int64 time_snapShotStarts, double sampRate, Ipp32fc *CPICHsig,
					   int len_corrSegment, int num_corrSegments, cellSearchCandidate *scrCodeTbl, int num_elemScrCodeTbl);
void Beta(Ipp32fc *BBsig, int len_BBsig, __int64 time_snapShotStarts, double sampRate, Ipp32fc *CPICHsig,
					   int len_corrSegment, int num_corrSegments, cellSearchCandidate *scrCodeTbl, int num_candToScan);

// CUDA Stuff

#define CUDACORR 1
//#define IPPCORR 1
#ifdef CUDACORR 
#ifdef IPPCORR
#define CUDACORRCHECK 1
#endif
#endif

//#define CUDACORRCHECK 1
void CUDAtest();