A PISO (Parallel-In, Serial-Out) shift register is a type of shift register in which data is loaded in parallel into the register and then shifted out serially. Here's an example of a PISO shift register implemented in Verilog:
clk
is the clock signal that controls the shift register's operation.reset
is an optional asynchronous reset signal that resets the shift register and the shift counter to their initial states when asserted.parallel_in
is the 8-bit parallel input data that you want to load into the shift register.shift_enable
is a control signal that determines whether to load data in parallel or shift data serially.serial_out
is the serial output from the least significant bit of the shift register.
The always
block is triggered on the positive edge of the clock or the positive edge of the reset signal. When the reset signal is asserted, the shift register and shift counter are both reset to their initial states. When shift_enable
is asserted, the parallel data is loaded into the shift register, and the shift counter is incremented. When shift_enable
is deasserted, the data is shifted to the right.
You can instantiate this module in your top-level Verilog design and connect it to your clock, reset, parallel data, shift enable, and serial output signals as needed.
-
The
piso_shift_register
module is instantiated, and its inputs and outputs are connected to the testbench signals. -
A clock signal (
clk
) is generated, toggling every 5 time units. -
An initial block is used to apply stimulus and monitor the results. In this example, it includes the following steps:
- A reset pulse is applied to the PISO shift register.
- Data is loaded into the shift register using parallel input and
shift_enable
. - The serial output is monitored and displayed using
$display
.