Professional Documents
Culture Documents
VHDL04 Full
VHDL04 Full
VHDL04 Full
4. 설계 엔티티
한동일
학습 목표
설계 엔티티(design entity)의 정의와 구성 방법을
배 다
배운다.
엔티티 선언(entity declaration)의 정의와 엔티티
선언 구문을 배운다.
배운다
하드웨어의 입출력을 엔티티로 선언할 수 있다.
아키텍처 본체(architecture body)의 정의와 아키
텍처 본체 선언 구문을 배운다. 배운다
하드웨어의 동작을 아키텍처로 구현할 수 있다.
구성 선언(configuration declaration) 원리를 이
해한다.
2/37
설계 엔티티(design entity)
설계 엔티티(design
엔티티(d i entity)
tit )
설계 해야 할 하드웨어를 VHDL을 이용하여 추상화한 것
입,출력이 정의되어 있고
수행해야 할 기능이 정의되어 있는 하드웨어 설계를 표현
Design Entity
Hardware
Entity
Declaration
VHDL Modeling
Architecture
A hit t
Body
3/37 .
설계 엔티티(design entity)
설계 엔티티의 구성
엔티티 선언(entity declaration)
설계 엔티티와 외부 환경 사이의 인터페이스를 정의
아키텍처 본체(architecture body)
설계 엔티티의 입력 신호와 출력 신호들의 동작 관계 규정
구성 선언(configuration declaration)
아키텍처 본체와 엔티티의 연결을 정의
4/37 .
설계 엔티티(design entity)
Entity :
input output
Symbol ports
ports
Architecture :
Schematic
5/37
엔티티 선언
엔티티 선언(entity
선언( tit d declaration)의
l ti )의 BNF 정의
entityy_declaration ::=
entity identifier is
entityy_header
entity_declarative_part
[ begin
g
entity_statement_part ]
end [ entityy ] [ entityy_simple
p _name ] ;
entity Full_Adder is
port (X, Y, Cin: in Bit; Cout, Sum: out Bit);
end Full_Adder;
entity TestBench is
end TestBench;
7/37
엔티티 선언
엔티티 해더(entity
해더( tit h header)의
d )의 BNF 정의
entity_header ::=
[formal_generic_clause ]
[formal_port_clause ]
8/37
엔티티 선언
엔티티 해더(entity
해더( tit h header)의
d )의 BNF 정의 - 계속
fformal_p
port_clause ::= p
port ( fformal_p
port_list ) ;
formal_port_list ::= generic_port_element { ; generic_port_element }
generic_p
g port_element ::= ggeneric_p
port_declaration
generic_port_declaration ::=
[ signal
g ] identifier_list
_ : [ mode ] subtype_indication
yp _ [ bus ] [ := static_expression
_ p ]
mode ::= in | out | inout | buffer | linkage
제네릭절(
제네릭절(generic
i clause)
l )
외부 환경 정보들을 정의하고 설계 엔티티로 전달
포트절(
포트절(port
t clause)
l )
설계 엔티티에서 외부 인터페이스에 사용하는 입출력 신호들을 정의
9/37 .
엔티티 선언
포트절의 모드(mode)
모드( d )
mode remark
- 그 값을 읽을 수만 있고 새로운 값을 할당할 수는 없다.
in - 신호 배정문(<=)의 오른편에만 올 수 있다.
- 대부분의 신호 속성(attribute)값을 읽을 수 있다.
- 그 값을 읽을 수는 없고 새로운 값을 할당할 수는 있다.
out - 신호 배정문(<=)의 왼편에만 올 수 있다.
- 대부분의 신호 속성(attribute)값을 읽을 수 있다.
있다
- 그 값을 읽을 수도 있고 새로운 값을 할당할 수도 있다.
inout - 신호 배정문(<=)의 왼편, 오른편 모두에 올 수 있다.
- 대부분의 신호 속성(attribute)값을 읽을 수 있다.
있다
- 그 값을 읽을 수도 있고 새로운 값을 할당할 수도 있다.
buffer - 신호 배정문(<=)의 왼편, 오른편 모두에 올 수 있다.
- 대부분의 신호 속성(attribute)값을 읽을 수 있다.
- 그 값을 읽을 수도 있고 새로운 값을 할당할 수도 있다.
linkage - 신호 배정문(<
배정문(<=)의
)의 왼편,
왼편 오른편 모두에 올 수 있다.
있다
- 기타 다른 동작은 지원하지 않는다.
10/37
포트절의 모드
i
inout
t 모드와 buffer
b ff 모드의 차이점
inout
in 모드 + out 모드의 의미
양방향 버스, 메모리의 데이터 포트 모델링에 사용
포트의 모드로 in, i out,
t inout
i t 모드만 사용하기를 권장
buffer
out 모드 + 내부 신호(internal signal)의 의미
출력 신호를 내부적으로 사용하는 경우
buffer 모드의 사용은 가급적 자제
출력 신호와 내부 신호를 별도로 분리해서 사용 권장
11/37.
엔티티 선언
엔티티 선언부(entity
선언부( tit d declarative
l ti part)의
t)의 BNF 정의
entityy_declarative_p
part ::=
{ entity_declarative_item }
entity_declarative_item ::=
package_body | subprogram_body | package_declaration
| subprogram_declaration | type_declaration | subtype_declaration
| constant_declaration | signal_declaration | file_declaration
| shared_variable_declaration | alias_declaration
| attribute_declaration | attribute_specification | use_clause
| disconnection_specification | group_template_declaration
| group_declaration | package_instantiation_declaration
| subprogram_instantiation_declaration
12/37
엔티티 선언
엔티티 선언부(entity
선언부( tit d declarative
l ti part)의
t)의 예
entityy ROM is
port ( Addr: in Word;
Data: out Word;;
Sel: in Bit);
type
yp Instruction is arrayy ((1 to 5)) of Natural;;
type Program is array (Natural range <>) of Instruction;
p , Work.RegisterNames.all
use Work.OpCodes.all, g
constant ROM_Code: Program :=
( ((STM,, R14,, R12,, 12,, R13),
), ((LD,, R7,, 32,, 0,, R1 )) ;
end ROM;
설계 엔티티에 일관되게 적용되는 항목들에 대한 선언
13/37
엔티티 선언
엔티티 문장부(entity
문장부( tit statement
t t t part)의
t)의 BNF 정의
entity_statement_part ::=
{ entity_statement }
entity_statement ::=
concurrent_assertion_statement
| passive_concurrent_procedure_call_statement
| passive_process_statement
설계 엔티티에 공통으로 사용되는 문장들을 서술
이러한 문장들을 엔티티 문(entity statement)이라고 함
엔티티 문은 병렬문 형태이어야 함
엔티티 문은 수동문 형태이어야 함
동작 조건이나 특성을 모니터 하는 용도
신호 배정은 불가
14/37.
엔티티 선언
엔티티 문장부(entity
문장부( tit statement
t t t part)의
t)의 예
entity Latch is
port ( Din: in Word;
Dout: out Word;
Load: in Bit;
Clk: in Bit );
constant Setup: Time := 12 ns;
constant PulseWidth: Time := 50 ns;
use Work.TimingMonitors.all
begin
assert Clk='1' or Clk'Delayed'Stable (PulseWidth);
CheckTiming (Setup, Din, Load, Clk);
end Latch ;
15/37
아키텍처 본체
아키텍처 본체(architecture
본체( hit t b
body)의
d )의 BNF 정의
architecture_body ::=
architecture identifier of entity_name is
architecture_declarative_part
begin
architecture_statement_part
end [ architecture ] [ architecture_simple_name ] ;
16/37.
아키텍처 본체
아키텍처 선언부(declarative
선언부(d l ti part)의
t)의 BNF 정의
architecture_declarative_part ::=
{ block_declarative_item }
bl k d l ti it ::=
block_declarative_item
package_body | subprogram_body | package_declaration
| subprogram_declaration
b d l ti | type_declaration
t d l ti | subtype_declaration
bt d l ti
| constant_declaration | signal_declaration | file_declaration
| shared_variable_declaration
h d i bl d l ti | package_instantiation_declaration
k i t ti ti d l ti
| alias_declaration | component_declaration | attribute_declaration
| attribute_specification
tt ib t ifi ti | disconnection_specification
di ti ifi ti | use_clause
l
| configuration_specification | group_template_declaration
| group_declaration
d l ti | subprogram_instantiation_declaration
b i t ti ti d l ti
17/37
아키텍처 본체
아키텍처 문장부(statement
문장부( t t t part)의
t)의 BNF 정의
architecture statement part ::
architecture_statement_part ::=
{ concurrent_statement }
concurrent_statement ::=
block_statement
| process_statement
| concurrent_procedure_call_statement
| concurrent_assertion_statement
| concurrent_signal_assignment_statement
| component_instantiation_statement
| generate_statement
18/37
아키텍처 본체
아키텍처 본체(architecture
본체( hit t b
body)의
d )의 서술 예
architecture DataFlow of Full_Adder
Full Adder is
signal A,B: Bit;
begin
A <= X xor Y;
B <=
< A and Cin;
Sum <= A xor Cin;
Cout <
<= B or (X and Y);
end architecture DataFlow;
19/37
아키텍처 본체
아키텍처 본체(architecture
본체( hit t b
body)의
d )의 서술 예
library
y Test;;
use Test.Components.all
architecture Structure of TestBench is
component Full_Adder
port (X, Y, Cin: in Bit; Cout, Sum: out Bit);
end component;
signal A, B, C, D, E, F, G: Bit;
signal OK: Boolean;
begin
UUT: Full_Adder
Full Adder port map (A, B, C, D, E);
Generator: AdderTest port map (A, B, C, F, G);
Comparator: AdderCheck port map (D, E, F, G, OK);
end Structure;
20/37
아키텍처 본체
아키텍처 본체(architecture
본체( hit t b
body)의
d )의 서술 예
architecture Behavior of And_Gate is
begin
process (Inputs)
variable Temp: Bit;
begin
Temp := '1';
for i in Inputs'Range loop
if Inputs(i) = '0' then
Temp := '0'; exit;
end if;
end
d lloop;
Result <= Temp after 10 ns;
end process;
end Behavior;
21/37
아키텍처 본체
반가산기(H lf Add
반가산기(Half Adder)의
)의 구현 예
dataflow modeling을 이용한 구현 기법 예
behavioral modeling을 이용한 구현 기법 예
structural modeling을 이용한 구현 기법 예
dataflow, behave, structure의 조합도 가능
A B S C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
22/37.
반가산기의 구현 예
반가산기(H lf Add
반가산기(Half Adder)의
)의 엔티티 선언
입력 포트와 출력 포트를 정의
library IEEE;
use IEEE.std_logic_1164.all;
entity HalfAdder is
port( A, B: in std_logic;
S, C : out std_logic);
end HalfAdder;
23/37
반가산기의 구현 예
자료 흐름 모델링(dataflow
모델링(d t fl modeling)
d li ) 기법
단순 로직의 표현에 많이 사용
주로 병렬 신호 배정문을 이용
부울 대수식, 논리식의 하드웨어 동작 표현
. .
. .
. .
24/37.
반가산기의 구현 예
자료 흐름 모델링(dataflow
모델링(d t fl modeling)
d li ) 기법
architecture Dataflow of HalfAdder is
begin
S <= A xor B;
C <= A and B;
end Dataflow;
25/37
반가산기의 구현 예
거동 모델링(behavioral
모델링(b h i l modeling)
d li ) 기법
알고리즘의 서술에 유용한 동작 표현 기법
정의된 순서 및 절차에 의해서 하드웨어의 동작을 표현
주로 프로세스문 내부의 순차문을 이용하여 동작 표현
26/37.
반가산기의 구현 예
거동 모델링(behavioral
모델링(b h i l modeling)
d li ) 기법
architecture Behave of HalfAdder is
begin
process(A, B)
begin
if A = '0' then
if B = '0' then
th S <= '0'
'0'; C <= '0'
'0';
else S <= '1'; C <= '0'; end if;
else
if B = '0' then S <= '1'; C <= '0';
else S <= '0';; C <= '1';; end if;;
end if;
end process;
end Behave;
27/37
반가산기의 구현 예
구조적 모델링(structural
모델링( t t l modeling)
d li ) 기법
상호 연결된 콤포넌트로 하드웨어의 동작을 표현
기존의 도면을 그리는 방법과 유사
콤포넌트 실체화문을 이용하여 동작 표현
mode
mode
. time_info .
Button
. Interface .
. up Time time_info .
Preset
up_pulse
Clock
Counter
set_pulse
28/37.
반가산기의 구현 예
구조적 모델링(structural
모델링( t t l modeling)
d li ) 기법
설계 완료된 and_gate
library IEEE;
use IEEE.std
.std_logic
og c_1164.all;
6 .a ;
eentity
t ty AND
N _GGATE iss
port ( A, B: in std_logic;
O : out std_
std logic);
og c);
end AND_GATE;
architecture Dataflow of AND_GATE
AND GATE is
begin
O <= A and B;
end Dataflow;
29/37
반가산기의 구현 예
구조적 모델링(structural
모델링( t t l modeling)
d li ) 기법
설계 완료된 xor_gate
library IEEE;
use IEEE.std
.std_logic
og c_1164.all;
6 .a ;
eentity
t ty XOR
O _GGATE iss
port ( A, B: in std_logic;
O : out std_
std logic);
og c);
end XOR_GATE;
architecture Dataflow of XOR_GATE
XOR GATE is
begin
O <= A xor B;
end Dataflow;
30/37
반가산기의 구현 예
구조적 모델링(structural
모델링( t t l modeling)
d li ) 기법
architecture Structure of HalfAdder is
component AND_GATE
port ( a, b: in std_logic;
o : out std_logic);
end component;
component XOR_GATE
port ( a, b: in std_logic;
o : out std_logic);
std logic);
end component;
begin
U0 : AND_GATE port map (a=>a, b=>b, o=>c);
U1 : XOR_GATE port map (a=>a, b=>b, o=>s);
end Structure;
31/37
구성(configuration)
구성 선언(configuration
선언( fi ti d
declaration)
l ti )
하나의 엔티티에 아키텍처 본체가 복수개 존재할 경우
하나의 아키텍처 본체를 해당 엔티티와 연결 짓는 작업
수행
별도의 라이브러리에 존재하는 콤포넌트를 연결 짓는 작
업 수행
32/37.
구성(configuration)
구성 선언의 BNF 정의
configuration_declaration ::=
configuration identifier of entity_name is
configuration_declarative_part
block_configuration
end [ configuration ] [ configuration_simple_name ] ;
configuration_declarative_part ::=
{ configuration_declarative_item
fi ti d l ti it }
configuration_declarative_item ::=
use_clause
l
| attribute_specification
33/37
구성(configuration)
구성 선언의 BNF 정의(계속)
block_configuration
g ::=
for block_specification
{ use_clause }
{ configuration_item }
end for ;
block_specification ::=
architecture_name
hi
| block_statement_label
configuration_item
fi i i ::=
block_configuration
| component_configuration
fi i
34/37
구성(configuration)
구성 선언의 사용 예 1
library IEEE;
use IEEE.std_logic_1164.all;
entity HalfAdder is
port (A, B: in std_logic; S, C : out std_logic);
end HalfAdder;
architecture
hit t D t fl off HalfAdder
Dataflow H lfAdd isi
begin
S <=
< A xor B; C < <= A and B;
end Dataflow;
g
configuration HalfAdder_Conf of HalfAdder is
for Dataflow
end for;
end configuration HalfAdder_Conf;
35/37
구성(configuration)
구성 선언의 사용 예 2
architecture Structure_View of Processor is
component ALU port ( ··· ); end component;
component MUX port ( ··· ); end component;
component Latch port ( ··· ); end component;
begin
A1: ALU port map ( ··· );
M1: MUX port map ( ··· );
M2: MUX port map ( ··· );
M3: MUX port map ( ··· );
L1: Latch port map ( ··· );
L2: Latch port map ( ··· );
end Structure_View;
36/37
구성(configuration)
구성 선언의 사용 예 2 - 계속
library TTL, Work;
configuration Processor_Conf1 of Processor is
use Work.all
for Structure_View
for A1: ALU
use configuration TTL.SN74LS181;
end for ;
for M1,M2,M3: MUX
use entity
y Multiplex4
p (Behavior);
( );
end for ;
for all: Latch
-- use defaults
end for ;
eend
d for
o ;
end configuration Processor_Conf1;
37/37