Challenge - 5 Problems
VHDL Component Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple component instantiation
Given the following VHDL code, what is the output on the signal
Assume inputs
Y after one clock cycle?library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity AND_GATE is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC);
end AND_GATE;
architecture Behavioral of AND_GATE is
begin
Y <= A and B;
end Behavioral;
entity TOP is
Port ( X1 : in STD_LOGIC;
X2 : in STD_LOGIC;
Y : out STD_LOGIC);
end TOP;
architecture Structural of TOP is
component AND_GATE
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC);
end component;
signal S1 : STD_LOGIC;
begin
U1: AND_GATE port map(A => X1, B => X2, Y => S1);
Y <= S1;
end Structural;Assume inputs
X1 = '1' and X2 = '0'.Attempts:
2 left
💡 Hint
Remember that AND operation outputs '1' only if both inputs are '1'.
✗ Incorrect
The AND_GATE component outputs the logical AND of inputs A and B. Since X1='1' and X2='0', the output Y will be '0'.
❓ Predict Output
intermediateSignal value after component instantiation with multiple signals
Consider the following VHDL snippet. What is the value of signal
Inputs are
OUT_SIG after the component OR_GATE is instantiated?library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity OR_GATE is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC);
end OR_GATE;
architecture Behavioral of OR_GATE is
begin
Y <= A or B;
end Behavioral;
entity TOP is
Port ( IN1 : in STD_LOGIC;
IN2 : in STD_LOGIC;
OUT_SIG : out STD_LOGIC);
end TOP;
architecture Structural of TOP is
component OR_GATE
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC);
end component;
signal TEMP : STD_LOGIC;
begin
U1: OR_GATE port map(A => IN1, B => IN2, Y => TEMP);
OUT_SIG <= TEMP;
end Structural;Inputs are
IN1 = '0' and IN2 = '0'.Attempts:
2 left
💡 Hint
OR gate outputs '1' if any input is '1'.
✗ Incorrect
Both inputs are '0', so OR operation results in '0'.
❓ Predict Output
advancedOutput of nested component instantiations
Analyze the following VHDL code with nested component instantiations. What is the final output
Inputs are
F_OUT?library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity NOT_GATE is
Port ( A : in STD_LOGIC;
Y : out STD_LOGIC);
end NOT_GATE;
architecture Behavioral of NOT_GATE is
begin
Y <= not A;
end Behavioral;
entity AND_GATE is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC);
end AND_GATE;
architecture Behavioral of AND_GATE is
begin
Y <= A and B;
end Behavioral;
entity TOP is
Port ( IN1 : in STD_LOGIC;
IN2 : in STD_LOGIC;
F_OUT : out STD_LOGIC);
end TOP;
architecture Structural of TOP is
component NOT_GATE
Port ( A : in STD_LOGIC;
Y : out STD_LOGIC);
end component;
component AND_GATE
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC);
end component;
signal S1, S2 : STD_LOGIC;
begin
U1: NOT_GATE port map(A => IN1, Y => S1);
U2: AND_GATE port map(A => S1, B => IN2, Y => S2);
F_OUT <= S2;
end Structural;Inputs are
IN1 = '0' and IN2 = '1'.Attempts:
2 left
💡 Hint
First invert IN1, then AND with IN2.
✗ Incorrect
IN1='0' inverted is '1'. Then '1' AND '1' equals '1'. So F_OUT='1'.
❓ Predict Output
advancedError type from incorrect port mapping
What error will occur when compiling the following VHDL code?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity BUF_GATE is
Port ( A : in STD_LOGIC;
Y : out STD_LOGIC);
end BUF_GATE;
architecture Behavioral of BUF_GATE is
begin
Y <= A;
end Behavioral;
entity TOP is
Port ( IN1 : in STD_LOGIC;
OUT1 : out STD_LOGIC);
end TOP;
architecture Structural of TOP is
component BUF_GATE
Port ( A : in STD_LOGIC;
Y : out STD_LOGIC);
end component;
begin
U1: BUF_GATE port map(A => IN1, Z => OUT1);
end Structural;Attempts:
2 left
💡 Hint
Check if all port names in port map match the component declaration.
✗ Incorrect
Port map uses 'Z' which is not declared in BUF_GATE component ports, causing a compilation error.
🧠 Conceptual
expertNumber of component instances and signal connections
In a VHDL design, you instantiate a component
MY_COMP three times inside an architecture. Each instance connects to a unique signal for output but shares the same input signal. How many unique output signals must be declared in the architecture to avoid signal conflicts?Attempts:
2 left
💡 Hint
Each component instance output must connect to a separate signal to avoid conflicts.
✗ Incorrect
Each instance drives its own output signal; sharing output signals causes conflicts. So 3 unique output signals are needed.
