Challenge - 5 Problems
LFSR Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a 4-bit LFSR with given taps
What is the output sequence of this 4-bit LFSR after 5 clock cycles?
module lfsr_4bit(
input clk,
input rst,
output reg [3:0] q
);
wire feedback = q[3] ^ q[2];
always @(posedge clk or posedge rst) begin
if (rst) q <= 4'b0001;
else q <= {q[2:0], feedback};
end
endmoduleAttempts:
2 left
💡 Hint
Think about how the feedback bit is calculated and shifted in.
✗ Incorrect
The feedback is XOR of bits 3 and 2. Starting from 0001, the sequence is generated by shifting the bits such that new state = {q[2:0], feedback}.
🧠 Conceptual
intermediate1:00remaining
Purpose of the feedback bit in an LFSR
What is the main role of the feedback bit in a Linear Feedback Shift Register (LFSR)?
Attempts:
2 left
💡 Hint
Think about how LFSR generates sequences.
✗ Incorrect
The feedback bit is calculated by XORing certain bits of the register to create a new bit that is shifted in, producing a pseudo-random sequence.
🔧 Debug
advanced2:00remaining
Identify the error in this LFSR Verilog code
This 3-bit LFSR code is intended to generate a pseudo-random sequence. What error will it cause when synthesized?
module lfsr_3bit(
input clk,
input rst,
output reg [2:0] q
);
wire feedback = q[2] ^ q[0];
always @(posedge clk or posedge rst) begin
if (rst) q <= 3'b001
else q <= {q[1:0], feedback};
end
endmoduleAttempts:
2 left
💡 Hint
Check the if statement syntax carefully.
✗ Incorrect
The if statement line 'if (rst) q <= 3'b001' is missing a semicolon at the end, causing a syntax error.
❓ Predict Output
advanced1:30remaining
Number of unique states in a 3-bit maximal LFSR
How many unique non-zero states will a 3-bit maximal LFSR cycle through before repeating?
Assume the feedback polynomial is x^3 + x + 1.
Assume the feedback polynomial is x^3 + x + 1.
Attempts:
2 left
💡 Hint
A maximal LFSR cycles through all possible states except zero.
✗ Incorrect
A 3-bit register has 2^3=8 states. Maximal LFSR cycles through all except the zero state, so 7 unique states.
🚀 Application
expert2:30remaining
Determine the next state of a 5-bit LFSR
Given this 5-bit LFSR with taps at bits 5 and 3 (positions 4 and 2 in zero-based indexing), and current state 10110, what is the next state?
Current state q = 5'b10110
Feedback = q[4] ^ q[2]
Next state = {q[3:0], feedback}Attempts:
2 left
💡 Hint
Calculate feedback bit first, then shift left and insert feedback at LSB.
✗ Incorrect
Feedback = q[4] ^ q[2] = 1 ^ 1 = 0. Next state = {q[3:0], feedback} = {0110, 0} = 01100.