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 | in | 1 bit | Output enable: drive the pad while '1' |
din | in | 1 bit | Value to drive onto the pad |
pin | inout | 1 bit | The pad, shared with the outside world |
dout | out | 1 bit | Level currently on the pad |
Declarations: VHDL, all ports std_logic; SystemVerilog, pin is inout wire, the other ports logic.
Behavior
- While
oe = '1':pincarriesdin, anddoutmirrors it (the read path stays live while driving) - While
oe = '0':pinis released to'Z'; whatever the outside world drives appears ondout - While
oe = '0'and nothing external drives:pinstays at'Z'even asdintoggles; the testbench wigglesdinwith the pad released and checks doutalways 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 withport ``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.