Challenge - 5 Problems
VHDL Selected Assignment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a selected assignment with simple case
What is the output value of
y when sel = "10"?VHDL
architecture Behavioral of example is signal sel : std_logic_vector(1 downto 0); signal y : std_logic_vector(3 downto 0); begin with sel select y <= "0001" when "00", "0010" when "01", "0100" when "10", "1000" when others; end Behavioral;
Attempts:
2 left
💡 Hint
Check which value matches the selector "10" in the with-select statement.
✗ Incorrect
The with-select statement assigns "0100" to y when sel is "10". Other values correspond to other selectors.
❓ Predict Output
intermediate2:00remaining
Selected assignment with overlapping conditions
Given this VHDL code, what value does
out_sig have when mode = "11"?VHDL
architecture Behavioral of example2 is signal mode : std_logic_vector(1 downto 0); signal out_sig : std_logic_vector(7 downto 0); begin with mode select out_sig <= x"0F" when "00", x"F0" when "01", x"AA" when "10", x"55" when others; end Behavioral;
Attempts:
2 left
💡 Hint
The selector "11" is not explicitly listed, so it falls under others.
✗ Incorrect
The with-select statement assigns x"55" to out_sig when mode is any value other than "00", "01", or "10". Since "11" is not listed, it matches others.
🔧 Debug
advanced2:00remaining
Identify the syntax error in selected assignment
Which option contains the syntax error in this with-select assignment?
VHDL
with sel select result <= "0001" when "00", "0010" when "01", "0100" when "10", "1000" when others ;
Attempts:
2 left
💡 Hint
Check the punctuation at the end of the with-select statement.
✗ Incorrect
In VHDL, each when clause in a with-select assignment must end with a comma, except the last one which must end with a semicolon. The code ends the last when clause with a comma, causing a syntax error.
🧠 Conceptual
advanced2:00remaining
Behavior of with-select when no matching choice and no others clause
What happens if a with-select statement does not include an 'others' clause and the selector value does not match any explicit choices?
Attempts:
2 left
💡 Hint
No assignment occurs if no match and no others, so retains previous value.
✗ Incorrect
If no matching choice is found and there is no others clause, no signal assignment is performed, and the signal retains its previous value.
🚀 Application
expert3:00remaining
Determine the number of unique output values from with-select
Given this with-select statement, how many unique values can
out_val take based on code?VHDL
with code select out_val <= "000" when "000", "001" when "001", "010" when "010", "011" when "011", "100" when "100", "101" when others;
Attempts:
2 left
💡 Hint
Count the distinct output values assigned explicitly and by others.
✗ Incorrect
There are 5 explicit choices with unique outputs plus one others clause with a unique output, totaling 6 unique output values.