FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog for sequential machines.

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

FSM Word Problems Today:
Counters Discussion D8.3.
Traffic light contoller using FSM
Sequential logic examples
Chapter #10: Finite State Machine Implementation
Synchronous Sequential Logic
Combinational Logic.
Table 7.1 Verilog Operators.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
Latches CS370 –Spring 2003 Section 4-2 Mano & Kime.
Latches and Flip-Flops Discussion D8.1 Section 13-9.
1 COMP541 Sequential Circuits Montek Singh Sep 17, 2014.
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits – I Flip-Flops A sequential circuit is a logic components whose outputs.
Lecture 22: Sequential Circuits Today’s topic –Clocks and sequential circuits –Finite state machines 1.
Our First Real System.
FPGA-Based System Design: Chapter 6 Copyright  2004 Prentice Hall PTR Register-transfer Design n Basics of register-transfer design: –data paths and controllers.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
FSM examples.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Latches Module M10.1 Section 7.1. Sequential Logic Combinational Logic –Output depends only on current input Sequential Logic –Output depends not only.
Modern VLSI Design 2e: Chapter 5 Copyright  1998 Prentice Hall PTR Topics n Sequential machine implementation: –clocking. n Sequential machine design.
ECE C03 Lecture 101 Lecture 10 Finite State Machine Design Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design 8.5 Finite State Machine.
Modern VLSI Design 2e: Chapter 5 Copyright  1998 Prentice Hall PTR Topics n Memory elements. n Basics of sequential machines.
1 Synchronous Sequential Circuit Design. 2 Sequential circuit design In sequential circuit design, we turn some description into a working circuit – We.
ELEN 468 Advanced Logic Design
Lecture #5 In this lecture we will introduce the sequential circuits.
Lecture 23 Design example: Traffic light controller.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Topics n Basics of sequential machines. n Sequential machine specification. n Sequential.
Sequential Logic in Verilog
1 COMP541 State Machines Montek Singh Feb 8, 2012.
FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Topics n Verilog styles for sequential machines. n Flip-flops and latches.
EE434 ASIC & Digital Systems
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Lab7-1 Lab 6: FSM Description Separate combinational and memory circuits –State memory uses FFs –Others are combinational circuits.
Register Transfer Level & Design with ASM
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Modern VLSI Design 4e: Chapter 5 Copyright  2008 Wayne Wolf Topics n Sequential machine implementation: –clocking. n Sequential machine design.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
IX - Sequential Logic Technology © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Sequential logic implementation Implementation  random logic.
IX - Sequential Logic TechnologyContemporary Logic Design1 Ch 9. Sequential Logic Technologies.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2007.
COMP541 Sequential Circuits
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
Verilog® HDL Behavioral Modeling (2)
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
Pusat Pengajian Kejuruteraan Mikroelektronik EMT 351/4 DIGITAL IC DESIGN Verilog Behavioural Modeling (Part 4) Week #
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Modern VLSI Design 3e: Chapter 8 Copyright  1998, 2002 Prentice Hall PTR Topics n Verilog register-transfer modeling: –basics using traffic light controller;
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Chapter #6: Sequential Logic Design
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
Synchronous Sequential Circuit Design
CS Fall 2005 – Lec. #5 – Sequential Logic - 1
Digital Logic Design Digital Design, M. Morris Mano and Michael D
SYNTHESIS OF SEQUENTIAL LOGIC
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
Topics Verilog styles for sequential machines. Flip-flops and latches.
Sequential logic implementation
The Verilog Hardware Description Language
Lecture 24 Logistics Last lecture Today HW7 back today
Lecture 3: Timing & Sequential Circuits
Presentation transcript:

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog for sequential machines

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog always statement n Use always to wait for clock edge: clock) // start execution at the clock edge begin // insert combinational logic here end

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog state machine clock) // start execution at the clock edge begin if (rst == 1) begin // reset code end else begin // state machine case (state) ‘state0: begin o1 = 0; state = ‘state1; end ‘state1: begin if (i1) o1 = 1; else o1 = 0; state = ‘state0; endcase end // state machine end

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Traffic light controller n Intersection of two roads: –highway (busy); –farm (not busy). n Want to give green light to highway –as much as possible. n Want to give green to farm –when needed. n Must always have –at least one red light.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Traffic light system highway farm road sensor traffic light

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR System operation n Sensor on farm road –indicates when cars on farm road are waiting for green light. n Must obey –required lengths for green, yellow lights.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Traffic light machine n Build controller out of two machines: –sequencer which sets colors of lights, etc. –timer which is used to control durations of lights. n Separate counter isolates logical design from clock period. n Separate counter greatly reduces number of states in sequencer.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Sequencer state transition graph hwy- green farm- green hwy- yellow farm- yellow (cars & long)’ / 0 green red cars & long / 1 green red short’ / 0 yellow red short / 1 yellow red cars & long’ / 0 red green cars’ & long / 1 red green short’ / 0 red yellow short/ 1 red yellow

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog model of controller module sequencer(rst,clk,cars,long,short,hg,hy,hr,fg,fy,fr,count_reset); input rst, clk; /* reset and clock */ input cars; // high when a car is present at the farm road input long, short; /* long and short timers */ output hg, hy, hr; // highway light: green, yellow, red output fg, fy, fr; /* farm light: green, yellow, red */ reg hg, hy, hr, fg, fy, fr; // remember these outputs output count_reset; /* reset the counter */ reg count_reset; // register this value for simplicity // define the state codes ‘define HWY_GREEN 0 ‘define HWY_YX 1 ‘define HWY_YELLOW 2 ‘define HWY_YY 3 ‘define FARM_GREEN 4 ‘define FARM_YX 5 ‘define FARM_YELLOW 6 ‘define FARM_YY 7 reg [2:0] state; // state of the sequencer clk) begin if (rst == 1) begin state = ‘HWY_GREEN; // default state count_reset = 1; end

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog model of controller, cont’d. else begin // state machine count_reset = 0; case (state) ‘HWY_GREEN: begin if (~(cars & long)) state = ‘HWY_GREEN; else begin state = ‘HWY_YX; count_reset = 1; end hg = 1; hy = 0; hr = 0; fg = 0; fy = 0; fr = 1; end ‘HWY_YX: begin state = ‘HWY_YELLOW; hg = 0; hy = 1; hr = 0; fg = 0; fy = 0; fr = 1; end ‘HWY_YELLOW: begin if (~short) state = ‘HWY_YELLOW; else begin state = ‘FARM_YY; end hg = 0; hy = 1; hr = 0; fg = 0; fy = 0; fr = 1; end ‘FARM_YY: begin state = ‘FARM_GREEN; hg = 0; hy = 0; hr = 1; fg = 1; fy = 0; fr = 0; end

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog model of system ‘FARM_GREEN: begin if (cars & ~long) state = ‘FARM_GREEN; else begin state = ‘FARM_YX; count_reset = 1; end hg = 0; hy = 0; hr = 1; fg = 1; fy = 0; fr = 0; end ‘FARM_YX: begin state = ‘FARM_YELLOW; hg = 0; hy = 0; hr = 1; fg = 1; fy = 0; fr = 0; end ‘FARM_YELLOW: begin if (~short) state = ‘FARM_YELLOW; else begin state = ‘HWY_GREEN; end hg = 0; hy = 0; hr = 1; fg = 0; fy = 1; fr = 0; end ‘HWY_YY: begin state = ‘HWY_GREEN; hg = 1; hy = 0; hr = 0; fg = 0; fy = 0; fr = 1; end endcase end // state machine end // always endmodule

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog model of timer module timer(rst,clk,long,short); input rst, clk; // reset and clock output long, short; // long and short timer outputs reg [3:0] tval; // current state of the timer clk) // update the timer and outputs if (rst == 1) begin tval = 4’b0000; short = 0; long = 0; end // reset else begin {long,tval} = tval + 1; // raise long at rollover if (tval == 4’b0100) short = 1’b1; // raise short after 2^2 end // state machine endmodule

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog model of system module tlc(rst,clk,cars,hg,hy,hr,fg,fy,fr); input rst, clk; // reset and clock input cars; // high when a car is present at the farm road output hg, hy, hr; // highway light: green, yellow, red output fg, fy, fr; // farm light: green, yellow, red wire long, short, count_reset; // long and short // timers + counter reset sequencer s1(rst,clk,cars,long,short, hg,hy,hr,fg,fy,fr,count_reset); timer t1(count_reset,clk,long,short); endmodule

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR The synchronous philosophy n All operation is controlled by the clock. –All timing is relative to clock. –Separates functional, performance optimizations. n Put a lot of work into designing the clock network so you don’t have to worry about it throughout the combinational logic.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Register characteristics n Form of clock signal –used to trigger the register. n How the behavior of data around the clock trigger affects the stored value. n When the stored value is presented at the output. n Whether there is ever a combinational path from input to output.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Types of registers n Latch: transparent when internal memory is being set. n Flip-flop: not transparent, reading and changing output are separate.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Types of registers n D-type (data). Q output is determined by the D input at the clocking event. n T-type (toggle). Toggles its state at input event. n SR-type (set/reset). Set or reset by inputs (S=R=1 not allowed). n JK-type. Allows both J and K to be 1, otherwise similar to SR.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Clock event n Change in clock signal that controls register behavior. –0-1 transition or 1-0 transition. n Data must generally be held constant around the clock event.

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Setup and hold times time clock D changing stable event setup hold

FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Duty cycle n Percentage of time that clock is active. 50%