index

# GNU Radio's CDMA Package

# Introduction

This CDMA module is intended to build a parameterized CDMA physical layer. Users can set spreading, modulation, framing parameters, etc in a global parameter file "python/cdma_paramters.py". The basic structure of this CDMA system is as follows:

Transmission is done in frames of length "symbols_per_frame". Each frame consists of two superimposed orthogonal physical channels: the training channel and the data channel. The training channel consists of a training sequence "training" of length "symbols_per_frame" that is spread using the same spreading code of "chips_per_symbol" chips for each symbol. For simplicity the training sequence is modulated using antipodal modulation (but this can be readily changed by the user). The data channel consists of "symbols_per_frame" data symbols that is spread using a spreading code of "chips_per_symbol" chips for each symbol which is orthogonal to the training code. The data symbols are composed of "symbols_per_header" header symbols and "coded_payload_symbols_per_frame" coded payload symbols modulated with (possibly different) modulation schemes. Further, the coded payload symbols are produced by CRC encoding "coded_payload_bytes_per_frame" with a user defined CRC code. The user can set the percentage of power used for training and data ("training_percent").

At the receiver, the core part is a timing/frequency acquisition engine which consists of a user-defined "n_filt" number of xlating matched-filters matched to training sequence at different frequencies (similarly user defined in the vector "freqs"). The output of the acquisition block is a stream of flags indicating the estimated begining of the frame and a stream of frequencies indicating the estimated frequency offset. The received samples are then frequency corrected, and "chopped" according to the generated flags. The samples are then input to two matched-filters, each matched to the training spreading pulse, and the data spreading pulse respectively, thus resulting in the despread training and data sequences. The training symbols are used to perform phase estimation using a symbol-spaced PLL. The phase estimates are used to derotate the data symbols which are then demodulated, using two constellation decoders corresponding to header and payload modulations, respectively. Finally, the header symbols are parsed and the data symbols are CRC decoded.

In addition, the despread, phase-corrected training samples are input to an SNR estimator (amp_var_est_hier) which estimates the signal amplitude and noise variance by method of moments. The estimated training energy and noise variance are dynamically detected by two probes to form an SNR estimate. This SNR estimate is used in the receiver to automatically switch between acquisition mode and training mode.

This CDMA Module contains three C++ blocks and three python blocks. The documentations of C++ blocks are shown in subsequent class documentation, and the documentations of python blocks are written in python files.

# GRC Hierarchical Blocks

The documentations of some hierarchical blocks are as follows.

## chopper_correlator

The chopper_correlator is used in the CDMA receiver where two orthogonal training and data channels are superimposed.

The chopper part aligns the input samples with the flags and extracts the samples relevant to a single frame. It has two matched-filters matched to the training pulse and data pulse respectively. So it has two correlation outputs: decimated_training and decimated_data. The phase offset is extracted from the decimated training output by multiplying by the known training sequence, and driving a PLL. This phase offest is used to correct the output of training and data. The corrected training is multiplied by the training sequence to get the unmodulated training output.

The flow graph of chopper_correlator is shown in Fig 1.

The chopper_correlator has two inputs:

- in: a received data stream after frequency offset correction.

- flag: a flag stream indicating the begining of a frame.

The chopper_correlator has two outputs:

- unmodulated_out_training: a stream of the unmodulated output which is the product of the corrected output and the known training sequence.

- corrected_data_out: a stream of the corrected data output which is the product of the estimated phase offset and the decimated correlation data output.

The chopper_correlator has five parameters:

- N: the length of the input data frame.

- ts: the training sequence given at the transmitter

- Q: the decimating factor. In DSSS system, it's the spreading factor.

- pulse: the pulse for the training stream.

- pulse_data: the pulse for the data stream.

Fig 1. Core elements of the chopper_correlator

## amp_var_est_hier

The amp_var_est_hier is performing amplitude and noise variance estimation of a constant sequence by means of moments shown in Fig 2.

Assume the input to be: $ y=\sqrt E_s \exp(j \phi) +n = (\sqrt E_s \cos(\phi)+n_1)+j(\sqrt E_s \sin(\phi)+n_2) $ with components $n_1$ and $n_2$ having zero mean and variance $\sigma^2$.

By taking the squared mean of the real part, we get $ A=E^2(\sqrt E_s \cos(\phi)+n_1)= E_s \cos^2(\phi) $, which is the squared amplitude estimate that this block produces.

The mean squared value of the same quantity is $ B = E[ ( \sqrt E_s \cos(\phi)+n_1)^2] = E_s \cos^2(\phi)+\sigma^2 $, and the noise variance estimate is formed as $ B^2-A = \sigma^2 $.

Note that the although the input to this block is the PLL output, ie, a phase corrected signal, any uncorrected phase rotation will affect the estimated SNR and will thus trigger re-aqcquisition.

The block has one input:

- in: input noisy data stream. In the CDMA system, it's the output of the unmodulated and phase-corrected training output.

The chopper_correlator has two inputs:

- amp2: estimated signal energy.

- noise_var: estimated noise variance.

Fig 2. Core elements of amp_var_est_hier

## cdma_tx_hier

This is the cdma transmitter hier block.

It has one input and one output. In the CDMA system, the input is payload bytes (0 to 255 per byte) and then is CRC coded. Then headers bits are generated from the coded payload streams and then BPSK modulated. The coded payload bytes are repacked to symbols representing m bits and then the symbols are modulated using a $2^m$-ary modulation. Then the modulated header and payload streams are muxed. The muxed payload stream is spread by "pulse_data" and scaled appropriately. On the other hand, the training symbols are spread by "pulse_training" (orthogonal to "pulse_data") and scaled accordingly. Then the two channels are superimposed to form a frame to be transmitted.

The flow graph of cdma_tx_hier is shown in Fig 3.

Fig 3. Core elements of cdma_tx_hier

## cdma_rx_hier

This is the cdma receiver hier block. How the receiver works is roughly described in the Introduction part. Some details are discussed in the following.

First, let's look at the complexity reduction of Tracking mode. From the complexity discussion in /python/kronecker_filter.py we know, the complexity of the freq_timing_estimator is roughly n_filt*(len(sequence2)+len(sequence1)). In Acquisition mode, sequence1 is the training sequence and the sequence2 is the training spreading pulse while in Training mode, sequence1 and sequence2 are all set to zero. Therefore it results in considerable complexity reduction in Tracking mode. The mode selection is controled by the acq parameter. When acq=1, Aquisition mode is selected and vice versa.

The cdma_rx_hier has five outputs:

- N0_est: estimated noisei power spectral density level $ N_0 $.

- Es_est: estimated symbol energy.

- decoded_payload: the decoded payload which represents $m$ bits per byte.

- decoded_header: the decoded header message.

- acq_frequency: the acquisition frequency (for display purposes)

# Applications

There are several applications available in this module.

## cdma_txrx

The cdma_txrx is a fully working CDMA system.

The source payload is a repeated random vector. The cdma_tx_hier block produces the CDMA frames. A Channel Model is used to simulate the AWGN channel with frequency offset and time delays. At the receiver, the cdma_rx_hier takes the received samples as input. There is a slider for dynamic change of acquisition threshold. Two choosers are used to control the mode. One is Manual/Auto chooser and the other is the Tracking/Aquisition chooser when Mannual is selected at the first chooser. Three probes are used to dynamically observe the outputs of the cdma_rx_hier. One probe obeserves the estimated symbol energy (Es_est), and another probe observes the estimated spectrum noise density (N0_est). Then the EsN0_est is computed dynamically from these two observations. Aqusition frequency is observed by the last probe and displayed. Finally there is a slider for selecting the minimum data EsN0 threshold that will trigger acquisition mode.

Observe that in this pure grc application, when the system enters tracking mode, essentially two things happen: First, the taps of all n_filt filters in the freq_timing_estimator block are set to (0,). This implies that this block does not produce any meaningful outputs, which is fine since we are in tracking mode. Alternatively, we could lock the graph, disconnect all these blocks and reconnect them back in acquisition mode. However, due to the yet unresolved bug in lock/unlock (see Bug #598) this method seemed like a good compromise (it is possible that calling all these blocks (even with 0 taps) results in significant performance loss). Second, the block flag_gen automatically generates flags at the correct period and at the offset set by the last flag generated at acquisition mode. This is not exactlt "tracking", but essentially maintaining the most recent acquisition parameters. This can be a nice "to do" item.

## cdma_tx and cdma_rx

This splits the previous application into cdma_tx and cdma_rx for operation as separate Tx and Rx (possibly using two different hosts and USRPs).

## freq_timing_acq_test

The application frequency/timing aquisition test is a simple system to test the frequency/timing aquisition. The structure of the system is similar to the cdma_tx_hier and cdma_rx_hier. But only training sequence is transmitted in the system.