Codiode

Valid and Ready Handshake Transmitter

MediumVerilog / SystemVerilogBuild

In a valid/ready handshake a transfer happens only on a cycle where both signals are high. The transmitter's job is to raise valid and hold its data steady until that cycle comes.

The transmitter module acts as a bridge. It receives a request to send data via a send signal. Upon receiving this request, it latches the incoming data_in, asserts the valid output, and holds the data steady on data_out. It simultaneously asserts a busy signal to indicate to the upstream source that it cannot accept new data. The valid signal remains high until the downstream receiver asserts ready. Once ready is sampled high while valid is high, the transaction completes, and the module returns to an idle state.

Timing and Reset Rules

  • Clock edge: posedge clk
  • Reset: Asynchronous active-low (rst_n)
  • Reset values: valid = 0, busy = 0, data_out = 8'b00000000
  • Priority rules: If busy is high, any assertion of send is ignored. data_out must remain strictly constant while valid is 1 and ready is 0. Once a transaction completes, data_out holds its last value until a new send request is processed.

Worked Trace

Cycle 1: rst_n=0 → valid=0, busy=0, data_out=0
Cycle 2: rst_n=1, send=1, data_in=170, ready=0 → (Registers update on next edge)
Cycle 3: send=0 → valid=1, busy=1, data_out=170
Cycle 4: ready=0 → valid=1, busy=1, data_out=170 (Hold state)
Cycle 5: ready=1 → (Handshake completes on this edge)
Cycle 6: send=0, ready=0 → valid=0, busy=0, data_out=170 (Idle, holding last data)

State Diagram

Timing Diagram

Port Table

Signal Direction Width Description
clk input 1 Positive-edge triggered clock
rst_n input 1 Asynchronous active-low reset; sets valid=0, busy=0, data_out=0
send input 1 Request to transmit data
data_in input 8 Data to be transmitted
ready input 1 Downstream receiver is ready to accept data
valid output 1 High when data_out contains valid data
data_out output 8 Data being transmitted; holds last value after completion
busy output 1 High when module is processing a transaction and cannot accept send

Constraints

  • Clock edge is posedge clk and reset is asynchronous active-low.
  • On reset, valid, busy, and data_out must all be 0.
  • If busy is high, any assertion of send must be ignored completely.
  • data_out must not change while valid is high and ready is low.
  • valid and busy must be registered outputs; they cannot depend combinationally on ready.

Topics

FSMHandshakeAXIProtocols

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 FSM Coding

Problem 11 of 15 in the FSM Coding track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

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