Presentation is loading. Please wait.

Presentation is loading. Please wait.

FSM 설계.

Similar presentations


Presentation on theme: "FSM 설계."— Presentation transcript:

1 FSM 설계

2 Contents RAM Finite State Machine(FSM) Mealy machine Moore machine
3bits up/down counter Binary/gray counter 실습내용

3 RAM entity raminfr is port( clk, en, we : in std_logic;
addr, di : in std_logic_vector( 3 downto 0 ); do : out std_logic_vector( 3 downto 0 ) ); end entity raminfr; architecture Behavioral of raminfr is type ram_type is array(15downto0)of std_logic_vector(3downto0); signal RAM : ram_type; signal read_addr : std_logic_vector( 3 downto 0 ); Begin process( clk ) begin if( clk = '1' and clk'event ) then if( en = '1' ) then if( we = '1' ) then RAM( conv_integer( addr ) ) <= di; end if; read_addr <= addr; end process; do <= RAM( conv_integer( read_addr ) ); end architecture Behavioral;

4 FSM Finite State Machine 짝수, 홀수 parity 검사기
일정한 천이 가능한 상태 내에서만 동작하는 순차 논리 회로 FSM의 출력과 다음상태는 현재 상태와 출력에 의해 결정 짝수, 홀수 parity 검사기 연속으로 입력되는 binary code 중 ‘1’의 수를 세어 parity 출력 짝수 parity 검사기 ‘1’의 개수가 홀수일 때 ‘1’을 출력 홀수 parity 검사기 ‘1’의 개수가 짝수일 때 ‘1’을 출력

5 짝수 parity 검사기 State diagram(상태도) ‘even’과 ‘odd’의 두가지 상태를 가짐
현재 까지 입력이 홀수 일때 0이 입력되면 그대로 홀수 1이 입력되면 짝수 상태천이를 나타내는 화살표 ‘제어입력/출력’의 형태로 표기 even odd 1/0 1/1 0/1 0/0

6 짝수 parity 검사기 State transition table(상태표) 상태표를 이용한 논리식
Even을 ‘0’, odd를 ‘1’ 상태표를 이용한 논리식 현재 상태(PS), 입력값(PI), 다음상태(NS), 추력(PO) Present state Input Next state Output 1

7 짝수 parity 검사기 DFF를 이용한 구현

8 Mealy machine 클럭의 이벤트와 상관없이 입력 값의 변화에 따라 출력이 즉시 반영
S는 FSM의 상태 집합, I는 제어 입력신호 집합, O는 출력 신호 집합 비동기 동작 특성을 가지고 있음

9 Moore machine 현재의 상태에 의해서만 출력값이 결정 클럭과 함께 동기동작

10 Mealy vs. Moore machine 일반적으로 밀리 상태기계는 천이에 의해서 출력값이 결정되므로 무어 상태기계보다 더 적은 상태 개수만으로도 동작 수행가능 두개 이상의 ‘0’이 둘어왔을 때 ‘1’을 출력하는 FSM

11 3bits up/down counter Increment input에 따른 증가 카운트 및 감소 카운트의 동작 Rst_n
Clk Cnt Low x 000 High Down count Up count Up/down counter Clk Incr Rst_n Cnt 3

12 3bits up/down counter 상태표 CS INPUT NS 000 1 001 111 110 010 101 011
110 010 101 011 100

13 3bits up/down counter 상태도 S0 S7 S4 S6 S5 S1 S2 S3 1

14 3bits up/down counter Module library IEEE;
use ieee.std_logic_1164.all; entity updown_cnt is port( clk, rst_n, incr : in std_logic; cnt : out std_logic_vector(2 downto 0)); end entity updown_cnt; architecture Behavioral of updown_cnt is signal state : std_logic_vector(2 downto 0); signal next_state : std_logic_vector(2 downto 0); begin cnt <= state; -- state registers process( clk, rst_n ) if( rst_n = '0' ) then state <= "000"; elsif( clk = '1' and clk'event ) then state <= next_state; end if; end process; -- fsm counter process( state, incr ) Begin Case state is when "000" => if( incr = '1' ) then next_state <= "001"; else next_state <= "111"; when "001" => next_state <= "010"; next_state <= "000"; when "010" => if( incr = '1' ) then next_state <= "011"; else next_state <= "001"; end if; when "011" => next_state <= "100"; next_state <= "010"; when "100" => next_state <= "101"; when "101" => next_state <= "110"; when "110" => next_state <= "111"; when others => next_state <= "000"; end case; end process; end architecture Behavioral;

15 3bits up/down counter Simulation result

16 Binary/gray counter Binary count Gray count
000, 001, 010, 011, 100, 101, 110, 111 Gray count 000, 001, 011, 010, 110, 111, 101, 100

17 Binary/gray counter Mode 입력에 따른 선택적 동작 Rst_n Mode Clk Cnt Low x 000
High Gray count Binary count Binary/gray counter Clk Mode Rst_n Cnt 3

18 Binary/gray counter 상태표 CS MODE NS 000 1 001 010 011 110 100 101 111

19 Binary/gray counter 상태도 S0 S7 S4 S6 S5 S1 S2 S3 1 0,1

20 실습내용 Binary/gray counter 설계 앞서의 binary/gray counter를 설계
주어진 entity, 상태표 및 상태도 사용 Testbench는 임의의 입력으로 작성( counter의 특성을 충분히 보여 줄 수 있는 입력을 직접 입력 ) entity bin_gray_cnt is port( clk, rst_n, mode : in std_logic; cnt : out std_logic_vector( 2 downto 0 ) ); end entity bin_gray_cnt;


Download ppt "FSM 설계."

Similar presentations


Ads by Google