Communications Blockset | ![]() ![]() |
Generate a pseudonoise sequence
Library
Sequence Generators sublibrary of Comm Sources
Description
The PN Sequence Generator block generates a sequence of pseudorandom binary numbers. A pseudonoise sequence can be used in a pseudorandom scrambler and descrambler. It can also be used in a direct-sequence spread-spectrum system.
The PN Sequence Generator block uses a shift register to generate sequences, as shown below.
All r registers in the generator update their values at each time step according to the value of the incoming arrow to the shift register. The adders perform addition modulo 2. The shift register is described by the Generator Polynomial parameter, which is a primitive binary polynomial in z,
. The coefficient
is 1 if there is a connection from the kth register, as labeled in the preceding diagram, to the adder. The leading term
and the constant term
of the Generator Polynomial parameter must be 1.
You can specify the Generator polynomial parameter using either of these formats:
0
.
For example, [1 0 0 0 0 0 1 0 1]
and [8 2 0]
represent the same polynomial, .
The Initial states parameter is a vector specifying the initial values of the registers. The Initial states parameter must satisfy these criteria:
For example, the following table indicates two sets of parameter values that correspond to a generator polynomial of .
Quantity |
Example 1 |
Example 2 |
Generator polynomial |
g1 = [1 0 0 0 0 0 1 0 1] |
g2 = [8 2 0] |
Degree of generator polynomial |
8, which is length(g1)-1 |
8 |
Initial states |
[1 0 0 0 0 0 1 0] |
[1 0 0 0 0 0 1 0] |
The Shift parameter shifts the starting point of the output sequence. With the default setting for this parameter, the only connection is along the arrow labeled m0, which corresponds to a shift of 0. The parameter is described in greater detail below.
You can shift the starting point of the PN sequence with the Shift parameter. You can specify the parameter in either of two ways:
The difference between the block's output when you set Shift (or mask) to 0, versus a positive integer d, is shown in the following table.
T = 0 |
T = 1 |
T = 2 |
![]() |
T = d |
T = d+1 |
|
Shift = 0 |
x0 |
x1 |
x2 |
![]() |
xd |
xd+1 |
Shift = d |
xd |
xd+1 |
xd+2 |
![]() |
x2d |
x2d+1 |
Alternatively, you can set the Shift parameter to a binary vector, corresponding to a polynomial in z,
, of degree at most r - 1. The mask vector corresponding to a shift of d is the vector that represents
modulo g(z), where g(z) is the generator polynomial. For example, if the degree of the generator polynomial is 4, then the mask vector corresponding to d = 2 is
[0 1 0 0]
, which represents the polynomial . The preceding schematic diagram shows how the Shift (or mask) parameter is implemented when you specify it as a mask vector. The default setting for the Shift (or mask) parameter is
[0 0 0 1]
, which corresponds to d = 0. You can calculate the mask vector using the Communications Toolbox function shift2mask
.
You can use an external signal to reset the values of the internal shift register to the initial state by selecting the Reset on nonzero input check box. This creates an input port for the external signal in the PN 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. The following example demonstrates the possible alternatives.
Example: Resetting a Signal
Suppose that the PN Sequence Generator block outputs [1 0 0 1 1 0 1 1]
when there is no reset. You then select the Reset on nonzero input check box and input a reset signal [0 0 0 1]. The following table shows three possibilities for the properties of the reset signal and the PN Sequence Generator block.
In the first two cases, the PN sequence is reset at the fourth bit, because the fourth bit of the reset signal is a 1 and the Sample time is 1. Note that in the second case, the frame sizes are 2, and the reset occurs at the end of the second frame.
In the third case, the PN sequence is reset at the seventh bit. This is because the reset signal has Sample time 2, so the reset bit is first sampled at the seventh bit. With these settings, the reset always occurs at the beginning of a frame.
Attributes of Output Signal
If the Frame-based outputs box is selected, the output signal is a frame-based column vector whose length is the Samples per frame parameter. Otherwise, the output signal is a one-dimensional scalar.
Sequences of Maximum Length
If you want to generate a sequence of the maximum possible length for a fixed degree, r, of the generator polynomial, you can set Generator polynomial to a value from the following table. See [1] for more information about the shift-register configurations that these polynomials represent.
Dialog Box
See Also
Kasami Sequence Generator, Scrambler
References
[1] Proakis, John G., Digital Communications, Third edition, New York, McGraw Hill, 1995.
[2] Lee, J. S., and L. E. Miller, CDMA Systems Engineering Handbook, Artech House, 1998.
[3] Golomb, S.W., Shift Register Sequences, Aegean Park Press, 1967.
![]() | PM Modulator Passband | Poisson Integer Generator | ![]() |