Chapter8: State Machine ppsx

27 156 0
Chapter8: State Machine ppsx

Đ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

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: 2 Agenda 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) 8. Chapter 8: State machines (Week6) 9. Chaper 9: Testbench and verification (Week7) 3 Why FSM ? 4 • Moore FSM model comb. circuit inputs memory elements next state comb. circuit outputs current state Finite State Machine Next state = F (current state, inputs) Outputs = G (current state) 5 • Moore FSM model Finite State Machine 6 • Mealy FSM model comb. circuit inputs memory elements next state comb. circuit outputs current state Finite State Machine Next state = F (current state, inputs) Outputs = G (current state, inputs) 7 Finite State Machine • Mealy FSM model 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 9 module FSM(o, a, b, reset); output o; reg o; input a, b, reset; reg [1:0] state, nextState; always @(a or b or state) case (state) 2’b00: begin nextState = a ? 2’b00 : 2’b01; o = a & b; end 2’b01: begin nextState = 2’b10; o = 0; end endcase Combinational block must be sensitive to any change on any of its inputs (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 10 module FSM(o, a, b); output o; reg o; input a, b; reg [1:0] state; always @(posedge clk or reset) if (reset) state <= 2’b00; else case (state) 2’b00: begin state <= a ? 2’b00 : 2’b01; o <= a & b; end 2’b01: begin state <= 2’b10; o <= 0; end endcase Method2: FSMs modeling [...]... else next _state = got10; got10: if (dataIn) next _state = got101; else next _state = reset; got101: if (dataIn) next _state = got1; else next _state = got10; default: next _state = reset; endcase // case (state) / /State FF Transition always @(posedge clock) if (reset == 1) state . model comb. circuit inputs memory elements next state comb. circuit outputs current state Finite State Machine Next state = F (current state, inputs) Outputs = G (current state) 5 • Moore FSM model Finite State Machine 6 • Mealy FSM model comb. circuit inputs memory elements next state comb. circuit outputs current state Finite. model comb. circuit inputs memory elements next state comb. circuit outputs current state Finite State Machine Next state = F (current state, inputs) Outputs = G (current state, inputs) 7 Finite State Machine • Mealy FSM model 8 FSMs modeling •. Cont’d) 13 //Combinational Next State Logic always @ (state or dataIn) case (state) reset: if (dataIn) next _state = got1; else next _state = reset; got1: if (dataIn) next _state = got1; else next _state = got10; got10: if

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

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan