Here is the test case, a shared variable x_i drives and output port o_x.
Code:
library ieee;
use ieee.std_logic_1164.all;
entity test_2 is
port (
o_x : out std_logic
);
end entity;
architecture beh of test_2 is
shared variable x_i : std_logic;
begin
process
begin
x_i := '1';
wait for 10 ns;
x_i := '0';
wait for 10 ns;
x_i := '1';
wait;
end process;
o_x <= x_i;
end architecture;
When the simulation is run, x_i changes as we expect. However, o_x stays in 'X' state.
Why doesn't x_i get assigned to o_x in this case? It would be great if Jim Lewis could answer this one.
I’ve never used shared variables, but I would suspect that either:
1) the assignment of o_x needs to be inside a process.
2) you need to tell the simulator you’re using VHDL 93 (or later)
I’ve never used shared variables, but I would suspect that either:
1) the assignment of o_x needs to be inside a process.
2) you need to tell the simulator you’re using VHDL 93 (or later)
Pre VHDL93 simulator setting gives syntax error for shared variable. Assignment in process makes no difference, at least in Modelsim.
I doubt that the behaviour of shared variable in this context is completely specified in VHDL language reference. Why are you using a shared variable? It doesn't seem to serve a specific purpose here.
Thanks to TrickyDicky for remembering the concept of equivalent process statement to describe the execution of concurrent signal assignments. It completely explains the observed behaviour.
The only place where I have used shared variables (and where it serves a purpose, I think) is to model dual port RAM, there the variable is read in clock sensitive processes, thus no simulation mismatch occurs.
architecture_body ::=
architecture identifier of entity_name is architecture_declarative_part
begin
architecture_statement_part
end [ architecture ] [ architecture_simple_name ] ;
architecture_body ::=
architecture identifier of entity_name is architecture_declarative_part
begin
architecture_statement_part
end [ architecture ] [ architecture_simple_name ] ;
The only place where I have used shared variables (and where it serves a purpose, I think) is to model dual port RAM, there the variable is read in clock sensitive processes, thus no simulation mismatch occurs.
I second this.
The OP seems to be trying to create some exotic implementation for shared variable.
@matrixofdynamism You wanted Jim Lewis to answer this Q, but did you make an effort to find out and understand what Jim has to say regarding shared variables at his webpage?