Skip to content

Latest commit

 

History

History

Day-22

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

In this Verilog code:

  • clock is the clock input signal.
  • reset is the reset input signal. When reset is asserted, the shift register is reset to all zeros.
  • serial_in is the serial input that gets shifted into the register.
  • parallel_out is the parallel output, which provides the current contents of the shift register.

The always block is triggered on the rising edge of the clock or when the reset signal is asserted. When the reset signal is high, the shift register is cleared to all zeros. Otherwise, the serial_in data is shifted into the register on each rising edge of the clock.

In this testbench:

  • We define signals for the clock, reset, and serial input, as well as a wire for the parallel output.
  • We instantiate the SIPO shift register module and connect the signals accordingly.
  • We generate a clock signal with a 10ns period (5ns high, 5ns low) using an always block.
  • In the initial block, we apply a reset signal, toggle the serial input, and observe the parallel output. You can add more test cases by changing the serial_in values and checking the parallel_out values as needed.
  • The assert statements check if the parallel output matches the expected values and display a message if the test fails.
  • Finally, the testbench terminates with a message when all tests have passed.

You can expand the testbench by adding more test cases or modifying the stimulus as necessary to thoroughly test your SIPO shift register module.