Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL tristate buffers

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
The simplest way I know to describe a tristate buffer is :

io_port <= driver when direction = '1' else 'Z'

But what if I do it in a more complex way - In a registered output FSM for example ?

--------------------------------
if rising_edge (clk) then

case state is

when state_1 =>
io_port <= ( others => 'Z' ) ;
registered_io_port <= io_port ;

when state_2 =>
io_port <= driver ;
--------------------------------


Will the above FSM code inffer (with guaranteed certainty) a tri-state buffer for "io_port" ?
 

std_match

Advanced Member level 4
Joined
Jul 9, 2010
Messages
1,215
Helped
451
Reputation
902
Reaction score
413
Trophy points
1,363
Location
Sweden
Activity points
9,420
The basic principle should work, but your code has a potential problem. The code for state_1 will tristate io_port from the current rising_edge, but the registered_io_port will store the value before the current rising_edge. The value you read is valid one clock cycle after you set the output to 'Z'.
 

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
Sure,
But that's the case with any reistered signal.
Output is good only at the next edge.
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,097
Helped
2,079
Reputation
4,177
Reaction score
2,037
Trophy points
1,393
Activity points
39,472
that wont work, you cannot register a 'z' value. you can however register the enable value that tristates the output.
 

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
that wont work, you cannot register a 'z' value.
I'm not trying to register the 'Z' value - I want to register the logic level at the "inout" pin when it's tristated...
 

std_match

Advanced Member level 4
Joined
Jul 9, 2010
Messages
1,215
Helped
451
Reputation
902
Reaction score
413
Trophy points
1,363
Location
Sweden
Activity points
9,420
that wont work, you cannot register a 'z' value. you can however register the enable value that tristates the output.

What you say is that the 'Z' assignment can't be done in a clocked process?

I see nothing wrong if we just see it as VHDL code, but I can understand if synthesis tools can't handle it.
 

dave9000

Full Member level 2
Joined
Dec 5, 2011
Messages
146
Helped
40
Reputation
80
Reaction score
38
Trophy points
1,308
Activity points
2,129
Precision Synthesis has got no problem with it. I have a working design like this:
Code:
In the FSM process:
   when s2 => my_bus_cld <= data_out;
   when s4 => my_bus_cld <= (others => 'Z');
   when s5 => data_in <= my_bus;     -- NOTE: not my_bus_cld

Outside the process:
   my_bus <= my_bus_cld;
my_bus is the inout port. Note that I wait a clock tic before samplig the data.
 

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
std_match, you say:
"but I can understand if synthesis tools can't handle it" - I don't.
What's wrong with sampling in the logic level of an inout port ?
Can you suggest another way ?
 

std_match

Advanced Member level 4
Joined
Jul 9, 2010
Messages
1,215
Helped
451
Reputation
902
Reaction score
413
Trophy points
1,363
Location
Sweden
Activity points
9,420
std_match, you say:
"but I can understand if synthesis tools can't handle it" - I don't.
What's wrong with sampling in the logic level of an inout port ?
Can you suggest another way ?

The last posts have not been discussing the reading of the port. We are discussing the tristating by setting the port to 'Z' in a clocked process. It isn't a problem for the VHDL language, but a synthesis tool must create at least one extra register for each group of outputs that are tristated together. The special value 'Z' can not be held in the same register as the "normal" value.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,426
Helped
14,442
Reputation
29,148
Reaction score
13,239
Trophy points
1,393
Location
Bochum, Germany
Activity points
284,427
What's wrong with sampling in the logic level of an inout port ?
Nothing is wrong, it's just misunderstanding, I presume. You didn't say clearly that io_port is an external pin and registered_io_port an internal signal sampled from this port. I also didn't understand it at first sight.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top