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
| Port | Direction | Type | Description |
|---|---|---|---|
oe_i | in | 1 bit | Output enable: drive the pad while '1' |
data_i | in | 1 bit | Value to drive onto the pad |
pin_io | inout | 1 bit | The pad, shared with the outside world |
data_o | out | 1 bit | Level currently on the pad |
Declare all ports as std_logic.
Behavior
- While
oe_i = '1':pin_iocarriesdata_i, anddata_omirrors it (the read path stays live while driving) - While
oe_i = '0':pin_iois released to'Z'; whatever the outside world drives appears ondata_o - While
oe_i = '0'and nothing external drives:pin_iostays at'Z'even asdata_itoggles; the testbench wigglesdata_iwith the pad released and checks data_oalways 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.
Click Run to execute your code. Output will appear here.