An LFSR is a shift register where the input bit is a linear function (usually XOR) of its previous state bits. It generates pseudo-random sequences used in testing and cryptography.
Click to reveal answer
beginner
How does feedback work in an LFSR?
Feedback is created by XORing selected bits (called taps) of the register and feeding the result back into the input bit of the shift register.
Click to reveal answer
intermediate
What is the role of 'taps' in an LFSR?
Taps are specific bit positions in the register used to calculate the feedback bit by XOR operation. The choice of taps affects the sequence length and randomness.
Click to reveal answer
intermediate
Write a simple Verilog code snippet for a 4-bit LFSR with taps at bits 4 and 3.
module lfsr_4bit(clk, reset, out);
input clk, reset;
output reg [3:0] out;
wire feedback = out[3] ^ out[2];
always @(posedge clk or posedge reset) begin
if (reset) out <= 4'b0001;
else out <= {out[2:0], feedback};
end
endmodule
Click to reveal answer
beginner
Why is the initial value (seed) important in an LFSR?
The seed sets the starting state of the LFSR. If it is zero, the LFSR will stay at zero and not generate a sequence. A non-zero seed ensures the LFSR cycles through states.
Click to reveal answer
What operation is commonly used to generate the feedback bit in an LFSR?
AOR
BAND
CXOR
DNOT
✗ Incorrect
The feedback bit in an LFSR is typically generated by XORing selected bits (taps) of the register.
What happens if the initial seed of an LFSR is all zeros?
AIt generates a maximum length sequence
BIt resets automatically
CIt generates random numbers
DIt stays at zero and produces no sequence
✗ Incorrect
An all-zero seed causes the LFSR to remain stuck at zero, producing no sequence.
In a 4-bit LFSR, which of these could be valid taps for feedback?
ABits 4 and 3
BBits 1 and 2
CBits 2 and 2
DBits 5 and 6
✗ Incorrect
Taps must be valid bit positions within the register size. For 4-bit, bits 4 and 3 are valid taps.
What is the main use of an LFSR in hardware design?
ATo generate pseudo-random sequences
BTo store large data
CTo perform arithmetic operations
DTo control power supply
✗ Incorrect
LFSRs are mainly used to generate pseudo-random sequences for testing and cryptography.
In Verilog, how do you shift bits to the left and insert a new bit at the right end?
AUsing register << 1
BUsing {register[2:0], new_bit}
CUsing {new_bit, register[3:1]}
DUsing register >> 1
✗ Incorrect
Concatenation {register[2:0], new_bit} shifts bits left and inserts new_bit at the right.
Explain how an LFSR generates a pseudo-random sequence and the role of taps in this process.
Think about how bits move and how feedback is calculated.
You got /5 concepts.
Describe how you would implement a 4-bit LFSR in Verilog including reset and clock signals.
Focus on the always block and how the register updates each clock cycle.
You got /7 concepts.
Practice
(1/5)
1.
What is the main purpose of a Linear Feedback Shift Register (LFSR) in digital circuits?
easy
A. To store large amounts of data
B. To perform arithmetic addition
C. To convert analog signals to digital
D. To generate a pseudo-random sequence of bits
Solution
Step 1: Understand LFSR function
An LFSR uses shift and XOR feedback to produce a sequence of bits that appears random.
Step 2: Identify main use
This sequence is used for pseudo-random number generation and testing, not arithmetic or storage.
Final Answer:
To generate a pseudo-random sequence of bits -> Option D
Quick Check:
LFSR = pseudo-random bit generator [OK]
Hint: LFSR creates random-like bits by shifting and XOR [OK]
Common Mistakes:
Confusing LFSR with memory storage
Thinking LFSR does arithmetic
Assuming LFSR converts analog signals
2.
Which of the following is the correct Verilog syntax to declare a 4-bit register named lfsr?
easy
A. reg [3:0] lfsr;
B. reg lfsr[3:0];
C. wire [4:1] lfsr;
D. reg (3:0) lfsr;
Solution
Step 1: Recall Verilog register declaration
Registers are declared with reg [msb:lsb] name; syntax.
After 1 clock cycle, lfsr = 3'b010, which matches 3'b010.
Final Answer:
3'b010 -> Option B
Quick Check:
Shift and XOR feedback = 010 after 1 cycle [OK]
Hint: Track bits step-by-step for each clock cycle [OK]
Common Mistakes:
Mixing bit order in concatenation
Calculating feedback incorrectly
Confusing initial and next states
4.
Identify the error in this Verilog LFSR code snippet:
reg [3:0] lfsr = 4'b0000;
always @(posedge clk) begin
lfsr <= {lfsr[2:0], lfsr[3] ^ lfsr[0]};
end
medium
A. The register size declaration is wrong
B. The feedback XOR taps are incorrect for 4-bit LFSR
C. Initial value can't be all zeros in LFSR
D. The concatenation order is reversed
Solution
Step 1: Check initial value
LFSRs must not start with all zeros because they will stay stuck at zero forever (no feedback).
Step 2: Verify other parts
Feedback taps and concatenation are valid for a 4-bit LFSR. Register size is correctly declared as 4 bits.
Final Answer:
Initial value can't be all zeros in LFSR -> Option C
Quick Check:
All-zero start = stuck LFSR [OK]
Hint: Never start LFSR with all zeros [OK]
Common Mistakes:
Using zero initial value
Misunderstanding feedback tap positions
Incorrect bit concatenation order
5.
You want to design an 8-bit LFSR in Verilog that cycles through all 255 non-zero states before repeating. Which of the following tap combinations is a valid maximal-length feedback polynomial?
hard
A. Taps at bits 8 and 5 (lfsr[7] and lfsr[4])
B. Taps at bits 8 and 7 (lfsr[7] and lfsr[6])
C. Taps at bits 8 and 6 (lfsr[7] and lfsr[5])
D. Taps at bits 8 and 4 (lfsr[7] and lfsr[3])
Solution
Step 1: Recall maximal-length tap sets for 8-bit LFSR
Common maximal-length taps for 8-bit LFSR are bits 8 and 5 (1-based indexing).
Step 2: Match options with known polynomials
Taps at bits 8 and 5 (lfsr[7] and lfsr[4]) matches a valid maximal-length set. Taps at bits 8 and 7 (lfsr[7] and lfsr[6]), 8 and 6 (lfsr[7] and lfsr[5]), and 8 and 4 (lfsr[7] and lfsr[3]) are not maximal-length taps.
Step 3: Check indexing in Verilog (0-based)
Bits 8 and 5 correspond to lfsr[7] and lfsr[4], which is Taps at bits 8 and 5 (lfsr[7] and lfsr[4]).
Final Answer:
Taps at bits 8 and 5 (lfsr[7] and lfsr[4]) -> Option A
Quick Check:
Maximal taps for 8-bit LFSR = bits 8 and 5 [OK]
Hint: Use known maximal taps like bits 8 and 5 for full cycle [OK]
Common Mistakes:
Choosing non-maximal tap positions
Confusing bit indexing (1-based vs 0-based)
Assuming any two taps produce maximal length
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.