Communications Blockset

Sequence Generator Examples

This section presents two example models that illustrate the blocks in the Sequence Generator library.

Example: Pseudorandom Sequences

This example describes the autocorrelation properties of the pseudorandom sequences generated by the following three blocks:

• PN Sequence Generator
• Gold Sequence Generator
• Kasami Sequence Generator

The model displays the output sequences of the three blocks in a scope. All three blocks have the same Generator polynomial parameter,
[1 0 0 0 0 1 1], whose digits are the coefficients of the polynomial x6 + x + 1. Since this polynomial has degree 6, the output sequence has period 26 - 1 = 63.

When you run the model, the scope displays two periods of data for each the three signals:

The model also sends the output sequences to the MATLAB workspace as the vectors pn, gold, and kas. You can verify the autocorrelation properties of the output of the PN Sequence Generator by entering the following code at the MATLAB prompt:

• x = pn(1:63); % Take one period only
x = 1 - 2.*x; % Convert to bipolar
for i = 1:63  % Determine the cyclic autocorrelation
corrvec(i) = x' * [x(i:end); x(1:i-1)];
end
corrvals = unique(sort(corrvec)) % Choose the unique values

The code calculates the cyclic autocorrelation of the PN sequence, by taking the inner product of one period of the sequence with each of its 63 cyclic rotations, and stores the results in a vector, corrvec, of length 63. The code then sorts the entries of corrvec and finds the unique autocorrelation values. The result is

• corrvals =
-1    63

The first entry of the vector corrvec is 63, while all other values are -1, as you can verify by entering corrvec at the MATLAB prompt. This means that 63 occurs only by taking the inner product of the sequence pn with an unrotated copy of itself. All other inner products have the value -1.

You can analyze the output sequences of the Gold Sequence Generator block and the Kasami Sequence Generator block similarly by changing the first line of the preceding code to

• x = gold(1:63);

and

• x = kas(1:63);

respectively.

For the Gold and Kasami sequences, the autocorrelation takes on three values. For example, the three values for the Gold sequence are

• corrvals =
-17    -1    15    63

The three values for the Kasami sequence are

• corrvals =
-9    -1     7    63

Of the three types of sequences, the PN sequences are best suited for synchronization because the autocorrelation takes on just two values. However, the Gold and Kasami sequences provide a larger number of sequences with good cross-correlation properties than do the PN sequences.

Also note that the peak value of corrvals for the Kasami sequence is less than the peak value for the Gold sequence. In fact, the small set of Kasami sequences satisfy the lower bounds for correlation values, and for this reason they are also referred to as optimal sequences.

Example: Orthogonal Sequences

This example demonstrates the orthogonality of pairs of sequences generated using different Code index parameters, for each of the following three blocks:

• Walsh Code Generator
• OVSF Code Generator

The model displays the output sequences of the three blocks in a scope. All three blocks output sequences of period 64, corresponding to their Code length parameters. When you run the model, the scope displays two periods of data for each sequence.

The following code runs the model twice, the first time with the Code index parameter of 60 for all three blocks, and the second time with a Code index of 30. The code then calculates, for each of the three blocks, the cross correlation between the sequence generated by the first run with the sequence generated by the second run

• % Simulate once
set_param('doc_ortho/Walsh Code Generator', 'index', '60');
set_param('doc_ortho/OVSF Code Generator', 'index', '60');
sim('doc_ortho');

% Store the codes
walsh60 = walsh(1:64);
ovsf60 = ovsf(1:64);

% Simulate twice
set_param('doc_ortho/Walsh Code Generator', 'index', '31');
set_param('doc_ortho/OVSF Code Generator', 'index', '31');
sim('doc_ortho');

% Store the codes
walsh31 = walsh(1:64);
ovsf31 = ovsf(1:64);

% Calculate the cross-correlation
walshcorr = walsh60(1:64)'*walsh31(1:64);
walshcorr
ovsfcorr = ovsf60(1:64)'*ovsf31(1:64);
ovsfcorr

The results are