Parameterized Interface with Modports
A SystemVerilog interface bundles a bus's signals so they travel between modules as one port, and modports say which side drives what. A width parameter lets the same interface carry a 32-bit or an 8-bit stream.
The system consists of three modules and one interface. The axis_if interface encapsulates a simplified AXI Stream protocol. The producer module receives data from the external system and initiates a transfer across the interface. The consumer module listens on the interface, accepts the transfer, and outputs the received data to the external system. The solution module is the top-level wrapper that instantiates the interface and connects the producer and consumer together.
Timing and reset rules:
- Clock edge:
clkis positive-edge triggered. - Reset type:
rst_nis asynchronous and active-low. - Reset behavior: On reset,
producermust drivetvalidto 0.consumermust drivedoneto 0,data_outto 0, and continuously drivetreadyto 1. - Normal operation (
producer): Whenstartis 1, it capturesdata_ininto an internal register. On the next clock cycle, it assertstvalidto 1 and places the captured data ontdata. It holdstvalidhigh untiltreadyis 1. - Normal operation (
consumer): It continuously drivestreadyto 1. When it detectstvalidis 1, it capturestdataintodata_outand assertsdoneto 1 on the following clock cycle. Thedonesignal is a one-cycle pulse. - Priority: If
startis asserted during reset, the reset takes priority and no transfer initiates.
Cycle-by-cycle worked trace:
- Cycle 1:
rst_n=0 →producertvalid=0.consumertready=1,done=0,data_out=0. - Cycle 2:
rst_n=1 → System idle.start=1,data_in=0xAA. - Cycle 3:
start=0 →producerassertstvalid=1,tdata=0xAA.consumerseestvalid=1 andtready=1. - Cycle 4:
producerseestready=1, dropstvalid=0.consumerassertsdone=1, updatesdata_out=0xAA. - Cycle 5:
consumerseestvalid=0, dropsdone=0.data_outholds 0xAA.
| Signal | Direction | Width | Description |
|---|---|---|---|
| clk | input | 1 | Positive-edge triggered clock |
| rst_n | input | 1 | Asynchronous active-low reset |
| start | input | 1 | Initiates a transfer from the producer |
| data_in | input | WIDTH | Data to be transferred |
| done | output | 1 | One-cycle pulse indicating consumer received data |
| data_out | output | WIDTH | Data received by the consumer; resets to 0 |
Constraints
- The
axis_ifinterface must be parameterized byDATA_WIDTH(default 32). - The
axis_ifinterface must takeclkandrst_nas interface ports. - The
axis_ifinterface must declare exactly three logic signals:tvalid,tready, andtdata. - The
axis_ifinterface must define amastermodport (outputs:tvalid,tdata; inputs:tready,clk,rst_n). - The
axis_ifinterface must define aslavemodport (outputs:tready; inputs:tvalid,tdata,clk,rst_n). - The
producermodule must NOT haveclkandrst_nin its module port list. It must extract them from them_axismodport. - The
consumermodule must NOT haveclkandrst_nin its module port list. It must extract them from thes_axismodport. - The
solutionmodule must instantiateaxis_if,producer, andconsumer, passing theWIDTHparameter to all three.
Topics
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 SystemVerilog RTL
Problem 14 of 15 in the SystemVerilog RTL track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks