State Machine & Timing Design

90
1 State Machine & Timing Design

description

State Machine & Timing Design. Finite State Machine(FSM) Mealy Machine Moore Machine FSM in VHDL More VHDL codes for FSMs Techniques for simple sequential logic design. 강의 내용. Finite State Machines (FSMs). Any circuit with memory is a finite state machine (FSM: 유한 상태 기계 ) - PowerPoint PPT Presentation

Transcript of State Machine & Timing Design

Page 1: State Machine & Timing Design

1

State Machine & Timing Design

Page 2: State Machine & Timing Design

모바일컴퓨터특강 2

강의 내용

Finite State Machine(FSM) Mealy Machine Moore Machine

FSM in VHDL More VHDL codes for FSMs Techniques for simple sequential logic design

Page 3: State Machine & Timing Design

모바일컴퓨터특강 3

Finite State Machines (FSMs)

Any circuit with memory is a finite state machine (FSM: 유한 상태 기계 ) Even computers can be viewed as huge FSMs

Design of FSMs involves Defining states Defining transitions between states Optimization / minimization

Manual optimization/minimization is practical for small FSMs only

Page 4: State Machine & Timing Design

모바일컴퓨터특강 4

Moore FSM

Output is a function of a present state only

Present Stateregister

Next Statefunction

Outputfunction

Inputs

Present StateNext State

Outputs

clockreset

Page 5: State Machine & Timing Design

모바일컴퓨터특강 5

Moore Machine

state 1 /output 1

state 2 /output 2

transitioncondition 1

transitioncondition 2

Page 6: State Machine & Timing Design

모바일컴퓨터특강 6

Mealy FSM

Output is a function of a present state and inputs

Next Statefunction

Outputfunction

Inputs

Present StateNext State

Outputs

Present Stateregister

clockreset

Page 7: State Machine & Timing Design

모바일컴퓨터특강 7

Mealy Machine

state 1 state 2

transition condition 1 /output 1

transition condition 2 /output 2

Page 8: State Machine & Timing Design

모바일컴퓨터특강 8

Moore vs. Mealy FSM (1)

Moore and Mealy FSMs can be functionally equivalent Equivalent Mealy FSM can be derived from Moore FSM and

vice versa Mealy FSM has richer description and usually require

s smaller number of states Smaller circuit area

Page 9: State Machine & Timing Design

모바일컴퓨터특강 9

Moore vs. Mealy FSM (2)

Mealy FSM computes outputs as soon as inputs change Mealy FSM responds one clock cycle sooner than

equivalent Moore FSM Moore FSM has no combinational path

between inputs and outputs Moore FSM is more likely to have a shorter critical

path

Page 10: State Machine & Timing Design

모바일컴퓨터특강 10

Moore FSM - Example 1

Moore FSM that recognizes sequence “10”

S0 / 0 S1 / 0 S2 / 1

00

0

1

11

reset

Meaning of states:

S0: No elements of the sequenceobserved

S1: “1”observed

S2: “10”observed

Page 11: State Machine & Timing Design

모바일컴퓨터특강 11

Mealy FSM - Example 1

Mealy FSM that recognizes sequence “10”

S0 S1

0 / 0 1 / 0 1 / 0

0 / 1reset

Meaning of states:

S0: No elements of the sequenceobserved

S1: “1”observed

Page 12: State Machine & Timing Design

모바일컴퓨터특강 12

Moore & Mealy FSMs – Example 1

clock

input

Moore

Mealy

0 1 0 0 0

S0 S1 S2 S0 S0

S0 S1 S0 S0 S0

Page 13: State Machine & Timing Design

모바일컴퓨터특강 13

FSMs in VHDL

Finite state machines can be easily described with processes

Synthesis tools understand FSM description if certain rules are followed State transitions should be described in a process

sensitive to clock and asynchronous reset signals only

Outputs described as concurrent statements outside the process

Page 14: State Machine & Timing Design

모바일컴퓨터특강 14

State Machine - Mealy Machine

Mealy Machine 현재의 상태 (Current State) 와 현재의 입력 (Inputs) 에 의해

출력이 결정됨

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

Page 15: State Machine & Timing Design

모바일컴퓨터특강 15

해석

1. WindowAct 신호가 0 에서 1 로 변하면 S1 state 으로 전환 , 이 때 output RiseShot 을 1 로 ,

2. WindowAct 신호가 1 에서 0 으로 변하면 S0 state 으로 전환 , FallShot을 1 로 만들어야 함 .

3. State 전환이 없으면 output 들은 모두 0

해석

1. WindowAct 신호가 0 에서 1 로 변하면 S1 state 으로 전환 , 이 때 output RiseShot 을 1 로 ,

2. WindowAct 신호가 1 에서 0 으로 변하면 S0 state 으로 전환 , FallShot을 1 로 만들어야 함 .

3. State 전환이 없으면 output 들은 모두 0

S0

S1

0/00

1/00

0/01 1/10

WindowAct / RiseShot, FallShot

입력 / 출력 1, 출력2

Reset

Mealy FSM 의 해석 – State diagram

Page 16: State Machine & Timing Design

모바일컴퓨터특강 16

Mealy Machine 구현 – Process 2 개사용

Library ieee; Use ieee.std_logic_1164.all;

ENTITY RiseFallShot IS

PORT( clk : IN STD_LOGIC;

reset : IN STD_LOGIC;

WindowAct : IN STD_LOGIC;

RiseShot, FallShot : OUT STD_LOGIC);

END RiseFallShot;ARCHITECTURE a OF RiseFallShot IS

TYPE STATE_TYPE IS (s0, s1);SIGNAL state: STATE_TYPE;

BEGINPROCESS (clk, reset)BEGIN IF reset = '0' THEN state <= s0; ELSIF clk'EVENT AND clk = '1' THEN CASE state IS

WHEN s0 => IF WindowAct='1' THEN

state <= s1; ELSE

state <= s0; END IF;

WHEN others => IF WindowAct='0' THEN

state <= s0; ELSE

state <= s1; END IF;END CASE;

END IF;END PROCESS;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

새로운 Data type

“STATE_TYPE” 지정

새로운 Data type

“STATE_TYPE” 지정

Page 17: State Machine & Timing Design

모바일컴퓨터특강 17

Mealy Machine 구현 – Process 2 개 사용

PROCESS(state, WindowAct)

BEGIN

if( state= s0 and WindowAct='1') then

RiseShot <='1';

else

RiseShot <='0';

end if;

if( state= s1 and WindowAct='0') then

FallShot <='1';

else

FallShot <='0';

end if;

END PROCESS;

END a;

Combinational

Logic F/F

Outputs

Current State

Combinational

Logic

Next State

Inputs

같은 부분같은 부분

Page 18: State Machine & Timing Design

모바일컴퓨터특강 18

Mealy Machine 구현 – Process 3 개 사용

library ieee;Use ieee.std_logic_1164.all;ENTITY RiseFallShot_v2 IS

PORT(clk : IN STD_LOGIC;reset : IN STD_LOGIC;WindowAct : IN STD_LOGIC;RiseShot, FallShot : OUT STD_LOGIC);

END RiseFallShot_v2;

ARCHITECTURE a OF RiseFallShot_v2 ISTYPE STATE_TYPE IS (s0, s1);SIGNAL State, NextState: STATE_TYPE;

BEGINPROCESS (State, WindowAct)BEGIN

CASE State ISWHEN s0 =>

IF WindowAct='1' THENNextState <= s1;

ELSENextState <= s0;

END IF;WHEN others =>

IF WindowAct='0' THENNextState <= s0;

ELSENextState <= s1;

END IF;END CASE;

END PROCESS;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

Page 19: State Machine & Timing Design

모바일컴퓨터특강 19

Mealy Machine 구현– Process 3 개 사용

PROCESS(reset,clk)BEGIN

IF reset = '0' THENState <= s0;

ELSIF clk'EVENT AND clk = '1' THENState <= NextState;

END IF;END PROCESS;

process(State,WindowAct) begin if( State= s0 and WindowAct='1') then RiseShot <='1'; else RiseShot <='0'; end if; if( State= s1 and WindowAct='0') then FallShot <='1'; else FallShot <='0'; end if; end process;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

같은 부분같은 부분

Page 20: State Machine & Timing Design

모바일컴퓨터특강 20

State Machine - Moore Machine

Moore Machine 현재의 상태 (Current State) 만에 의해 출력 (Outputs) 이

결정됨 “Moore is less”

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

Page 21: State Machine & Timing Design

모바일컴퓨터특강 21

Moore Machine 해석– State diagram

상태출력

입력 : WindowAct 출력 : y(2:0)

해석

1. WindowAct 신호가 0 일 때는 State 의 변화가 없으며 , 1 일 때는 state 의 변화가 S0->S1->S2->S0 로 순환한다 .

2. 출력신호 y(2:0) 은 상태가 S0 인 경우 “ 000” 을 S1 인 경우에는 “ 010” 을 S2 인 경우에는 “ 101” 을 출력한다 .

해석

1. WindowAct 신호가 0 일 때는 State 의 변화가 없으며 , 1 일 때는 state 의 변화가 S0->S1->S2->S0 로 순환한다 .

2. 출력신호 y(2:0) 은 상태가 S0 인 경우 “ 000” 을 S1 인 경우에는 “ 010” 을 S2 인 경우에는 “ 101” 을 출력한다 .

S0000

S1010

0

01

1

S2101

1

Reset

Page 22: State Machine & Timing Design

모바일컴퓨터특강 22

Moore Machine 구현– Process 2 개 사용

Library ieee; Use ieee.std_logic_1164.all;

ENTITY MooreMachine ISPORT( clk, reset, WindowAct : IN STD_LOGIC;

y : OUT STD_LOGIC_vector(2 downto 0));END MooreMachine;

ARCHITECTURE a OF MooreMachine ISTYPE STATE_TYPE IS (s0, s1,s2);SIGNAL state: STATE_TYPE;

BEGINPROCESS (clk, reset)BEGIN IF reset = '0' THEN state <= s0; ELSIF clk'EVENT AND clk = '1' THEN CASE state IS

WHEN s0 => IF WindowAct='1' THEN state <= s1;

ELSE state <= s0; END IF;

WHEN s1 => IF WindowAct='1' THEN state <= s2;

ELSE state <= s1; END IF;

WHEN others => IF WindowAct='1' THEN state <= s0;

ELSE state <= s2; END IF;

END CASE; END IF;END PROCESS;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

Page 23: State Machine & Timing Design

모바일컴퓨터특강 23

Moore Machine 구현– Process 2 개 사용

PROCESS(state)BEGIN

CASE state ISWHEN s0 =>

y <= "000";WHEN s1 =>

y <= "010";WHEN others =>

y <= "101"; END CASE;END PROCESS;END a;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

Page 24: State Machine & Timing Design

모바일컴퓨터특강 24

Moore Machine 구현– Process 3 개 사용

Library ieee; Use ieee.std_logic_1164.all;

ENTITY MooreMachine_v3 ISPORT( clk, reset, WindowAct : IN STD_LOGIC;

y : OUT STD_LOGIC_vector(2 downto 0));END MooreMachine_v3;

ARCHITECTURE a OF MooreMachine_v3 ISTYPE STATE_TYPE IS (s0, s1,s2);SIGNAL state, NextState: STATE_TYPE;

BEGINPROCESS ( State, WindowAct)BEGIN

CASE State ISWHEN s0 =>

IF WindowAct='1' THEN NextState <= s1;ELSE NextState <= s0;

END IF;WHEN s1 =>

IF WindowAct='1' THEN NextState <= s2;ELSE NextState <= s1;

END IF;WHEN others =>

IF WindowAct='1' THEN NextState <= s0;ELSE NextState <= s2;

END IF;END CASE;

END PROCESS;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

Page 25: State Machine & Timing Design

모바일컴퓨터특강 25

Moore Machine 구현– Process 3 개 사용

PROCESS (clk, reset)BEGIN IF reset = '0' THEN state <= s0; ELSIF clk'EVENT AND clk = '1' THEN

state <= NextState; END IF;END PROCESS;

PROCESS(state)BEGIN

CASE state ISWHEN s0 =>

y <= "000";WHEN s1 =>

y <= "010";WHEN others =>

y <= "101"; END CASE;END PROCESS;END a;

Combinational

Logic F/FInputs

Outputs

Current State

Combinational

Logic

Next State

같은 부분같은 부분

같은 부분같은 부분

Page 26: State Machine & Timing Design

모바일컴퓨터특강 26

Moore FSM

Present StateRegister

Next Statefunction

Outputfunction

Inputs

Present State

Next State

Outputs

clockreset

process(clock, reset)

concurrent statements

Page 27: State Machine & Timing Design

모바일컴퓨터특강 27

Mealy FSM

Next Statefunction

Outputfunction

Inputs

Present StateNext State

Outputs

Present StateRegister

clockreset

process(clock, reset)

concurrent statements

Page 28: State Machine & Timing Design

모바일컴퓨터특강 28

Moore FSM - Example 1

Moore FSM that Recognizes Sequence “10”

S0 / 0 S1 / 0 S2 / 1

00

0

1

11

reset

Page 29: State Machine & Timing Design

모바일컴퓨터특강 29

TYPE state IS (S0, S1, S2);SIGNAL Moore_state: state;

U_Moore: PROCESS (clock, reset)BEGIN

IF(reset = ‘1’) THENMoore_state <= S0;

ELSIF (clock = ‘1’ AND clock’event) THENCASE Moore_state IS

WHEN S0 => IF input = ‘1’ THEN

Moore_state <= S1; ELSE Moore_state <= S0; END IF;

Moore FSM in VHDL (1)

Page 30: State Machine & Timing Design

모바일컴퓨터특강 30

Moore FSM in VHDL (2)

WHEN S1 => IF input = ‘0’ THEN

Moore_state <= S2; ELSE Moore_state <= S1; END IF;

WHEN S2 => IF input = ‘0’ THEN

Moore_state <= S0; ELSE

Moore_state <= S1; END IF;

END CASE;END IF;

END PROCESS;

Output <= ‘1’ WHEN Moore_state = S2 ELSE ‘0’;

Page 31: State Machine & Timing Design

모바일컴퓨터특강 31

Mealy FSM - Example 1

Mealy FSM that Recognizes Sequence “10”

S0 S1

0 / 0 1 / 0 1 / 0

0 / 1reset

Page 32: State Machine & Timing Design

모바일컴퓨터특강 32

Mealy FSM in VHDL (1)

TYPE state IS (S0, S1);SIGNAL Mealy_state: state;

U_Mealy: PROCESS(clock, reset)BEGIN

IF(reset = ‘1’) THENMealy_state <= S0;

ELSIF (clock = ‘1’ AND clock’event) THENCASE Mealy_state IS

WHEN S0 => IF input = ‘1’ THEN

Mealy_state <= S1; ELSE Mealy_state <= S0; END IF;

Page 33: State Machine & Timing Design

모바일컴퓨터특강 33

Mealy FSM in VHDL (2)

WHEN S1 => IF input = ‘0’ THEN

Mealy_state <= S0; ELSE Mealy_state <= S1; END IF;

END CASE;END IF;

END PROCESS;

Output <= ‘1’ WHEN (Mealy_state = S1 AND input = ‘0’) ELSE ‘0’;

Page 34: State Machine & Timing Design

모바일컴퓨터특강 34

C z 1 =

resetn

B z 0 = A z 0 = w 0 =

w 1 =

w 1 =

w 0 =

w 0 = w 1 =

Moore FSM – Example 2: State diagram

Page 35: State Machine & Timing Design

모바일컴퓨터특강 35

Present Next state Outputstate w = 0 w = 1 z

A A B 0 B A C 0 C A C 1

Moore FSM – Example 2: State table

Page 36: State Machine & Timing Design

모바일컴퓨터특강 36

Moore FSM with 2’s Processes

Present StateRegister

Next Statefunction

Outputfunction

Input: w

Present State: y

Next State

Output: z

clockresetn

process(clock, reset)

concurrent statements

Page 37: State Machine & Timing Design

모바일컴퓨터특강 37

USE ieee.std_logic_1164.all ;

ENTITY simple ISPORT ( clock : IN STD_LOGIC ;

resetn : IN STD_LOGIC ; w : IN STD_LOGIC ;

z : OUT STD_LOGIC ) ;END simple ;

ARCHITECTURE Behavior OF simple ISTYPE State_type IS (A, B, C) ;SIGNAL y : State_type ;

BEGINPROCESS ( resetn, clock )BEGIN

IF resetn = '0' THENy <= A ;

ELSIF (Clock'EVENT AND Clock = '1') THEN

Moore FSM – Example 2: VHDL code

(1)

Page 38: State Machine & Timing Design

모바일컴퓨터특강 38

CASE y ISWHEN A =>

IF w = '0' THEN y <= A ;

ELSE y <= B ;

END IF ;WHEN B =>

IF w = '0' THENy <= A ;

ELSEy <= C ;

END IF ;WHEN C =>

IF w = '0' THENy <= A ;

ELSEy <= C ;

END IF ;END CASE ;

Moore FSM – Example 2: VHDL code

(2)

Page 39: State Machine & Timing Design

모바일컴퓨터특강 39

END IF ; END PROCESS ;

z <= '1' WHEN y = C ELSE '0' ;

END Behavior ;

Moore FSM – Example 2: VHDL code

(3)

Page 40: State Machine & Timing Design

모바일컴퓨터특강 40

Moore FSM with 3’s Processes

Present StateRegister

Next Statefunction

Outputfunction

Input: w

Present State: y_present

Next State: y_next

Output: z

clockresetn

process(w, y_present)

concurrent statements

process(clock, resetn)

Page 41: State Machine & Timing Design

모바일컴퓨터특강 41

ARCHITECTURE Behavior OF simple ISTYPE State_type IS (A, B, C) ;SIGNAL y_present, y_next : State_type ;

BEGINPROCESS ( w, y_present )BEGIN

CASE y_present ISWHEN A =>

IF w = '0' THENy_next <= A ;

ELSEy_next <= B ;

END IF ;WHEN B =>

IF w = '0' THENy_next <= A ;

ELSEy_next <= C ;

END IF ;

Alternative VHDL code (1)

Page 42: State Machine & Timing Design

모바일컴퓨터특강 42

WHEN C =>IF w = '0' THEN

y_next <= A ;ELSE

y_next <= C ;END IF ;

END CASE ;END PROCESS ;

PROCESS (clock, resetn)BEGIN

IF resetn = '0' THENy_present <= A ;

ELSIF (clock'EVENT AND clock = '1') THENy_present <= y_next ;

END IF ;END PROCESS ;

z <= '1' WHEN y_present = C ELSE '0' ;END Behavior ;

Alternative VHDL code (2)

Page 43: State Machine & Timing Design

모바일컴퓨터특강 43

A

w 0 = z 0 = /

w 1 = z 1 = / B w 0 = z 0 = /

resetn w 1 = z 0 = /

Mealy FSM – Example 2: State diagram

Page 44: State Machine & Timing Design

모바일컴퓨터특강 44

Present Next state Outputz

state w = 0 w = 1 w = 0 w = 1

A A B 0 0 B A B 0 1

Mealy FSM – Example 2: State table

Page 45: State Machine & Timing Design

모바일컴퓨터특강 45

Mealy FSM with 2’s Processes

Next Statefunction

Outputfunction

Input: w

Present State: yNext State

Output: z

Present StateRegister

clockresetn

process(clock, reset)

concurrent statements

Page 46: State Machine & Timing Design

모바일컴퓨터특강 46

LIBRARY ieee ;USE ieee.std_logic_1164.all ;

ENTITY Mealy ISPORT ( clock : IN STD_LOGIC ;

resetn : IN STD_LOGIC ; w : IN STD_LOGIC ;

z : OUT STD_LOGIC ) ;END Mealy ;

ARCHITECTURE Behavior OF Mealy ISTYPE State_type IS (A, B) ;SIGNAL y : State_type ;

BEGINPROCESS ( resetn, clock )BEGIN

IF resetn = '0' THENy <= A ;

ELSIF (clock'EVENT AND clock = '1') THEN

Mealy FSM – Example 2: VHDL code

(1)

Page 47: State Machine & Timing Design

모바일컴퓨터특강 47

CASE y IS WHEN A => IF w = '0' THEN

y <= A ;ELSE

y <= B ;END IF ;

WHEN B =>IF w = '0' THEN

y <= A ;ELSE

y <= B ; END IF ;END CASE ;

Mealy FSM – Example 2: VHDL code

(2)

Page 48: State Machine & Timing Design

모바일컴퓨터특강 48

END IF ;END PROCESS ;

WITH y SELECTz <= w WHEN B,

z <= ‘0’ WHEN others;

END Behavior ;

Mealy FSM – Example 2: VHDL code

(3)

Page 49: State Machine & Timing Design

모바일컴퓨터특강 49

Timing Design - 강의순서

State Machine 응용 Shift Register 응용 Counter 응용

주어진 타이밍도로부터 회로를 설계하는 방법을 다양한 형태의 접근 방법을 통해

습득한다 . 각종 디바이스의 데이터 북상에 나타나는 타이밍 도의 이해를 위한 더욱 심화된

지식을 배양한다 .

주어진 타이밍도로부터 회로를 설계하는 방법을 다양한 형태의 접근 방법을 통해

습득한다 . 각종 디바이스의 데이터 북상에 나타나는 타이밍 도의 이해를 위한 더욱 심화된

지식을 배양한다 .

Page 50: State Machine & Timing Design

모바일컴퓨터특강 50

Timing Design – State Machine Application

(1)1. 아래와 같은 Timing 입출력 파형을 갖는 회로를 설계해보자

• 해석 : WindowAct 신호가 0 에서 1 로 변하는 순간부터 다음 clock 의 rising edge 까지 RiseShot 을 1 로 만들고

• WindowAct 신호가 1 에서 0 으로 변하는 순간부터 다음 clock 의 rising edge 까지 FallShot 을 1 로 만들어야 함 .

• 해석 : WindowAct 신호가 0 에서 1 로 변하는 순간부터 다음 clock 의 rising edge 까지 RiseShot 을 1 로 만들고

• WindowAct 신호가 1 에서 0 으로 변하는 순간부터 다음 clock 의 rising edge 까지 FallShot 을 1 로 만들어야 함 .

Page 51: State Machine & Timing Design

모바일컴퓨터특강 51

S0

S1

0/00

1/00

0/01 1/10

2.Excercise: Mealy-machine state diagram 을 완성하라

WindowAct / RiseShot, FallShot

입력 / 출력 1, 출력2

Timing Design – State Machine Application

(2)

Page 52: State Machine & Timing Design

모바일컴퓨터특강 52

Timing Design – State Machine

Application (3)

S0

S1

0/00

1/00

0/01 1/10

상태도에서 입력에 따른 상태의 변화만을

기술

상태도에서 입력에 따른 상태의 변화만을

기술

Page 53: State Machine & Timing Design

모바일컴퓨터특강 53

Timing Design – State Machine Application

(4)

S0

S1

0/00

1/00

0/01 1/10

상태도에서 입력에 따른 출력의 변화만을 기술

상태도에서 입력에 따른 출력의 변화만을 기술

Note: The outputs react to input asynchronously.

Page 54: State Machine & Timing Design

모바일컴퓨터특강 54

Timing Design – State Machine Application

(5) Result

Page 55: State Machine & Timing Design

모바일컴퓨터특강 55

Timing Design – State Machine Application

(6)3. 상태도를 이용하지 않는 다른 방법은 ?

Timing 만을 고려한 설계

Q 는 WindowAct 를 D F/F

으로 통과시킨 출력

Q 는 WindowAct 를 D F/F

으로 통과시킨 출력

1 3

24

1,3 에서 RiseShot= WindowAct

and Q’

1,3 에서 RiseShot= WindowAct

and Q’ 2,4 에서

FallShot= WindowAct’ and Q

2,4 에서

FallShot= WindowAct’ and Q

Page 56: State Machine & Timing Design

모바일컴퓨터특강 56

Timing Design – State Machine Application

(7)3. Timing 만을 고려한 설계방식 - BDF

Q 는 WindowAct를 D FF 으로 통과시킨 출력

Q 는 WindowAct를 D FF 으로 통과시킨 출력

not Q

WindowAct and Q’

WindowAct and Q’

WindowAct’ and QWindowAct’ and Q

not WindowAct

Page 57: State Machine & Timing Design

모바일컴퓨터특강 57

Timing Design – State Machine Application

(8)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity RiseFallShot_time is port( WindowAct : in std_logic; clk,nclr : in std_logic; RiseShot,FallShot : out std_logic);end RiseFallShot_time;architecture a of RiseFallShot_time is

signal q : std_logic;signal RisingShotPules :

std_logic;begin-- shift register 1bits process(nclr,clk) begin

if( nclr='0') thenq <='0';

elsif(clk'event and clk='1') thenq <= WindowAct;

end if; end process;-- rising shot pulse gen. RiseShot <= WindowAct and not q; FallShot <= not WindowAct and q;end a;

같은 회로같은 회로

같은 회로같은 회로

3. Timing 만을 고려한 설계방식 - VHDL

Page 58: State Machine & Timing Design

모바일컴퓨터특강 58

Timing Design – Shift Register

Application (1) 아래와 같은 Timing 입출력 파형을 갖는 회로를

설계해보자 . 입력신호 : reset, clk, WindowAct 출력신호 : y0, y1, y2, y3, y4, y5, y6

Page 59: State Machine & Timing Design

모바일컴퓨터특강 59

Timing Design – Shift Register

Application (2)

1. 먼저 아래의 회로를 만들어보자 . 입력신호 : reset, clk, WindowAct 출력신호 : y0

어떤 방식으로 설계해야 하는가 ? 1 차적으로 생각할 수 있는 방법은 Shift Register 를 이용하는

방법

Page 60: State Machine & Timing Design

모바일컴퓨터특강 60

Timing Design – Shift Register

Application (3)

그림과 같은 Shift Register 를 사용하게 되면 Q0, Q1, Q2 의

타이밍을 예상할 수 있다 .

그림과 같은 Shift Register 를 사용하게 되면 Q0, Q1, Q2 의

타이밍을 예상할 수 있다 .

출력신호 y0 는 Q1가 1 이 되는 부분과 Q2 가 0 이 되는 700-900ns

부분에서 1 이 된다 .

Y0=Q1 and Q2’

출력신호 y0 는 Q1가 1 이 되는 부분과 Q2 가 0 이 되는 700-900ns

부분에서 1 이 된다 .

Y0=Q1 and Q2’

Y0 = Q1 and not Q2

Page 61: State Machine & Timing Design

모바일컴퓨터특강 61

Timing Design – Shift Register

Application (4)2. 이번에는 y1 을 만들어보자 .

Page 62: State Machine & Timing Design

모바일컴퓨터특강 62

Timing Design – Shift Register

Application (5)

Y0 를 clk 의 falling edge 를 이용하여 shift 하면 반클럭 shift 된 Y1 을 만들 수

있다 .

Y0 를 clk 의 falling edge 를 이용하여 shift 하면 반클럭 shift 된 Y1 을 만들 수

있다 .

Page 63: State Machine & Timing Design

모바일컴퓨터특강 63

Timing Design – Shift Register

Application (6)3. 이번에는 y2 를 만들어보자 .

Page 64: State Machine & Timing Design

모바일컴퓨터특강 64

Timing Design – Shift Register

Application (7)

Y2 는 Y0 와 Y1 을 OR 한 것임을 알 수

있다 .

Y2 = Y0 or Y1

Y2 는 Y0 와 Y1 을 OR 한 것임을 알 수

있다 .

Y2 = Y0 or Y1

Y2 = Y0 or Y1

Page 65: State Machine & Timing Design

모바일컴퓨터특강 65

Timing Design – Shift Register

Application (8)4. 이번에는 y3 을 만들어보자 .

Page 66: State Machine & Timing Design

모바일컴퓨터특강 66

Timing Design – Shift Register

Application (9)

Y3 는 11 개의 shift register중에서 Q9 가 1

이면 Q10 이 0 인 구간에 1 이

출력되는 신호 .

Y3 는 11 개의 shift register중에서 Q9 가 1

이면 Q10 이 0 인 구간에 1 이

출력되는 신호 .

11 bits Shift

Register

11 bits Shift

Register

Page 67: State Machine & Timing Design

모바일컴퓨터특강 67

Timing Design – Shift Register

Application (10)

Y3 는 11 개의 shift register 중에서 Q10 과

Q9 를 이용한 신호임 .

Y3 = Q9 and Q10’

Y3 는 11 개의 shift register 중에서 Q10 과

Q9 를 이용한 신호임 .

Y3 = Q9 and Q10’

Page 68: State Machine & Timing Design

모바일컴퓨터특강 68

Timing Design – Shift Register

Application (11)

5. 이번에는 y4 을 만들어보자 .

Page 69: State Machine & Timing Design

모바일컴퓨터특강 69

Timing Design – Shift Register

Application (12)

Y4 는 Y1 와 Y3 을 OR 한

것임을 알 수 있다 .

Y4 = Y1 or Y3

Y4 는 Y1 와 Y3 을 OR 한

것임을 알 수 있다 .

Y4 = Y1 or Y3

Page 70: State Machine & Timing Design

모바일컴퓨터특강 70

Timing Design – Shift Register

Application (13)

6. 이번에는 y5 을 만들어보자 .

Page 71: State Machine & Timing Design

모바일컴퓨터특강 71

Timing Design – Shift Register

Application (14)

Y5 는 Q2 가 1이며 Q10 이 0인 구간에 1 을

출력 .

Y5 는 Q2 가 1이며 Q10 이 0인 구간에 1 을

출력 .

Page 72: State Machine & Timing Design

모바일컴퓨터특강 72

Timing Design – Shift Register

Application (15)7. 이번에는 y6 을 만들어보자 .

Page 73: State Machine & Timing Design

모바일컴퓨터특강 73

Timing Design – Shift Register

Application (16)

Y6p 는 Q1 이 1이며 Q9가 0 인

구간에 1을 출력 .

Y6p 는 Q1 이 1이며 Q9가 0 인

구간에 1을 출력 .

Y6 는 Y6p 를 Clk 의 Falling Edge 를 이용하여 반 클럭 밀어준 신호임 .

Y6 는 Y6p 를 Clk 의 Falling Edge 를 이용하여 반 클럭 밀어준 신호임 .

Page 74: State Machine & Timing Design

모바일컴퓨터특강 74

Timing Design – Shift Register

Application (17)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity shift_app2 is port( clk,nclr,WindowAct : in

std_logic; y : buffer std_logic_vector(0 to

6));end shift_app2;architecture a of shift_app2 is

signal q : std_logic_vector(0 to 10);signal y6p : std_logic;

beginShiftRegster :

process(nclr,clk)begin

if( nclr='0') thenq<="00000000000";

elsif(clk'event and clk='1') then

q(0)<= WindowAct;for i in 0 to 9 loop

q(i+1) <= q(i);

end loop;end if;

end process;

y(0) <= q(1) and not q(2);

동일회로

동일회로

동일회로

동일회로

Page 75: State Machine & Timing Design

모바일컴퓨터특강 75

Timing Design – Shift Register

Application (18)process(nclr,clk)begin

if( nclr='0') theny(1)<='0';

elsif(clk'event and clk='0') then

y(1)<=y(0);end if;

end process;

y(2) <= y(0) or y(1); y(3) <= q(9) and not q(10); y(4) <= y(1) or y(3);y(5) <= q(2) and not q(10);

y6p <= q(1) and not q(9); process(nclr,clk)begin

if( nclr='0') theny(6)<='0';

elsif(clk'event and clk='0') then

y(6)<=y6p;end if;

end process;

end a;

동일회로

동일회로

동일회로

동일회로

동일회로

동일회로

Page 76: State Machine & Timing Design

모바일컴퓨터특강 76

Timing Design – Result (1)

Page 77: State Machine & Timing Design

모바일컴퓨터특강 77

Timing Design – Result (2)

Page 78: State Machine & Timing Design

모바일컴퓨터특강 78

Timing Design – Resource Usage

Page 79: State Machine & Timing Design

모바일컴퓨터특강 79

Timing Design – Counter Application (1)

아래와 같은 Timing 입출력 파형을 갖는 회로를 Shift Register 가 아닌 다른 방식 (Counter 응용 ) 으로 설계해보자 .

입력신호 : reset, clk, WindowAct 출력신호 : y0, y1, y2, y3, y4, y5, y6

Page 80: State Machine & Timing Design

모바일컴퓨터특강 80

Timing Design – Counter Application (2)

1. 입력신호 들로부터 cnt[3..0] 을 만들 수 있는가 ?

Page 81: State Machine & Timing Design

모바일컴퓨터특강 81

Timing Design – Counter Application (3)

이 카운터는 WindowAct 가 1 일

때만 증가되며 , WindowAct 가 0 일 때는 0 으로 된다 .

이 카운터는 WindowAct 가 1 일

때만 증가되며 , WindowAct 가 0 일 때는 0 으로 된다 .

process(nclr,clk)

begin

if( nclr='0') then

cnt<="0000";

elsif(clk'event and clk='1') then

if(WindowAct='0') then

cnt<="0000";

else

cnt <= cnt+1;

end if;

end if;

end process;

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity cnt_app2 is

port( clk,nclr,WindowAct : in std_logic;

y : buffer std_logic_vector(0 to 6));

end cnt_app2;

architecture a of cnt_app2 is

signal cnt : std_logic_vector(3 downto 0);

begin

Cnt[3..0] 을 사용

Cnt[3..0] 을 사용

Cnt 회로

Cnt 회로

Page 82: State Machine & Timing Design

모바일컴퓨터특강 82

Timing Design – Counter Application (4)

2. 입력신호 들과 cnt[3..0] 로 부터 Y0, Y3 을 만들 수 있는가 ?

Page 83: State Machine & Timing Design

모바일컴퓨터특강 83

Timing Design – Counter Application (5)

process(cnt)

begin

if( cnt=2) then

y(0)<='1';

else

y(0)<='0';

end if;

end process;

Y0 발생부Y0 발생부Y3 발생부Y3 발생부

process(cnt)begin

if( cnt=10) theny(3)<='1';

elsey(3)<='0';

end if;end process;

Page 84: State Machine & Timing Design

모바일컴퓨터특강 84

Timing Design – Counter Application (6)

3. Y1,Y2,Y4 의 발생은 ?

Page 85: State Machine & Timing Design

모바일컴퓨터특강 85

Timing Design – Counter Application (7)

process(nclr,clk)begin

if( nclr='0') theny(1)<='0';

elsif(clk'event and clk='0') then

y(1)<=y(0);end if;

end process;

y(2) <= y(0) or y(1); y(4) <= y(1) or y(3);

Y2,Y4발생

Y2,Y4발생

Y2 는 Y0 와 Y1을 OR 한 것임을

알 수 있다 .

Y2 = Y0 or Y1

Y2 는 Y0 와 Y1을 OR 한 것임을

알 수 있다 .

Y2 = Y0 or Y1

Y0 를 clk 의 falling edge 를

이용하여 시프트하면

반클럭 시프트된 Y1 을 만들 수 있다 .

Y0 를 clk 의 falling edge 를

이용하여 시프트하면

반클럭 시프트된 Y1 을 만들 수 있다 .

Y4 는 Y1 와 Y3을 OR 한 것임을

알 수 있다 .

Y2 = Y0 or Y1

Y4 는 Y1 와 Y3을 OR 한 것임을

알 수 있다 .

Y2 = Y0 or Y1

Page 86: State Machine & Timing Design

모바일컴퓨터특강 86

Timing Design – Counter Application (8)

4. Y5,Y6 의 발생은 ?

Page 87: State Machine & Timing Design

모바일컴퓨터특강 87

Timing Design – Counter Application (9)

process(nclr,clk)begin

if( nclr='0') theny(5)<='0';

elsif(clk'event and clk='1') thenif(cnt=2) then

y(5)<='1';elsif(cnt=10) then

y(5)<='0';else

y(5)<=y(5);end if;

end if;end process;

Y5 발생부 : Cnt=2일 때 1 로 변하고

Cnt=0 일 때 0 으로 변한다 . Clk 의 risin

g Edge 기준

Y5 발생부 : Cnt=2일 때 1 로 변하고

Cnt=0 일 때 0 으로 변한다 . Clk 의 risin

g Edge 기준

Y6 발생부 : Cnt=2일 때 1 로 변하고

Cnt=0 일 때 0으로 변한다 . Clk의 Falling Edge

기준

Y6 발생부 : Cnt=2일 때 1 로 변하고

Cnt=0 일 때 0으로 변한다 . Clk의 Falling Edge

기준

process(nclr,clk)begin

if( nclr='0') theny(6)<='0';

elsif(clk'event and clk='0') then

if(cnt=2) then

y(6)<='1';elsif(cnt=10)

then

y(6)<='0';else

y(6)<=y(6);end if;

end if;end process;

end a;

Page 88: State Machine & Timing Design

모바일컴퓨터특강 88

Timing Design – Result (1)

Page 89: State Machine & Timing Design

모바일컴퓨터특강 89

Timing Design – Result (2)

Page 90: State Machine & Timing Design

모바일컴퓨터특강 90

Timing Design – Result (3)