Challenge - 5 Problems
Concatenation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this VHDL signal assignment?
Consider the following VHDL code snippet:
What is the value of signal C after this assignment?
signal A : std_logic_vector(3 downto 0) := "1010"; signal B : std_logic_vector(3 downto 0) := "1100"; signal C : std_logic_vector(7 downto 0); C <= A & B;
What is the value of signal C after this assignment?
VHDL
signal A : std_logic_vector(3 downto 0) := "1010"; signal B : std_logic_vector(3 downto 0) := "1100"; signal C : std_logic_vector(7 downto 0); C <= A & B;
Attempts:
2 left
💡 Hint
Remember that the & operator joins two vectors by placing the left operand bits first, then the right operand bits.
✗ Incorrect
The concatenation operator (&) joins the bits of A and B in order. Since A is "1010" and B is "1100", C becomes "10101100".
❓ Predict Output
intermediate1:30remaining
What is the length of the resulting vector?
Given the following VHDL code:
What is the length of signal Z after the concatenation?
signal X : std_logic_vector(7 downto 0); signal Y : std_logic_vector(3 downto 0); signal Z : std_logic_vector(11 downto 0); Z <= X & Y;
What is the length of signal Z after the concatenation?
VHDL
signal X : std_logic_vector(7 downto 0); signal Y : std_logic_vector(3 downto 0); signal Z : std_logic_vector(11 downto 0); Z <= X & Y;
Attempts:
2 left
💡 Hint
Add the lengths of both vectors being concatenated.
✗ Incorrect
X has 8 bits (7 downto 0) and Y has 4 bits (3 downto 0). Concatenating them results in 8 + 4 = 12 bits.
🔧 Debug
advanced2:30remaining
Why does this concatenation cause a compilation error?
Examine the following VHDL code:
Why does this code cause a compilation error?
signal A : std_logic_vector(3 downto 0); signal B : std_logic_vector(2 downto 0); signal C : std_logic_vector(7 downto 0); C <= A & B;
Why does this code cause a compilation error?
VHDL
signal A : std_logic_vector(3 downto 0); signal B : std_logic_vector(2 downto 0); signal C : std_logic_vector(7 downto 0); C <= A & B;
Attempts:
2 left
💡 Hint
Check the total length of the concatenated vector and compare it to C's length.
✗ Incorrect
A has 4 bits, B has 3 bits, so A & B has 7 bits total. But C is declared as 7 downto 0, which is 8 bits. The sizes don't match, causing an error.
📝 Syntax
advanced1:30remaining
Which option correctly concatenates two std_logic_vectors?
Select the correct VHDL syntax to concatenate two std_logic_vectors A and B into C:
VHDL
signal A, B : std_logic_vector(3 downto 0); signal C : std_logic_vector(7 downto 0);
Attempts:
2 left
💡 Hint
The concatenation operator in VHDL is &.
✗ Incorrect
Only option C uses the correct concatenation operator (&). Options A, B, and C are invalid syntax or functions.
🚀 Application
expert3:00remaining
What is the output of this concatenation and slicing operation?
Given the following VHDL code:
What is the value of signal C after this assignment?
signal A : std_logic_vector(7 downto 0) := "10110011"; signal B : std_logic_vector(3 downto 0) := "1101"; signal C : std_logic_vector(7 downto 0); C <= (A & B)(11 downto 4);
What is the value of signal C after this assignment?
VHDL
signal A : std_logic_vector(7 downto 0) := "10110011"; signal B : std_logic_vector(3 downto 0) := "1101"; signal C : std_logic_vector(7 downto 0); C <= (A & B)(11 downto 4);
Attempts:
2 left
💡 Hint
Concatenate A and B, then select bits 11 downto 4 from the result.
✗ Incorrect
Concatenation A & B is 12 bits: bits 11 downto 0 = A(7 downto 0) & B(3 downto 0) = "101100111101". Selecting bits 11 downto 4 gives the upper 8 bits "10110011", which is assigned to C.