Instructor: Justin Hsia

Slides:



Advertisements
Similar presentations
Part 4: combinational devices
Advertisements

Finite State Machines (FSMs)
Circuits require memory to store intermediate data
Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.
CS 61C L29 Combinational Logic Blocks (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS 61C L14 State (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #14: State and FSMs Andy.
CS 300 – Lecture 3 Intro to Computer Architecture / Assembly Language Sequential Circuits.
CS61C L21 State Elements : Circuits that Remember (1) Spring 2007 © UCB 161 Exabytes In 2006  In 2006 we created, captured, and replicated 161 exabytes.
CS61C L22 Representations of Combinatorial Logic Circuits (1) Garcia, Spring 2008 © UCB 100 MPG Car contest!  The X Prize Foundation has put up two prizes;
CS61C L21 State Elements : Circuits that Remember (1) Garcia, Fall 2006 © UCB One Laptop per Child  The OLPC project has been making news recently with.
CS61C L17 Combinatorial Logic Blocks (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
CS61C L22 Representations of Combinatorial Logic Circuits (1) Eric, Spring 2010 © UCB Cal Alumni Wins 2009 Turing Award! Charles P. Thacker was named.
Give qualifications of instructors: DAP
CS61C L18 Combinational Logic Blocks, Latches (1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design Finite State.
11/10/2004EE 42 fall 2004 lecture 301 Lecture #30 Finite State Machines Last lecture: –CMOS fabrication –Clocked and latched circuits This lecture: –Finite.
CS 61C L15 Blocks (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #15: Combinational Logic Blocks.
CS61C L17 Combinational Logic (1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #17.
CS 61C: Great Ideas in Computer Architecture Finite State Machines
CS61C L15 Synchronous Digital Systems (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
CS 61C L15 State & Blocks (1) A Carle, Summer 2006 © UCB inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #15: State 2 and Blocks.
CS 105 Digital Logic Design
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Constructing a Computer Creating a general purpose computing device.
CS3350B Computer Architecture Winter 2015 Lecture 5.2: State Circuits: Circuits that Remember Marc Moreno Maza [Adapted.
CS 61C: Great Ideas in Computer Architecture Lecture 10: Finite State Machines, Functional Units Instructor: Sagar Karandikar
1 COMP541 State Machines Montek Singh Feb 8, 2012.
IKI a-Combinatorial Components Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Computer Organization and Design Lecture 16 – Combinational Logic Blocks Close call!   Cal squeaked by Washington in Overtime We win, and then.
CS3350B Computer Architecture Winter 2015 Lecture 5.4: Combinational Logic Blocks Marc Moreno Maza [Adapted from lectures.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
DLD Lecture 26 Finite State Machine Design Procedure.
COMP541 Arithmetic Circuits
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
EKT 221 : Chapter 4 Computer Design Basics
CS 61C: Great Ideas in Computer Architecture Finite State Machines, Functional Units 1 Instructors: John Wawrzynek & Vladimir Stojanovic
COMP541 Arithmetic Circuits
CS 61C L4.1.2 State (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture State and FSMs Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Arithmetic-logic units1 An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the “heart” of a processor—you.
Instructor: Justin Hsia 7/24/2013Summer Lecture #181 CS 61C: Great Ideas in Computer Architecture Combinational and Sequential Logic, Boolean Algebra.
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
Digital Logic Design Basics Combinational Circuits Sequential Circuits Pu-Jen Cheng Adapted from the slides prepared by S. Dandamudi for the book, Fundamentals.
Addition and multiplication Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
CS61C L24 State Elements : Circuits that Remember (1) Garcia, Fall 2014 © UCB Senior Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
CS 61C: Great Ideas in Computer Architecture Sequential Elements, Synchronous Digital Systems 1 Instructors: Vladimir Stojanovic & Nicholas Weaver
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 23 Introduction Computer Specification –Instruction Set Architecture (ISA) - the specification.
CS 61C: Great Ideas in Computer Architecture Finite State Machines, Functional Units 1 Instructors: Vladimir Stojanovic and Nicholas Weaver
CS 110 Computer Architecture Lecture 9: Finite State Machines, Functional Units Instructor: Sören Schwertfeger School of.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Addition and multiplication1 Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
Revisão de Circuitos Lógicos PARTE III. Review Use this table and techniques we learned to transform from 1 to another.
Flip Flops Lecture 10 CAP
State Circuits : Circuits that Remember
Inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #21 State Elements: Circuits that Remember Hello to James Muerle in the.
Instructors: Randy H. Katz David A. Patterson
Instructor: Justin Hsia
Instructor Paul Pearce
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Inst.eecs.berkeley.edu/~cs61c CS61CL : Machine Structures Lecture #8 – State Elements, Combinational Logic Greet class James Tu, TA.
Arithmetic and Decisions
TA David “The Punner” Eitan Poll
Combinational Circuits
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
EGR 2131 Unit 12 Synchronous Sequential Circuits
Instructor: Michael Greenbaum
Presentation transcript:

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

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/25/2013 Summer 2013 -- Lecture #19

Dealing with Waveform Diagrams Easiest to start with CLK on top Solve signal by signal, from inputs to outputs Can only draw the waveform for a signal if all of its input waveforms are drawn When does a signal update? A state element updates based on CLK triggers A combinational element updates ANY time ANY of its inputs changes 7/25/2013 Summer 2013 -- Lecture #19

Example: T = 10 ns. tsetup = thold = 0. tclk-to-q = 1 ns Example: T = 10 ns. tsetup = thold = 0. tclk-to-q = 1 ns. tprop = 1 ns for all gates. Each “tick” below is 1 ns. Solve for the waveform of the output Y.

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

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

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/25/2013 Summer 2013 -- Lecture #19

Accumulator Revisited ...Again reset signal shown In practice X might not arrive to the adder at the same time as Si-1 Si temporarily is wrong, but register always captures correct value In good circuits, instability never happens around rising edge of clk 7/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

Where Does Timing Come From? Example D flip-flop implementation: Changing the D signal around the time E (CLK) changes can cause unexpected behavior 7/25/2013 Summer 2013 -- Lecture #19

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 = Max Freq = 1/Max Delay Setup Time + CLK-to-Q Delay + CL Delay Hold time is included in CLK-to-Q delay. 7/25/2013 Summer 2013 -- Lecture #19

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 Critical Path = CL Delay 1 + CL Delay 2 + CL Delay 3 + Adder Delay 3 4 2 1 7/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

Question: Want to run on 1 GHz processor. tadd = 100 ps. tmult = 200 ps. tsetup = thold = 50 ps. What is the maximum tclk-to-q we can use? 550 ps (A) 750 ps (B) 500 ps (C) 700 ps (D)

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

Administrivia Midterm re-grade requests due today We will re-grade the entire test Project 2 Part 2 will be posted today HW5 posted today, due Thu Aug. 1 7/25/2013 Summer 2013 -- Lecture #19

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

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/25/2013 Summer 2013 -- Lecture #19

Gates in Logisim Click gate type, click to place 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/25/2013 Summer 2013 -- Lecture #19

Registers in Logisim Flip-flops and Registers in “Memory” folder 8-bit accumulator: 7/25/2013 Summer 2013 -- Lecture #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 Tunnels: all tunnels with same label are connected “Splitter” used to adjust bus widths 7/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

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

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/25/2013 Summer 2013 -- Lecture #19

FSM Overview An FSM (in this class) is defined by: A set of states S (circles) An initial state s0 (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/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

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/25/2013 Summer 2013 -- Lecture #19

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

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 1 01 10 11 XX X 7/25/2013 Summer 2013 -- Lecture #19

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

3 Ones FSM in Hardware 2-bit Register needed for state CL: NS1 = CS0In, NS0 = CS1’CS0’In, Out = CS1In 7/25/2013 Summer 2013 -- Lecture #19

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

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/25/2013 Summer 2013 -- Lecture #19

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

1-bit 4-to-1 MUX (1/2) Schematic: Truth Table: How many rows? Boolean Expression: e = s1’s0’a + s1’s0b + s1s0’c + s1s0d 26 7/25/2013 Summer 2013 -- Lecture #19

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

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

Get To Know Your Instructor 7/25/2013 Summer 2013 -- Lecture #19

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

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/25/2013 Summer 2013 -- Lecture #19

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

Adder/Subtractor: 1-bit LSB Adder Carry-out bit 7/25/2013 Summer 2013 -- Lecture #19

Adder/Subtractor: 1-bit Adder Possible carry-in c1 Here defining XOR of many inputs to be 1 when an odd number of inputs are 1 7/25/2013 Summer 2013 -- Lecture #19

Adder/Subtractor: 1-bit Adder Circuit Diagrams: 7/25/2013 Summer 2013 -- Lecture #19

N x 1-bit Adders  N-bit Adder Connect CarryOuti-1 to CarryIni to chain adders: b0 + 7/25/2013 Summer 2013 -- Lecture #19

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

Detecting Overflow Unsigned overflow Signed 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 Overflow from adding “large” positive numbers Overflow from adding “large” negative numbers 7/25/2013 Summer 2013 -- Lecture #19

Signed Overflow Examples (4-bit) Overflow from two positive numbers: 0111 + 0111, 0111 + 0001, 0100 + 0100. Carry-out from the 2nd 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 2nd MSB) neg + neg ≠ pos Expression for signed overflow: Cn XOR Cn-1 7/25/2013 Summer 2013 -- Lecture #19

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 2S 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/25/2013 Summer 2013 -- Lecture #19

BONUS SLIDES You are responsible for the material contained on the following slides, though we may not have enough time to get to them in lecture. They have been prepared in a way that should be easily readable and the material will be touched upon in the following lecture. 7/25/2013 Summer 2013 -- Lecture #19

Direct-Mapped Cache Internals Four words/block, cache size = 1 Ki words 31 30 . . . 13 12 11 . . . 4 3 2 1 0 Byte offset Hit Data 32 Block offset 20 Tag 8 Index Data (words) Index Tag Valid 1 2 . 253 254 255 20 and 7/25/2013 Summer 2013 -- Lecture #19

4-Way Set Associative Cache 28 = 256 sets each with four slots for blocks Byte offset 31 30 . . . 13 12 11 . . . 2 1 0 22 Tag 8 Index Index Data Tag V 1 2 . 253 254 255 Data Tag V 1 2 . 253 254 255 Data Tag V 1 2 . 253 254 255 Data Tag V 1 2 . 253 254 255 Slot 0 Slot 1 Slot 2 Slot 3 Hit Data 32 4x1 select 7/25/2013 Summer 2013 -- Lecture #19