12. Maximal-length LFSR
Build an 8-bit Fibonacci linear feedback shift register that steps through all 255 non-zero values before repeating.
Use the feedback polynomial x^8 + x^6 + x^5 + x^4 + 1. With the register bits numbered q[7] (the oldest) down to q[0], the new bit is q[7] XOR q[5] XOR q[4] XOR q[3]. On each enabled edge the register shifts left by one place and the new bit enters at q[0].
rst (synchronous, active high) loads the seed 0000_0001. When en = 0 the register holds.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
clk | in | 1 | Clock. |
rst | in | 1 | Synchronous reset to the seed 0x01. |
en | in | 1 | Step enable. |
q | out | 8 | Register contents. |
Example
From the seed 0x01 the register reads 0x02, 0x04, 0x08, then 0x11 (the feedback picks up the 1 at q[3]), 0x23, 0x47, 0x8E. After 255 steps it is back at 0x01.
Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.
Press Build to check your code with Yosys. Errors and warnings show here, and a clean build draws the logic diagram.
Build your design to drive it by hand and see its signals here.