1 / 16

VHDL Package and Sub program

VHDL Package and Sub program. Library : package 나 컴파일 된 VHDL 모델의 저장 장소 library 예 > - work : 현재 실행중인 작업이 저장 되는 곳 - IEEE : std_logic_1164, std_logic_arith, std_logic_signed, std_logic_unsigned 등의 패캐지가 저장 되어 있는 곳 . Package : VHDL 코드의 저장장소 .

lucky
Download Presentation

VHDL Package and Sub program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VHDL Package and Sub program Library : package 나 컴파일 된 VHDL 모델의 저장 장소 library 예> - work : 현재 실행중인 작업이 저장 되는 곳 - IEEE : std_logic_1164, std_logic_arith, std_logic_signed, std_logic_unsigned 등의 패캐지가 저장 되어 있는 곳. Package : VHDL 코드의 저장장소. - 자료형(data type), 함수 (function), 프로시듀어(procedure), 컴포넌트 (component) 등을 한 장소(file)에 모아서 선언하고 이 패캐지는 다른 설계에서 불러내서 사용할 수 있다. - library 문에 종속된다. - 패캐지는 패캐지 선언과 몸체로 나누어 진다. Library and Package 예> Library ieee; -- IEEE package이 있는 library 이름 Use ieee.std_logic_1164.all; -- Ieee.std_logic_1164 package 사용

  2. VHDL Package and Sub program Package의 구성 : • 자료형 선언(data type declaration) • 상수 선언(constant declaration) • 신호 선언(signal declaration) • 부프로그램 선언(subprogram declaration) • 컴포넌트 선언(component declaration) • 부 프로그램 (subprogram) 구문 • ( 함수, 프로시듀어 ) Package declaration Package body *자료형과 상수만을 선언할 경우 package body 부분은 없어도 된다.

  3. VHDL Package and Sub program Package 선언 예 > LIBRARY IEEE; USE IEEE.std_logic_1164.all; PACKAGE gate_package IS component and_2 port(A, B : in std_logic; Y: out std_logic); end component; component or_2 port(A, B : in std_logic; Y : out std_logic); end component; component nand_2 port(A, B : in std_logic; Y : out std_logic); end component; component nor_2 port(A, B : in std_logic; Y : out std_logic); end component; component inv port(A : in std_logic; Y : out std_logic); end component END gate_package ; * and_2, or_2, nand_2, nor_2 Inv 에 대한 behavior description 파일은 미리 작성되어 있어야함

  4. VHDL Package and Sub program 다른 회로에서의 응용 예 > LIBRARY IEEE; USE IEEE.std_logic_1164.all; USE work.gate_package.all; ENTITY logic_system IS PORT(A, B, C : IN std_logic; X, Y : OUT std_logic); END logic_system; ARCHITECTURE structure OF logic_system IS signal aorb, bandc, cbar : std_logic; BEGIN gate0 : or_2 PORT MAP(A, B, aorb); gate1 : and_2 PORT MAP(B, C, bandc); gate2 : inv PORT MAP(C, cbar); gate3 : nand_2 PORT MAP(aorb, cbar, X); gate4 : nor_2 PORT MAP(bandc, cbar, Y); END structure;

  5. VHDL Package and Sub program Package에서 component 문 지정 사용형식 package 패키지_이름 is component 컴포넌트_이름 port( 포트신호_이름); end component; end 패키지_이름; 사용예 package full_adder_package is component full_add port( X, Y, Ci : in std_logic; S, Co : out std_logic ); end component; end full_adder_package;

  6. Logic_system 구조도 Gate0: OR_2 Gate3: NAND_2 aorb Gate1: and_2 bandc Gate4: NOR_2 Gate2: INV cbar VHDL Package and Sub program

  7. VHDL Package and Sub program • Subprogram : • 여러 번 반복 사용되는 부분을 하나의 모듈로써 지정하고, 필요 시마다 • 불러내어 사용하는 VHDL 문장 블록 • 서브프로그램 이름과 매개 변수를 이용하여 호출함으로써 서브프로그램을 • 실행하고 계산된 결과를 반환 받는다 • 서브프로그램으로는 procedure 와 function 이 있다. • procedure는 다수의 매개변수를 이용하여 다수의 문장을 처리한 후 얻어 • 지는 결과를 반환 받는 반면에 function은 하나의 함수식에 대한 한 변수의 처리결과 를 반환 받는다. • - Sub program의 위치는 Architecture 내의 선언부, Process 문장 선언부, Package 문장 선언부 내에 기술 가능하다.

  8. VHDL Package and Sub program Procedure 와 function 의 차이점

  9. VHDL Package and Sub program • Subprogram 호출 방식 • - 순차 호출(Sequential Call) 순차문 내에서의 호출 (Process) • - 병행 호출(Concurrent Call) 병행처리문 내에서의 호출 (architecture) • - 매개변수의 mode 가 in 인 경우 : 상수 객체로 가정 • out, inout 인 경우 : 변수 객체로 가정 • - 매개 변수로써 변수, 상수는 사용가능하나 signal 은 사용 불가능 • - procedure 에서 반환값은 mode 가 out 인 매개변수로 정의 • - procedure는 순차호출만 가능, function은 순차/병행 호출 가능 • - function 에서 모든 매개변수는 상수 값

  10. VHDL Package and Sub program • Function 선언 형식 : • function 함수_이름(매개변수_리스트) return 반환값_자료형; • Function 몸체 형식 : • function 함수_이름(매개변수_리스트) return 반환값_자료형 is • [ 선 언 문 ] • begin • [ 순 차 문 ] • end 함수_이름

  11. VHDL Package and Sub program Function 선언 형식 예> architecture a of test is function or4bit(x,y: in std_logic_vector) return std_logic_vector is variable temp : std_logic_vector(3 downto 0); begin temp := x or y ; return(temp); end or4bit; begin y <= or4bit(a,b); end a; 함수 선언 (몸체 형식) 함수 call • a, b 는 entity 에서 a, b : in std_logic_vector(3 downto 0)으로 기 지정되어야 함 • 함수 선언문에서는 Variable만 선언이 가능

  12. VHDL Package and Sub program • Procedure 선언 형식 : • Procedure 프로시듀어_이름(매개변수_리스트) return 반환값_자료형; • Procedure 몸체 형식 : • Procedure 프로시듀어_이름(매개변수_리스트) return 반환값_자료형 is • [ 선 언 문 ] • begin • [ 순 차 문 ] • end 프로시듀어_이름

  13. VHDL Package and Sub program Procedure 사용 예> library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity bin_adder is port(A, B : in std_logic_vector(3 downto 0); S : out std_logic_vector(4 downto 0)); end bin_adder; architecture behav of bin_adder is procedure add(a, b : in std_logic_vector; c : out std_logic_vector) is -- add procedure declaration begin c := a + b; end add; begin process(A, B) variable sum : std_logic_vector(4 downto 0); begin add(A, B, sum); -- add 호출 S <= sum; end process; end behav;

  14. VHDL Package and Sub program Generic statement (범용문) 회로의 입출력 개수를 매개변수(parameter)에 의해 결정하도록 한다. 사용형식 entity 엔티티_이름 generic(범용문_이름); port(포트신호_이름); end 엔티티_이름; 사용 예> entity a is generic(n:integer :=4); port(X:in std_logic_vector(1 to n); Y:out std_logic_vector(1 to n) ); end a;

  15. Attribute (속성) * Brain world VHDL 자료 참조

  16. Attribute (속성) * Brain world VHDL 자료 참조

More Related