0
0
Verilogprogramming~10 mins

Shift register (SIPO, PISO, SISO) in Verilog - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a 4-bit shift register.

Verilog
reg [3:0] [1] ;
Drag options to blanks, or click blank then click option'
Ashift_reg
Bdata_out
Cinput_data
Dclk
Attempts:
3 left
💡 Hint
Common Mistakes
Using signal names like clk or input_data as register name.
2fill in blank
medium

Complete the code to shift data left by one bit on the rising edge of clock.

Verilog
always @(posedge clk) begin
    [1] <= {shift_reg[2:0], serial_in};
end
Drag options to blanks, or click blank then click option'
Aserial_out
Bshift_reg
Cdata_in
Dclk
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning to serial_out or clk inside always block.
3fill in blank
hard

Fix the error in the code to correctly output the serial data from the shift register.

Verilog
assign serial_out = [1][3];
Drag options to blanks, or click blank then click option'
Adata_in
Bclk
Cshift_reg
Dserial_in
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning output from serial_in or clock signals.
4fill in blank
hard

Fill both blanks to complete the parallel load logic for a PISO shift register.

Verilog
always @(posedge clk or posedge reset) begin
    if (reset) begin
        shift_reg <= 4'b0000;
    end else if (load) begin
        shift_reg <= [1];
    end else begin
        shift_reg <= {shift_reg[2:0], [2];
    end
end
Drag options to blanks, or click blank then click option'
Aparallel_in
Bserial_out
Cserial_in
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using serial_out instead of serial_in for shifting.
5fill in blank
hard

Fill all three blanks to complete a SISO shift register that shifts right and outputs the LSB.

Verilog
always @(posedge clk or posedge reset) begin
    if (reset) begin
        shift_reg <= 4'b0000;
    end else begin
        shift_reg <= { [1], shift_reg[3:1] };
    end
end

assign [3] = shift_reg[[2]];
Drag options to blanks, or click blank then click option'
Aserial_in
B0
Dserial_out
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing MSB and LSB positions in shifting and output.