Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. VHDL과 합성 설계 1.1 HDL: Hardware Description Language 집적회로의 설계환경의 변화

Similar presentations


Presentation on theme: "1. VHDL과 합성 설계 1.1 HDL: Hardware Description Language 집적회로의 설계환경의 변화"— Presentation transcript:

1 1. VHDL과 합성 설계 1.1 HDL: Hardware Description Language 집적회로의 설계환경의 변화
설계규모의 대형화 및 복잡화 추세 - 간결한 하드웨어 표현 - 편리한 문서화 - 설계 정보의 교환 - 상위 레벨에서의 설계 자동화 필요 - 설계 자동화 도구의 변화 : 모델링, 합성, 검증, 설계 모듈 관리 HDL의 예 - C, AHPL, CDL, IDL, TI-HDL, UDL 등 - VHDL, Verilog-HDL

2 1.2 VHDL의 등장과 특징 VHDL(VHSIC HDL)의 출현
년 6월 미국 Woods Hole에서 개최된 하드웨어 기술언어 Workshop에서 미국방성의 VHSIC(Very High Speed Integrated Circuit) 프로그램에서 요구되는 HDL사양을 근간으로 하는 미국방성의 HDL 요건(Department of Defense Requirements for HDL)이라는 공식 문건을 발간 VHDL개발의 근간 년 7월 Intermetrics, IBM, Texas Instruments 사로 구성된 공동 개발팀 구성 년 VHDL 7.2 Version 탄생 초기개발 목적을 설계의 문서화와 시뮬레이션에 둠 년 12월 IEEE 1076 표준 탄생 미국방성과의 계약 체결 뿐만 아니라 산업체에서의 상업용으로 사용할 수 있도록 확장 년 IEEE 1076에 추가적으로 합성기능의 강화 관련 CAD 업체의 본격적인 합성 도구 개발이 시작 년 미 정부지원 공인 HDL로 VHDL을 지정 년 VHDL응용과정에서의 추가요건을 반영한 IEEE - 국내외적으로 VHDL의 사용이 확대되고 있으며 VHDL 시뮬레이터 및 합성을 대부분의 설계자동화 도구에서 지원

3 VHDL을 이용한 설계의 특징 - 설계 싸이클의 단축 : 초기 설계과정에서의 설계 오류 수정
합성 설계에 의한 도면 생성 및 관리 작업의 불필요 설계 변경의 용이 - 설계의 질 향상 : 다양한 설계기법의 검색에 의한 최적해 도달 선택적 최적화 기법을 이용한 합성 설계 - Technology에 무관한 description 및 설계 : 특정 ASIC 제조업체 및 특정 구현 기술과 무관하게 초기 설계 및 기술 가능 ( 설계 싸이클의 마지막에 고려) 동일한 VHDL 설계의 다른 라이브러리를 이용한 합성 신속한 칩 원형화 (rapid prototyping) 가능 - 낮은 설계 비용 : 상위레벨 설계 도구의 사용에 따른 설계 생산성 향상 설계 기간 단축에 따른 설계 비용 감소 설계의 재사용에 의한 설계 비용의 감소

4 (Application Specific IC)
- 표준 HDL 및 사용의 확대 : IEEE 표준인 동시에 미국 정부의 공인 HDL 전세계적으로 설계 및 설계정보 교환의 수단으로 사용이 점차적으로 확대 - 기술에 따른 성장 : 반도체 기술 및 ASIC 기술 발전에 따른 VHDL 합성설계 도구의 기능 및 능력의 확장 - 효과적인 설계관리 : VHDL 언어의 structured design 기능을 이용한 전체 설계의 기능별 분할 설계 및 설계의 관리 및 문서화 용이 IC 제조 기술 발전 ASIC (Application Specific IC) 등장 설계 도구 성능 향상 -주문형( semi-custom ) 반도체 -소량 ( application specific ) -개발 기간 단축 ( shorter design turnaround time (DAT) )

5 1.3 VHDL과 ASIC 설계 환경 가. 합성 가능한 함수 및 합성 원칙 합성 가능한 함수
가. 합성 가능한 함수 및 합성 원칙 합성 가능한 함수 - ASIC설계를 사용한 디지털 시스템은 일반적으로 랜덤 로직, 메모리, 그리고 megafunction 등으로 이루어짐 - 랜덤 로직 회로 설계는 게이트나 플립플롭과 같은 primitive logic cell을 building block으로 하여 논리합성함이 효율적이다 - RAM이나 ROM과 같은 규칙적인 구조의 메모리의 설계는 일반적으로 전용 컴파일러를 사용함이 적절하다 - 합성 가능한 조합형 논리 함수 예: Multiplexer, Decoder, Encoder, Comparator, Adder/Subtractor, ALU, Multiplier, Lookup table, Parity generator, PLA, Gates 등 - 합성 가능한 순차형 논리 함수 예: 각종 Counter, Register, Latch, Parallel/Serial converter, Sequencer, Controller, Finite state machine, Synchronizer 등

6 circuit design with HDL logic synthesis simulation VHDL 합성의 필요성 회로가 점차
netlist 자동 추출. DAT 단축 언어로 기술할 경우 회로 복잡도에 상관없음. 회로가 점차 복잡해짐 잦은 설계 변경 용이. 성능 평가 logic synthesis 초기 설계 단계에서 오류 검출 simulation

7 - VHDL 합성설계 방식은 VHDL로 설계를 기술하고 시뮬레이션하며
방식이다 1) 합성회로의 결과는 VHDL 표현방식에 따라 크게 좌우된다. 즉, VHDL 기술방식에 따라 합성된 결과 회로는 기능은 동일하더라도 게이트의 수 또는 critical path, 그리고 회로의 구조 등이 다를 수 있다 자신이 원하는 논리구조로 합성해 낼 수 있도록 VHDL 코딩 할 수 있어야 한다. 2) 시뮬레이션 가능한 모든 VHDL code 모두 합성 가능한 것은 아니다. 일반적으로 합성 가능한 code는 RTL(Register Transfer Level) 기술로 하여야 하며 tool dependent 하다. 3) 합성 설계를 성공적으로 수행하기 위해서는 논리회로 설계 기법에 익숙하고 ASIC 설계 경험 또한 풍부하여야 한다 4) VHDL test bench를 이용하여 합성 전후의 효과적인 시뮬레이션을 수행함이 바람직하다

8 Technology Targeting & Synthesis
나. ASIC 설계 프로세스 System Design & Partitioning 기본적인 시스템 요건 분석 적용 가능한 알고리즘의 분석 하드웨어, 소프트웨어 설계 분할 ASIC의 설계 사양 및 블록도 ASIC의 논리함수 구현 방법 시스템 인터페이스 방식 등 ASIC Block Diagram & Specification VHDL 모델링, RTL 시뮬레이션 설계의 수정 및 설계최적화 Technology Targeting & Synthesis Logic Design Logic Simulation 게이트 레벨 시뮬레이션 Layout 및 배선 타이밍분석, 설계규칙 검사 전기규칙검사 및 I/O 핀 할당 Pre and Post-Layout Verification Prototype ASIC Fabrication & Test

9 다. 논리회로 설계 흐름도의 비교 Schematic Entry VHDL Coding Netlist Generation
다. 논리회로 설계 흐름도의 비교 Schematic Entry VHDL Coding Netlist Generation RTL Level VHDL Simulation Gate Level Logic Simulation Logic Synthesis A) 기존의 게이트 레벨 논리회로 B) VHDL 합성을 이용한 논리회로 설계 흐름도 설계 흐름도

10 2. VHDL 합성설계의 기본과 Coding Issues 2.1 4가지 VHDL code 예
- D flip flop, Latch, AND 게이트, Multiplexer의 예를 통하여 비슷한 VHDL 기술 스타일과 원하는 합성 회로의 차이를 유의하여야 한다. 가. D Flip Flop entity D_FF is port( b, c : in bit; qout : out bit); end D_FF; architecture test of D_FF is begin process wait until clk’event and clk = ‘1’; qout <= b; end process; end test; b D Q clk qout c

11 나. Latch entity D_Latch is port(data, enable : in bit;
qout : out bit); end D_Latch; architecture test of D_Latch is begin process(data, enable) if (enable = ‘1’) then qout <= data; end if; end process; end test; data D Q Enable qout enable

12 architecture test of AND2 is begin process if (c = ‘1’) then
entity AND2 is port( b, c : in bit; and_out : out bit); end AND2; architecture test of AND2 is begin process if (c = ‘1’) then and_out <= b; else and_out <= ‘0’; end if; end process; end test; b and_out c

13 architecture test of MUX is begin process case s is
라. 2 x 1 Multiplexer entity MUX is port( b, c, s : in bit; mux_out : out bit); end MUX; architecture test of MUX is begin process case s is when ‘0’ <= mux_out <= b; when ‘1’ <= mux_out <= c; end case; end process; end test; b 1 select mux_out c s 주의 : 위와 같이 s의 값이 ‘1’이 아닐 때 출력의 값이 분명히 명시가 되어 있으면 멀티플렉서가 합성되지만 그렇지 않을 경우 출력은 이전 값을 유지하는 latch가 합성된다

14 2.2 일반적인 VHDL Coding Issues 가. VHDL Types
- 설계 hierarchy 상에서 서로 다른 레벨에서 합성된 netlist를 통합하고 자 할 때 변환함수(conversion function)의 사용을 피하기 위해서는 entity 에서의 port 선언을 위해서 std_logic 자료형(type)을 사용하는 것이 좋다. - 자료형의 일관성을 유지하기 위하여 자료형 ‘buffer’의 사용을 피하 는 것이 좋다. 아래의 예는 내부 signal을 이용하여 자료형 ‘buffer’의 사용을 피하는 효과적인 방법을 보여 준다. entity buf is port ( a, b : in std_logic ; c : out std_logic ); end buf ; architecture Behavioral of buf is signal c_int : std_logic ; begin process c_int <= a + b + c_int ; end process c <= c_int ; end Behavioral;

15 나. Signals and Variables
- 시뮬레이션시 Signal은 값이 update 될 때 delta time이 있지만 Variable은 delay 없이 즉시 값이 바뀐다. - Variable을 사용시 시뮬레이션은 빨라지지만 설계의 기능성에 영향을 미칠 수 있는 glitch의 검출을 놓칠 수 있다. - Variable은 시뮬레이션 중 예상치 않은 결과를 발생시킬 가능성이 높다 다. Priority Encoding Structure - 통상 ‘if’ 문의 조건문 순위는 회로 합성시 priority encoding 회로로 추론 된다. 따라서, 이를 피하기 위해서는 ‘case’ 문을 사용하여야 한다. VHDL 예제 : 두개의 load signal을 갖는 8-비트 카운터를 모델링하고자 한다. Signal ‘load0’가 active 일 때 bus의 하위 4비트가 카운터의 하위 4비트로 load 되고, signal ‘load1’이 active 일 때 bus의 상위 4비트가 카운터의 상위 4비트로 load 되며, 그 이외의 경우는 카운터가 가산을 한다. load1 load0 MSB LSB 8-비트 카운터 8-비트 BUS

16 Library IEEE use IEEE.std_logic_1164.all ; use IEEE.std_logic_unsigned.all ; entity ld_cnt is port ( load : in std_logic_vector(1 downto 0) ; databus : in std_logic_vector(7 downto 0) ; clk : in std_logic ; count : out std_logic_vector(7 downto 0) ; end ld_cnt ; architecture behavior of ld_cnt is signal int_cnt : std_logic_vector(7 downto 0) ; begin count <= int_cnt ; process wait until clk=‘1’ and clk’event ; if(load = “10”) then int_cnt <= databus(7 downto 4) & int_cnt(3 downto 0) ; elsif (load = “01”) then int_cnt <= int_cnt(7 downto 4) & databus(3 downto 0) ; else int_cnt <= int_cnt + 1 ; end if ; end process ; end behavior ;

17 - 동기식 reset 신호를 갖는 회로는 ‘if’ 문이 클록문(clock statement) 이
라. 원치 않는 Latches - 원치 않는 Latch가 합성되지 않게 하기 위해서는 ‘if’ 문과 ‘case’ 문의 기술시 모든 조건을 빠짐없이 포함시켜야 한다 (2.1 참조) 마. 동기식과 비동기식 Resets - 동기식 reset 신호를 갖는 회로는 ‘if’ 문이 클록문(clock statement) 이 후에 나타나야 하며, 비동기식 reset 신호를 갖는 회로는 ‘if’ 문이 클 록문 이전에 나타나야 한다. 비동기 reset 신호를 갖는 설계의 예: entity test_reset is port ( X, clk, rst : in bit ; Z : out bit ) ; end test_reset ; architecture behavior of test_reset is type state is (S0, S1, S2, S3); signal ST: state; begin

18 process begin if rst = ‘0’ then ST <= S0 ; Z <= ‘0’ ; elsif clk’event and clk = ‘1’ then if X = ‘0’ then Z <= ‘0’ ; else case ST is - end case ; end if ; end process ; end behavior ; 동기 reset 신호를 갖는 설계 : architecture behavior of test_reset is wait until clk’event and clk = ‘1’ ; if rst = ‘0’ then ST <= S0 ; Z <= ‘0’ ; elsif X = ‘0’ then Z <= ‘0’ ; -- 이후의 기술은 비동기식에서의 예와 같음 --

19 - 3장에서의 기본 논리회로의 VHDL 합성설계의 예는 주로 LODECAP
3. 기본 논리회로의 설계 예 - 3장에서의 기본 논리회로의 VHDL 합성설계의 예는 주로 LODECAP 에서의 Sample 들과 기타 기본 회로들로 구성하였다. 3.1 조합회로의 예 가. Multiplexer Ô 2-way 2 x 1 multiplexer : <muxType1.vhd> library IEEE; use IEEE.std_logic_logic_1164.all; use IEEE.std_logic_signed.all; entity muxType1 is port(a, b : IN std_logic_vector(1 downto 0); s : IN std_logic; z : OUT std_logic_vector(1 downto 0)); end muxType1; architecture RTL of muxType1 is signal TMP : std_logic_vector(1 downto 0); begin z <= a when s = ‘0’ else b; end RTL; a 2 2 2 x 1 MUX z b 2 s

20 4 x 1 MUX library IEEE; use IEEE.std_logic_signed.all; a z
VHDL과 디지털회로설계 Ô 2-way 2 x 1 multiplexer : <muxType2.vhd> library IEEE; use IEEE.std_logic_signed.all; entity muxType2 is port(a, b : IN std_logic_vector(1 downto 0); s : IN std_logic; z : OUT std_logic_vector(1 downto 0)); end muxType2; architecture RTL of muxType2 is signal TMP : std_logic_vector(1 downto 0); begin process(a, b, s) if s = ‘0’ then z <= a; else z <= b; end if; end process; end RTL; 4 x 1 MUX 2 a 2 z 2 b s

21 VHDL과 디지털회로설계 그림 1. Muxtype2의 합성 회로

22 VHDL과 디지털회로설계 그림 2. Muxtype2의 시뮬레이션 결과

23 4 x 1 MUX library IEEE; use IEEE.std_logic_1164.all;
VHDL과 디지털회로설계 Ô 2-way 4 x 1 multiplexer : <muxType3.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity muxType3 is port(a, b, c, d : IN std_logic_vector(1 downto 0); s : IN std_logic(1 downto 0); z : OUT std_logic_vector(1 downto 0)); end muxType3; architecture RTL of muxType3 is begin process(a, b, c, d, s) case s is when “00” => z <=a; when “01” => z <=b; when “10” => z <=c; when “11” => z <=d; when others => z <=“00”; end case; end process; end RTL; 4 x 1 MUX 2 s(1:0) a b d z c

24 4 x 1 MUX Ô Enable 갖는 4-way 4 x 1 multiplexer : <mux4.vhd>
VHDL과 디지털회로설계 Ô Enable 갖는 4-way 4 x 1 multiplexer : <mux4.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity MUX4 is port(l0, l1, l2, l3 : IN std_logic_vector(3 downto 0); ENABLE : IN std_logic; SEL : IN std_logic_vector(1 downto 0); Y : OUT std_logic_vector(3 downto 0)); end MUX4; architecture RTL of MUX4 is begin process ( SEL, ENABLE, l0, l1, l2, l3) if ENABLE = ‘0’ then case SEL is when “00” => Y <= l0; when “01” => Y <= l1; when “10” => Y <= l2; when others=> Y <= l3; end case; else Y <= “0000”; else if; end process; end RTL; ENABLE 4 x 1 MUX 4 2 SEL(1:0) I0 I1 I3 Y I2

25 VHDL과 디지털회로설계 그림 3. 4x1 Multiplexer 의 합성 회로

26 그림 4. 4x1 Multiplxer의 시뮬레이션 결과
VHDL과 디지털회로설계 그림 4. 4x1 Multiplxer의 시뮬레이션 결과

27 나. Decoder 회로 decoder1 Ô 2-to-4 decoder <decoder1.vhd>
VHDL과 디지털회로설계 나. Decoder 회로 Ô 2-to-4 decoder <decoder1.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity decoder1 is port(a : IN std_logic_vector(1 downto 0); d : OUT std_logic_vector(3 downto 0)); end decoder1; architecture RTL of decoder1 is begin process case a is when “00” => d <= “0001”; when “01” => d <= “0010”; when “10” => d <= “0100”; when others => d <= “1000”; end case; end process; end RTL; decoder1 2 4 a d

28 VHDL과 디지털회로설계 그림 7. Decoder1의 합성 회로 그림 8. Decoder1의 시뮬레이션 결과

29 BCD-to-7 Segment Decoder
VHDL과 디지털회로설계 Ô BCD-to-7segment decoder <BCD_7.vhd> y(6) BCD-to-7 Segment Decoder G G y(5) F y(4) F B E 4 y(3) A D y(2) BCD_data C E C y(1) B D y(0) A library IEEE; use IEEE.std_logic_1164.all; entity BCD_7 is port(BCD_data : IN std_logic_vector(3 downto 0); Y : OUT std_logic_vector(6 downto 0)); end BCD_7;

30 architecture RTL of BCD_7 is begin process(BCD_data)
VHDL과 디지털회로설계 architecture RTL of BCD_7 is begin process(BCD_data) case BCD_data is when “0000” => Y <= “ ”; when “0001” => Y <= “ ”; when “0010” => Y <= “ ”; when “0011” => Y <= “ ”; when “0100” => Y <= “ ”; when “0101” => Y <= “ ”; when “0110” => Y <= “ ”; when “0111” => Y <= “ ”; when “1000” => Y <= “ ”; when “1001” => Y <= “ ”; when others => Y <= “ ”; end case; end process; end RTL;

31 VHDL과 디지털회로설계 그림 9. BCD_7의 합성 회로 그림 10. BCD_7의 시뮬레이션 결과

32 library IEEE; encoder a(3) use IEEE.std_logic_1164.all; z(1)
VHDL과 디지털회로설계 다. Encoder 회로 Ô <encoder.vhd> 예제 library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity encoder is port(a : IN std_logic_vector(3 downto 0); z : OUT std_logic_vector(1 downto 0)); end encoder; architecture RTL of encoder is begin z <= “00” when a(0) = ‘1’ else “01” when a(1) = ‘1’ else “10” when a(2) = ‘1’ else “11”; end RTL; encoder a(3) z(1) a(2) z(0) a(1) a(0)

33 Ô <func2.vhd> 예제 library IEEE; use IEEE.std_logic_1164.all;
use IEEE.std_logic_signed.all; entity FUNC2 is port(A, B, C, D : IN std_logic; ENC_OUT : OUT std_logic_vector(1 downto 0)); end FUNC2; architecture RTL of FUNC2 is begin process(A, B, C, D) if D = ‘0’ then ENC_OUT <= “00”; elsif C = ‘0’ then ENC_OUT <= “01”; elsif B = ‘0’ then ENC_OUT <= “10”; elsif A = ‘0’ then ENC_OUT <= “11”; elsif ENC_OUT <= “00”; end if; end process; end RTL;

34 Ô 1-bit Full-Adder :<FA1.vhd> 예제
VHDL과 디지털회로설계 Ô 1-bit Full-Adder :<FA1.vhd> 예제 library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity FA1 is port( A, B, CIN : IN std_logic; SUM,COUT : OUT std_logic); end FA1; architecture RTL of FA1 is begin process(A, B, CIN) variable TEMP : std_logic_vector(2 downto 0); TEMP := A & B & CIN; case TEMP is when “000” => SUM <= ‘0’; COUT <= ‘0’; when “001” | “010” | “100” => SUM <= ‘1’; COUT <= ‘0’; when “011” | “101” | “110” => SUM <= ‘0’; COUT <= ‘1’; when “111” => sum <= ‘1’; COUT <= ‘1’; when others => SUM <= ‘0’; COUT <=‘0’; end case; end process; end RTL;

35 Ô 9 bit adder : <adder9.vhd>
VHDL과 디지털회로설계 Ô 9 bit adder : <adder9.vhd> library IEEE; use IEEE.std_logic_1164.all; entity adder9 is port(cin : IN std_logic; a, b : IN std_logic_vector(8 downto 0); sum : OUT std_logic_vector(8 downto 0); cout : OUT std_logic); end adder9; architecture RTL of adder9 is begin process ( cin, a, b) variable carry : std_logic; carry := cin; for i in 0 to 8 loop sum(i) <= a(i) XOR b(i) XOR carry; carry := (carry and (a(i) XOR b(i))) or (a(i) and b(i)); end loop; cout <= carry; end process; end RTL;

36 + Ô Pipelined adder 회로 : < pipeAdder.vhd> Reg_a Reg_b inBus
VHDL과 디지털회로설계 Ô Pipelined adder 회로 : < pipeAdder.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity pipeAdder is port ( clk : in std_logic; inBus :in std_logic_vector(7 downto 0); outBus :out std_logic_vector(8 downto 0)); end pipeAdder; architecture RTL of pipeAdder is signal reg_a : std_logic_vector(7 downto 0); signal reg_b : std_logic_vector(8 downto 0); begin outBus <= reg_b; process ( clk) if ( clk = ‘1’ and clk’event) then reg_a <= inBus; reg_b <= (‘0’ & reg_a) + (‘0’ & inBus); end if; end process; end RTL; inBus Reg_a + Reg_b Out_Bus

37 VHDL과 디지털회로설계 그림 15. Pipeadder 의 합성 회로

38 VHDL과 디지털회로설계 그림 16. Pipeadder 의 시뮬레이션 결과

39 Ô 4-bit 수 차의 절대값 연산 : < absdiff.vhd>
VHDL과 디지털회로설계 Ô 4-bit 수 차의 절대값 연산 : < absdiff.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity absdiff is port (a : IN std_logic_vector(3 downto 0); b : IN std_logic_vector(3 downto 0); d :OUT std_logic_vector(3 downto 0)); end absdiff; architecture RTL of absdiff is begin process (a, b) if (a > b) then d <= a - b; else d <= b - a; end if; end process; end RTL;

40 ALU Ô ALU 연산 : <ALU.vhd> OP1 OP2 8 8 3 OPCODE 8 ALU_OUT
VHDL과 디지털회로설계 Ô ALU 연산 : <ALU.vhd> OP1 OP2 8 8 3 OPCODE ALU 8 ALU_OUT library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity ALU is port(OPCODE : IN std_logic_vector(2 downto 0); OP1,OP2 : IN std_logic_vector(7 downto 0); ALU_OUT : OUT std_logic_vector(7 downto 0)); end ALU;

41 architecture RTL of ALU is begin process (OPCODE, OP1, OP2)
VHDL과 디지털회로설계 architecture RTL of ALU is begin process (OPCODE, OP1, OP2) case OPCODE is when “000” => ALU_OUT <= OP1 + OP2; when “001” => ALU_OUT <= OP1 - 1; when “010” => ALU_OUT <= OP1 - OP2; when “011” => ALU_OUT <= OP1 + 1; when “100” => ALU_OUT <= OP1 and OP2; when “101” => ALU_OUT <= OP1 or OP2; ALU_OUT <= not OP2; when others => ALU_OUT <= OP1; end case; end process; end RTL;

42 VHDL과 디지털회로설계 그림 17. Alu 의 합성 회로

43 VHDL과 디지털회로설계 그림 18. Alu 의 시뮬레이션 결과

44 library IEEE; Ô Increment 회로 : < inc.vhd>
VHDL과 디지털회로설계 Ô Increment 회로 : < inc.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity INC is port(PC_ADDR : IN std_logic_vector(4 downto 0); INC_ADDR : OUT std_logic_vector(4 downto 0)); end INC; architecture RTL of INC is begin INC_ADDR <= PC_ADDR + 1; end RTL;

45 VHDL과 디지털회로설계 그림 19. Increment의 합성 회로

46 VHDL과 디지털회로설계 그림 20. Increment의 시뮬레이션 결과

47 Ô Decrement 회로 : <dec.vhd>
VHDL과 디지털회로설계 Ô Decrement 회로 : <dec.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity DEC is port(PC_ADDR : IN std_logic_vector(4 downto 0); DEC_ADDR : OUT std_logic_vector(4 downto 0)); end DEC; architecture RTL of DEC is begin DEC_ADDR <= PC_ADDR -1; end RTL;

48 VHDL과 디지털회로설계 3.2 순차회로의 예 가. 계수기(counter) Ô 6-bit up counter 회로 : < upCount.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity upCount is port(CLK32M, MRESET : in std_logic; upCountOut : out std_logic_vector(5 downto 0)); end upCount; architecture RTL of upCount is signal TMP : std_logic_vector(5 downto 0); begin upCountOut <= TMP; process (CLK32M, MRESET) if MRESET = ‘1’ then TMP <= “000000”; elsif (CLK32M = ‘0’ and CLK32M’event) then TMP <= TMP + ‘1’; end if; end process; end RTL;

49 Ô Enable과 load가 있는 6-bit up-counter 회로 : <upCount2.vhd>
VHDL과 디지털회로설계 Ô Enable과 load가 있는 6-bit up-counter 회로 : <upCount2.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity upCount2 is port( clk, reset, enable, load : in std_logic; dataBus : in std_logic_vector(5 downto 0); upCount2Out : out std_logic_vector(5 downto 0)); end upCount2; architecture RTL of upCount2 is signal TMP : std_logic_vector(5 downto 0); signal clkEnable : std_logic; begin upCount2Out <= TMP; clkEnable <= clk and enable; process ( clkEnable, reset, load) if reset ‘1’ then TMP <= “000000”; elsif ( clkEnable = ‘1’ and clkEnable’event) then if load = ‘1’ then TMP <= dataBus; else TMP <= TMP + ‘1’; end if; end process; end RTL;

50 VHDL과 디지털회로설계 그림 25. Upcount2 의 합성 회로

51 VHDL과 디지털회로설계 그림 26. Upcount2 의 합성 회로

52 Ô 6-bit up/down counter 회로 : < upDownCount.vhd>
VHDL과 디지털회로설계 Ô 6-bit up/down counter 회로 : < upDownCount.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity upDownCount is port( clk, reset, up_down, enable, load : in std_logic; dataBus : in std_logic_vector(5 downto 0); count : out std_logic_vector(5 downto 0)); end upDownCount; architecture RTL of upDownCount is signal TMP : std_logic_vector(5 downto 0); signal clkEnable : std_logic; constant ZERO : std_logic_vector := “000000”; begin count <= TMP; clkEnable <= clk and enable; process( clkEnable, reset, load) if reset ‘1’ then TMP <= ZERO; elsif ( clkEnable = ‘1’ and clkEnable’event) then if load = ‘1’ then TMP <= dataBus; elsif up_down = ‘1’ then TMP <= TMP + 1; else TMP <= TMP - 1; end if; end process; end RTL;

53 나. Clock 발생기 Ô Clock 5 분기 회로 : < clk_gen.vhd> library IEEE;
use IEEE.std_logic_1164.all; entity CLK_GEN is port(CLK, RST : IN std_logic; CLK_HOT : OUT std_logic_vector(4 downto 0); end CLK_GEN; architecture RTL of CLK_GEN is signal CURRENT_STAT, NEXT_STATE : std_logic_vector(4 downto 0); begin process(CURRNT_STATE) if CURRENT_STATE = “00000” then NEXT_STATE <= “00001”; elsif CURRENT_STATE = “00001” then NEXT_STATE <= “00010”; elsif CURRENT_STATE = “00010” then NEXT_STATE <= “00100”; elsif CURRENT_STATE = “00100” then NEXT_STATE <= “01000”; elsif CURRENT_STATE = “01000” then NEXT_STATE <= “10000”; elsif CURRENT_STATE = “10000” then NEXT_STATE <= “00001”; else NEXT_STATE <= “00001”; end if; end process; process (CLK, RST) if RST = ‘0’ then CURRENT <= “00000”; elsif CLK = ‘0’ and CLK’event then CURRENT_STATE <= NEXT_STATE; CLK_HOT <= CURRENT_STATE; end RTL;

54 그림 31. Clock generator 의 합성 회로
VHDL과 디지털회로설계 그림 31. Clock generator 의 합성 회로

55 그림 32. Clock generator 의 시뮬레이션 결과
VHDL과 디지털회로설계 그림 32. Clock generator 의 시뮬레이션 결과

56 - address bus=8, data bus=8
VHDL과 디지털회로설계 < RAM 메모리의 모델링 > - address bus=8, data bus=8 Modeling Guide - 2차원 Memory 공간에 대한 선언. - Address 값의 std_logic_vector를 Integer로 변환하는 Subprogram 인식. - RAM 기억공간의 Signal로의 선언. - Chip Disable과 Write Mode인 경우에 ‘Z’를 출력. library IEEE; use IEEE.std_logic_1164.ALL; use IEEE.std_logic_unsigned.ALL; entity RAM is port ( ADDR : in std_logic_vector(0 to 7); CE_N, RD_N, WR_N : in std_logic; DATA : inout std_logic(7 downto 0)); end RAM;

57 architecture RTL of RAM is subtype RAM_WORD is
VHDL과 디지털회로설계 architecture RTL of RAM is subtype RAM_WORD is std_logic_vector(7 downto 0); type RAM_TABLE is array(0 to 255) of RAM_WORD; signal RAM_DATA : RAM_TABLE; begin process (CE_N,RD_N,WR_N,ADDR) variable TMP : integer; DATA <= “ZZZZZZZZ”; TMP := conv_integer(ADDR); if CE_N=’0’ and RD_N=’0’ then DATA <= RAM_DATA(TMP); elsif CE_N=‘0’ and WR_N=’0’ then RAM_DATA(TMP) <= DATA; end if; end process; end RTL;

58 - Address bus=3, Data bus=5
VHDL과 디지털회로설계 < ROM 메모리의 모델링 > - Address bus=3, Data bus=5 Modeling Guide - 2차원 Memory 공간에 대한 선언. - Address 값의 std_logic_vector를 Integer로 변환하는 Subprogram 인식. - ROM 기억공간의 Constant로의 선언. - Chip Disable의 경우 ‘Z’를 출력. library IEEE; use IEEE.std_logic_1164.ALL; use IEEE.std_logic_unsigned.ALL; entity ROM is port ( ADDR : in std_logic_vector(0 to 2); CE_N, OE_N : in std_logic; DATA : out std_logic_vector(4 downto 0)); end ROM;

59 architecture RTL of ROM is subtype ROM_WORD is
VHDL과 디지털회로설계 architecture RTL of ROM is subtype ROM_WORD is std_logic_vector(4 downto 0); type ROM_TABLE is array(0 to 7) of ROM_WORD; constant ROM_DATA : ROM_TABLE := ROM_ TABLE’( “10101”, “10000”, “11111”, “11011”, “10001”, “01100”, “00101”, “10011”); begin process (CE_N,OE_N,ADDR) begin if CE_N=’0’ and OE_N=’0’ then DATA <= ROM_DATA (conv_integer(ADDR)); else DATA <= “ZZZZZ”; end if; end process; end RTL;

60 Ô Clock 배수에 폭을 갖는 펄스 발생기 : <pgen.vhd>
VHDL과 디지털회로설계 Ô Clock 배수에 폭을 갖는 펄스 발생기 : <pgen.vhd> library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_signed.all; entity pgen is port( clk, reset, trig : in std_logic; pulse : OUT std_logic; count : OUT std_logic_vector(4 downto 0)); end pgen; architecture RTL of pgen is signal count_TMP : std_logic_vector(4 downto 0); signal pulse_TMP : std_logic; constant WIDTH : std_logic_vector := “00111”; begin count <= count_TMP; pulse <= pulse_TMP; process ( clk, reset) if reset = ‘1’ then pulse_TMP <= ‘0’; count_TMP <= “00000”; elsif ( clk = ‘1’ and clk’event) then if trig = ‘1’ then pulse_TMP <= ‘1’; end if; if pulse_TMP = ‘1’ then if count_TMP = WIDTH then

61 count_TMP <= count_TMP; else pulse_TMP <= pulse_TMP;
VHDL과 디지털회로설계 count_TMP <= count_TMP; else pulse_TMP <= pulse_TMP; count_TMP <= count_TMP + ‘1’; end if; pulse_TMP <= ‘0’; count_TMP <= “00000”; end process; end RTL;

62 다. Memory 응용 회로 Ô set과 reset이 있는 flip-flop 회로 : <dff1.vhd>
VHDL과 디지털회로설계 다. Memory 응용 회로 Ô set과 reset이 있는 flip-flop 회로 : <dff1.vhd> library IEEE; use IEEE.std_logic_1164.all; entity dff1 is port (set, reset, CLOCK : IN std_logic; DIN : IN std_logic; q : OUT std_logic_vector(1 downto 0); qb : OUT std_logic); end dff1; architecture rtl of dff1 is signal TMP : std_logic; begin q <= TMP; qb <= not TMP; process (clock, DIN, set, reset) if (set = ‘0’) then TMP <= ‘1’; elsif (reset = ‘0’) then TMP <= ‘0’; elsif(clock = ‘1’ and clock’event) then TMP <= DIN; end if; end process; end rtl;

63 VHDL과 디지털회로설계 그림 33. D flip flop 의 합성 회로

64 VHDL과 디지털회로설계 그림 34. D flip flop 의 시뮬레이션 결과

65 Ô 데이터 load가 가능한 8 bit register 회로 : <register1.vhd>
VHDL과 디지털회로설계 Ô 데이터 load가 가능한 8 bit register 회로 : <register1.vhd> library IEEE; use IEEE.std_logic_1164.all; entity register1 is port (ENABLE, LOAD, CLOCK : IN std_logic; RESET : IN std_logic; REGIN : IN std_logic_vector(7 downto 0); LOADDATA : IN std_logic_vector(7 downto 0); REGOUT : OUT std_logic_vector(7 downto 0)); end register1; architecture rtl of register1 is signal GATEDCLOCK : std_logic; begin GATEDCLOCK <= ENABLE and CLOCK; process (GATEDCLOCK, LOAD, RESET, ENABLE, CLOCK) if RESET = ‘0’ then REGOUT <= “ ”; elsif (GATEDCLOCK = ‘0’ and GATEDCLOCK’event) then if LOAD = ‘1’ then REGOUT <= LOADDATA; else REGOUT <= REGIN; end if; end process; end RTL;

66 VHDL과 디지털회로설계 그 림 35. Register1 의 합성 회로

67 VHDL과 디지털회로설계 그 림 36. Register1 의 시뮬레이션 결과

68 Ô Left/right로의 천이가 가능한 shift register : < shiftreg.vhd>
VHDL과 디지털회로설계 Ô Left/right로의 천이가 가능한 shift register : < shiftreg.vhd> library IEEE; use IEEE.std_logic_1164.all; entity shiftreg is port (ENABLE, LOAD, CLOCK : IN std_logic; DIN : IN std_logic; REGIN : IN std_logic_vector(7 downto 0); MODE : IN std_logic; REGOUT : OUT std_logic_vector (7 downto 0)); end shiftreg; architecture rtl of shiftreg is signal gatedClock : std_logic; signal TMP : std_logic_vector( 7 downto 0); begin gatedClock <= ENABLE and CLOCK; REGOUT <= TMP; if ( gatedClock = ‘1’ and gatedClock’event) then if LOAD = ‘1’ then TMP <= REGIN; elsif MODE = ‘0’ then TMP <= TMP(6 downto 0) & DIN; else TMP <= DIN & TMP(7 downto 1); end if; end process; end RTL;

69 라. FSM(Finite State Machine)
VHDL과 디지털회로설계 라. FSM(Finite State Machine) - 디지털 하드웨어를 설계할 때 제어신호를 생성하는 제어기는 FSM으로 규정되며 FSM의 동작표현은 state transition diagram 또는 state transition table 등으로 표현된다 - FSM은 state 변수를 기억하는 레지스터 블록과 state 변수의 천이를 표현하 는 함수와 출력 값을 결정하는 조합논리 회로로 구성된다 - FSM은 출력이 발생되는 방법에 따라 Mealy Machine과 Moore Machine으로 분류할 수 있다 - Mealy Machine : 순차회로의 출력이 현재의 상태(state)와 입력에 따라 결정 된다 Next state = function [current state, inputs] Outputs = function [current state, inputs] Input Logic State Memory Output Current State Inputs Outputs - Moore Machine : 순차회로의 출력이 입력과 관계없이 현재의 상태의 함수로만 결정된다 Next state = function [current state, inputs] Outputs = function [current state]

70 Inputs Input Logic State Memory Output Logic Outputs Current State
VHDL과 디지털회로설계 Inputs Input Logic State Memory Output Logic Outputs Current State Mealy Machine 의 VHDL 예제 1 S0 S1 S2 S3 X/Z 1/1 1/0

71 Ô Mealy Machine VHDL 예제 1 : <FSM1.vhd> library IEEE ;
use IEEE.std_logic_1164.all ; entity FSM1 is port (X, clock : in std_logic ; Z : out std_logic ); end FSM1; architecture RTL1 of FSM1 is type state is (S0, S1, S2, S3) ; signal ST : state ; begin process (clock) if clock’event and clock = ‘1’ then if X = ‘0’ then Z = 0 ; else case ST is when S0 => ST <= S1 ; Z <= ‘0’ ; when S1 => ST <= S2 ; Z <= ‘0’ ; when S2 => ST <= S3 ; Z <= ‘0’ ; when S3 => ST <= S0 ; Z <= ‘1’ ; end case ; end if; end process ; end RTL1 ;

72 그림 37. Finite State Machine 의 합성 회로
VHDL과 디지털회로설계 그림 37. Finite State Machine 의 합성 회로

73 그림 38. Finite State Machine 의 시뮬레이션 결과
VHDL과 디지털회로설계 그림 38. Finite State Machine 의 시뮬레이션 결과

74 Ô FSM1의 또 다른 모델링 방법 - 다음의 예는 FSM을 합성할 때 추천되는 모델링 기법으로 FSM에서의
VHDL과 디지털회로설계 Ô FSM1의 또 다른 모델링 방법 - 다음의 예는 FSM을 합성할 때 추천되는 모델링 기법으로 FSM에서의 설계의 동기회로 부분(SYNCH)을 조합회로 부분 (COMB)과 분리 함 으로써 순차회로와 조합회로의 설계를 용이하게 할 뿐 만 아니라 설계의 수정이나 오류정정이 훨씬 간단하다는 장점을 가지고 있다. architecture RTL2 of FSM1 is type ST is (S0, S1, S2, S3) ; signal Current_ST, Next_ST : state ; begin COMB : process(Current_ST , X) case Current_ST is when S0 => if X = ‘0’ then Z <= ‘0’ ; Next_ST <= S0 ; else Z <= ‘0’ ; Next_ST <= S1 ; end if ; when S1 => Z <= ‘0’ ; Next_ST <= S2 ;

75 Z <= ‘0’ ; Next_ST <= S2 ; else Z <= ‘0’ ; Next_ST <= S3 ;
VHDL과 디지털회로설계 when S0 => if X = ‘0’ then Z <= ‘0’ ; Next_ST <= S2 ; else Z <= ‘0’ ; Next_ST <= S3 ; end if ; when S3 => Z <= ‘1’ ; Next_ST <= S0 ; end case ; SYNCH : process begin wait until clock’event and clock = ‘1’ ; Current_ST <= Next_ST ; end process ; end RTL2 ;

76 Ô Mealy Machine VHDL 예제 2 : <FSM2.vhd)
reset=‘0’ 0/0 S0 x/z 0/1 0/0 0/0 1/1 S1 S2 1/0 Library IEEE ; use IEEE.std_logic_1164.all ; entity FSM2 is port (RESET, CLK, X : in std_logic ; Z : out std_logic) ; end FSM2 ; architecture RTL of FSM2 is type STATE is (S0, S1, S2); signal C_STATE, N_STATE:STATE; begin SYNC: process(RESET, CLK) if RESET=‘0’ then C_STATE <= S0;

77 elsif CLK=‘0’ and CLK’event then C_STATE <=N_STATE; end if;
VHDL과 디지털회로설계 elsif CLK=‘0’ and CLK’event then C_STATE <=N_STATE; end if; end process; COMB= process (C_STATE, X) begin case C_STATE is when S0 => Z <= '0'; if X=’0' then N_STATE <= S0; else N_STATE <= S1; when S1 => Z <= '0'; if X=‘0’ then N_STATE <= S0; N_STATE <= S2; when S2 => N_STATE <= SO; Z <= ‘1’;

78 else N_STATE <= S1; Z <= ‘1’; end if; end case; end process;
VHDL과 디지털회로설계 else N_STATE <= S1; Z <= ‘1’; end if; end case; end process; end RTL;

79 Ô Mealy Machine 예제 3 : <FSM3.vhd>
VHDL과 디지털회로설계 Ô Mealy Machine 예제 3 : <FSM3.vhd> library IEEE; use IEEE.std_logic_1164.all; entity FSM3 is port(RESET, CLK, X : in std_logic; z : out std_logic); end FSM3; architecture RTL of FSM3 is type STATE is (S0, S1, S2); signal C_STATE, N_STATE : STATE; begin SYNC : process (RESET, CLK) if RESET = ‘0’ then C_STATE <= S0; elsif CLK = ‘0’ and CLK’event then C_STATE <= N_STATE; end if; end process; COMB : process ( C_STATE, X) case C_STATE is

80 if X = ‘0’ then N_STATE <= S0; else N_STATE <= S1; end if;
VHDL과 디지털회로설계 when S0 => Z <= ‘0’; if X = ‘0’ then N_STATE <= S0; else N_STATE <= S1; end if; when S1 => Z <= ‘0’; else N_STATE <= S2; when S2 => if X = ‘0’ then N_STATE <= S0 ; Z <= ‘0’; else N_STATE <= S1 : Z <= ‘1’; end case; end process; end RTL;

81 Ô 파형발생기의 예제 : <WAVEGEN.vhd>
VHDL과 디지털회로설계 Moore Machine의 예 Ô 파형발생기의 예제 : <WAVEGEN.vhd> PH1,PH2,TMP_PH3 RESET=‘0’ 110 001 010 111 101 011 CLK PH1 PH2 PH3

82 use IEEE.std_logic_1164.all ; entity WAVEGEN is
VHDL과 디지털회로설계 library IEEE : use IEEE.std_logic_1164.all ; entity WAVEGEN is port (RESET, CLOCK : in std_logic; PH1, PH2, PH3 : out std_logic); end WAVEGEN; architecture RTL of WAVEGEN is constant S0 : std_logic_vector(2 downto 0) := ”110"; constant S1 : std_logic_vector(2 downto 0) := “010”; constant S2 : std_logic_vector(2 downto 0) := “111”; constant S3 : std_logic_vector(2 downto 0) := “011”; constant S4 : std_logic_vector(2 downto 0) := “101”; constant S5 : std_logic_vector(2 downto 0) =: “001”; signal C_STATE, N_STATE : std_logic_vector(2 downto 0); signal TMP_PH3 : std_logic; signal PH : std_logic_vector(2 downto 0); begin P1: process (RESET, CLOCK) if RESET=’0' then C_STATE <= S0; elsif CLOCK =‘1’ and CLOCK'event then C_STATE <= N_STATE; end if;

83 when S0 => PH <= S0 ; N_STATE <= S1;
VHDL과 디지털회로설계 end process P1; P2: process (C_STATE) begin case C_STATE is when S0 => PH <= S0 ; N_STATE <= S1; when S1 => PH <= S1; N_STATE <= S2; when S2 => PH <= S2; N_STATE <= S3; when S3 => PH <= S3; N_STATE <= S4; when S4 => PH <= S4; N_STATE <= S5; when others => PH <= S5; N_STATE <= S0; end case; PH1 <= PH(2); PH2 <= PH(1); TMP_PH3 <= PH(0); end process P2; P3: process (CLOCK) if CLOCK=‘0’ and CLOCK’event then PH3 <= TMP_PH3 end if; end process P3; end RTL;

84 그림 39. Moore Machine 을 이용한 Wave generator의 합성 회로
VHDL과 디지털회로설계 그림 39. Moore Machine 을 이용한 Wave generator의 합성 회로

85 그림 40. Moore Machine 을 이용한 Wave generator의 시뮬레이션 결과
VHDL과 디지털회로설계 그림 40. Moore Machine 을 이용한 Wave generator의 시뮬레이션 결과


Download ppt "1. VHDL과 합성 설계 1.1 HDL: Hardware Description Language 집적회로의 설계환경의 변화"

Similar presentations


Ads by Google