Consider the following VHDL entity and architecture. What is the output on Y after the port map instantiation?
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; Z : out STD_LOGIC); end TOP; architecture Structural of TOP is signal S : STD_LOGIC; begin U1: entity work.AND_GATE port map(X1, X2, S); Z <= S; end Structural;
Remember that the AND gate outputs '1' only when both inputs are '1'. Positional port map matches ports in order.
The port map uses positional association: X1 connects to A, X2 to B, and S to Y. The AND gate outputs '1' only if both inputs are '1', so Z follows that logic.
Given the following VHDL code, what is the value of Z when X1='0' and X2='1'?
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 ( X1 : in STD_LOGIC; X2 : in STD_LOGIC; Z : out STD_LOGIC); end TOP; architecture Structural of TOP is signal S : STD_LOGIC; begin U1: entity work.OR_GATE port map(B => X1, A => X2, Y => S); Z <= S; end Structural;
Check how named association connects signals to ports regardless of order.
Named association connects B to X1 ('0') and A to X2 ('1'). The OR gate outputs '1' if either input is '1', so Z is '1'.
What error will occur when compiling the following VHDL code?
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 TOP is Port ( X : in STD_LOGIC; Z : out STD_LOGIC); end TOP; architecture Structural of TOP is signal S : STD_LOGIC; begin U1: entity work.NOT_GATE port map(A => X, B => S); Z <= S; end Structural;
Check the port names in the entity and the port map association.
The NOT_GATE entity has ports A and Y. The port map tries to connect a non-existent port B, causing a compilation error.
Which option contains the correct syntax for port map association in VHDL?
Remember the correct symbol for named association in port maps.
In VHDL, named association uses the => symbol inside port map. Other symbols cause syntax errors.
Given the following VHDL code snippet, how many signals are connected to the component ports after the port map?
entity COMPLEX_COMP is Port ( CLK : in STD_LOGIC; RST : in STD_LOGIC; DATA_IN : in STD_LOGIC_VECTOR(3 downto 0); DATA_OUT : out STD_LOGIC_VECTOR(3 downto 0); READY : out STD_LOGIC ); end COMPLEX_COMP; architecture Behavioral of COMPLEX_COMP is begin -- Implementation end Behavioral; entity TOP is Port ( CLK_TOP : in STD_LOGIC; RST_TOP : in STD_LOGIC; IN_TOP : in STD_LOGIC_VECTOR(3 downto 0); OUT_TOP : out STD_LOGIC_VECTOR(3 downto 0); READY_TOP : out STD_LOGIC ); end TOP; architecture Structural of TOP is signal internal_ready : STD_LOGIC; begin U1: entity work.COMPLEX_COMP port map( CLK => CLK_TOP, RST => RST_TOP, DATA_IN => IN_TOP, DATA_OUT => OUT_TOP, READY => internal_ready ); READY_TOP <= internal_ready; end Structural;
Count each port in the component and check how many signals are connected in the port map.
The component COMPLEX_COMP has 5 ports: CLK, RST, DATA_IN, DATA_OUT, READY. All are connected to signals in the port map, so 5 signals are connected.
