Sign in

Learn

0/8
0/6
0/6
0/6

Practice

Try the challenge first: Bidirectional Pin Driver

Know this topic? Give it a go. The lesson is here if you need it.

Port Directions

Two sensor cards share one status wire. Sometimes card A drives it, sometimes card B does, and both cards can observe its level. What must A do before B starts driving the opposite value?

Port direction describes ownership, not just the direction an arrow points in a diagram.

Who drives an ordinary port?

DirectionInside this componentSurrounding design
InputReads the valueSupplies the driver
OutputSupplies the driverReads the value
BidirectionalMay drive or release, and may readFollows the same shared-wire contract

Do not assign to your own input in ordinary RTL. For an output, provide one owning driver; reading it does not create another driver.

The keywords are in, out, and inout. GHDL rejects an assignment to an input, for example port "line_i" can't be assigned. VHDL-2008 allows reading your own out port. Older code may use an internal signal or the older buffer mode instead.

Releasing a wire is not driving zero

High impedance, written Z, means this driver lets go. It does not mean the shared wire must become zero, or that everyone else stopped driving.

The example's line_driver uses this recipe:

line_io <= value_i when enable_i = '1' else 'Z';
seen_o  <= line_io;

Read the first line as “drive the chosen value while enabled; otherwise disconnect this driver.” The second line observes the shared wire, including another card's contribution. Conditional Assignment teaches the selection syntax later.

The example declares line_io : inout std_logic. std_logic resolves contributions from multiple drivers into the observed simulation value.

Predict a handover

For this push-pull interface, a card can drive either zero or one. The protocol allows only one enabled card at a time. Assume no pull-up or other driver in this paper trace:

IntervalA contributesB contributes
First1Z
SecondZZ
ThirdZ0

Predict the shared value and what A reads in each interval before checking the explanation below.

The shared sequence is 1, Z, 0, and A reads that same sequence. A's release does not stop it from listening. Driving zero during the middle interval would not count as releasing the wire.

Can a clean value hide bad ownership?

Question 1 of 1

Electrical contention can stress real output drivers. Guarantee the handover in the design rather than waiting for an unknown waveform value. A real floating input also needs an appropriate electrical design; a pull-up can provide a defined released level where the interface permits it.

Inspect the supplied evidence

The read-only example connects two line_driver instances to status_line. Find A's release gap, then B's turn. Inspect both enable signals and both seen_o outputs, not just the shared value. This waveform demonstrates deliberate turn-taking; it does not contain the overlapping-driver experiment above.

Do not generalize the push-pull rule to every bus. For ordinary open-drain I2C, devices pull low or release, and multiple low drivers can coexist. The pull-up supplies the high level. NXP's I2C specification defines that electrical contract. You do not need its protocol details for this first ownership exercise.

Tri-State Buses develops arbitration and FPGA I/O implications. The next exercise practices this shared-pin interface.

Key Takeaways

  • Direction identifies who owns a driver and who reads its value.
  • Z releases one driver; the observed wire depends on all its drivers and pulls.
  • Check ownership directly. Neither a clean value nor an X is a complete diagnosis.
Loading editor...
No waveform is available for this example. You can continue with the lesson and example code.