Generate a pseudo-noise (PN) sequence
The PNSequence object generates a sequence of pseudorandom binary numbers using a linear-feedback shift register (LFSR). This block implements LFSR using a simple shift register generator (SSRG, or Fibonacci) configuration. You can use a pseudonoise sequence in a pseudorandom scrambler and descrambler. You can also use one in a direct-sequence spread-spectrum system.
To generate a PN sequence:
H = comm.PNSequence creates a pseudo-noise (PN) sequence generator System object™, H. This object generates a sequence of pseudorandom binary numbers using a linear-feedback shift register (LFSR).
H = comm.PNSequence(Name,Value) creates a PN sequence generator object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).
Specify the polynomial that determines the shift register's feedback connections. The default is [1 0 0 0 0 1 1]. You can specify the generator polynomial as a numeric, binary vector that lists the coefficients of the polynomial in descending order of powers. The first and last elements must equal 1, and the length of this vector must be n+1. The value n indicates the degree of the generator polynomial. Alternatively, you can specify the generator polynomial as a numeric 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, [1 0 0 0 0 0 1 0 1] and [8 2 0] represent the same polynomial, . The PN sequence has a period of (applies only to maximal length sequences).
Source of initial conditions
Specify the source of the initial conditions that determines the start of the PN sequence as one of Property | Input port. The default is Property. When you set this property to Property, the initial conditions can be specified as a scalar or binary vector using the InitialConditions property. When you set this property to Input port, you specify the initial conditions as an input to the step method. The object accepts a binary scalar or a binary vector input. The length of the input must equal the degree of the generator polynomial that the Polynomial property specifies.
Initial conditions of shift register
Specify the initial values of the shift register as a binary, numeric scalar or a binary, numeric vector. The default is [0 0 0 0 0 1]. Set the vector length equal to the degree of the generator polynomial. If you set this property to a vector, each element of the vector corresponds to the initial value of the corresponding cell in the shift register. If you set this property to a scalar, the initial conditions of all the cells of the shift register are the specified scalar value. The scalar, or at least one element of the specified vector, must be nonzero for the object to generate a nonzero sequence.
Source of mask to shift PN sequence
Specify the source of the mask that determines the shift of the PN sequence as one of Property | Input port. The default is Property. When you set this property to Property, the mask can be specified as a scalar or binary vector using the Mask property. When you set this property to Input port, the mask, which is an input to the step method, can only be specified as a binary vector. This vector must have a length equal to the degree of the generator polynomial specified in the Polynomial property.
Mask to shift PN sequence
Specify the mask that determines how the PN sequence is shifted from its starting point as a numeric, integer scalar or as a binary vector. The default is 0.
When you set this property to an integer scalar, the value is the length of the shift. A scalar shift can be positive or negative. When the PN sequence has a period of , where n is the degree of the generator polynomial that you specify in the Polynomial property, the object wraps shift values that are negative or greater than N.
When you set this property to a binary vector, its length must equal the degree of the generator polynomial specified in the Polynomial property. The mask vector that represents modulo g(z), where g(z) is the generator polynomial, and the mask vector corresponds to a shift of D. For example, for a generator polynomial of degree of 4, the mask vector corresponding to D = 2 is [0 1 0 0], which represents the polynomial .
Enable variable-size outputs
Set this property to true to enable an additional input to the step method. The default is false. When you set this property to true, the enabled input specifies the output size of the PN sequence used for the step. The input value must be less than or equal to the value of the MaximumOutputSize property.
When you set this property to false, the SamplesPerFrame property specifies the number of output samples.
Maximum output size
Specify the maximum output size of the PN sequence as a positive integer 2-element row vector. The second element of the vector must be 1. The default is [10 1].
This property applies when you set the VariableSizeOutput property to true.
Number of outputs per frame
Specify the number of PN sequence samples that the step method outputs as a numeric, positive, integer scalar value. The default is 1. If you set this property to a value of M, then the step method outputs M samples of a PN sequence that has a period of . The value n represents the degree of the generator polynomial that you specify in the Polynomial property. If you set the BitPackedOutput property to false, the samples are bits from the PN sequence. If you set the BitPackedOutput property to true, then the output corresponds to SamplesPerFrame groups of bit-packed samples.
Enable generator reset input
Set this property to true to enable an additional input to the step method. The default is false. This input resets the states of the PN sequence generator to the initial conditions specified in the InitialConditions property.
Output integer representations of bit-packed words
Set this property to true to enable bit-packed outputs. The default is false. In this case, the step method outputs a column vector of length M, which contains integer representations of bit words of length P. M is the number of samples per frame specified in the SamplesPerFrame property. P is the size of the bit-packed words specified in the NumPackedBits property. The first bit from the left in the bit-packed word is considered the most significant bit.
Number of bits per bit-packed word
Specify the number of bits to pack into each output data word as a numeric, integer scalar value between 1 and 32. The default is 8. This property applies when you set the BitPackedOutput property to true.
Output signed bit-packed words
Set this property to true to obtain signed, bit-packed, output words. The default is false. In this case, a 1 in the most significant bit (sign bit) indicates a negative value. The property indicates negative numbers in a two's complement format. This property applies when you set the BitPackedOutput property to true.
Data type of output
Specify the output data type as one of double | logical | Smallest unsigned integer when the BitPackedOutput property is false. The default is double. Specify the output data type as double | Smallest unsigned integer when the BitPackedOutput property is set to true.
You must have a Fixed-Point Designer™ user license to use this property in Smallest unsigned integer mode.
|clone||Create PN sequence generator object with same property values|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs from step method|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|reset||Reset states of PN sequence generator object|
|step||Generate a pseudo-noise (PN) sequence|
Get 2 frames of 14 samples of a maximal length PN-sequence of period 23–1 (i.e., get two periods of the sequence).
hpn = comm.PNSequence('Polynomial',[3 2 0], ... 'SamplesPerFrame', 14, 'InitialConditions',[0 0 1]); x1 = step(hpn); x2 = step(hpn); [x1 x2]
This object implements the algorithm, inputs, and outputs described on the PN Sequence Generator block reference page. The object properties correspond to the block parameters, except:
The object does not have a property to select frame based outputs.
The object does not have a property that corresponds to the Sample time parameter.