PN Sequence Generator
A pseudo-noise sequence generator.
blockType: PNSequenceGenerator
Path in the library:
|
Description
Block PN Sequence Generator generates a sequence of pseudorandom binary numbers using a linear feedback shift register (LFSR). Pseudorandom sequences are commonly used for pseudorandom scrambling and in systems with a spectrum extended by the direct sequence method. For more information, see Additional Info.
Ports
Output
#
Out
—
a sequence of pseudorandom noise
binary vector
Details
The sequence PN returned as a binary vector. The output data type is determined by the parameter Output data type.
| Data types |
|
| Complex numbers support |
No |
Input
#
Rst
—
the sequence of reset signals
0 | 1
Details
A sequence of reset signals, the values can be 0 or 1. For more information, see Behavior reset.
Dependencies
To use this option, select the option checkbox. Reset on nonzero input.
| Data types |
|
| Complex numbers support |
No |
#
Mask
—
output mask
binary vector
Details
The output mask for the delay of the PN sequence from the initial time, specified as a binary vector with elements . – the degree of the generating polynomial.
Dependencies
To use this parameter, set for the parameter Output mask source meaning Input port.
| Data types |
|
| Complex numbers support |
No |
Parameters
Main
#
Generator polynomial —
generating polynomial
String
Details
The generating polynomial that defines the feedback of the shift register. Set as:
-
A symbolic vector or a string scalar of a polynomial whose constant member is
1. -
A binary vector is a string of length , representing the coefficients of the polynomial in descending order of degree. The length of this vector should be equal to , where – the degree of the polynomial. The first and last values must be equal
1, which indicates a leading term with degree and a permanent member, equal to1. -
An integer vector is a string specifying exponentials for nonzero terms of a polynomial in descending order of strength. The last element must be equal to
0, which means a permanent term equal to1.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
# Initial states — initial states of the shift register
Details
The initial states of the shift register of the PN sequence generator at the start of the simulation, specified as a binary vector string. The length of the vector must be equal to the degree of the generating polynomial specified by the parameter Generator polynomial. For more information, see Simple shift register generator and The order of the polynomial and the orientation of the shift register.
| In order for the block to generate a nonzero sequence, the parameter vector Initial states must contain at least one non-zero element. |
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
#
Output mask source —
The source of the output mask
Dialog parameter | Input port
Details
The source of the output mask, indicating how information about the output mask is transmitted to the block. Set as:
-
Dialog parameter– to use the parameter Output mask vector (or scalar shift value). -
Input port– to add and use the Mask input port.
| Values |
|
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
# Output mask vector (or scalar shift value) — output mask vector or scalar shift value
Details
The output mask vector or scalar shift value, specified as an integer scalar or a binary string vector. , where – the degree of the generating polynomial. This parameter determines the delay of the PN sequence from the initial time. For more information, seeOffset of the starting point of the PN sequence.
Dependencies
To use this parameter, set for the parameter Output mask source meaning Dialog parameter.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
#
Sample time —
sampling period
Real number
Details
The sampling period of the signal, specified as a positive scalar.
-
If the value is set to
-1, the output signal inherits the sampling time from the lower one. Information about the relationship between the parameters Sample time and Samples per frame see the section Sampling period.
| Example |
|
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
#
Samples per frame —
number of counts per frame
Real number
Details
The number of samples per frame in one output channel, set as a positive integer. To get information about the relationship between the parameters Sample time and Samples per frame see the section Sampling period.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
#
Reset on nonzero input —
reset with non-zero input
Logical
Details
Check this box to add the Rst input port. For more information, see the section Behavior reset.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
#
Output data type —
type of output data
Float64 | Bool
Details
The type of output data specified as Float64 or Bool.
| Values |
|
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
Additional Info
Simple shift register generator
To generate PN sequences, a linear feedback shift register (LFSR) is used, implemented as a simple shift register generator (SSRG). This type of shift register is also known as the Fibonacci implementation.
The polynomial defines the feedback of the shift register. This is a primitive binary polynomial. . For the coefficient , where – from 0 before , coefficient equal to 1 if there is a connection from -th register to the adder. The leading member, , and a permanent member, , the generating polynomial must be equal to 1 because the polynomial must be primitive. At each time step, all registers are the generator updates its values according to the value of the incoming arrow in the shift register. Adders perform addition modulo 2. The LFSR output reflects the sum of all connections in the mask vector .
-
is set by the parameter Generator polynomial.
-
Initial value is set by the parameter Initial states.
-
defines the offset of the starting point of the PN sequence and is set by the parameter Output mask vector (or scalar shift value)] or the Mask port.
This table shows two sets of parameter values that correspond to the generating polynomial. .
| Quantity | Example 1 | Example 2 |
|---|---|---|
|
|
|
Degree of the generating polynomial, |
|
|
Initial states |
|
|
The order of the polynomial and the orientation of the shift register
The implementation orients the shift registers from left to right, while the generating polynomial ( ), the initial states and the mask output are determined in descending order. In particular, .
When trying to model and compare the results from the literature, you should understand whether your source uses the same convention or a mirror image of that convention and whether they are defined in ascending order.
Offset of the starting point of the PN sequence
To shift the starting point of the PN sequence, specify the parameter Output mask vector (or scalar shift value) how:
-
An integer representing the length of the shift.
Default value
0the parameter Output mask vector (or scalar shift value), corresponds to the absence of a shift. As shown in the diagram of the LFSR shift register in Simple shift register generator, there is no shift when the only connection occurs along the arrow indicated by .This table shows the shift that occurs when set for the parameter Output mask vector (or scalar shift value) meaning
0compared to a positive integer .
T = 0 |
T = 1 |
T = 2 |
… |
T = |
T = |
|
Shift = |
|
|
|
… |
|
|
Shift = |
|
|
|
… |
|
|
-
A binary vector whose length is equal to the degree of the generating polynomial. In the diagram of the LFSR shift register in A simple shift register generator is shown Output mask vector (or scalar shift value), set as a vector mask, . The binary vector must contain elements where – the degree of the generating polynomial.
A binary vector corresponds to a polynomial , degrees not higher than . The mask vector corresponding to the shift by , is a vector that represents modulo , where the generating polynomial.
For example, if the degree of the generating polynomial is 4, then the mask vector corresponding to , this is [0 1 0 0], which represents the polynomial .
Reset behavior
Before resetting the generator sequence, you need to check the option box. Reset on nonzero input to enable the Rst input port. Assume that the block PN Sequence Generator outputs [1 0 0 1 1 0 1 1] when there is no reset. This table shows the effect on the block output. PN Sequence Generator the specified parameter values.
| Resetting the signal | Signal Reset Parameters | Block PN Sequence Generator | Signal reset and output signal |
|---|---|---|---|
There is no reset |
|
|
|
Scalar reset signal |
|
|
|
Vector reset signal |
|
|
If there is no reset, the block outputs the sequence without resetting. For the cases of scalar and vector reset signals, the unit provides a reset signal. [0 0 0 1 0 0 0 0] to the Rst port. Since the fourth bit of the reset signal is 1, and Sample time – This is 1, the block resets the sequence output in the fourth bit.
Sequences of maximum length
To generate a sequence of maximum length for a generating polynomial having degree , set for the parameter Generator polynomial the value is from the following table. The maximum length of the sequence is .
| r | Generator Polynomial | r | Generator Polynomial | r | Generator Polynomial | r | Generator Polynomial |
|---|---|---|---|---|---|---|---|
2 |
|
15 |
|
28 |
|
41 |
|
3 |
|
16 |
|
29 |
|
42 |
|
4 |
|
17 |
|
30 |
|
43 |
|
5 |
|
18 |
|
31 |
|
44 |
|
6 |
|
19 |
|
32 |
|
45 |
|
7 |
|
20 |
|
33 |
|
46 |
|
8 |
|
21 |
|
34 |
|
47 |
|
9 |
|
22 |
|
35 |
|
48 |
|
10 |
|
23 |
|
36 |
|
49 |
|
11 |
|
24 |
|
37 |
|
50 |
|
12 |
|
25 |
|
38 |
|
51 |
|
13 |
|
26 |
|
39 |
|
52 |
|
14 |
|
27 |
|
40 |
|
53 |
|
For more information about the configurations of the shift registers that these polynomials represent, see [1].
Sampling period
The time between output updates is equal to the product of the parameter values Samples per frame and Sample time. For example, if Sample time and Samples per frame equal 1, the block outputs one count every second. If you increase the value Samples per frame before 10, then the block will output a vector 10×1 every 10 seconds. This synchronization ensures that the equivalent output speed is independent of the parameter. Samples per frame.