Forum Discussion
Well, these are typically beginner mistakes in VHDL coding.
- A signal/variable cannot be updated in two different Processes.
- A signal/register/variable cannot be assigned values at both clock edges of two different clock signals.
process (signal_1, signal_2) begin
if(signal_1) then
signal_out <= 0;
else
signal_out <= 1;
end if
end process;In the above code, there's an issue... signal_out gets assigned 0 when signal_1 =1 and irrespective of signal_2. Same goes for the else condition. To avoid, this we have to specify all logically exclusive conditions in the if-else loop.
process (signal_1, signal_2) begin
if(signal_1 == '1' and signal_2 = '0') then
signal_out <= 0;
else if (signal_1 == '0' and signal_2 == '1') then --left out conditions are sig_1 = sig_2 == 1 , sig_1 = sig_2 == 0.
signal_out <= 1;
end if
end process;Normally, you assign signals on the rising edge or falling edge of a periodic signal like a clock and have the other signal in the sensitivity list of the process as the reset so that the Flops in the design can be reset to a known state on Power ON.
process( clock, reset) begin
if(reset == '0') then
signal_out <= '0';
else if (rising_edge/falling_edge clock) then
signal_out <= '1'
end if
end processThis will make sure that the code infers flip-flops and not larches or other combinational logic that is unwanted (unless or course you are designing combinational circuits, in which case you would code it in a different way.)
- CLa_R6 years ago
Occasional Contributor
Thank you for your answer.
What I try to do is change signal_out when signal_1 or signal_2 change their state.
It is assumed that signal_1 and signal_2 CANNOT change at the same time.
In the first case, if signal_1 changes, then signal_out must be set to 0. In any case, both that signal_1 goes from 0 to 1, and that it passes from 1 to 0.
It's an asynchronous design and I'm not using any clock.
Can I do this with the code you showed me?