I am trying to implement a 24 bit random bit shift register in a small microcontroller. The output will be used as white noise and fed into an IIR pink noise filter also implemented on the MCU (see other posts, yes its possible). I need an 8 bit random number, so I am shifting the register 8 bits at a time and XORing the two high bits. This will probably not be a maximal length register. But 24 bits is huge so I am guessing it will be long enough (at least 5 seconds worth, which needs to be 40000 samples times 8 bits * 5 seconds 1.6million clock cycles) This seems like a very good way to generate lots of random numbers without repeating for a few seconds.
So, of the 24 bits, the high BYTE, the output byte, is A, the middle byte is B, and the low byte (with bit 0, the input bit) is C. So the steps are:
Take A as output, i.e. use it as the random number. Move B to A Move C to B Loop the following 8 times: XOR high bits of A and put result into first bit of C Shift C left one bit Shift A left one bit Repeat
Problem is, I this takes too many cycles. Is there some clever way to accomplish the XORing of each bit pair in a byte and put the output in another byte in say 5 or 6 cycles? The way I have outlined above will probably take about 40 cycles just for the loop.