Can some one explain why the golden rule when writing VHDL is that the if-then-else statement must be in a process. Is it because inside the process, the statements are executed sequentially, while outside they're not.
7
votes
3 Answers
12
votes
0
votes
I might be wrong, but I think the main reason that if statements need to be in a process is that an if statement can potentially assign to more than one signal, if you wanted to do the same thing outside of a process you would need to use more than one conditional signal assignment.
For example:
process(C0, C1, A, B, C) is
begin
if C0 = '1' then
F <= A;
G <= C;
elsif C1 = '1' then
F <= B;
G <= B;
else
F <= C;
G <= A;
end if;
end process;
The equivalent conditional signal assignments outside of the process would be:
F <= A when C0 = '1' else B when C1 = '1' else C;
G <= C when C0 = '1' else B when C1 = '1' else A;
-1
votes
if else statement :-
Syntax:
if then
statements
...
[
elsif then
statements
...
else
statements
...
]
endif;
for more information please check this