With N bits a Maximal LFSR will have (2**N) - 1 states. When considering the implementation of the LFSR, the bit width of the random number and the repeatability of the number need to be considered. Implementation is relatively simple, a shift register with a number of terms XORd together to create the feedback term. Just put it in a loop and let the synthesis tool figure out the logic: module fibonacci_lfsr_nbitĭata_next = Īssign stage = !stage ^ stage Īn LFSR is often the first port of call. Repeating Morgan's example below, but to get a 5 bit number each cycle: module fibonacci_lfsr_5bit(Įdit: Added a new version below which doesn't require you to do the math. However, if you want a new number every clock cycle the other option is to unroll the loop and predict what the number will be in N cycles. If you want an N bit random number you have to run the LFSR for N cycles. The number of bits in the LFSR only set how many values you get before the sequence repeats. As noted in Morgan's answer this will only produce a single random bit.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |