Reputation: 318
I have created a process that assigns values to a signal in the purpose of re-using the signal within a different process:
Signaling : process(button0, button1)
begin
if (button1= '0') AND (button0 = '0') then -- if both buttons are pressed
BothButtons <= "00";
elsif (button1 = '0') AND (button0 = '1') then -- if button1 is pressed
BothButtons <= "01";
elsif (button1 = '1') AND (button0 = '0') then -- if button0 is pressed
BothButtons <= "10";
elsif (button1 = '1') AND (button0 = '1') then -- if no button are pressed
BothButtons <= "11";
else
--BothButtons <= "11";
BothButtons <= button0 & button1;
end if;
end process;
The other process which I am re-using this signal is:
Counting : process(button0, BothButtons)
variable count0 : integer range 0 to 9; -- to hold the counter value
begin
if falling_edge(Button0) then -- I am using button0 as a clock because the onboard clock is too fast
if BothButtons = "00" then
count0 := 0;
elsif BothButtons = "01" then
count0 := count0 + 1;
elsif BothButtons = "10" then
count0 := count0 + 1;
else
count0 := count0 + 1; -- when i have included this i have discovered that the signal value is not visible within this process
end if;
end process;
Please ignore the contents of this if-statement I know it does not make sense but am just testing to see if the signals value is visisble within this process!
The output is not as expected, it does not seem like the second process is responding to changes within the signal!
Upvotes: 0
Views: 674
Reputation: 10281
Short answer: yes. As a rule of thumb, write to your signal in only one process (this is the signal 'driver'), and read it in any other process.
It's a bit more complicated than this, but you can ignore the complications to start with. You actually write to the signal in an 'effective process' (which can be a concurrent assignment, for example, instead of a process), and you can have multiple drivers if you want to deal with resolution functions.
Your code is all messed up, though. First, you have major race problems. both processes are sensitive to the same signals and you don't know what order they'll execute in. Second, your first process can be completely replaced with a simple concurrent assignment (the one in your else branch). Your second process is also too complicated.
Upvotes: 2
Reputation: 492
You are allowed to write to a signal in one process and read it in one or more other processes. You are however never allowed to write to the same signal from more than one process, which isn't the case here.
Upvotes: 1