Main Content

# Kasami Sequence Generator

Generate Kasami sequence from set of Kasami sequences

## Library

Sequence Generators sublibrary of Comm Sources

• ## Description

The Kasami Sequence Generator block generates a sequence from the set of Kasami sequences. The Kasami sequences are a set of sequences that have good cross-correlation properties.

This block can output sequences that vary in length during simulation. For more information about variable-size signals, see Variable-Size Signal Basics (Simulink).

### Kasami Sequences

There are two sets of Kasami sequences: the small set and the large set. The large set contains all the sequences in the small set. Only the small set is optimal in the sense of matching Welch's lower bound for correlation functions.

Kasami sequences have period N = 2n - 1, where n is a nonnegative, even integer. Let u be a binary sequence of length N, and let w be the sequence obtained by decimating u by 2n/2 +1. The small set of Kasami sequences is defined by the following formulas, in which T denotes the left shift operator, m is the shift parameter for w, and $\oplus$ denotes addition modulo 2.

Small Set of Kasami Sequences for n Even

`${K}_{s}\left(u,n,m\right)=\left\{\begin{array}{ll}u\hfill & m=-1\hfill \\ u\oplus {T}^{m}w\hfill & m=0,...,{2}^{n/2}-2\hfill \end{array}$`

Note that the small set contains 2n/2 sequences.

For mod(n, 4) = 2, the large set of Kasami sequences is defined as follows. Let v be the sequence formed by decimating the sequence u by 2n/2 + 1+ 1. The large set is defined by the following table, in which k and m are the shift parameters for the sequences v and w, respectively.

Large Set of Kasami Sequences for mod(n, 4) = 2

The sequences described in the first three rows of the preceding figure correspond to the Gold sequences for mod(n, 4) = 2. See the reference page for the Gold Sequence Generator block for a description of Gold sequences. However, the Kasami sequences form a larger set than the Gold sequences.

The correlation functions for the sequences takes on the values

{-t(n), -s(n), -1, s(n) -2 , t(n) - 2}

where

### Block Parameters

The Generator polynomial parameter specifies the generator polynomial, which determines the connections in the shift register that generates the sequence u. You can specify the Generator polynomial parameter using these formats:

• A polynomial character vector that includes the number `1`, for example, ```'z^4 + z + 1'```.

• A vector that lists the coefficients of the polynomial in descending order of powers. The first and last entries must be 1. Note that the length of this vector is one more than the degree of the generator polynomial.

• A vector containing the exponents of z for the nonzero terms of the polynomial in descending order of powers. The last entry must be `0`.

For example, `'z^8 + z^2 + 1'`, ```[1 0 0 0 0 0 1 0 1]```, and `[8 2 0]` represent the same polynomial, p(z) = z8+z2+1.

The Initial states parameter specifies the initial states of the shift register that generates the sequence u. Initial States is a binary scalar or row vector of length equal to the degree of the Generator polynomial. If you choose a binary scalar, the block expands the scalar to a row vector of length equal to the degree of the Generator polynomial, all of whose entries equal the scalar.

The Sequence index parameter specifies the shifts of the sequences v and w used to generate the output sequence. You can specify the parameter in either of two ways:

• To generate sequences from the small set, for n is even, you can specify the Sequence index as an integer m. The range of m is [-1, ..., 2n/2 - 2]. The following table describes the output sequences corresponding to Sequence index `m`:

Sequence IndexRange of IndicesOutput Sequence
`-1` m = -1 u
`m` m = 0, ... , 2n/2 - 2

$u\oplus {T}^{m}w$

• To generate sequences from the large set, for mod (n, 4) = 2, where n is the degree of the Generator polynomial, you can specify Sequence index as an integer vector [k m]. In this case, the output sequence is from the large set. The range for k is [-2, ..., 2n - 2], and the range for m is [-1, ..., 2n/2 - 2]. The following table describes the output sequences corresponding to Sequence index [k m]:

Sequence Index [k m]Range of IndicesOutput Sequence
`[-2 -1]` k = -2, m = -1 u
`[-1 -1]` k = -1, m = -1 v
`[k -1]`

k = 0, 1, ... , 2n - 2

m = -1

$u\oplus {T}^{k}v$

`[-2 m]`

k = -2

m = 0, 1, ..., 2n/2 - 2

$u\oplus {T}^{m}w$

`[-1 m]`

k = -1

m = 0, ... , 2n/2 - 2

$v\oplus {T}^{m}w$

`[k m]`

k = 0, ... , 2n - 2

m = 0, ... , 2n/2 - 2

$u\oplus {T}^{k}v\oplus {T}^{m}w$

You can shift the starting point of the Kasami sequence with the Shift parameter, which is an integer representing the length of the shift.

You can use an external signal to reset the values of the internal shift register to the initial state by selecting Reset on nonzero input. This creates an input port for the external signal in the Kasami Sequence Generator block. The way the block resets the internal shift register depends on whether its output signal and the reset signal are sample-based or frame-based. See Reset Behavior for an example.

### Polynomials for Generating Kasami Sequences

The following table lists some of the polynomials that you can use to generate the Kasami set of sequences.

nNPolynomialSet
4 15 [4 1 0] Small
6 63 [6 1 0] Large
8 255 [8 4 3 2 0] Small
10 1023 [10 3 0] Large
12 4095 [12 6 4 1 0] Small

## Parameters

Generator polynomial

Character vector or binary vector specifying the generator polynomial for the sequence u.

Initial states

Binary scalar or row vector of length equal to the degree of the Generator polynomial, which specifies the initial states of the shift register that generates the sequence u.

Sequence index

Integer or vector specifying the shifts of the sequences v and w used to generate the output sequence.

Shift

Integer scalar that determines the offset of the Kasami sequence from the initial time.

Output variable-size signals

Select this if you want the output sequences to vary in length during simulation. The default selection outputs fixed-length signals.

Maximum output size source

Specify how the block defines maximum output size for a signal.

• When you select `Dialog parameter`, the value you enter in the Maximum output size parameter specifies the maximum size of the output. When you make this selection, the `oSiz` input port specifies the current size of the output signal and the block output inherits sample time from the input signal. The input value must be less than or equal to the Maximum output size parameter.

• When you select ```Inherit from reference port```, the block output inherits sample time, maximum size, and current size from the variable-sized signal at the Ref input port.

This parameter only appears when you select Output variable-size signals. The default selection is ```Dialog parameter```.

Maximum output size

Specify a two-element row vector denoting the maximum output size for the block. The second element of the vector must be 1. For example, [10 1] gives a 10-by-1 maximum sized output signal. This parameter only appears when you select Output variable-size signals.

Sample time

Output sample time, specified as `-1` or a positive scalar that represents the time between each sample of the output signal. If Sample time is set to `-1`, the sample time is inherited from downstream. For information on the relationship between Sample time and Samples per frame, see Sample Timing.

Samples per frame

Samples per frame, specified as a positive integer indicating the number of samples per frame in one channel of the output data. For information on the relationship between Sample time and Samples per frame, see Sample Timing.

Reset on nonzero input

When selected, you can specify an input signal that resets the internal shift registers to the original values of the Initial states.

Output data type

The output type of the block can be specified as a `boolean` or `double`. By default, the block sets this to `double`.

## Example

### Kasami Spreading for Multiuser System in Multipath Channel

This model simulates Kasami sequence spreading for two users in a multipath transmission environment. This is similar to a mobile channel environment where the signals are received over multiple paths. Each path can have different amplitudes and delays. The receiver combines the independent paths coherently using diversity reception to realize gains from the multipath transmissions received. The modeled system does not simulate fading effects and the receiver gets perfect knowledge of the number of paths and their respective delays.

The model uses random binary data, which is BPSK modulated (real), spread by Kasami sequences, and then transmitted over a multipath AWGN channel. The receiver consists of a despreader, a diversity combiner, and a BPSK demodulator. Using the same transmission data, the model calculates the performance for two-user transmissions through identically configured multipath AWGN channels.

The computed BER indicates transmission data spread using Kasami sequences exhibit low cross-correlation. The Kasami sequences provide a balance between the ideal cross-correlation properties of orthogonal codes and the ideal auto-correlation properties of PN sequences.

To experiment further, open the model. Modify the settings to see how the performance varies for different path delays or with different Kasami sequence generator settings for the individual users.

## Reference

 Peterson and Weldon, Error Correcting Codes, 2nd Ed., MIT Press, Cambridge, MA, 1972.

 Proakis, John G., Digital Communications, Third edition, New York, McGraw Hill, 1995.

 Sarwate, D. V. and Pursley, M.B., "Crosscorrelation Properties of Pseudorandom and Related Sequences," Proc. IEEE, Vol. 68, No. 5, May 1980, pp. 583-619.

expand all

## Compatibility Considerations

expand all

Behavior changed in R2020a

## Extended Capabilities

### C/C++ Code GenerationGenerate C and C++ code using Simulink® Coder™.

Introduced before R2006a

## Support

#### Bridging Wireless Communications Design and Testing with MATLAB

Download white paper