1. Trang chủ
  2. » Công Nghệ Thông Tin

Chapter8: State Machine ppsx

27 157 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 27
Dung lượng 737,77 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

NATIONAL UNIVERSITY OF HO CHI MINH CITY UNIVERSITY OF INFORMATION TECHNOLOGY FACULTY OF COMPUTER ENGINEERING LECTURE Lecturer: Lam Duc Khai VERILOG Hardware Design Language Chapter8: St

Trang 1

NATIONAL UNIVERSITY OF HO CHI MINH CITY UNIVERSITY OF INFORMATION TECHNOLOGY FACULTY OF COMPUTER ENGINEERING

LECTURE

Lecturer: Lam Duc Khai

VERILOG Hardware Design Language

Chapter8: State Machine

Subject:

Trang 2

1 Chapter 1: Introduction ( Week1)

2 Chapter 2: Fundamental concepts (Week1)

3 Chapter 3: Modules and hierarchical structure (Week2)

4 Chapter 4: Primitive Gates – Switches – User defined

primitives (Week2)

5 Chapter 5: Structural model (Week3)

6 Chapter 6: Behavioral model – Combination circuit &

Sequential circuit (Week4 & Week5)

7 Chapter 7: Tasks and Functions (Week6)

Trang 3

3Why FSM ?

Trang 4

Finite State Machine

Next state = F (current state, inputs)

Outputs = G (current state)

Trang 5

• Moore FSM model

Finite State Machine

Trang 6

Finite State Machine

Next state = F (current state, inputs) Outputs = G (current state, inputs)

Trang 7

7Finite State Machine

• Mealy FSM model

Trang 8

FSMs modeling

• There are many ways to model FSMs:

 Method1: Define the next-state logic combinationally and

define the state-holding latches explicitly

 Method2: Define the behavior in a single always

@(posedge clk) block

• Variations on these themes

Trang 9

reg [1:0] state, nextState;

always @(a or b or state)

(Implies state-holding elements otherwise)

Output o is declared a reg because it is assigned procedurally, not because it holds state

always @(posedge clk or reset)

if (reset) state <= 2’b00;

else state <= nextState;

Latch implied by sensitivity

to the clock or reset only

Method1:

FSMs modeling

Trang 11

11Example1: A Moore 101 Detector

Trang 12

module Moore101Detector (dataIn, found, clock, reset);

//Input and Output Declarations

Trang 13

//Combinational Next State Logic

always @(state or dataIn)

else state <= next_state;

//Combinational Output Logic

assign found = (state == got101) ? 1: 0;

endmodule // Moore101Detector

Example1: A Moore 101 Detector ( Cont’d)

Trang 14

Example2: A Mealy 101 Detector

Trang 15

module Mealy101Detector (dataIn, found, clock, reset);

//Input and Output Declarations

Trang 16

//Combinational Next State Logic

always @(state or dataIn)

else state <= next_state;

//Combinational Output Logic

assign found = (state == got10 &&

dataIn == 1) ? 1: 0;

Example2: A Mealy 101 Detector (Cont’d)

Trang 17

Example3: Traffic Light Controller

Trang 18

? Tabulation of Inputs and Outputs:

place FSM in initial state

detect vehicle on farmroad

short time interval expired

long time interval expired

Description

assert green/yellow/red highway lights

assert green/yellow/red farmroad lights

start timing a short or long interval

? Tabulation of Unique States: Some light configuration imply others

Specifications

Example3: Traffic Light Controller (Cont’d)

Trang 19

HR HG HY FR FG FY

Block diagram

Example3: Traffic Light Controller (Cont’d)

Trang 20

State transition diagram

S0: HGS1: HYS2: FGS3: FY

Reset

TL + C

S0 TL•C/ST TS

Trang 21

module traffic_light(HG, HY, HR, FG, FY, FR,ST_o,

tl, ts, clk, reset, c) ;output HG, HY, HR, FG, FY, FR, ST_o;

input tl, ts, clk, reset, c ;

reg ST_o, ST ;

reg[0:1] state, next_state ;

parameter EVEN= 0, ODD=1 ;

Trang 22

// flip-flops

always@ (posedge clk or posedge reset)

if(reset) // an asynchronous resetbegin

state = S0 ;ST_o = 0 ;end

elsebeginstate = next_state ;

Example3: Traffic Light Controller (Cont’d)

Verilog FSM Description (Cont’d)

Trang 23

ST = 1 ;end

elsebeginnext_state = S0 ;

ST = 0 ;end

Reset

TL + C

S0 TL•C/ST TS

Example3: Traffic Light Controller (Cont’d)

Verilog FSM Description (Cont’d)

Trang 24

if (ts) begin

next_state = S2 ;

ST = 1 ;end

else begin

next_state = S1 ;

ST = 0 ;end

Example3: Traffic Light Controller (Cont’d)

Verilog FSM Description (Cont’d)

Trang 25

S3:

if(ts)beginnext_state = S0 ;

ST = 1 ;end

elsebeginnext_state = S3 ;

ST = 0 ;end

Example3: Traffic Light Controller (Cont’d)

Verilog FSM Description (Cont’d)

Trang 26

Tips on FSM

Trang 27

END

Ngày đăng: 31/07/2014, 14:20

TỪ KHÓA LIÊN QUAN