Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20705 Discussions

about Tri-State Logic gate

Altera_Forum
Honored Contributor II
1,389 Views

i want to make a Tri-State Logic gate,but the putout is always high impedance .why 

here's my code; 

library ieee; 

use ieee.std_logic_1164.all; 

entity e is 

port( 

datain:in std_logic_vector(7 downto 0); 

enable:in std_logic; 

dataout:out std_logic_vector(7 downto 0) 

); 

end e; 

architecture b of e is 

begin 

process(enable,datain) 

begin 

if (enable='0') then dataout<="ZZZZZZZZ"; 

else dataout<=datain; 

end if; 

end process; 

end b;
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
709 Views

dataout needs to be an inout to have a tristate

0 Kudos
Altera_Forum
Honored Contributor II
709 Views

but is the problem in simulation or on hardware?

0 Kudos
Altera_Forum
Honored Contributor II
709 Views

in simulation.but it's so strange.today i try again.when enable is 1,dataout is same as datain.but when enable is 0,dataout is always 0.so my question is changed.dose 0 stand for high impedance in quartus ii?

0 Kudos
Altera_Forum
Honored Contributor II
709 Views

anyone?help.

0 Kudos
Altera_Forum
Honored Contributor II
709 Views

did you make dataout an inout port? it wont work as just an out port. 

And is this an RTL simulation or post place and route?
0 Kudos
Altera_Forum
Honored Contributor II
709 Views

thank you.when i change dataout to inout,it works well.at first,i thought "inout" means "buffer",because i never learned inout.

0 Kudos
Altera_Forum
Honored Contributor II
709 Views

inout is needed for tri-state buffer on real hardware. 

a "buffer" type is an output that can be read internally (it is NOT tri-stated). It is quite rarely used, as most coding guidelines recommend you use internal signals instead.
0 Kudos
Altera_Forum
Honored Contributor II
709 Views

can you tell me why

0 Kudos
Altera_Forum
Honored Contributor II
709 Views

you cannot read an out port, so there is no need to tri-state it. Because of that your logic got converted to a mux. 

 

I am assuming you did a post compilation simulation, because you would have seen no problems with an RTL simulation (and then the differences between hardware and simulation would have caused you problems).
0 Kudos
Altera_Forum
Honored Contributor II
709 Views

thank you very much

0 Kudos
Reply