Note that this link is tri-state, not ternary. The "tri-state" is still binary, the third state is to allow attaching multiple outputs to the same bus. Or in the C pseudocode:
Regular binary:
enum { FALSE, TRUE } value;
value = result()
Ternary: enum { UNKNOWN, FALSE, TRUE } value;
value = result()
Tri-state (as Z80 and every modern computer does it): enum { FALSE, TRUE } value;
if (enabled())
value = result()
(the idea is you might have multiple components driving the same "value", and only one of them should be enabled at a time. Bad things happen if more than one is enabled at a time, or none are)But replicating that with an ATMEL or similar generally requires dancing around with resistor ladders or similar.
For the output side, I guess I you can tri-state the output, but this will by default keep the previous voltage, you will need some resistors to actually emit a voltage outer than "low" or "high". And Z80 cannot even control this on per-pin basis, since it has no integrated GPIOs.
For the input side, I have no idea how would Z80 get more than two states. All the peripherals I know of (like 82C55 GPIO chips) also only provide two input levels as well.
The only way to get 3-state input into a system I can think of are:
- ADC input followed by software thresholding (this will be pretty slow, and works with hundreds of states, not just 3)
- Use external voltage comparators to split a single input wire into multiple input pins. This no long is "single pin" though.
- Some FPGA/CPLDs have multiple banks with changeable input thresholds. This lets you avoid external comparators. You'd still need multiple pins for each input wire.
I'd be curious how modern fpgas do it.