Challenge - 5 Problems
Shift Register Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a 4-bit SIPO shift register
What is the output of the 4-bit SIPO shift register after 4 clock cycles if the serial input is 1, 0, 1, 1 respectively?
Assume the register is initially cleared (all zeros).
Assume the register is initially cleared (all zeros).
Verilog
module sipo(clk, serial_in, parallel_out); input clk, serial_in; output reg [3:0] parallel_out; always @(posedge clk) begin parallel_out <= {parallel_out[2:0], serial_in}; end endmodule
Attempts:
2 left
💡 Hint
Think about how bits shift in from the right and older bits move left.
✗ Incorrect
Each clock cycle, the register shifts left and the new serial input bit enters the least significant bit. After 4 cycles with inputs 1,0,1,1, the register holds 1011.
❓ Predict Output
intermediate2:00remaining
Output of a 4-bit PISO shift register
Given a 4-bit PISO shift register loaded with 4'b1101, what is the serial output after 4 clock cycles if no new parallel load occurs?
Assume the serial output is the least significant bit shifted out.
Assume the serial output is the least significant bit shifted out.
Verilog
module piso(clk, load, parallel_in, serial_out); input clk, load; input [3:0] parallel_in; output reg serial_out; reg [3:0] shift_reg; always @(posedge clk) begin if (load) shift_reg <= parallel_in; else begin serial_out <= shift_reg[0]; shift_reg <= shift_reg >> 1; end end endmodule
Attempts:
2 left
💡 Hint
Look at the least significant bit shifting out each cycle.
✗ Incorrect
The register starts at 1101. On each clock without load, the LSB is output and the register shifts right. The bits output in order are 1,0,1,1.
🔧 Debug
advanced2:00remaining
Identify the error in this SISO shift register code
This SISO shift register code is intended to shift a single bit serially on each clock. What error will it cause when synthesized or simulated?
Verilog
module siso(clk, serial_in, serial_out);
input clk, serial_in;
output reg serial_out;
always @(posedge clk) begin
serial_out <= serial_in;
serial_in <= serial_out;
end
endmoduleAttempts:
2 left
💡 Hint
Inputs cannot be assigned values inside the module.
✗ Incorrect
The code tries to assign a value to 'serial_in', which is an input port. Inputs are read-only inside the module, so this causes a syntax error.
📝 Syntax
advanced2:00remaining
Syntax error in PISO shift register code
Which option contains the correct syntax to shift right and output the least significant bit in a PISO register on positive clock edge?
Attempts:
2 left
💡 Hint
Remember to use non-blocking assignments for sequential logic and shift in the correct direction.
✗ Incorrect
Option C uses non-blocking assignments (<=) and shifts right, outputting the least significant bit. Option C uses blocking assignments which are not recommended in sequential always blocks. Option C shifts left which is incorrect for PISO. Option C outputs the most significant bit, not the least.
🚀 Application
expert3:00remaining
Determine the final parallel output of a 4-bit SIPO after mixed inputs
A 4-bit SIPO shift register starts cleared (0000). The serial input bits over 5 clock cycles are: 1, 1, 0, 1, 0.
What is the parallel output after the 5th clock cycle?
Note: The register shifts left each clock, inserting the new bit at the rightmost position.
What is the parallel output after the 5th clock cycle?
Note: The register shifts left each clock, inserting the new bit at the rightmost position.
Verilog
module sipo(clk, serial_in, parallel_out); input clk, serial_in; output reg [3:0] parallel_out; always @(posedge clk) begin parallel_out <= {parallel_out[2:0], serial_in}; end endmodule
Attempts:
2 left
💡 Hint
Track the bits shifting in one by one, oldest bit moves left out of the register.
✗ Incorrect
After each clock, bits shift left and new bit enters right. After 5 clocks, the register holds the last 4 bits: 1,0,1,0.