Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H Appendix B.7. B.8, B.10, B.11.

Slides:



Advertisements
Similar presentations
Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H Appendix B.7. B.8, B.10, B.11.
Advertisements

State & Finite State Machines Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H Appendix C.7. C.8, C.10, C.11.
1 Lecture 14 Memory storage elements  Latches  Flip-flops State Diagrams.
Classification of Digital Circuits  Combinational. Output depends only on current input values.  Sequential. Output depends on current input values and.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /23/2013 Lecture 7: Computer Clock & Memory Elements Instructor: Ashraf Yaseen DEPARTMENT OF MATH &
Sequential Circuits1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
Circuits require memory to store intermediate data
Dr. ClincyLecture1 Appendix A – Part 2: Logic Circuits Current State or output of the device is affected by the previous states Circuit Flip Flops New.
State and Finite State Machines
Sequential Circuit Analysis & Design Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals Dr. Aiman H. El-Maleh.
LOGIC GATES ADDERS FLIP-FLOPS REGISTERS Digital Electronics Mark Neil - Microprocessor Course 1.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Appendix B.7. B.8, B.10, B.11.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Appendix B.7. B.8, B.10, B.11.
Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H 2.4 (signed), 2.5, 2.6, C.6, and Appendix C.6.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University State & Finite State Machines See: P&H Appendix C.7. C.8, C.10, C.11.
Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.
Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University Memory See: P&H Appendix C.8, C.9.
ECE 331 – Digital System Design Introduction to and Analysis of Sequential Logic Circuits (Lecture #20) The slides included herein were taken from the.
11/16/2004EE 42 fall 2004 lecture 331 Lecture #33: Some example circuits Last lecture: –Edge triggers –Registers This lecture: –Example circuits –shift.
CS 151 Digital Systems Design Lecture 20 Sequential Circuits: Flip flops.
State & Finite State Machines Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See P&H Appendix C.7. C.8, C.10, C.11.
Fall 2007 L16: Memory Elements LECTURE 16: Clocks Sequential circuit design The basic memory element: a latch Flip Flops.
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.
1 Sequential Circuits Registers and Counters. 2 Master Slave Flip Flops.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See: P&H Chapter 2.4, 3.2, B.2, B.5, B.6.
1 CSE370, Lecture 14 Lecture 14 u Logistics n Midterm 1: Average 90/100. Well done! n Midterm solutions online n HW5 due date delayed until this Friday.
Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Constructing a Computer Creating a general purpose computing device.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Appendix B.8 (register files) and B.9.
COE 202: Digital Logic Design Sequential Circuits Part 1
Flip-flops, Latches and State Prof. Sirer COMP 303 Koç University.
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Chapter 2Basic Digital Logic1 Chapter 2. Basic Digital Logic2 Outlines  Basic Digital Logic Gates  Two types of digital logic circuits Combinational.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Chapter: , 1.6, Appendix B.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University Memory See: P&H Appendix C.8, C.9.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University Memory See: P&H Appendix C.8, C.9.
Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Memory Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University.
Numbers and Arithmetic Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Sequential Circuits. Two primary differences between combinational circuits and sequential circuits –Sequential circuits are synchronous (use a clock)
1 CSE370, Lecture 15 Lecture 15 u Logistics n HW5 due this Friday n HW6 out today, due Friday Feb 20 n I will be away Friday, so no office hour n Bruce.
1 CSE370, Lecture 17 Lecture 17 u Logistics n Lab 7 this week n HW6 is due Friday n Office Hours íMine: Friday 10:00-11:00 as usual íSara: Thursday 2:30-3:20.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
Finite State Machines Prof. Sirer COMP 303 Koç University.
MicroComputer Engineering DigitalCircuits slide 1 Combinational circuits Changes at inputs propagate at logic speed to outputs Not clocked No internal.
CEC 220 Digital Circuit Design Latches and Flip-Flops Monday, March 03 CEC 220 Digital Circuit Design Slide 1 of 19.
Synchronous Sequential Logic A digital system has combinational logic as well as sequential logic. The latter includes storage elements. feedback path.
Numbers and Arithmetic Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H Appendix B.8 (register files) and B.9.
COMBINATIONAL AND SEQUENTIAL CIRCUITS Guided By: Prof. P. B. Swadas Prepared By: BIRLA VISHVAKARMA MAHAVDYALAYA.
Chapter 3 Boolean Algebra and Digital Logic T103: Computer architecture, logic and information processing.
Chapter #6: Sequential Logic Design
Computer Architecture & Operations I
State & Finite State Machines
Dr. Clincy Professor of CS
ECE Digital logic Lecture 16: Synchronous Sequential Logic
CS Fall 2005 – Lec. #5 – Sequential Logic - 1
Prof. Kavita Bala and Prof. Hakim Weatherspoon
Hakim Weatherspoon CS 3410 Computer Science Cornell University
Hakim Weatherspoon CS 3410 Computer Science Cornell University
Instructor: Alexander Stoytchev
Dr. Clincy Professor of CS
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
SEQUENTIAL CIRCUITS __________________________________________________
Hakim Weatherspoon CS 3410 Computer Science Cornell University
Instructor: Michael Greenbaum
Presentation transcript:

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H Appendix B.7. B.8, B.10, B.11

PC imm memory d in d out addr target offset cmp control =? new pc register file inst extend +4 A Single cycle processor alu

We can generalize 1-bit Full Adders to 32 bits, 64 bits … A 0 B 0 S0S0 A 1 B 1 S1S1 A 2 B 2 S2S2 A 3 B 3 S3S3 C0C0

We can generalize 1-bit Full Adders to 32 bits, 64 bits … S0S0 S1S1 S2S2 S3S3 over flow A0A0 B0B0 A1A1 B1B1 A2A2 B2B2 A3A3 B3B3 mux 0=add 1=sub

decoder 8 8 S A B 8 0=add 1=sub

adder mux decoder S A B 8 0=add 1=sub

We can generalize 1-bit Full Adders to 32 bits, 64 bits … How long does it take to compute a result? S0S0 S1S1 S2S2 S3S3 over flow A0A0 B0B0 A1A1 B1B1 A2A2 B2B2 A3A3 B3B3 mux 0=add 1=sub

We can generalize 1-bit Full Adders to 32 bits, 64 bits … How long does it take to compute a result? A) 2 ns B) 2 gate delays C) 10 ns D) 10 gate delays E) 8 gate delays

We can generalize 1-bit Full Adders to 32 bits, 64 bits … How long does it take to compute a result? S0S0 S1S1 S2S2 S3S3 over flow A0A0 B0B0 A1A1 B1B1 A2A2 B2B2 A3A3 B3B3 mux 0=add 1=sub t=10 t=8 t=6t=4t=2t=0

We can generalize 1-bit Full Adders to 32 bits, 64 bits … How long does it take to compute a result? Can we store the result? S0S0 S1S1 S2S2 S3S3 over flow A0A0 B0B0 A1A1 B1B1 A2A2 B2B2 A3A3 B3B3 mux 0=add 1=sub t=10 t=8 t=6t=4t=2t=0

Speed of a circuit is affected by the number of gates in series (on the critical path or the deepest level of logic) Combinational Logic t combinational inputs arrive outputs expected

A3A3 B3B3 S3S3 C4C4 A1A1 B1B1 S1S1 A2A2 B2B2 S2S2 A0A0 B0B0 C0C0 S0S0 C1C1 C2C2 C3C3 First full adder, 2 gate delay Second full adder, 2 gate delay … Carry ripples from lsb to msb

Until now is combinationial logic Output is computed when inputs are present System has no internal state Nothing computed in the present can depend on what happened in the past! Need a way to record data Need a way to build stateful circuits Need a state-holding device Finite State Machines Inputs Combinational circuit Outputs N M

State How do we store one bit? Attempts at storing (and changing) one bit –Set-Reset Latch –D Latch –D Flip-Flops –Master-Slave Flip-Flops Register: storing more than one bit, N-bits Basic Building Blocks Decoders and Encoders Finite State Machines (FSM) How do we design logic circuits with state? Types of FSMs: Mealy and Moore Machines Examples: Serial Adder and a Digital Door Lock

How do we store store one bit?

B A C

0 1 Does not work! Unstable Oscillates wildly! B A C

In stable state, A = B How do we change the state? A B A B 1 A B A Simple Device Stable and unstable equilibria?

B R Q A S

Set-Reset (S-R) Latch Stores a value Q and its complement SRQ S R Q ABORNOR

Set-Reset (S-R) Latch Stores a value Q and its complement SRQ 00 01?? S R Q ABORNOR Q will be 0 if R is 1 1 SRQ

Set-Reset (S-R) Latch Stores a value Q and its complement SRQ ?? 11 S R Q ABORNOR Q will be 1 0 SRQ

Set-Reset (S-R) Latch Stores a value Q and its complement SRQ 00?? S R Q ABORNOR If Q is 1, will stay 1 if Q is 0, will stay 0 0 SRQ 00Q 

Set-Reset (S-R) Latch Stores a value Q and its complement SRQ 00Q ?? S R Q ABORNOR Q will be 0 since R is 1 0 What happens when S,R changes from 1,1 to 0,0?

Set-Reset (S-R) Latch Stores a value Q and its complement SRQ 00Q ?? S R Q ABORNOR 010 1 01 0 0101 0 10 1 SRQ 00Q forbidden What happens when S,R changes from 1,1 to 0,0? 0  1  0 0  1  0  1 0 0

Set-Reset (S-R) Latch Stores a value Q and its complement S R Q S R Q SRQ 00Q forbidden SRQ 00Q hold 0101 reset 1010 set 11 forbidden

Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state.

How do we avoid the forbidden state of S-R Latch?

Fill in the truth table? D S R Q Q D DQ 0 1 S R Q ABORNOR

D S R Q Q D DQ S R Q ABORNOR Fill in the truth table? Data (D) Latch Easier to use than an SR latch No possibility of entering an undefined state When D changes, Q changes –… immediately (…after a delay of 2 Ors and 2 NOTs) Need to control when the output changes

Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state. (Unclocked) D Latch can store and change a bit like an SR Latch while avoiding the forbidden state.

How do we coordinate state changes to a D Latch?

Clock helps coordinate state changes Usually generated by an oscillating crystal Fixed period; frequency = 1/period 1 0 clock period clock high clock low rising edge falling edge

Level sensitive State changes when clock is high (or low) Edge triggered State changes at clock edge positive edge-triggered negative edge-triggered

Clock Methodology Negative edge, synchronous –Edge-Triggered: Signals must be stable near falling clock edge Positive edge synchronous clk computesave t setup t hold computesavecompute t combinational

S R D Q

S R D clk Q DQ Fill in the truth table

clkDQ S R D Q SRQ 00 Q hold reset set 11 forbidden clkDQ 00 Q 01 Q Fill in the truth table

S R D clk Q DQ 00 Q 01 Q D Q Level Sensitive D Latch Clock high: set/reset (according to D) Clock low: keep state (ignore D)

D Flip-Flop Edge-Triggered Data captured when clock is high Output changes only on falling edges DQDQ LL clk D X Q c X c Q D Activity#1: Fill in timing graph and values for X and Q

D Flip-Flop Edge-Triggered Data captured when clock is high Output changes only on falling edges DQDQ LL clk D X Q c X c Q D

Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state. (Unclocked) D Latch can store and change a bit like an SR Latch while avoiding a forbidden state. An Edge-Triggered D Flip-Flip (aka Master-Slave D Flip- Flip) stores one bit. The bit can be changed in a synchronized fashion on the edge of a clock signal.

How do we store more than one bit, N bits?

Register D flip-flops in parallel shared clock extra clocked inputs: write_enable, reset, … clk D0 D3 D1 D bit reg clk

Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state. (Unclocked) D Latch can store and change a bit like an SR Latch while avoiding a forbidden state. An Edge-Triggered D Flip-Flip (aka Master-Slave D Flip- Flip) stores one bit. The bit can be changed in a synchronized fashion on the edge of a clock signal. An N-bit register stores N-bits. It is be created with N D-Flip-Flops in parallel along with a shared clock.

4-bit reg Clk Decoder

4-bit reg Clk Run WER Reset Decoder A[4] 1 = 0001 =B[4] S[4] C out

7-Segment LED photons emitted when electrons fall into holes d7d6 d5d4 d3d2 d1d0

7-Segment LED photons emitted when electrons fall into holes d7d6 d5d4 d3d2 d1d0

3 inputs encode 0 – 7 in binary 7 outputs one for each LED 7LED decode

b2b1b0d6d5d4d3d2d1d d1 d2 d3 d4 d5 d6 b2b1b0d6d5d4d3d2d1d

d1 d2 d3 d4 d5 d6 b2b1b0d6d5d4d3d2d1d

binary encoder 2N2N N binary decoder N 2N2N Multiplexor N M N N N N M -1

encoder N... Log 2 (N) outputs wires N Input wires e.g. Voting: Can only vote for one out of N candidates, so N inputs. But can encode vote efficiently with binary encoding.

a b 1 c d o1o1 A 3-bit encoder with 4 inputs for simplicity abcd o0o0 o1o1 o2o2

a b 1 c d o1o1 A 3-bit encoder with 4 inputs for simplicity abcdo2o1o o0o0 o1o1 o2o2 o2 = abcd o1 = abcd + abcd o0 = abcd + abcd

Ballots The 3410 optical scan vote reader machine detect enc LED decode

We can now build interesting devices with sensors Using combinationial logic We can also store data values (aka Sequential Logic) In state-holding elements Coupled with clocks

Make sure to go to your Lab Section this week Completed Lab1 due before winter break, Friday, Feb 14th Note, a Design Document is due when you submit Lab1 final circuit Work alone Homework1 is out Due a week before prelim1, Monday, February 24th Work on problems incrementally, as we cover them in lecture Office Hours for help Work alone Work alone, BUT use your resources Lab Section, Piazza.com, Office Hours Class notes, book, Sections, CSUGLab

Check online syllabus/schedule Slides and Reading for lectures Office Hours Homework and Programming Assignments Prelims (in evenings): Tuesday, March 4 th Thursday, May 1 th Schedule is subject to change

“Black Board” Collaboration Policy Can discuss approach together on a “black board” Leave and write up solution independently Do not copy solutions Late Policy Each person has a total of four “slip days” Max of two slip days for any individual assignment Slip days deducted first for any late assignment, cannot selectively apply slip days For projects, slip days are deducted from all partners 25% deducted per day late after slip days are exhausted Regrade policy Submit written request to lead TA, and lead TA will pick a different grader Submit another written request, lead TA will regrade directly Submit yet another written request for professor to regrade.

State How do we store one bit? Attempts at storing (and changing) one bit –Set-Reset Latch –D Latch –D Flip-Flops –Master-Slave Flip-Flops Register: storing more than one bit, N-bits Basic Building Blocks Decoders and Encoders Finite State Machines (FSM) How do we design logic circuits with state? Types of FSMs: Mealy and Moore Machines Examples: Serial Adder and a Digital Door Lock

How do we design logic circuits with state?

An electronic machine which has external inputs externally visible outputs internal state Output and next state depend on inputs current state

Machine is M = ( S, I, O,  ) S:Finite set of states I:Finite set of inputs O:Finite set of outputs  :State transition function Next state depends on present input and present state

Finite State Machine inputs from external world outputs to external world internal state combinational logic Next State Current State Input Output Registers Comb. Logic

Legend state input/output start state A B CD down/on up/off down/on down/off up/off down/off up/off Input: up or down Output: on or off States: A, B, C, or D

Legend state input/output start state A B CD down/on up/off down/on down/off up/off down/off up/off Input: = up or = down Output: = on or = off States: = A, = B, = C, or = D

Legend S1S0S1S0 i0i1i2…/o0o1o2…i0i1i2…/o0o1o2… S1S0S1S /11/1 0/00/0 1/11/1 1/01/0 0/00/0 1/01/0 0/00/0 0/00/0 Input: 0=up or 1=down Output: 1=on or 0=off States: 00=A, 01=B, 10=C, or 11=D

General Case: Mealy Machine Outputs and next state depend on both current state and input Next State Current State Input Output Registers Comb. Logic

Special Case: Moore Machine Outputs depend only on current state Next State Current State Input Output Registers Comb. Logic

Legend state out input start out A off B on C off D off down up down up down up Input: up or down Output: on or off States: A, B, C, or D

Legend state input/output start state A B CD down/on up/off down/on down/off up/off down/off up/off Input: up or down Output: on or off States: A, B, C, or D

Add two infinite input bit streams streams are sent with least-significant-bit (lsb) first …10110 …01111 …00101 Sum: output

Add two infinite input bit streams streams are sent with least-significant-bit (lsb) first …10110 …01111 …00101 Sum: output Carry-out 1

Add two infinite input bit streams streams are sent with least-significant-bit (lsb) first …10110 …01111 …00101 Sum: output Carry-in 1

Add two infinite input bit streams streams are sent with least-significant-bit (lsb) first …10110 …01111 …00101 Carry-out 1 1 Sum: output

Add two infinite input bit streams streams are sent with least-significant-bit (lsb) first How many states are needed to represent FSM? Draw and Fill in FSM diagram …10110 …01111 …00101 Strategy: (1) Draw a state diagram (e.g. Mealy Machine) (2) Write output and next-state tables (3) Encode states, inputs, and outputs as bits (4) Determine logic equations for next state and outputs Sum: output

Two states: S0 (no carry in), S1 (carry in) Inputs: a and b Output: z z is the sum of inputs a, b, and carry-in (one bit at a time) A carry-out is the next carry-in state.. …10110 …01111 …00101 a b z

Two states: S0 (no carry in), S1 (carry in) Inputs: a and b Output: z z is the sum of inputs a, b, and carry-in (one bit at a time) A carry-out is the next carry-in state. Arcs labeled with input bits a and b, and output z S0 S1 __/_ …10110 …01111 …00101 a b z

S0 S1 00/0 11/1 01/0 11/0 10/0 10/1 00/1 01/1 Two states: S0 (no carry in), S1 (carry in) Inputs: a and b Output: z z is the sum of inputs a, b, and carry-in (one bit at a time) A carry-out is the next carry-in state. Arcs labeled with input bits a and b, and output z (Mealy Machine) …10110 …01111 …00101 a b z

ab Current state z Next state S0 S1 00/0 11/1 01/0 11/0 10/0 10/1 00/1 01/1 (2) Write down all input and state combinations

ab Current state z Next state 00S S1 00 1S0 01S S0 S1 00/0 11/1 01/0 11/0 10/0 10/1 00/1 01/1

(3) Encode states, inputs, and outputs as bits Two states, so 1-bit is sufficient A single flip-flop will encode the state abs zs' /0 11/1 01/0 11/0 10/0 10/1 00/1 01/1

Next State Current State Input Output Comb. Logic a b DQ s z s' Next State abs zs'

Strategy: (1) Draw a state diagram (e.g. Mealy Machine) (2) Write output and next-state tables (3) Encode states, inputs, and outputs as bits (4) Determine logic equations for next state and outputs Next State Current State Input Output Comb. Logic a b DQ s z s' Next State

We can now build interesting devices with sensors Using combinational logic We can also store data values Stateful circuit elements (D Flip Flops, Registers, …) Clock to synchronize state changes State Machines or Ad-Hoc Circuits