GDan wrote:
As 'U' is the left most state and if it really is the strongest - how
can I ever set the wire to anything else?
Just rive 'Z' from your testbench to that wire.
Speaking from a micro controller point of view as a programmer I would
have to set a port bit to input and then have another driver actually
driving the input to say get a low or high sample.
What you do with this action is switching a bidirectional in/out pad
from one direction to another. How does this work? Setting output
direction just means activating a driver, that drives the value from
inside to outside while input direction means setting this driver to
tri-state. Ok, that was for the output signal - the input signal is even
simpler: you just read the value at the pad.
inp_______
|
|\ |
outp__| \_|__pad
| /
|/o
|
dir_____|
As you can see: internally there are two signals: inp and outp (plus a
direction selector). Only the signal pad is a true bidirectional INOUT
signal.
So do I have to model this in VHDL where one process sets the line to
say a High Impedance 'Z' from it's default left most state of 'U' and
then another process say changing it's state from '0' and '1' if it
were a bidirectional data line and the data was say a simply clock for
arguments sake.
process
begin
test <= 'Z';
end process;
You can just write:
test <= 'Z'; -- not inside a process - its the same
-- process which is now driving?
process
begin
test <= '1';
end process;
Both processes "drive". The value '1' wins, because it is stronger.
I've built a simple switch out of 74hc573's and want to design this in
a CPLD. I thought I'd start by creating a 1bit version of the switch
and expand up.
Does your CPLD have pads like I have "pictured"? If yes, use them!
When googling I found mention of a Resolve(...)
function for a simlar purpose but it's not completely clear why.
If more than one driver drives a signal to a wire, the VHDL simulator
has to determine the resulting value. If you use std_logic(_vector) for
signals with more than one driver this determination is done by it's
resolve-function. How does it work? The resolution function builds a
vector with the width being equal to the number of drivers to a wire.
Every driver "gets a bit" inside this vector. If one of these drivers
changes, the function is checking the value of all drivers (a for-loop
over the vector) and computes the resulting value.
You don't have to care, how the resolution function works. It just
determines the resulting value of a wire, that is driven by more than
one driver. Every process or concurrent signal assignment is one driver.
Let me add: It is always helpful to use std_Ulogic(_vector) for signals
with only one driver, because this signal type does not have a
resolution function and therefore multiple drivers are an error. It is a
nice check, if one did a mistake and you save simulation computing time.
Ralf