CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Instructor: Mohsen Imani. Slides from Tajana Simunic Rosing

Similar documents
CSE140L: Components and Design Techniques for Digital Systems Lab. Power Consumption in Digital Circuits. Pietro Mercati

Synchronous Sequential Circuit Design. Dr. Ehab A. H. AL-Hialy Page 1

Example: vending machine

Models for representing sequential circuits

Synchronous Sequential Circuit Design

EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

Ch 7. Finite State Machines. VII - Finite State Machines Contemporary Logic Design 1

Ch 9. Sequential Logic Technologies. IX - Sequential Logic Technology Contemporary Logic Design 1

Chapter 6. Synchronous Sequential Circuits

Last lecture Counter design Finite state machine started vending machine example. Today Continue on the vending machine example Moore/Mealy machines

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences

Present Next state Output state w = 0 w = 1 z A A B 0 B A C 0 C A C 1

Power Dissipation. Where Does Power Go in CMOS?

Synchronous Sequential Circuit Design. Digital Computer Design

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process

EE141Microelettronica. CMOS Logic

Spiral 2 7. Capacitance, Delay and Sizing. Mark Redekopp

EE241 - Spring 2000 Advanced Digital Integrated Circuits. Announcements

Design of Datapath Controllers

Low Power CMOS Dr. Lynn Fuller Webpage:

Finite State Machine (FSM)

Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

Lecture 2: CMOS technology. Energy-aware computing

EE241 - Spring 2001 Advanced Digital Integrated Circuits

Where Does Power Go in CMOS?

EE 466/586 VLSI Design. Partha Pande School of EECS Washington State University

EECS150 - Digital Design Lecture 23 - FSMs & Counters

Review Problem 1. should be on. door state, false if light should be on when a door is open. v Describe when the dome/interior light of the car

Lecture 7: Logic design. Combinational logic circuits

EECS 270 Midterm 2 Exam Answer Key Winter 2017

ECE321 Electronics I

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING QUESTION BANK

Different encodings generate different circuits

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BENG (HONS) ELECTRICAL & ELECTRONICS ENGINEERING EXAMINATION SEMESTER /2017

CIS 371 Computer Organization and Design

Chapter 8. Low-Power VLSI Design Methodology

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

ALU, Latches and Flip-Flops

Introduction to CMOS VLSI Design (E158) Lecture 20: Low Power Design

Adders, subtractors comparators, multipliers and other ALU elements

CARNEGIE MELLON UNIVERSITY DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING DIGITAL INTEGRATED CIRCUITS FALL 2002

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

EXPERIMENT Traffic Light Controller

Sequential Logic Optimization. Optimization in Context. Algorithmic Approach to State Minimization. Finite State Machine Optimization

ENGG 1203 Tutorial _03 Laboratory 3 Build a ball counter. Lab 3. Lab 3 Gate Timing. Lab 3 Steps in designing a State Machine. Timing diagram of a DFF

Lab #10: Design of Finite State Machines

Lecture 6 Power Zhuo Feng. Z. Feng MTU EE4800 CMOS Digital IC Design & Analysis 2010

EE115C Digital Electronic Circuits Homework #4

14.1. Unit 14. State Machine Design

MODULE III PHYSICAL DESIGN ISSUES

Generalized FSM model: Moore and Mealy

EECS 427 Lecture 11: Power and Energy Reading: EECS 427 F09 Lecture Reminders

Announcements. EE141- Fall 2002 Lecture 7. MOS Capacitances Inverter Delay Power

CSE140: Design of Sequential Logic

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

THE INVERTER. Inverter

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

EE115C Winter 2017 Digital Electronic Circuits. Lecture 6: Power Consumption

ELEC Digital Logic Circuits Fall 2014 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10)

Dynamic operation 20

L16: Power Dissipation in Digital Systems. L16: Spring 2007 Introductory Digital Systems Laboratory

Objective and Outline. Acknowledgement. Objective: Power Components. Outline: 1) Acknowledgements. Section 4: Power Components

ECE 407 Computer Aided Design for Electronic Systems. Simulation. Instructor: Maria K. Michael. Overview

Chapter 3. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 3 <1>

Name: Answers. Mean: 83, Standard Deviation: 12 Q1 Q2 Q3 Q4 Q5 Q6 Total. ESE370 Fall 2015

EECS 312: Digital Integrated Circuits Midterm Exam 2 December 2010

CSE140: Components and Design Techniques for Digital Systems. Midterm Information. Instructor: Mohsen Imani. Sources: TSR, Katz, Boriello & Vahid

Synchronous Sequential Logic

Lecture 16: Circuit Pitfalls

Digital Integrated Circuits A Design Perspective

Dynamic Combinational Circuits. Dynamic Logic

MOSIS REPORT. Spring MOSIS Report 1. MOSIS Report 2. MOSIS Report 3

Dynamic Combinational Circuits. Dynamic Logic

NTE74HC299 Integrated Circuit TTL High Speed CMOS, 8 Bit Universal Shift Register with 3 State Output

Lecture 8-1. Low Power Design

Last Lecture. Power Dissipation CMOS Scaling. EECS 141 S02 Lecture 8

State Graphs FSMs. Page 1

CSE 140 Midterm 2 Tajana Simunic Rosing. Spring 2008

CMPE12 - Notes chapter 1. Digital Logic. (Textbook Chapter 3)

CSC 322: Computer Organization Lab

CprE 281: Digital Logic

Lecture 21: Packaging, Power, & Clock

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 9 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

ELCT201: DIGITAL LOGIC DESIGN

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary

Fig. 1 CMOS Transistor Circuits (a) Inverter Out = NOT In, (b) NOR-gate C = NOT (A or B)

MODULE 5 Chapter 7. Clocked Storage Elements

Chapter 3. Chapter 3 :: Topics. Introduction. Sequential Circuits

Fundamentals of Computer Systems

NTE74HC109 Integrated Circuit TTL High Speed CMOS, Dual J K Positive Edge Triggered Flip Flop w/set & Reset

Chapter 5 Synchronous Sequential Logic

LOGIC CIRCUITS. Basic Experiment and Design of Electronics. Ho Kyung Kim, Ph.D.

Testability. Shaahin Hessabi. Sharif University of Technology. Adapted from the presentation prepared by book authors.

ESE570 Spring University of Pennsylvania Department of Electrical and System Engineering Digital Integrated Cicruits AND VLSI Fundamentals

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

5.0 CMOS Inverter. W.Kucewicz VLSICirciuit Design 1

Fundamentals of Computer Systems

Adders, subtractors comparators, multipliers and other ALU elements

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output of

Transcription:

CSE140L: Components and Design Techniques for Digital Systems Lab FSMs Instructor: Mohsen Imani Slides from Tajana Simunic Rosing Source: Vahid, Katz 1

FSM design example Moore vs. Mealy Remove one 1 from every string of 1s on the input Moore Mealy zero [0] 1 0 zero [0] 0/0 0 0 one1 [0] 1 two1s [1] 1 0/0 one1 [0] 1/0 1/1

Verilog FSM - Reduce 1s example Moore machine module reduce (clk, reset, in, out); input clk, reset, in; output out; state assignment (easy to change, if in one place) parameter zero = 2 b00; parameter one1 = 2 b01; parameter two1s = 2 b10; reg out; reg [1:0] state; // state variables reg [1:0] next_state; always @(posedge clk)begin if (reset) state = zero; else state = next_state; end 0 0 zero [0] 1 one1 [0] 1 two1s [1] 0 1 Always include a reset signal!!!

Moore Verilog FSM (cont d) always @(in or state) begin case (state) zero: // last input was a zero begin if (in) next_state = one1; else next_state = zero; end one1: // we've seen one 1 begin if (in) next_state = two1s; else next_state = zero; end two1s: // we've seen at least 2 ones begin if (in) next_state = two1s; else end endcase end next_state = zero; crucial to include all signals that are input to state determination note that output depends only on state always @(state) begin case (state) zero: out = 0; one1: out = 0; two1s: out = 1; endcase end endmodule

Mealy Verilog FSM module reduce (clk, reset, in, out); input clk, reset, in; output out; reg out; reg state; // state variables reg next_state; always @(posedge clk)begin if (reset) state = zero; else state = next_state; end always @(in or state) case (state) zero: // last input was a zero begin out = 0; if (in) next_state = one; else next_state = zero; end one: // we've seen one 1 if (in) begin next_state = one; out = 1; end else begin next_state = zero; out = 0; end endcase end endmodule 0/0 zero [0] one1 [0] 1/0 0/0 1/1

Mealy/Moore Summary Mealy machines tend to have fewer states different outputs on arcs (i*n) rather than states (n) Mealy machines react faster to inputs react in same cycle don't need to wait for clock delay to output depends on arrival of input Moore machines are generally safer to use outputs change at clock edge (always one cycle later) in Mealy machines, input change can cause output change as soon as logic is done a big problem when two machines are interconnected asynchronous feedback 6

Example: Traffic light controller Highway/farm road intersection farm road car sensors highway

Traffic light controller (cont.) Detectors C sense the presence of cars waiting on the farm road with no car on farm road, light remain green in highway direction if vehicle on farm road, highway lights go from Green to Yellow to Red, allowing the farm road lights to become green these stay green only as long as a farm road car is detected but never longer than a set interval; after the interval expires, farm lights transition from Green to Yellow to Red, allowing highway to return to green even if farm road vehicles are waiting, highway gets at least a set interval of green Assume you have an interval timer that generates: a short time pulse (TS) and a long time pulse (TL), in response to a set (ST) signal. TS is to be used for timing yellow lights and TL for green lights

Traffic light controller (cont.) inputs description outputs description reset place FSM in initial state HG, HY, HR assert green/yellow/red highway lights C detect vehicle on the farm road FG, FY, FR assert green/yellow/red highway lights TS short time interval expired ST start timing a short or long interval TL long time interval expired state description HG highway green (farm road red) HY highway yellow (farm road red) FG farm road green (highway red) FY farm road yellow (highway red) (TL C)' TL C / ST HG Reset TS / ST TS' HY FY TS' TS / ST FG TL+C' / ST (TL+C')'

Traffic light controller (cont.) Generate state table with symbolic states Consider state assignments output encoding similar problem to state assignment (Green = 00, Yellow = 01, Red = 10) Inputs Present State Next State Outputs C TL TS ST H F 0 HG HG 0 Green Red 0 HG HG 0 Green Red 1 1 HG HY 1 Green Red 0 HY HY 0 Yellow Red 1 HY FG 1 Yellow Red 1 0 FG FG 0 Red Green 0 FG FY 1 Red Green 1 FG FY 1 Red Green 0 FY FY 0 Red Yellow 1 FY HG 1 Red Yellow SA1: HG = 00 HY = 01 FG = 11 FY = 10 SA2: HG = 00 HY = 10 FG = 01 FY = 11 SA3: HG = 0001 HY = 0010 FG = 0100 FY = 1000 (one-hot)

Traffic light controller FSM Specification of inputs, outputs, and state elements module FSM(HR, HY, HG, FR, FY, FG, ST, TS, TL, C, reset, Clk); output HR; output HY; output HG; parameter highwaygreen = 6'b001100; output FR; parameter highwayyellow = 6'b010100; output FY; parameter farmroadgreen = 6'b100001; output FG; parameter farmroadyellow = 6'b100010; output ST; input TS; input TL; assign HR = state[6]; input C; assign HY = state[5]; input reset; assign HG = state[4]; input Clk; assign FR = state[3]; assign FY = state[2]; reg [6:1] state; assign FG = state[1]; reg ST; specify state bits and codes for each state as well as connections to outputs

Traffic light controller FSM initial begin state = highwaygreen; ST = 0; end always @(posedge Clk) begin if (reset) begin state = highwaygreen; ST = 1; end else begin ST = 0; case (state) highwaygreen: end endmodule case statement triggerred by clock edge if (TL & C) begin state = highwayyellow; ST = 1; end highwayyellow: if (TS) begin state = farmroadgreen; ST = 1; end farmroadgreen: if (TL!C) begin state = farmroadyellow; ST = 1; end farmroadyellow: if (TS) begin state = highwaygreen; ST = 1; end endcase end

Timer FSM for traffic light controller module Timer(TS, TL, ST, Clk); output TS; output TL; input ST; input Clk; integer value; assign TS = (value >= 4); // 5 cycles after reset assign TL = (value >= 14); // 15 cycles after reset always @(posedge ST) value = 0; // async reset always @(posedge Clk) value = value + 1; endmodule

Complete traffic light controller Tying it all together (FSM + timer) with structural Verilog (same as a schematic drawing) module main(hr, HY, HG, FR, FY, FG, reset, C, Clk); output HR, HY, HG, FR, FY, FG; input reset, C, Clk; Timer part1(ts, TL, ST, Clk); FSM part2(hr, HY, HG, FR, FY, FG, ST, TS, TL, C, reset, Clk); endmodule traffic light controller ST timer TS TL

Finite state machines summary Models for representing sequential circuits abstraction of sequential elements finite state machines and their state diagrams inputs/outputs Mealy, Moore, and synchronous Mealy machines Finite state machine design procedure deriving state diagram deriving state transition table determining next state and output functions implementing combinational logic Hardware description languages Use good coding style Communicating FSMs

Design space of digital circuits When designing circuits, we want to achieve a desired functionality while looking for tradeoffs between the following: - Performance (e.g. timing, delay, clock frequency) - Power consumption Power Slow, power hungry Slow, low power Fast, power hungry Fast, low power Power and performance are closely related. In general, you cannot decrease one without increasing the other Performance Your design might have a number of additional constraints: - Area - Accuracy 16

What is power? In physics: Power is the rate of doing work (i.e. the rate of consuming Energy) P = E t Units of measure: - Power: Watt - Energy: Joule 1 Watt = 1 Joule / 1 second Power is a function of time, energy is not! P(t) Energy consumed in a time interval [t 0, t 1 ]: t 0 t 1 time t 1P E = න t dt t 0 17

Power consumption of circuits The definition of work done per unit time is still valid We need to investigate more into details what the work done is in electrical circuits Work done = E = V Q V = voltage Q = charge P = work done per unit time = E t = VQ t = V I Example: Resistor V I Conservation of energy: energy cannot be created or destroyed, but can be altered from one form to another Electrical energy dissipated on a resistor turns into heat 18

There is power consumed every time there is a current flowing (I) subject to a difference of electric potential (V). Remember: - Transistors have an intrinsic resistance - We model the output connection of gates with a load capacitance Example: CMOS inverter When is that the inverter is consuming electric power? - When the output is changing its values (and transistors are switching) - Also, when transistor are OFF, they are still leaking some current Where is this power going to? - Dissipated as heat - Spent for charging the load capacitor 19

Power consumption Power dissipation in CMOS circuits comes from two components: Dynamic Power Takes place when transistors are switching Charging and discharging (switching) of the load capacitance Short-Circuit current while both pmos and nmos networks are partially ON Static Power Given by leakage currents Subtreshold conduction Tunneling current Leakage through reverse biased diodes 20

Dynamic power Dynamic power can be modeled by a relatively simple mathematical model: V: Operating voltage of the circuit P dynamic = A C V 2 f f: Operating frequency (i.e. clock) of the circuit C: Capacitance - Equivalent capacitance of the circuit - Once the circuit is built, this is a fixed property of the circuit - It is a function of number and dimension of wires and transistors A: Activity factor - It is a term that accounts for how much the transistors are switching - It is a property of the workload of the circuit (for example, the application you are executing on your computer) 21

Static power Static power can be expressed by the product of voltage times leakage current: P static = V I leakage - The leakage current I leakage is a rather complicated term, which is itself the sum of different contributions (depending on the physical origin of the leak). - Subthreshold leakage - Gate leakage - Junction leakage - Contention current - Such contributions have much more complicated equations, which depend on many technological and physical parameters of transistors 22

Problems related to power consumption - Data centers: - Electricity bill $$$ - Mobile devices: - Battery - Common problem: Higher temperature - Temperature increases linearly with power. - Data centers: fans, cooling systems, AC even higher electricity bill! - Mobiles: Overheating, discomfort for the user, risk of damaging the device. - Higher temperature higher static power consumption! 23

How to reduce dynamic power consumption? Dynamic power reduction: P dynamic = A C V 2 f Decrease activity factor Selective clock gating Drawback: if the system transitions rapidly from an idle mode to a fully active mode a large di/dt spike will occur Decrease switching capacitance Small transistors Careful floor planning to reduce interconnect Decrease power supply Adjust voltage depending on the operating mode Decrease operating frequency Modern OS and processors support Dynamic Voltage Frequency Scaling (DVFS) 24

Example 1: GPU, power and FPS Your operating system can control the operating frequency and voltage of your GPU while playing 3D games. This would also impact the quality of the game, referred to as Frames per Second (FPS). For the game to be playable, the FPS should be at least 60. Assume that FPS increases linearly with frequency: FPS = b f Where b = 0.5 1.15 Voltage [V] Assume the GPU has a range of frequency 100 300 Mhz, and can switch only between fixed Voltage-frequency pairs 1.1 1.05 1 0.95 0.9 0.85 0.8 50 100 150 200 250 300 350 Frequency [MHz] 25

Example 1: GPU, power and FPS 1.15 Voltage [V] FPS target = b f target 1.1 1.05 f target = FPS target b = 60 0.5 = 120Mhz 1 0.95 0.9 0.85 f selected = 150MHz V selected = 0.95V 0.8 50 100 150 200 250 300 350 Frequency [MHz] FPS = b f selected = 75 > FSP target Assuming that A = 0.8, C = 120pF, and that the static power is constant and equal to 5W, calculate the total power consumption P dynamic = ACV 2 f = 0.8 120 10 9 0.95 2 150 10 6 13W P total = P dynamic + P static = 13W + 5W = 18W 26

Example 2: Smartphone under the sun If your phone is under the sun, the temperature of the processor is 70 C. When it is under the shade, the temperature is 40 C. Assume that the static power is described by: P static = a e bt Where a = 1 W and b = 1 50 1 C Assuming that the battery has 2000J of residual capacity, how long do you increase the battery lifetime by keeping it on the shade? (assume that the dynamic power is zero and that the power consumption of other components is negligible) E t 40 C = P static (40 C) = 2000J 900 s 2.22W E t 70 C = P static (70 C) 500s 27