0
0
VHDLprogramming~10 mins

Selected assignment (with-select) in VHDL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Selected assignment (with-select)
Start
Evaluate select expression
Match expression to choice
Choice 1?
YesAssign value 1 to target
Choice 2?
YesAssign value 2 to target
Others
YesAssign default value
End
The selected assignment evaluates an expression and assigns a value based on matching choices, with a default if no match.
Execution Sample
VHDL
with sel select
  out <= "0001" when "00",
         "0010" when "01",
         "0100" when "10",
         "1000" when others;
Assigns a 4-bit output based on 2-bit select input using selected assignment.
Execution Table
Stepsel valueMatched choiceAssigned out valueNotes
1"00""00""0001"sel matches first choice
2"01""01""0010"sel matches second choice
3"10""10""0100"sel matches third choice
4"11"others"1000"sel matches default (others)
5---End of selected assignment execution
💡 All possible sel values matched; assignment complete.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
selundefined"00""01""10""11"varies per step
outundefined"0001""0010""0100""1000"varies per step
Key Moments - 2 Insights
Why does the 'others' choice assign a value when sel is "11"?
Because 'others' covers all values not explicitly listed, so when sel is "11" it matches 'others' as shown in execution_table row 4.
What happens if sel matches multiple choices?
In VHDL selected assignment, sel matches only one choice; the matching choice is used. The execution_table shows unique matches per step.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of 'out' when sel is "10"?
A"0100"
B"1000"
C"0010"
D"0001"
💡 Hint
Check execution_table row 3 under 'Assigned out value'.
At which step does the 'others' choice get assigned?
AStep 1
BStep 3
CStep 4
DStep 2
💡 Hint
Look at execution_table row 4 under 'Matched choice'.
If sel is "01", what will 'out' be assigned according to the execution table?
A"0001"
B"0010"
C"0100"
D"1000"
💡 Hint
Refer to execution_table row 2 for sel "01".
Concept Snapshot
Selected assignment syntax:
with <expression> select
  <target> <= <value1> when <choice1>,
             <value2> when <choice2>,
             ...
             <default_value> when others;

Behavior:
Evaluates expression once,
assigns target based on matching choice,
uses 'others' as default fallback.
Full Transcript
This visual execution trace shows how a VHDL selected assignment works. The select expression 'sel' is checked against each choice. When a match is found, the corresponding value is assigned to 'out'. If no explicit match occurs, the 'others' choice assigns a default value. The execution table steps through different sel values and shows the assigned output. The variable tracker records how 'sel' and 'out' change at each step. Key moments clarify why 'others' is important and how matching is unique. The quiz tests understanding of matching and assignment. The snapshot summarizes syntax and behavior for quick reference.