A pseudo-number generator produces numbers that are random but deterministic. These are pseudorandom because the following numbers can be determined algorithmically if the seed value is known. The linear feedback shift register (LFSR) is one of the more widely used algorithms to implement this.
- A shift right function and an XOR or XNOR logic gate can be combined so as to implement an LFSR.
At each clock cycle, the bits in the shift register are shifted one position to the right. The value of the feedback bit is computed as the exclusive-or (XOR) of one or more of the bits in the register, as specified by the feedback taps. The bits in the LFSR state that influence the input are called taps. The feedback bit is then added to the leftmost position of the register, and the contents of the register form the next state of the LFSR.
- The XOR positions and taps are defined by the feedback/characteristic polynomial.
- The feedback polynomial is a mathematical equation that determines the next value in the sequence based on the current state of the LFSR. In simple terms, the feedback polynomial is like a set of rules that tell the LFSR how to generate its output sequence. The coefficients of the polynomial represent the taps (or positions) in the shift register that contribute to the next value in the sequence. For example, an 8-bit LFSR, the feedback polynomial isπ₯8+π₯6+π₯5+π₯4+1=0. Hence, outputs of flipflops 8,6,5,4 are summed via XNOR gates and fed back into the first flip-flop.
- The seed in a Pseudo Random Number Generator (PRNG) implemented using a Linear Feedback Shift Register (LFSR) is the initial state of the LFSR. The seed determines the starting point of the sequence generated by the PRNG, and as a result, affects the entire sequence of numbers produced. A carefully chosen seed can ensure that the sequence produced by the PRNG has desired properties, such as good randomness, long cycle length, or a specific pattern.
LFSR output streams are said to be deterministic. If the present state and the positions of the XOR gates in the LFSR are known, the next state can be predicted. This is not possible with truly random events. With maximal-length LFSRs, it is much easier to compute the next state, as there are only an easily limited number of them for each length.
In the implementation of the circuit in CircuitVerse, the seed or the initial state can be set by making the reset=1, then pre-setting the bits to the desired seed. The sequence of random number generated will change depending on the this initial state. The change in values of outputs from the DFFs can be observed after every clock cycle.