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'.
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.
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, 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.
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.