Lec4 - Hierarchical Design With VHDL
Lec4 - Hierarchical Design With VHDL
a temp
b
c d
The 2-input OR Gate
entity or_gate is
port(a, b: in std_logic;
c: out std_logic);
end or_gate;
• This is NOT a good idea (I/Os can be changed as the circuit is designed
and tested) and should be avoided (particularly in direct instantiation)
Example
• Two-bit wide 4-to-1 multiplexer to enable the selection of four characters
that are displayed on a 7-segment display
M1 M0
0 0 d
0 1 E
1 0 1
1 1
Component Declaration
ARCHITECTURE Structure OF part5 IS
COMPONENT mux_2bit_4to1
PORT ( S, U, V, W, X : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
M : OUT STD_LOGIC_VECTOR(1 DOWNTO 0));
END COMPONENT;
COMPONENT char_7seg
PORT ( C : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
Display : OUT STD_LOGIC_VECTOR(0 TO 6));
END COMPONENT;
SIGNAL Ch_Sel, Ch0, Ch1, Ch2, Ch3 :
STD_LOGIC_VECTOR(1 DOWNTO 0);
SIGNAL H3_Ch, H2_Ch, H1_Ch, H0_Ch :
STD_LOGIC_VECTOR(1 DOWNTO 0);
BEGIN
Component Instantiation
• Create an instance of a component
• Map formal signals to actual signals
M3: mux_2bit_4to1 PORT MAP (Ch_Sel, Ch0, Ch1, Ch2, Ch3, H3_Ch);
M2: mux_2bit_4to1 PORT MAP (Ch_Sel, Ch1, Ch2, Ch3, Ch0, H2_Ch);
M1: mux_2bit_4to1 PORT MAP (Ch_Sel, Ch2, Ch3, Ch0, Ch1, H1_Ch);
M0: mux_2bit_4to1 PORT MAP (Ch_Sel, Ch3, Ch0, Ch1, Ch2, H0_Ch);