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
oe_iin1 bitOutput enable: drive the pad while '1'
data_iin1 bitValue to drive onto the pad
pin_ioinout1 bitThe pad, shared with the outside world
data_oout1 bitLevel currently on the pad

Declare all ports as std_logic.

Behavior

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

Constraints

  • Two assignment outside a procedural blocks: the tri-state recipe plus the read-back The first run fails before you've declared the ports because the testbench cannot connect to a component that has none.

  • It stops with signal "oe_i" is not an interface name, 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.