본문 바로가기
전자/임베디드 시스템

VHDL component와 port map 사용법

by Begi 2021. 5. 1.
반응형

VHDL에서 component는 C에서 함수와 비슷한 것으로 로직 모듈을 나타내는 것이다. port map은 component 사이의 연결을 나타내는 것이다.

 

아래 예제는 INV와 CMM이라는 컴포넌트를 사용한다. G1은 INV 컴포넌트의 인스턴스 이름이고 G2는 CMM 컴포넌트의 인스턴스 이름이다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library IEEE; 
use IEEE.STD_LOGIC_1164.all; 
 
entity MUX is 
    port (SEL, A, B: in STD_LOGIC;
          F : out STD_LOGIC); 
end; 
 
architecture STRUCTURE of MUX is 
 
  component INV 
  port (A: in STD_LOGIC;
          F: out STD_LOGIC);
  end component;
 
  component CMM 
    port (A, B, C, D: in STD_LOGIC;
          F : out STD_LOGIC);
  end component; 
 
signal SELB: STD_LOGIC; 
 
begin 
    G1: INV port map (SEL, SELB);
    G2: CMM port map (SEL, A, SELB, B, F);
end;
cs

 

콤포넌트의 인스턴스는 다음 예제와 같이 여러개가 될 수 있다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
LIBRARY adk;
USE adk.all;

ENTITY mux5 IS
    PORT(
        a_input : IN STD_LOGIC;
        b_input : IN STD_LOGIC;
        c_input : IN STD_LOGIC;
        d_input : IN STD_LOGIC;
        e_input : IN STD_LOGIC;
        sel : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
        z_out : OUT STD_LOGIC
);
END mux5;

ARCHITECTURE test OF mux5 IS
    SIGNAL temp0, temp1, temp2, temp3 : STD_LOGIC;
   
    COMPONENT mux21 PORT( a0,a1,s0 : IN STD_LOGIC;
                y : OUT STD_LOGIC); END COMPONENT;

   COMPONENT inv01 PORT( a : IN STD_LOGIC;
                y : OUT STD_LOGIC); END COMPONENT;

BEGIN
    U1 : mux21 PORT MAP(a0 => a_input,
                        a1 => b_input,
                        s0 => sel(0),
                        y => temp0);
    U2 : mux21 PORT MAP(a0 => c_input,
                        a1 => d_input,
                        s0 => sel(0),
                        y => temp1);
    U3 : mux21 PORT MAP(a0 => temp0,
                        a1 => temp1,
                        s0 => sel(1),
                        y => temp2);
    U4 : mux21 PORT MAP(a0 => temp2,
                        a1 => e_input,
                        s0 => sel(2),
                        y => temp3);
    U5 : inv01 PORT MAP(a => temp3,
                        y => z_out);
END test;
cs

 

반응형

'전자 > 임베디드 시스템' 카테고리의 다른 글

RTL 이란?  (0) 2021.05.05
LVC와 LVC1G의 동작 전압  (0) 2021.05.03
Code Composer Studio 버전  (0) 2021.02.26
윈도우 10에서 Code Composer Studio 3.3 설치  (0) 2021.02.25
Call Stack 이란?  (0) 2021.01.29

댓글