0
0
VHDLprogramming~5 mins

Conditional assignment (when-else) in VHDL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a conditional assignment using when-else in VHDL?
It is a way to assign a value to a signal based on a condition. The syntax uses when to specify the condition and else for the default value.
Click to reveal answer
beginner
Write the syntax of a simple conditional assignment using when-else in VHDL.
signal_name <= value1 when condition else value2;
This means if condition is true, assign value1, otherwise assign value2.
Click to reveal answer
intermediate
Can you chain multiple conditions using when-else in VHDL?
Yes, you can chain multiple when-else statements to check several conditions in order. For example:<br>
signal_name <= value1 when cond1 else value2 when cond2 else value3;
Click to reveal answer
beginner
What happens if none of the conditions in a when-else chain are true?
The last else value is assigned as a default. This ensures the signal always gets a value.
Click to reveal answer
intermediate
Why use when-else conditional assignment instead of an if statement in VHDL?
Because when-else is a concurrent statement, it can be used outside processes and is simpler for simple conditional assignments. if statements are sequential and used inside processes.
Click to reveal answer
What does the following VHDL code do?<br>
out_signal <= '1' when in_signal = '0' else '0';
AAssigns '1' to out_signal if in_signal is '0', else '0'
BAssigns '0' to out_signal if in_signal is '0', else '1'
CAssigns '1' to out_signal always
DAssigns '0' to out_signal always
Which statement is true about when-else in VHDL?
AIt is a concurrent statement used outside processes
BIt cannot be chained for multiple conditions
CIt is a sequential statement used inside processes
DIt does not require an else clause
How do you write a conditional assignment with multiple conditions in VHDL?
AUsing nested if statements
BUsing chained when-else statements
CUsing case statements only
DUsing loops
What is the default value in a when-else chain?
AThe first value assigned
BThere is no default value
CThe value after the last else
DThe value assigned if no conditions are true
Which of these is a valid conditional assignment in VHDL?
Asignal := '1' when condition else '0';
Bsignal <= '1' if condition else '0';
Csignal <= '1' when condition else '0';
Dsignal = '1' when condition else '0';
Explain how conditional assignment using when-else works in VHDL and give a simple example.
Think about assigning a signal based on a true or false condition.
You got /3 concepts.
    Describe how to handle multiple conditions using when-else in VHDL and why the else part is important.
    Consider what happens if none of the conditions are true.
    You got /3 concepts.