摘要:Open Drain
A kind of PAD.
Can perform wire-AND function, it was called open-collector in Biploar.
How do I describe an open-drain, bidirectional I/O pin?
Q:
I am trying to build a ps/2 mouse interface for the xs40. I have been relying on http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/PS2/ps2.htm for specs of the protocol, and I am now trying to build the open- drain collector shown on this page for the bidirectional I/O. (pullup -> transistor -> gnd). How do I do this?
A:
You can do an open-drain output like this:
ps: inout std_logic;
...
ps <= '0' when data='0' else 'Z';
u0: pullup port map(O=>ps);
The first statement declares a port which can be used as an input or output. The next statement pulls the ps output low if a logic 0 is being driven, but places the output in a high-impedance state if a logic '1' is being driven. The second statement attaches an internal pull-up resistor to the output pin. You might also use an external pullup resistor since the internal pullups are around 100 Kohms. You may need an explicit component declaration for the pullup as well:
component pullup -- pullup component port( O: out std_logic ); end component;