Codiode

Parallel In Serial Out with Load Control

MediumVerilog / SystemVerilogBuild2 solved

UART and SPI transmitters load a byte in parallel and then send it out one bit per clock. This shift register does both jobs, chosen by its control inputs.

The module maintains an internal 8-bit register. When the load signal is asserted, it captures the parallel input byte. When the shift enable signal is asserted, it shifts the data left by one bit, outputting the most significant bit (MSB) and shifting in a zero at the least significant bit (LSB). The load operation takes strict priority over the shift operation if both are asserted simultaneously. The serial output continuously reflects the MSB of the internal register.

Timing and Reset Rules:

  • Clock edge: posedge clk
  • Reset type: Asynchronous
  • Reset polarity: Active-low (rst_n)
  • Reset behavior: The internal register clears to 8'b00000000, causing s_out to become 0
  • Priority: load takes priority over shift_en

Worked Trace:
Cycle 1: rst_n=0 → reg=8'h00, s_out=0
Cycle 2: rst_n=1, load=1, d_in=8'hA5, shift_en=0 → reg=8'hA5, s_out=1
Cycle 3: load=0, shift_en=1 → reg=8'h4A, s_out=0 (shifted left)
Cycle 4: shift_en=0 → reg=8'h4A, s_out=0 (hold)
Cycle 5: load=1, shift_en=1, d_in=8'hC3 → reg=8'hC3, s_out=1 (load overrides shift)

Signal Direction Width Description
clk input 1 Positive-edge triggered clock
rst_n input 1 Asynchronous active-low reset; clears register to 8'b0
load input 1 Active-high load enable; captures d_in into the register
shift_en input 1 Active-high shift enable; shifts register left by one bit
d_in input 8 Parallel data input byte
s_out output 1 Serial data output; continuously reflects the MSB of the register

Constraints

  • The module must implement an asynchronous active-low reset.
  • The load signal must override the shift_en signal if both are asserted on the same clock edge.
  • The shift operation must be a logical left shift, shifting in a 0 at the LSB.
  • The s_out signal must continuously output the MSB (bit 7) of the internal register, including immediately upon reset.

Topics

Shift RegisterPriority LogicInterface

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.

This problem is part of Codiode Pro. The statement above is free to read.

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Part of Sequential RTL

Problem 13 of 26 in the Sequential RTL track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.