Learn

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

Practice

Bidirectional Pin Driver

Build the pad driver for one bidirectional pin of a microcontroller. The firmware side gives you an output-enable and a data value; the pad itself is shared with the outside world. While enabled, the pad carries your data. While disabled, the pad is released so the outside can drive it. A read-back output always reports the level actually on the pad.

As in the first exercise, the template ships with the port list missing, and this time choosing each port's direction is the point. Declare all four ports, then implement the body with the tri-state recipe from the lesson, used as-is.

Interface

PortDirectionTypeDescription
oein1 bitOutput enable: drive the pad while '1'
dinin1 bitValue to drive onto the pad
pininout1 bitThe pad, shared with the outside world
doutout1 bitLevel currently on the pad

Declarations: VHDL, all ports std_logic; SystemVerilog, pin is inout wire, the other ports logic.

Behavior

  • While oe = '1': pin carries din, and dout mirrors it (the read path stays live while driving)
  • While oe = '0': pin is released to 'Z'; whatever the outside world drives appears on dout
  • While oe = '0' and nothing external drives: pin stays at 'Z' even as din toggles; the testbench wiggles din with the pad released and checks
  • dout always equals the pad; when nothing drives at all, it reads 'Z' (checked)

Constraints

  • Two concurrent assignments: the tri-state recipe plus the read-back
  • Expect the first run to fail before the ports are declared: VHDL stops with signal "oe" is not an interface name; SystemVerilog with port ``oe'' is not a port of dut, one such line per missing port. Declare the ports and the errors disappear.
Loading editor...

Click Run to execute your code. Output will appear here.