Codiode

Inout Port Mechanics

EasyVerilog / SystemVerilogBuildFree28 solved

A bidirectional pin is one wire that both sides take turns driving. The rule that keeps it safe: whoever is not talking must let go of the line by driving z.

The module controls an 8-bit bidirectional data line. When the module is transmitting, it drives the external data line with its internal transmit data. When the module is receiving, it must release the bus by driving a high impedance state, allowing other external devices to drive the line safely without electrical contention. The module simultaneously monitors the external data line and routes its current state to an internal receive data port.

Timing and Reset Rules:

  • Purely combinational logic; no clock or reset signals are used.
  • Output values reflect inputs immediately.
  • High impedance must be driven to the bidirectional bus when not actively transmitting.
Signal Direction Width Description
tx_en input 1 Transmit enable; when 1, the module drives bus_io
tx_data input 8 Internal data to be transmitted
rx_data output 8 Internal data received from the bus
bus_io inout 8 External bidirectional bus

Constraints

  • bus_io must be driven to 8'bzzzzzzzz when tx_en is 0.
  • rx_data must continuously reflect the resolved state of bus_io.
  • Purely combinational logic; no latches or registers.

Topics

BidirectionalContinuous AssignmentHigh Impedance

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.

Free to solve. A Codiode account keeps your progress.

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 Verilog Syntax and Language Basics

Problem 3 of 25 in the Verilog Syntax and Language Basics track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

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