Page 1 of 14 LFSR: Linear Feedback Shift-Register§0
§0
§0It is formed from a long chain of components (flip-flops IRL, Repeaters IG) that hold a state for a clock cycle, and a XOR gate that taps into specific elements (Repeaters) to randomize output.
Page 2 of 14 (In the implementation I use of the LSFR, the XOR gate provides 3 ticks of delay, which is why a repeater is necessary after it, so that total delay = 4 ticks which keeps the clock rates stable as the XOR gate also acts as an element)
Page 3 of 14 Once started, this device begins counting until it reaches the initial value it started at (0111...11 in all the LFSRs I have made) then it restarts. In order to more fully understand it we must examine a simple example of the LFSR, one that takes 6
Page 4 of 14 seconds only to reset to its initial position after going through 15 different unique values with a clock period of 4 ticks (0.4s), therefore 15 values x 0.4s = 6 seconds.§0
§0
§0We're talking here about a 4-bit LFSR (4 elements only) You can get the total no.
Page 5 of 14 of values it goes through via this equation: [(2^n)-1] where n = number of repeaters (bits) (remember that the XOR gate also counts as a repeater, which is why its output is sampled in the decoder)§0
§0
§0From all of the above, we can deduce that a
Page 6 of 14 4-bit LFSR with taps on 3 and 4 and a seed (starting value) of 0111 would cycle like this:§0
§0NOTE: The 1s travel in this direction every cycle. ===>§0
§0An (X) will be put next to every value where the XOR gates outputs 1
Page 7 of 14 0111§0
§00011§0
§00001(X)§0
§01000§0
§00100§0
§00010(X)§0
§01001(X)§0
§01100§0
§00110(X)§0
§01011§0
§00101(X)§0
§01010(X)§0
§01101(X)
Page 8 of 14 1110(X)§0
§01111(6 seconds have passed)§0
§00111(Now it's back at the start)§0
§0
§0A XOR gate is a logic gate that has 2 inputs (A and B) and 1 output (X) and the following truth table...
Page 9 of 14 A B ==> X§0
§00 0 ==> 0§0
§01 1 ==> 0§0
§00 1 ==> 1§0
§01 0 ==> 1§0
§01 = HIGH (aka there's redstone power)§0
§00 = LOW (aka turned off)§0
§0The XOR gate turns on when the outputs are different.
Page 10 of 14 The Decoder: It turns OFF (can be inverted with a torch, which is recommeded) when the counter reaches the required value. If the decoder is not made to detect the end of counting (1111) then it must also reset the LFSR or the clock will continue counting
Page 11 of 14 until it reaches 1111, which will make only the first pulse accurate as the clock will either count more or less than the required time before the value the decoder is looking for is outputted again. In order to construct a decoder for a specific time,
Page 12 of 14 you need to take a look at a table of outputs (Excel is recommended) and for every element that outputs 0, you put a repeater, and for every 1 you put a torch (to invert it). Refer to the numerous LFSRs I have in the castle for reference.
Page 13 of 14 This book is intended to be simple and to provide a general understanding of LFSRs. It does not cover everything and it will not bother to describe exactly how they are built. §0
§0
§0The writer was bored and slightly sleep-deprived while
Page 14 of 14 writing this book, so it may contain numerous errors, if you find one, feel free to shove a stick up your anus while crying about it