Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch2-2. VHDL Basic VHDL lexical element VHDL description

Similar presentations


Presentation on theme: "Ch2-2. VHDL Basic VHDL lexical element VHDL description"— Presentation transcript:

1 Ch2-2. VHDL Basic VHDL lexical element VHDL description
VHDL data type and object HDL attribute VHDL operator VHDL statement (1)

2 VHDL 어휘 요소 1-1.주석문 (comment)
프로그램의 부가적인 설명을 위한 문장으로 프로그램의 동작 에는 영향이 없다. 주석문은 연자부호(-)를 연속적으로 2개 사용 “- -” 하여 프로그램과 분리한 후 문장을 기술한다. 예) Entity AND_OR is Entity declaration port( A, B, C : in std_logic; input port Y : out std_logic ); output port End AND_OR;

3 VHDL 어휘 요소 1-2. 식별어 (identifier) 사용자가 지정하는 이름으로, 신호이름, 변수이름, 엔티티 이름
사용자가 지정하는 이름으로, 신호이름, 변수이름, 엔티티 이름 등을 말하고, 프로그램상의 지정어와 구분된다. 예) entity andg is -- black character is identifier Generic( tphz, tplz : time :=3 ns; default_value: integer: =1); port(a, b : in bit; z : out bit); end andg; 식별어는 영문자(a~z, A~Z), 숫자(0~9), 그리고 밑줄(_)로 구성한다. 반드시 영문자로 시작한다. 식별어는 밑줄(_)로 시작 하거나 끝이 나면 안된다. 연속적으로 밑줄을 포함해서는 안된다. 공백을 가지지 않으며 대소문자 구별은 없다.

4 VHDL 어휘 요소 1-3. 지정어 (reserved word, keywords)
지정어의 종류> ABS, ACCESS, AFTER, ALIAS, ALL, AND, ARCHITECTURE, ARRAY, ASSERT, ATTRIBUTE, BEGIN, BLOCK, BODY, BUFFER, BUS, CASE, COMPONENT, CONFIGURATION, CONSTANT, DISCONNECT, DOWNTO, ELSE, ELSEIF, END, ENTITY, EXIT, FILE, FOR, FUNCTION, GENERATE, GENERIC, GUARDED, IF, IN, INOUT, IS, LABEL, LIBRARY, LINKAGE, LOOP, MAP, MOD, NAND, NEW, NEXT, NOR, NOT, NULL, OF, ON, OPEN, OR, OTHERS, OUT, PACKAGE, PORT, PROCEDUR, PROCESS, RANGE, RECORD, REGISTER, REM, REPORT, RETURN, SELECT, SEVERITY, SIGNAL, SUBTYPE, THEN, TO, TRANSPORT, TYPE, UNITS, UNTIL, USE, VARIABLE, WAIT, WHEN, WHILE, WITH, XNOR, XOR

5 VHDL 어휘 요소 1-4. 리터럴 (literal) 수치값을 표현하기 위해 사용하며 정수(integer)과 실수(real) 리터럴이 있다. 또한 2진수, 8진수, 16진수도 표현 가능하다. “_” 밑줄기호를 사용하여 긴 숫자를 구분할 수 있다. 예) 정수리터럴 > 0, 234, 3445 실수리터럴 > 0.0, 32.45, 진수 > 2#101023#, 2#100001# 8진수 > 8# 23525#, 8#34247# 16진수 > 16#AD324#, 16#14AB3# > 314_245_235_423 2# # > 2#1001_0001_1110# - 진수의 표현에는 #의 기호를 사용하며 #기호를 수의 앞,뒤에 두고 # 기호 앞에는 진수의 종류를 표시한다.

6 VHDL 어휘 요소 1-5. 문자, 문자열, 비트문자열 문자(Characters) : 문자열(Strings)
하나의 문자로 표현하며 단일 인용부호 ‘ ‘ 를 사용 예) ‘A’, ‘c’, ‘0’, ‘1’ 문자열(Strings) 2개 이상의 문자들로 구성된 문자 배열로 이중 인용부호“ “사용 예) “string s”, “111000”, “234 ABC” 비트 문자열(Bit Strings) 비트열을 2/8/16 진수 형태의 문자열로 표현하며 ”비트열”앞에 진수표시 문자(b/o/x)을 지정하고 사용한다. 예) b”001_0000”, o”67432”, x”A3D”

7 VHDL Description 2. Entity and Architecture description
- Entity : 회로의 Input, Output 등을 선언 - Architecture : 회로의 동작 및 상호 연결을 기술 (VHDL description) Entity와 Architecture는 쌍으로 표현한다 상위 묘듈과 이에 포함된 하위의 모듈들을 표현할 때, 상위모듈도 Entity-Architecture 쌍으로, 하위 모듈들도 Entity-Architecture쌍으로 표현하여 준다.

8 VHDL Description Entity : 1. 회로블록의 이름을 정의, I/O 인터페이스 정의 디자인 파라미터의 전달
3. Generic 선언 형식 4. Port 선언 형식 ENTITY 엔티티_이름 IS GENERIC (파라미터_리스트 ); PORT(포트_리스트); END 엔티티_이름; GENERIC ( 신호_이름,.. : [모드] 자료형[:=표현] ; … ); PORT ( 신호_이름,.. : [모드] 자료형[:=표현] ; … );

9 Entity and Architecture
Entity description 예) entity andg is Generic( tphz, tplz : time :=3 ns; -- tphz, tplz에 상수값 지정 default_value: integer: =1); -- default_value 에 상수값 지정 port(a, b : in bit; in 은 모드, bit는 a, b의 자료형 z : out bit); out 은 모드, bit는 z의 자료형 end andg; A Z B

10 VHDL Description Mode의 종류: In, Out, Inout, buffer
TYPE (data type) : 모든 신호는 자료형을 가져야 한다. 신호가 1개인 경우 : bit, std_logic 으로 표현 신호가 2개 이상인 경우 : bit_vector, std_logic_vector 로 표현 예) 4비트 표현 : bit_vector(0 to 3), bit_vector(3 downto 0) * std_logic 표현을 사용하기 위해서는 다음의 문장을 entity 이전에 표현 해 주어야 한다. Library ieee; Use ieee.std_logic_1164.all;

11 Entity and Architecture
4-bit 전 덧셈기 Entity Adder4 is port (A, B : in bit_vector(3 down to 0); Co : in bit; -- input S: out bit_vector(3 down to 0); Cj : out bit ); --output End Adder4 ;

12 Entity and Architecture
내부동작, 연결, 구조를 기술 2. architecture 선언형식 ARCHITECTURE 아키텍쳐_이름 OF 엔티티_이름 IS { 선언부 } BEGIN { 병행문 } END 아키텍쳐_이름; Architecture 예) architecture sample of andg is begin z <= a and b; end sample;

13 Entity and Architecture
선언부 : 문장부에서 사용하는 신호, 변수, 상수 등을 정의하는 영역 1. 자료형 선언(Data type declaration) 2. 상수 선언(constant declaration) 3. 신호 선언(signal declaration) 4. 컴포넌트 선언(component declaration) 병행문 : 논리회로의 내부 동작이나 구조를 묘사한 병행 문장을 포함하는 영역 1. 컴포넌트 사례화문 (component instantiation statement) 2. 병행 할당문 (concurrent assignment statement) 3. 생성문 (generate statement) 4. 프로세스문 (process statement)

14 Entity and Architecture
Entity Adder4 is port (A, B : in bit_vector(3 down to 0); Ci : in bit; -- input S: out bit_vector(3 down to 0); Co : out bit ); --output End Adder4 ; Architecture structure of Adder 4 is component Fulladder component declaration port (x, y, cin : in bit ; input cout, sum : out bit) ; output end component ; signal C : bit_vector (3 down to 1) ; signal declaration Begin component instantiation statement FA0 : Fulladder port map (A(0), B(0), Ci, C(1), S(0) ); FA1 : Fulladder port map (A(1), B(1), C(1), C(2), S(1) ); FA2 : Fulladder port map (A(2), B(2), C(2), C(3), S(2) ); FA3 : Fulladder port map (A(3), B(3), C(3), Co, S(3) ); End Structure ;

15 Entity and Architecture

16 Entity and Architecture
다음은 어떤 gate 를 나타내는 VHDL 구문인가 ? OR gate에 대하여 VHDL 구문을 완성하라. Library ieee; Use ieee.std_logic_1164.all; Entity and_2 is port( a, b : in std_logic; y : out std_logic ); end and_2; Architecture dataflow of and_2 is begin y <= a and b; end dataflow;

17 Entity and Architecture
MAX-PLUSII 실행결과

18 Entity and Architecture
Sequential statement (순차문) 문장들이 하나씩 차례로 수행되는 문 문장들이 순차적으로 수행되기 위해서 process statement 사용 Process statement의 begin ~ end 내부에서 순차적으로 한 문장씩 수행 Concurrent statement (동시진행문, 병행문) 문장들이 프로그램내의 순서에 상관없이 동시에 병행적으로 수행되는 문 Process statement 자체는 동시 진행문으로서 여러 개의 process 문이 있으면 동시에 수행 예) A, B, C, D 의 초기값이 1,2,3,0 인 경우 10ns 후 D가 4로 변한다. A <= B ; B <= C ; C <= D ; Time A B C D

19 Data type and Object 3.1 Data type (자료형) : 신호, 변수, 상수의 형식 Scalar Type
정수형(integer type) : 부울형(Boolean type) 열거형(enumeration type) IEEE 1164 표준 자료형(IEEE 1164 standard type) 부동 소수점 형 Composition Type 배열형 레코드형

20 Data type and Object Data type 의 지정 : TYPE 자료형_이름 IS 자료형_서술;
SUBTYPE 부자료형_이름 IS 기본자료형 표현범위; 예) TYPE Bit_3 IS (‘0’, ‘1’, ‘Z’); -- 열거형 자료 선언 TYPE Digit IS (Integer range 0 to 7); -- 사용자 지정형 선언 TYPE A_NUMBER IS (integer range 0 to 287); --사용자 지정형 선언 TYPE boolean is (false, true); --부울형 선언 TYPE state_type is (S0, S1, S2, S3, S4); --열거형 선언 SUBTYPE WORD IS STD_LOGIC_VECTOR(15 DOWNTO 0); SUBTYPE BYTE is STD_LOGIC_VECTOR(7 DOWNTO 0); SUBTYPE Part_number is A_number range 0 to 15;

21 Data type and Object Integer type (정수형)
32 비트 크기의 정수를 표현 ~ +(231-1) = ~ 음의 정수는 2의 보수로써 표현 Boolean type (부울형) 참(True) : 1, 거짓(False) : 0 의 두 가지 값을 가진다 Enumeration type (열거형) 신호, 변수등이 가질수 있는 값을 나열하여 정의 TYPE State_type IS (stateA, stateB, stateC); TYPE Bit_2 IS (‘0’, ‘1’); TYPE Bit_3 IS (‘0’, ‘1’, ‘Z’); TYPE Bit_4 IS (‘0’, ‘1’, ‘X’, ‘Z’ ); Floating Type (부동소수점형) standard: -1.0E38 to 1.0E38 의 수 표현

22 Data type and Object IEEE 1164 Standard Data Types Bit, Bit_vector
Bit object : ‘0’ 또는 ‘1’ Bit_vector object : Bit object의 배열 ‘0’과 ‘1’만으로 표현하므로 high impedance 표현을 하지 못함. Std_logic, std_logic_vector IEEE 1164에 이미 정의된 자료형 Std_logic object : ‘0’, ’1’, ’Z’, ’-’, ’L’, ’H’, ’U’, ‘X’, ‘W’ Std_logic_vector object : std_logic object의 배열 Signed, unsigned (부호형,비부호형) Signed 자료형 : signed number 연산 Unsigned 자료형 : unsigned number 연산 library package : library ieee; use ieee_std_logic_arith.all;

23 Data type and Object Std_logic object 의 종류 : ‘0’ : Strong Logic 0
‘L’ : Weak Logic 0 ‘H’ : Weak Logic 1 ‘Z’ : High Impedance ‘X’ : Strong Unknown ‘W’ : Weak Unknown ‘U’ : Un-initialized ‘-’ : Don’t Care 사용예) type Bit_4 is (‘0’, ‘1’, ‘X’, ‘Z’ ); signal A : bit_4; A <= ‘Z’

24 Data type and Object signal : 시간에 따라 값이 변하는 변수, 외적변수
Object : signal, variable, constant 와 같이 어떤 값을 가지고 있는 것을 객체 (object)라고 한다. Object는 각각의 형식 (data type) 을 가진다 signal : 시간에 따라 값이 변하는 변수, 외적변수 variable : 계산 결과에 따라 값이 변하는 변수, 내적 변수 constant : 값이 시간과 계산결과에 상관 없이 값은 일정

25 Data type and Object Signal : 논리회로에서 신호 또는 선 (wire)를 나타내며, 각 컴포넌트간의 연결에 사용되는 외적 변수이다. 신호의 할당은 “<=“ (할당 연산자)를 사용하고 신호가 정의는 entity 선언부, architecture의 선언부, package의 선언부에서 모두 가능하다. 예) signal A, B, C : bit signal D : bit_4 signal X : stand_logic signal Y : stand_logic_vector (1 to 4) signal Z : stand_logic_vector (7 downto 0) A <= ‘1’;, D <=‘1’;, X <=‘0’;, Y <= “1001”;, Z<=“ ”;

26 Data type and Object Variable : 임의의 계산에서 결과를 가질 때 사용하므로, 결과를 임시 저장하는 역할을 한다. 이 변수는 프로세스문 또는 부 프로그램 내에서만 유효한 내적 변수이다. Variable에 값을 주기 위한 할당 연산자는 “:=“ 이다. 예1) variable A : integer; variable B : std_logic; variable C : std_logic_vector(7 to 0); ~ A := 3;, B := ‘1’;, C := “0100_1000”; 예2) process (x) variable ABC : std_logic; begin ABC := x(0); ABC := x(1) and ABC; ABC := x(2) and ABC; ABC := x(3) and ABC; Y <= not(ABC); end process;

27 Data type and Object Constant : 값이 변하지 않는 객체, 초기에 선언한 값을 유지하는데 사용한다.
상수의 초기값은 즉시 대입되며, 한번 대입되면 이후 변경이 불가능하다. Constant 에 값을 주기 위한 할당자로는 Variable과 마찬가지로 “:=“를 사용한다. 예) constant Weight : integer := 256; constant sig2 : std_logic_vector:=“0000_0000”; constant dealy1 : time:= 5 ns; Data type으로 time 을 자정할 수 있는 데 이때 값은 fs, ps, ns, ms, sec, min, hr을 단위로 하는 정수이다.


Download ppt "Ch2-2. VHDL Basic VHDL lexical element VHDL description"

Similar presentations


Ads by Google