CS 61C: Great Ideas in Computer Architecture. Functional Units, Finite State Machines

Similar documents
CS 61C: Great Ideas in Computer Architecture Finite State Machines. Machine Interpreta4on

EE 42/100 Lecture 24: Latches and Flip Flops. Rev B 4/21/2010 (2:04 PM) Prof. Ali M. Niknejad

Lecture 8: Synchronous Digital Systems

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

Register File, Finite State Machines & Hardware Control Language

Latches, the D Flip-Flop & Counter Design. ECE 152A Winter 2012

EE360: Digital Design I Course Syllabus

Chapter 2 Logic Gates and Introduction to Computer Architecture

Introduction to CMOS VLSI Design (E158) Lecture 8: Clocking of VLSI Systems

A New Paradigm for Synchronous State Machine Design in Verilog

Lecture 7: Clocking of VLSI Systems

CHAPTER 3 Boolean Algebra and Digital Logic

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Computer organization

Lesson 12 Sequential Circuits: Flip-Flops

CS311 Lecture: Sequential Circuits

Binary Adders: Half Adders and Full Adders

Flip-Flops, Registers, Counters, and a Simple Processor

ASYNCHRONOUS COUNTERS

The 104 Duke_ACC Machine

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

Latch Timing Parameters. Flip-flop Timing Parameters. Typical Clock System. Clocking Overhead

CSE140: Components and Design Techniques for Digital Systems

Understanding Logic Design

Systems I: Computer Organization and Architecture

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

University of St. Thomas ENGR Digital Design 4 Credit Course Monday, Wednesday, Friday from 1:35 p.m. to 2:40 p.m. Lecture: Room OWS LL54

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Lab 1: Full Adder 0.0

Let s put together a Manual Processor

Gates, Circuits, and Boolean Algebra

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

DEPARTMENT OF INFORMATION TECHNLOGY

Take-Home Exercise. z y x. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

5 Combinatorial Components. 5.0 Full adder. Full subtractor

Quartus II Introduction for VHDL Users

Gates, Plexers, Decoders, Registers, Addition and Comparison

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

CHAPTER 11: Flip Flops

ECE232: Hardware Organization and Design. Part 3: Verilog Tutorial. Basic Verilog

3.Basic Gate Combinations

1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1.

(Refer Slide Time: 00:01:16 min)

United States Naval Academy Electrical and Computer Engineering Department. EC262 Exam 1

Memory Elements. Combinational logic cannot remember

Gray Code Generator and Decoder by Carsten Kristiansen Napier University. November 2004

SIM-PL: Software for teaching computer hardware at secondary schools in the Netherlands

Lecture 11: Sequential Circuit Design

Lecture 10 Sequential Circuit Design Zhuo Feng. Z. Feng MTU EE4800 CMOS Digital IC Design & Analysis 2010

Counters and Decoders

Lecture 10: Sequential Circuits

Digital Controller for Pedestrian Crossing and Traffic Lights

Sequential Logic Design Principles.Latches and Flip-Flops

Asynchronous counters, except for the first block, work independently from a system clock.

EXPERIMENT 4. Parallel Adders, Subtractors, and Complementors

Counters are sequential circuits which "count" through a specific state sequence.

Digital Electronics Detailed Outline

Generating MIF files

Lecture 5: Gate Logic Logic Optimization

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Binary full adder. 2-bit ripple-carry adder. CSE 370 Spring 2006 Introduction to Digital Design Lecture 12: Adders

Xilinx ISE. <Release Version: 10.1i> Tutorial. Department of Electrical and Computer Engineering State University of New York New Paltz

Getting the Most Out of Synthesis

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

Traffic Light Controller. Digital Systems Design. Dr. Ted Shaneyfelt

路 論 Chapter 15 System-Level Physical Design

RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

Chapter 9 Latches, Flip-Flops, and Timers

Chapter 5. Sequential Logic

6-BIT UNIVERSAL UP/DOWN COUNTER

Building a computer. Electronic Numerical Integrator and Computer (ENIAC)

EXPERIMENT 8. Flip-Flops and Sequential Circuits

Design of Digital Circuits (SS16)

The string of digits in the binary number system represents the quantity

Wiki Lab Book. This week is practice for wiki usage during the project.

Lecture-3 MEMORY: Development of Memory:

Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17

CS 61C: Great Ideas in Computer Architecture. Dependability: Parity, RAID, ECC

Module 3: Floyd, Digital Fundamental

EE361: Digital Computer Organization Course Syllabus

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December :59

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute. 2nd (Spring) term 2012/2013

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

So far we have investigated combinational logic for which the output of the logic devices/circuits depends only on the present state of the inputs.

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

Asynchronous Counters. Asynchronous Counters

AC : A PROCESSOR DESIGN PROJECT FOR A FIRST COURSE IN COMPUTER ORGANIZATION

Sequential 4-bit Adder Design Report

Decimal Number (base 10) Binary Number (base 2)

16-bit ALU, Register File and Memory Write Interface

SEQUENTIAL CIRCUITS. Block diagram. Flip Flop. S-R Flip Flop. Block Diagram. Circuit Diagram

Aims and Objectives. E 3.05 Digital System Design. Course Syllabus. Course Syllabus (1) Programmable Logic

BINARY CODED DECIMAL: B.C.D.

Having read this workbook you should be able to: recognise the arrangement of NAND gates used to form an S-R flip-flop.

Sequential Circuits. Combinational Circuits Outputs depend on the current inputs

Making Basic Measurements. Publication Number August Training Kit for the Agilent Technologies Series Logic Analysis System

IE1204 Digital Design F12: Asynchronous Sequential Circuits (Part 1)

FPGA. AT6000 FPGAs. Application Note AT6000 FPGAs. 3x3 Convolver with Run-Time Reconfigurable Vector Multiplier in Atmel AT6000 FPGAs.

Sequential Logic. (Materials taken from: Principles of Computer Hardware by Alan Clements )

Transcription:

CS 61C: Great Ideas in Computer Architecture Functional Units, Finite State Machines Instructor: Justin Hsia 7/19/2012 Summer 2012 Lecture #19 1

Review of Last Lecture Synchronous Digital Systems Pulse of a Clock controls flow of information All signals are seen as either 0 or 1 Hardware systems are constructed from Stateless Combinational Logic and Stateful Memory Logic (registers) Combinational Logic: equivalent circuit diagrams, truth tables, and Boolean expressions Boolean Algebra allows minimization of gates State registers implemented from Flip flops 7/19/2012 Summer 2012 Lecture #19 2

Great Idea #1: Levels of Representation/Interpretation Higher Level Language Program (e.g. C) Assembly Language Program (e.g. MIPS) Machine Language Program (MIPS) Machine Interpretation Hardware Architecture Description (e.g. block diagrams) Architecture Implementation Compiler Assembler Logic Circuit Description (Circuit Schematic Diagrams) 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) 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 We are here 7/19/2012 Summer 2012 Lecture #19 3

Hardware Design Hierarchy system datapath control code registers multiplexer comparator state registers combinational logic Today register logic switching networks 7/19/2012 Summer 2012 Lecture #19 4

Agenda State Elements Continued Administrivia Logisim Introduction Finite State Machines Multiplexers ALU Design Adder/Subtracter 7/19/2012 Summer 2012 Lecture #19 5

Model for Synchronous Systems Collection of Combinational Logic blocks separated by registers Feedback is optional depending on application Clock (CLK): square wave that synchronizes the system Clock signal connects only to clock input of registers Register: several bits of state that samples input on rising edge of CLK 7/19/2012 Summer 2012 Lecture #19 6

Accumulator Revisited...Again reset signal shown 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 7/19/2012 Summer 2012 Lecture #19 7

Register Timing Terms (Review) Setup Time: how long the input must be stable before the CLK trigger for proper input read Hold Time: how long the input must be stable after the CLK trigger for proper input read CLK to Q Delay: how long it takes the output to change, measured from the CLK trigger 7/19/2012 Summer 2012 Lecture #19 8

Maximum Clock Frequency What is the max frequency of this circuit? Limited by how much time needed to get correct Next State to Register Max Delay = Setup Time + CLK to Q Delay + CL Delay Max Freq = 1/Max Delay 7/19/2012 Summer 2012 Lecture #19 9

The Critical Path The critical path is the longest delay between any two registers in a circuit The clock period must be longer than this critical path, or the signal will not propagate properly to that next register Reg 1 2 + Reg 7/19/2012 Summer 2012 Lecture #19 10 3 4 Critical Path = CL Delay 1 + CL Delay 2 + CL Delay 3 + Adder Delay

Pipelining and Clock Frequency (1/2) Clock period limited by propagation delay of adder and shifter Add an extra register to reduce the critical path! Timing: 7/19/2012 Summer 2012 Lecture #19 11

Pipelining and Clock Frequency (2/2) Extra register allows higher clock freq (more outputs per sec) However, takes two (shorter) clock cycles to produce first output (higher latency for initial output) + CLK to Q delay + Adder delay + setup time + CLK to Q delay + Shifter delay + setup time + CLK to Q delay 7/19/2012 Summer 2012 Lecture #19 12

Pipelining Basics By adding more registers, break path into shorter stages Aim is to reduce critical path Signals take an additional clock cycle to propagate through each stage New critical path must be calculated Affected by placement of new pipelining registers Faster clock rate higher throughput (outputs) More stages higher startup latency Pipelining tends to improve performance More on this (application to CPUs) next week 7/19/2012 Summer 2012 Lecture #19 13

Agenda State Elements Continued Administrivia Logisim Introduction Finite State Machines Multiplexers ALU Design Adder/Subtracter 7/19/2012 Summer 2012 Lecture #19 14

Administrivia Midterm re grade requests due today We will re grade the entire test Project 2 Part 2 will be posted today 7/19/2012 Summer 2012 Lecture #19 15

Agenda State Elements Continued Administrivia Logisim Introduction Finite State Machines Multiplexers ALU Design Adder/Subtracter 7/19/2012 Summer 2012 Lecture #19 16

Logisim Open source (i.e. free!) graphical tool for designing and simulating logic circuits Runs on Java on any computer Download to your home computer via class login or the Logisim website (we are using version 2.7.1) No programming involved Unlike Verilog, which is a hardware description language (HDL) Click and drag; still has its share of annoying quirks http://ozark.hendrix.edu/~burch/logisim/ 7/19/2012 Summer 2012 Lecture #19 17

Gates in Logisim Types of Gates Click gate type, click to place Can set options before placing or select gate later to change Options bus width n # inputs labeling not necessary, but can help 7/19/2012 Summer 2012 Lecture #19 18

Registers in Logisim Flip flops and Registers in Memory folder 8 bit accumulator: 7/19/2012 Summer 2012 Lecture #19 19

Wires in Logisim Click and drag on existing port or wire Color schemes: Gray: unconnected Dark Green: low signal (0) Light Green: high signal (1) Red: error Blue: undetermined signal Orange: incompatible widths Splitter used to adjust bus widths Tunnels: all tunnels with same label are connected 7/19/2012 Summer 2012 Lecture #19 20

Common Mistakes in Logisim Connecting wires together Crossing wires vs. connected wires Losing track of which input is which Mis wiring a block (e.g. CLK to Enable) Grabbing wrong wires off of splitter Errors: 7/19/2012 Summer 2012 Lecture #19 21

Agenda State Elements Continued Administrivia Logisim Introduction Finite State Machines Multiplexers ALU Design Adder/Subtracter 7/19/2012 Summer 2012 Lecture #19 22

Finite State Machines (FSMs) You may have seen FSMs in other classes Function can be represented with a state transition diagram With combinational logic and registers, any FSM can be implemented in hardware!... 7/19/2012 Summer 2012 Lecture #19 23

FSM Overview An FSM (in this class) is defined by: A set of states S (circles) An initial state s 0 (only arrow not between states) A transition function that maps from the current input and current state to the output and the next state (arrows between states) State transitions are controlled by the clock: On each clock cycle the machine checks the inputs and generates a new state (could be same) and new output 7/19/2012 Summer 2012 Lecture #19 24

Example: 3 Ones FSM FSM to detect 3 consecutive 1 s in the Input States: S0, S1, S2 Initial State: S0 Transitions of form: input/output 7/19/2012 Summer 2012 Lecture #19 25

Hardware Implementation of FSM Register holds a representation of the FSM s state Must assign a unique bit pattern for each state Output is present/current state (PS/CS) Input is next state (NS) Combinational Logic implements transition function (state transitions + output) + = 7/19/2012 Summer 2012 Lecture #19 26

FSM: Combinational Logic Read off transitions into Truth Table! Inputs: Current State (CS) and Input (In) Outputs: Next State (NS) and Output (Out) CS In NS Out 00 0 00 0 00 1 01 0 01 0 00 0 01 1 10 0 10 0 00 0 10 1 00 1 Implement logic for EACH output (2 for NS, 1 for Out) 7/19/2012 Summer 2012 Lecture #19 27

Unspecified Output Values (1/2) Our FSM has only 3 states 2 entries in truth table are undefined/unspecified Use symbol X to mean it can be either a 0 or 1 Make choice to simplify final expression CS In NS Out 00 0 00 0 00 1 01 0 01 0 00 0 01 1 10 0 10 0 00 0 10 1 00 1 11 0 XX X 11 1 XX X 7/19/2012 Summer 2012 Lecture #19 28

Unspecified Output Values (2/2) Let s find expression for NS 1 Recall: 2 bit output is just a 2 bit bus, which is just 2 wires Boolean algebra: NS 1 = CS 1 CS 0 In + CS 1 CS 0 In + CS 1 CS 0 In Is neighbor NS 1 = CS 0 In Karnaugh Map: NS 1 = CS 0 In Differs by 2 CS In 00 01 11 10 0 0 0 X 0 1 0 1 X 0 CS In NS Out 00 0 00 0 00 1 01 0 01 0 00 0 01 1 10 0 10 0 00 0 10 1 00 1 11 0 XX X 11 1 XX X 7/19/2012 Summer 2012 Lecture #19 29

3 Ones FSM in Hardware 2 bit Register needed for state CL: NS 1 = CS 0 In, NS 0 = CS 1 CS 0 In, Out = CS 1 In 7/19/2012 Summer 2012 Lecture #19 30

Agenda State Elements Continued Administrivia Logisim Introduction Finite State Machines Multiplexers ALU Design Adder/Subtracter 7/19/2012 Summer 2012 Lecture #19 31

Data Multiplexor Multiplexor ( MUX ) is a selector Place one of multiple inputs onto output (N to 1) Shown below is an n bit 2 to 1 MUX Input S selects between two inputs of n bits each This input is passed to output if selector bits match shown value 7/19/2012 Summer 2012 Lecture #19 32

Implementing a 1 bit 2 to 1 MUX Schematic: Boolean Algebra: Truth Table: s a b c 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 Circuit Diagram: 7/19/2012 Summer 2012 Lecture #19 33

1 bit 4 to 1 MUX (1/2) Schematic: Truth Table: How many rows? Boolean Expression: e = s 1 s 0 a + s 1 s 0 b + s 1 s 0 c + s 1 s 0 d 7/19/2012 Summer 2012 Lecture #19 34

1 bit 4 to 1 MUX (2/2) Can we leverage what we ve previously built? Alternative hierarchical approach: 7/19/2012 Summer 2012 Lecture #19 35

Subcircuits Example Logisim equivalent of procedure or method Every project is a hierarchy of subcircuits Incomplete wiring shown here 7/19/2012 Summer 2012 Lecture #19 36

Get To Know Your Instructor 7/19/2012 Summer 2012 Lecture #19 37

Agenda State Elements Continued Administrivia Logisim Introduction Finite State Machines Multiplexers ALU Design Adder/Subtracter 7/19/2012 Summer 2012 Lecture #19 38

Arithmetic and Logic Unit (ALU) 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, and bitwise OR Schematic: when S=00, R = A + B when S=01, R = A B when S=10, R = A AND B when S=11, R = A OR B 7/19/2012 Summer 2012 Lecture #19 39

Simple ALU Schematic Notice that 3 values are ALWAYS calculated in parallel, but only 1 makes it to the Result 7/19/2012 Summer 2012 Lecture #19 40

Adder/Subtractor: 1 bit LSB Adder Carry out bit 7/19/2012 Summer 2012 Lecture #19 41

Adder/Subtractor: 1 bit Adder Possible carry in c 1 Here defining XOR of many inputs to be 1 when and odd number of inputs are 1 7/19/2012 Summer 2012 Lecture #19 42

Adder/Subtractor: 1 bit Adder Circuit Diagrams: 7/19/2012 Summer 2012 Lecture #19 43

N x 1 bit Adders N bit Adder Connect CarryOut i 1 to CarryIn i to chain adders: b 0 + + + 7/19/2012 Summer 2012 Lecture #19 44

Two s Complement Adder/Subtractor Subtraction accomplished by adding negated number: x ^ 1 = x (flips the bits) Add 1 + + + Where did this come from? This signal is only high when you perform subtraction 7/19/2012 Summer 2012 Lecture #19 45

Detecting Overflow Unsigned overflow On addition, if carry out from MSB is 1 On subtraction, if carry out from MSB is 0 This case is a lot harder to see than you might think Signed overflow 1) Overflow from adding large positive numbers 2) Overflow from adding large negative numbers 7/18/2012 Spring 2011 Lecture #18 46

Signed Overflow Examples (4 bit) Overflow from two positive numbers: 0111 + 0111, 0111 + 0001, 0100 + 0100. Carry out from the 2 nd MSB (but not MSB) pos + pos neg Overflow from two negative numbers: 1000 + 1000, 1000 + 1111, 1011 + 1011. Carry out from the MSB (but not 2 nd MSB) neg + neg pos Expression for signed overflow: C n XOR C n 1 7/18/2012 Spring 2011 Lecture #18 47

Summary Critical path constrains clock rate Timing constants: setup, hold, and clk to q times Can adjust with extra registers (pipelining) Finite State Machines extremely useful Can implement systems with Register + CL Use MUXes to select among input S input bits selects one of 2 S inputs Each input is a bus n bits wide Build n bit adder out of chained 1 bit adders Can also do subtraction with additional SUB signal 7/19/2012 Summer 2012 Lecture #19 48