CS 110 Computer Architecture. Finite State Machines, Functional Units. Instructor: Sören Schwertfeger.

Similar documents
More Digital Circuits

Sequential Elements con t Synchronous Digital Systems

CS3350B Computer Architecture Winter 2015

CS61C : Machine Structures

CS61C : Machine Structures

Go BEARS~ What are Machine Structures? Lecture #15 Intro to Synchronous Digital Systems, State Elements I C

UC Berkeley CS61C : Machine Structures

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o. Lecture #14

CS61C : Machine Structures

CS 61C: Great Ideas in Computer Architecture

CS61C : Machine Structures

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

CS 151 Final. Instructions: Student ID. (Last Name) (First Name) Signature

COMP sequential logic 1 Jan. 25, 2016

1. Convert the decimal number to binary, octal, and hexadecimal.

CHAPTER 4: Logic Circuits

CS/ECE 250: Computer Architecture. Basics of Logic Design: ALU, Storage, Tristate. Benjamin Lee

Logic Design ( Part 3) Sequential Logic- Finite State Machines (Chapter 3)

Contents Slide Set 6. Introduction to Chapter 7 of the textbook. Outline of Slide Set 6. An outline of the first part of Chapter 7

BCN1043. By Dr. Mritha Ramalingam. Faculty of Computer Systems & Software Engineering

CHAPTER 4: Logic Circuits

COMP2611: Computer Organization. Introduction to Digital Logic

Multiplexor (aka MUX) An example, yet VERY useful circuit!

EECS150 - Digital Design Lecture 3 Synchronous Digital Systems Review. Announcements

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

1. a) For the circuit shown in figure 1.1, draw a truth table showing the output Q for all combinations of inputs A, B and C. [4] Figure 1.

Slide Set 6. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

Logic Design II (17.342) Spring Lecture Outline


Modeling Digital Systems with Verilog

MODULE 3. Combinational & Sequential logic

Chapter 3 Unit Combinational

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

EXPERIMENT: 1. Graphic Symbol: OR: The output of OR gate is true when one of the inputs A and B or both the inputs are true.

Outcomes. Spiral 1 / Unit 6. Flip-Flops FLIP FLOPS AND REGISTERS. Flip-flops and Registers. Outputs only change once per clock period

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design ALU and Storage Elements

Sequential Logic Design CS 64: Computer Organization and Design Logic Lecture #14

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

211: Computer Architecture Summer 2016

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

Logic Design II (17.342) Spring Lecture Outline

Computer Architecture and Organization

Chapter 3. Boolean Algebra and Digital Logic

ECE 263 Digital Systems, Fall 2015

Chapter 5: Synchronous Sequential Logic

Find the equivalent decimal value for the given value Other number system to decimal ( Sample)

Sequential logic circuits

Department of CSIT. Class: B.SC Semester: II Year: 2013 Paper Title: Introduction to logics of Computer Max Marks: 30

Logic Design. Flip Flops, Registers and Counters

ECEN454 Digital Integrated Circuit Design. Sequential Circuits. Sequencing. Output depends on current inputs

WINTER 15 EXAMINATION Model Answer

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

R13 SET - 1 '' ''' '' ' '''' Code No: RT21053

Sequential Logic Circuits

Midterm Exam 15 points total. March 28, 2011

Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Chapter 5 Synchronous Sequential Logic

R13. II B. Tech I Semester Regular Examinations, Jan DIGITAL LOGIC DESIGN (Com. to CSE, IT) PART-A

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 151) Pass Marks: 24

A clock is a free-running signal with a cycle time. A clock may be either high or low, and alternates between the two states.

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

Introduction to Microprocessor & Digital Logic

EMT 125 Digital Electronic Principles I CHAPTER 6 : FLIP-FLOP

CHAPTER1: Digital Logic Circuits

First Name Last Name November 10, 2009 CS-343 Exam 2

MUHAMMAD NAEEM LATIF MCS 3 RD SEMESTER KHANEWAL

ELE2120 Digital Circuits and Systems. Tutorial Note 8

Final Exam review: chapter 4 and 5. Supplement 3 and 4

Principles of Computer Architecture. Appendix A: Digital Logic

D Latch (Transparent Latch)

Contents Circuits... 1

Sequential Circuit Design: Part 1

IT T35 Digital system desigm y - ii /s - iii

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

Computer Systems Architecture

Digital Fundamentals: A Systems Approach

Chapter 5 Sequential Circuits

EECS 270 Group Homework 4 Due Friday. June half credit if turned in by June

Introduction to Sequential Circuits

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

SEMESTER ONE EXAMINATIONS 2002

Digital Logic & Computer Design CS Professor Dan Moldovan Spring Chapter 3 :: Sequential Logic Design

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science SOLUTIONS

Chapter Contents. Appendix A: Digital Logic. Some Definitions

LATCHES & FLIP-FLOP. Chapter 7

Flip Flop. S-R Flip Flop. Sequential Circuits. Block diagram. Prepared by:- Anwar Bari

The word digital implies information in computers is represented by variables that take a limited number of discrete values.

Sequential Circuit Design: Part 1

ASYNCHRONOUS COUNTER CIRCUITS

Sequential Logic. Introduction to Computer Yung-Yu Chuang

Dr. Shahram Shirani COE2DI4 Midterm Test #2 Nov 19, 2008

Transcription:

CS 110 Computer Architecture Finite State Machines, Functional Units Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University Slides based on UC Berkley's CS61C 1

Machine Interpretation Levels of Representation/Interpretation High Level Language Program (e.g., C) Compiler Assembly Language Program (e.g., MIPS) Assembler Machine Language Program (MIPS) Hardware Architecture Description (e.g., block diagrams) Architecture Implementation temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; lw $t0, 0($2) lw $t1, 4($2) sw $t1, 0($2) sw $t0, 4($2) Anything can be represented as a number, i.e., data or instructions 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 Logic Circuit Description (Circuit Schematic Diagrams) 2

Type of Circuits Synchronous Digital Systems consist of two basic types of circuits: Combinational Logic (CL) circuits Output is a function of the inputs only, not the history of its execution E.g., circuits to add A, B (ALUs) Sequential Logic (SL) Circuits that remember or store information aka State Elements E.g., memories and registers (Registers) 3

Uses for State Elements Place to store values for later re-use: Register files (like $1-$31 in MIPS) Memory (caches and main memory) Help control flow of information between combinational logic blocks State elements hold up the movement of information at input to combinational logic blocks to allow for orderly passage 4

Accumulator Example Why do we need to control the flow of information? X i SUM S Want: S=0; for (i=0;i<n;i++) S = S + X i Assume: Each X value is applied in succession, one per cycle After n cycles the sum is present on S 5

First Try: Does this work? Feedback No! Reason #1: How to control the next iteration of the for loop? Reason #2: How do we say: S=0? 6

Second Try: How About This? Register is used to hold up the transfer of data to adder Square wave clock sets when things change Rough timing High (1) Low (0) High (1) Low (0) High (1) Low (0) Time Rounded Rectangle per clock means could be 1 or 0 7

Model for Synchronous Systems Collection of Combinational Logic blocks separated by registers Feedback is optional Clock signal(s) connects only to clock input of registers Clock (CLK): steady square wave that synchronizes the system Register: several bits of state that samples on rising edge of CLK (positive edge-triggered) or falling edge (negative edge-triggered) 8

Register Internals n instances of a Flip-Flop Flip-flop name because the output flips and flops between 0 and 1 D is data input, Q is data output Also called D-type Flip-Flop 9

Flip-Flop Operation Edge-triggered d-type flip-flop This one is positive edge-triggered On the rising edge of the clock, the input d is sampled and transferred to the output. At all other times, the input d is ignored. Example waveforms:

Flip-Flop Timing Edge-triggered d-type flip-flop This one is positive edge-triggered On the rising edge of the clock, the input d is sampled and transferred to the output. At all other times, the input d is ignored. Example waveforms (more detail):

Camera Analogy Timing Terms Want to take a portrait timing right before and after taking picture Set up time don t move since about to take picture (open camera shutter) Hold time need to hold still after shutter opens until camera shutter closes Time click to data time from open shutter until can see image on output (viewscreen) 12

Hardware Timing Terms Setup Time: when the input must be stable before the edge of the CLK Hold Time: when the input must be stable after the edge of the CLK CLK-to-Q Delay: how long it takes the output to change, measured from the edge of the CLK 13

Accumulator Timing 1/2 Reset input to register is used to force it to all zeros (takes priority over D input). S i-1 holds the result of the i th -1 iteration. Analyze circuit timing starting at the output of the register.

Accumulator Timing 2/2 reset signal shown. Also, in practice X might not arrive to the adder at the same time as S i-1 S i temporarily is wrong, but register always captures correct value. In good circuits, instability never happens around rising edge of clk.

Maximum Clock Frequency What is the maximum frequency of this circuit? Hint: Frequency = 1/Period Max Delay = CLK-to-Q Delay + CL Delay + Setup Time 16

Critical Paths Timing Note: delay of 1 clock cycle from input to output. Clock period limited by propagation delay of adder/shifter. 17

Pipelining to improve performance Timing Insertion of register allows higher clock frequency. More outputs per second (higher bandwidth) But each individual result takes longer (greater latency) 18

Recap of Timing Terms Clock (CLK) - steady square wave that synchronizes system Setup Time - when the input must be stable before the rising edge of the CLK Hold Time - when the input must be stable after the rising edge of the CLK CLK-to-Q Delay - how long it takes the output to change, measured from the rising edge of the CLK Flip-flop - one bit of state that samples every rising edge of the CLK (positive edge-triggered) Register - several bits of state that samples on rising edge of CLK or on LOAD (positive edge-triggered)

Question Clock->Q 1ns Setup 1ns Hold 1ns AND delay 1ns What is maximum clock frequency? A: 5 GHz B: 500 MHz C: 200 MHz D: 250 MHz E: 1/6 GHz 20

Finite State Machines (FSM) Intro A convenient way to conceptualize computation over time We start at a state and given an input, we follow some edge to another (or the same) state The function can be represented with a state transition diagram. With combinational logic and registers, any FSM can be implemented in hardware. 21

FSM Example: 3 ones FSM to detect the occurrence of 3 consecutive 1 s in the input. Draw the FSM Input/output Assume state transitions are controlled by the clock: on each clock cycle the machine checks the inputs and moves to a new state and produces a new output 22

Hardware Implementation of FSM Therefore a register is needed to hold the a representation of which state the machine is in. Use a unique bit pattern for each state. + Combinational logic circuit is used to implement a function that maps from present state and input to next state and output. =? 23

FSM Combinational Logic Specify CL using a truth table Truth table PS Input NS Output 00 0 00 0 00 1 01 0 01 0 00 0 01 1 10 0 10 0 00 0 10 1 00 1 24

Representations of Combinational Logic (groups of logic gates) Truth Table Enumerate Inputs Sum of Products, Product of Sums Methods Enumerate Inputs Boolean Expression Use Equivalency between boolean operators and gates Gate Diagram

Building Standard Functional Units Data multiplexers Arithmetic and Logic Unit Adder/ Subtractor 26

Data Multiplexer ( Mux ) (here 2-to-1, n-bit-wide) 27

N instances of 1-bit-wide mux How many rows in TT? 28

How do we build a 1-bit-wide mux? 29

4-to-1 multiplexer? How many rows in TT? 30

Another way to build 4-1 mux? Ans: Hierarchically! 31

Arithmetic and Logic Unit Most processors contain a special logic block called the Arithmetic and Logic Unit (ALU) We ll show you an easy one that does ADD, SUB, bitwise AND, bitwise OR 32

Our simple ALU 33

Question Convert the truth table to a boolean expression (no need to simplify): A: F = xy + x(~y) B: F = xy + (~x)y + (~x)(~y) C: F = (~x)y + x(~y) D: F = xy + (~x)y x y F(x,y) 0 0 0 0 1 1 1 0 0 1 1 1 E: F = (x+y)(~x+~y) 34

How to design Adder/Subtractor? Truth-table, then determine canonical form, then minimize and implement as we ve seen before Look at breaking the problem down into smaller pieces that we can cascade or hierarchically layer 35

Adder/Subtractor One-bit adder LSB 36

Adder/Subtractor One-bit adder (1/2) 37

Adder/Subtractor One-bit adder (2/2) 38

N 1-bit adders => 1 N-bit adder b 0 + + + What about overflow? Overflow = c n? 39

Extremely Clever Subtractor: s = a + (-b) + + + XOR serves as conditional inverter! x sub XOR(x,sub) 0 0 0 0 1 1 1 0 1 1 1 0 40

In Conclusion Finite State Machines have clocked state elements plus combinational logic to describe transition between states Clocks synchronize D-FF change (Setup and Hold times important!) Standard combinational functional unit blocks built hierarchically from subcomponents 41