Scramble the input bit sequence using a feedback shift register. The initial state of the shift register is given by the initialState parameter, which should be a non-negative integer. The taps of the feedback shift register are given by the polynomial parameter, which should be a positive integer. The n-th bit of this integer indicates whether the n-th tap of the delay line is fed back. The low-order bit is called the 0-th bit, and should always be set. The next low-order bit indicates whether the output of the first delay should be fed back, etc. The input port receives boolean tokens. "TRUE" is treated as 1 and "FALSE" is treated as 0. All the bits that are fed back are exclusive-ored together (i.e., their parity is computed), and the result is exclusive-ored with the input bit. The result is produced at the output and shifted into the delay line.
With a proper choice of polynomial, the resulting output appears highly random even if the input is highly non-random. If the polynomial is a primitive polynomial, then the feedback shift register is a so-called maximal length feedback shift register. This means that with a constant input (or no input, which is equivalent to a constant false input) the output will be a sequence with period 2N-1, where N is the order of the polynomial (the length of the shift register). This is the longest possible sequence. Moreover, within this period, the sequence will appear to be white, in that a computed autocorrelation will be very nearly an impulse. Thus, the scrambler with a constant input can be very effectively used to generate a pseudo-random bit sequence.
The maximal-length feedback shift register with constant input will pass through 2N-1 states before returning to a state it has been in before. This is one short of the 2N states that a register with N bits can take on. This one missing state, in fact, is a lock-up state, in that if the input is an appropriate constant, the scrambler will cease to produce random-looking output, and will output a constant. For example, if the input is all zeros, and the initial state of the scrambler is zero, then the outputs will be all zero, hardly random. This is easily avoided by initializing the scrambler to some non-zero state. The default value for the shiftReg is set to 1.
The polynomial must be carefully chosen. It must represent a primitive polynomial, which is one that cannot be factored into two (nontrivial) polynomials with binary coefficients. See Lee and Messerschmitt (Kluwer, 1994) for more details. For convenience, we give here a set of primitive polynomials (expressed as octal numbers so that they are easily translated into taps on shift register). All of these will result in maximal-length pseudo-random sequences if the input is constant and lock-up is avoided:
order polynomial
2 07
3 013
4 023
5 045
6 0103
7 0211
8 0435
9 01021
10 02011
11 04005
12 010123
13 020033
14 042103
15 0100003
16 0210013
17 0400011
18 01000201
19 02000047
20 04000011
21 010000005
22 020000003
23 040000041
24 0100000207
25 0200000011
26 0400000107
27 01000000047
28 02000000011
29 04000000005
30 010040000007
The leading zero in the polynomial indicates an octal number. Note also that reversing the order of the bits in any of these numbers will also result in a primitive polynomial. Thus, the default value for the polynomial parameter is 0440001 in octal, or "100 100 000 000 000 001" in binary. Reversing these bits we get "100 000 000 000 001 001" in binary, or 0400011 in octal. This latter number is the one listed above as the primitive polynomial of order 17. The order is simply the index of the highest-order non-zero in the polynomial, where the low-order bit has index zero.
Since the polynomial and the feedback shift register are both implemented using type "int", the order of the polynomial is limited by the size of the "int" data type. For simplicity and portability, the polynomial is not allowed to be interpreted as a negative integer, so the sign bit cannot be used. Thus, if "int" is a 32-bit word, then the highest order polynomial allowed is 30 (recall that indexing for the order starts at zero, and we cannot use the sign bit). Java has 32-bit integers, so we give the primitive polynomials above only up to order 30.
For more information on scrambler, see Lee and Messerschmitt, Digital Communication, Second Edition, Kluwer Academic Publishers, 1994, pp. 595-603.
Field Detail |
public VisualSim.data.expr.Parameter polynomial
public VisualSim.data.expr.Parameter initialState
Created with the Personal Edition of HelpNDoc: Create cross-platform Qt Help files