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

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

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

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

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

6.3 Sequential Circuits (plus a few Combinational)

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

COMP sequential logic 1 Jan. 25, 2016

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

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

More Digital Circuits

211: Computer Architecture Summer 2016

MODULE 3. Combinational & Sequential logic

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

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

ELEN Electronique numérique

ECE 263 Digital Systems, Fall 2015

CHAPTER 4: Logic Circuits

CprE 281: Digital Logic

Logic Design II (17.342) Spring Lecture Outline

Combinational vs Sequential

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

Sequential Logic. Introduction to Computer Yung-Yu Chuang

CHAPTER 4: Logic Circuits

Chapter 3 Unit Combinational

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

Logic Design ( Part 3) Sequential Logic (Chapter 3)

Registers. Unit 12 Registers and Counters. Registers (D Flip-Flop based) Register Transfers (example not out of text) Accumulator Registers

Chapter 2. Digital Circuits

Registers & Counters. Logic and Digital System Design - CS 303 Erkay Savaş Sabanci University

CS 261 Fall Mike Lam, Professor. Sequential Circuits

Logic Devices for Interfacing, The 8085 MPU Lecture 4

CprE 281: Digital Logic

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

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

Spring 2017 EE 3613: Computer Organization Chapter 5: The Processor: Datapath & Control - 1

Logic Design. Flip Flops, Registers and Counters

CprE 281: Digital Logic

Midterm Exam 15 points total. March 28, 2011

Chapter 5 Sequential Circuits

CS 61C: Great Ideas in Computer Architecture

Registers, Register Transfers and Counters Dr. Fethullah Karabiber

Experiment 8 Introduction to Latches and Flip-Flops and registers

IS1500 (not part of IS1200) Logic Design Lab (LD-Lab)

Where Are We Now? e.g., ADD $S0 $S1 $S2?? Computed by digital circuit. CSCI 402: Computer Architectures. Some basics of Logic Design (Appendix B)

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

Modeling Digital Systems with Verilog

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

ECE321 Electronics I

Fall 2000 Chapter 5 Part 1

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

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

Dev Bhoomi Institute Of Technology Department of Electronics and Communication Engineering PRACTICAL INSTRUCTION SHEET

CprE 281: Digital Logic

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

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.

EEC 118 Lecture #9: Sequential Logic. Rajeevan Amirtharajah University of California, Davis Jeff Parkhurst Intel Corporation

Module 4:FLIP-FLOP. Quote of the day. Never think you are nothing, never think you are everything, but think you are something and achieve anything.

Principles of Computer Architecture. Appendix A: Digital Logic

Course Administration

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.

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

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Clocks. Sequential Logic. A clock is a free-running signal with a cycle time.

MODEL QUESTIONS WITH ANSWERS THIRD SEMESTER B.TECH DEGREE EXAMINATION DECEMBER CS 203: Switching Theory and Logic Design. Time: 3 Hrs Marks: 100

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

Chapter 3. Boolean Algebra and Digital Logic

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Review of Sequential Logic Circuits

MODU LE DAY. Class-A, B, AB and C amplifiers - basic concepts, power, efficiency Basic concepts of Feedback and Oscillation. Day 1

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 3 Logistics

Counters

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

COMP2611: Computer Organization. Introduction to Digital Logic

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

CSE140: Components and Design Techniques for Digital Systems. More D-Flip-Flops. Tajana Simunic Rosing. Sources: TSR, Katz, Boriello & Vahid

Asynchronous (Ripple) Counters

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

Introduction to Sequential Circuits

UNIVERSITI TEKNOLOGI MALAYSIA

VU Mobile Powered by S NO Group

WINTER 15 EXAMINATION Model Answer

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

CHAPTER1: Digital Logic Circuits

Computer Architecture and Organization

Sequential logic circuits

WINTER 14 EXAMINATION

Chapter 5: Synchronous Sequential Logic

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

Chapter 11 Latches and Flip-Flops

Introduction to Microprocessor & Digital Logic

FPGA Design. Part I - Hardware Components. Thomas Lenzi

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

CPS311 Lecture: Sequential Circuits

CprE 281: Digital Logic

Flip-Flops and Registers

CAD for VLSI Design - I Lecture 38. V. Kamakoti and Shankar Balachandran

Sequential Elements con t Synchronous Digital Systems

COMP12111: Fundamentals of Computer Engineering

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

Transcription:

CS/ECE 25: Computer Architecture Basics of Logic esign: ALU, Storage, Tristate Benjamin Lee Slides based on those from Alvin Lebeck, aniel, Andrew Hilton, Amir Roth, Gershon Kedem

Homework #3 ue Mar 7, :55pm Administrivia Readings Pragmatic Logic by William Eccles Linked on web page, skim for what you need. Combinational Circuits Ch 4.-4.2, Ch 5.3 Sequential Circuits Ch 6 CS/ECE 25 2

Arithmetic and Logical Operations in ISA What operations are there? How do we implement them? Consider a -bit Adder CS/ECE 25 3

A -bit Full Adder Cin a b Sum + Cout a b C in Sum C out CS/ECE 25 4

Example: 4-bit Ripple Carry Adder S3 S2 S S C out Full Adder Full Adder Full Adder Full Adder b3 a3 b2 a2 b a b a CS/ECE 25 5

Subtraction How do we perform integer subtraction? What is the HW? Remember: Subtraction is just addition X Y = X + (-Y) = X + (~Y +) CS/ECE 25 6

Example: Adder/Subtractor S3 S2 S S C out Full Adder Full Adder Full Adder Full Adder Add/Sub b3 a3 b2 a2 b a b a CS/ECE 25 7

Overflow How would we detect signed overflow? See if CI!= CO -bit!= is implemented with XOR If CI = and CO= Sum must produce the carry CO= only if A= and B= Adding two negative numbers to produce positive number If CI = and CO= Sum must consume the carry CO= only if A= and B= Adding two positive numbers to produce a negative number CS/ECE 25 8

Add/Subtract With Overflow etection Overflow S n- S n- 2 S S Full Adder Full Adder Full Adder Full Adder Add/Sub b n- a n- b n- 2 a n- 2 b a b a CS/ECE 25 9

ALU Slice C in a b 3 2 A F a + b a - b - NOT b - 2 a OR b - 3 a AN b Add/sub 2 Add/sub C ou t F CS/ECE 25

The ALU Overflow = Zero n- n-2 ALU Slice ALU Slice ALU Slice ALU Slice ALU control b n- a n- b n-2 a n-2 b a b a CS/ECE 25

Abstraction: The ALU General structure Two operand inputs Control inputs ALU Operation We can build circuits for Multiplication ivision They are more complex Input A Input B ALU Carry Out Zero Result Overflow CS/ECE 25 2

Shifts Remember the << and >> operations? Shift left/shift right? How would we implement these? Suppose an 8-bit number b 7 b 6 b 5 b 4 b 3 b 2 b b Shifted left by a 3 bit number s 2 s s Option : Truth Table? 248 rows? Not appealing CS/ECE 25 3

Let s simplify Simpler problem: 8-bit number shifted by bit number (shift amount selects each mux) b 7 out 7 b 6 out 6 b 5 b 4 out 5 out 4 b 3 out 3 b 2 out 2 b out b CS/ECE 25 out 4

Let s simplify Simpler problem: 8-bit number shifted by 2 bit number (new muxes selected by 2 nd bit) b 7 out 7 b 6 out 6 b 5 b 4 out 5 b 3 b 2 out 4 out 3 b out 2 b out out CS/ECE 25 5

Now shifted by 3-bit number Full problem: 8-bit number shifted by 3 bit number (new muxes selected by 3 rd bit) b 7 b 6 out 7 out 6 b 5 b 4 b 3 b 2 out 5 out 4 out 3 b out 2 b out out CS/ECE 25 6

Now shifted by 3-bit number Shifter in action: shift by b 7 b 6 out 7 out 6 b 5 b 4 b 3 b 2 out 5 out 4 out 3 b out 2 b out out CS/ECE 25 7

Now shifted by 3-bit number Shifter in action: shift by b 7 b 6 out 7 out 6 b 5 b 4 b 3 b 2 out 5 out 4 out 3 b out 2 b out out CS/ECE 25 8

Now shifted by 3-bit number Shifter in action: shift by b 7 b 6 out 7 out 6 b 5 b 4 b 3 b 2 out 5 out 4 out 3 b out 2 b out out CS/ECE 25 9

So far We can make logic to compute math Add, subtract, (we ll see multiply/divide later) Bitwise: AN, OR, NOT, Shifts Selection (MUX) But processors need state (hold value) Registers CS/ECE 25 2

Memory Elements All the circuits we looked at so far are combinational circuits: the output is a Boolean function of the inputs. We need circuits that can remember values (registers, memory) The output of the circuit is a function of the input and a stored value (state) Circuits with memory are called sequential circuits Key to storage: loops in circuit from outputs to inputs CS/ECE 25 2

NOR-based Set-Reset (SR) Latch R R S S R S - on t set both S & R to. Seriously, don t do it. CS/ECE 25 22

Set-Reset Latch (Continued) R R S S Time S R CS/ECE 25 23

Set-Reset Latch (Continued) R R S S Time S Set Signal Goes High R Output Signal Goes High CS/ECE 25 24

Set-Reset Latch (Continued) R R S S Time S Set Signal Goes Low R Output Signal Stays High CS/ECE 25 25

Set-Reset Latch (Continued) R R S S Time S Until Reset Signal Goes High R Then Output Signal Goes Low CS/ECE 25 26

SR Latch ownside: S and R at once = chaos ownside: Bad interface What is a better solution? CS/ECE 25 27

ata Latch ( Latch) Starting with SR Latch CS/ECE 25 28

ata Latch ( Latch) E nable ata Starting with SR Latch Change interface to ata + Enable ( + E) CS/ECE 25 29

ata Latch ( Latch) E nable ata Time E - E goes high E latched Stays as output CS/ECE 25 3

ata Latch ( Latch) E nable ata E - E goes low E Time oes not affect Output Output unchanged By changes to CS/ECE 25 3

ata Latch ( Latch) E nable ata Time E - E goes high E latched Becomes new output CS/ECE 25 32

ata Latch ( Latch) E nable ata Time E - Slight elay (Logic gates take time) E CS/ECE 25 33

Logic takes time: Logic Takes Time Gate delays: delay to switch each gate Wire delays: delay for signal to travel down wire Other factors (not going into them here) Need to make sure that signals timing is right on t want to have races CS/ECE 25 34

Clocks Processors have a clock: Alternates (low high low high) Latch à logic à latch in one clock cycle One clock cycle 3.4 GHz processor = 3.4 Billion clock cycles/sec CS/ECE 25 35

Level Triggered Clock First thoughts: Level Triggered Latch enabled when clock is high Hold value when clock is low 3 Logic latch 3 E latch E Clk CS/ECE 25 36

Level Triggered Clock How we d like this to work Clock is low, all values stable Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 37

Level Triggered Clock How we d like this to work Clock goes high, latches capture and transmit new value Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 38

Level Triggered Clock How we d like this to work Signals work their way through logic w/ high clk Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 39

Level Triggered Clock How we d like this to work Clock goes low before signals reach next latch Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 4

Level Triggered Clock How we d like this to work Clock goes low before signals reach next latch Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 4

Level Triggered Clock How we d like this to work Everything stable before clk goes high Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 42

Level Triggered Clock How we d like this to work Clk goes high again, repeat Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 43

Level Triggered Clock Problem: What if signal reaches latch too early? i.e., while clk is still high Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 44

Level Triggered Clock Problem: What if signal reaches latch too early? Signal goes right through latch, into next stage.. Clk 3 Logic latch 3 E latch E Clk CS/ECE 25 45

That would be bad Getting into a stage too early is bad Something else is going on there à corrupted Also may be a loop with one latch Consider incrementing counter (or PC) Too fast -- increment twice? Not good. latch E + 3 CS/ECE 25 46

Edge Triggered Instead of level triggered Latch a new value at a clock level (high or low) We use edge triggered Latch a value at an clock edge (rising or falling) Rising Edges Falling Edges CS/ECE 25 47

Flip-Flop C latch E latch E Rising edge triggered Flip-flop Two Latches w/ Opposite clking of enables CS/ECE 25 48

Flip-Flop C latch E latch E Rising edge triggered Flip-flop Two Latches w/ opposite clking of enables On Low Clk, first latch enabled (propagates value) Second not enabled, maintains value CS/ECE 25 49

Flip-Flop C latch E latch E Rising edge triggered Flip-flop Two Latches w/ opposite clking of enables On Low Clk, first latch enabled (propagates value) Second not enabled, maintains value On High Clk, second latch enabled First latch not enabled, maintains value CS/ECE 25 5

Flip-Flop latch E latch E latch E latch E C C No possibility of races Even if I put 2 FFs back-to-back By the time signal gets through 2 nd latch of st FF, st latch of 2 nd FF is disabled Still must ensure signals reach FF before clk rises Important concern in logic design is making timing CS/ECE 25 5

Flip-flops (continued ) Could also do falling edge triggered Switch which latch has NOT on clk Flip-flop is ubiquitous Typically people just say latch and mean FF Which edge is used does not matter As long as same edge is used consistently We will use rising edge CS/ECE 25 52

flip flops Generally do not draw clk input Have one global clk, assume it goes there Often see > as symbol meaning clk Maybe have explicit enable Might not want to write every cycle If no enable signal shown, implies always enabled FF > FF FF E Get output and NOT(output) for free CS/ECE 25 53

Register File Can store one value what about manyvalues? E.g., Register File (the physical storage for the regs) MIPS, 32 32-bit integer registers How do we build a Register File using Flip-Flops? What other components do we need? CS/ECE 25 54

Register File Reading the registers 32 input mux -- slow Need 32 32- MUXes -- big Other regs not pictured 32 bit reg E 32 bit reg E 32 bit reg E 32 bit reg E CS/ECE 25 55

Register File Reading the registers 32 input mux -- slow Need 32 32- MUXes -- big Other regs not pictured Writing the registers Need to pick which reg Have reg num (e.g., 9) Make En9= En, En, = Wrata En En En3 En3 32 bit reg E 32 bit reg E 32 bit reg E 32 bit reg E CS/ECE 25 56

ecoders First task: convert binary number to one hot N bits in 2 N bits out 2 N - bits are, bit (matching the input) is 3 ecoder CS/ECE 25 57

ecoder Logic ecoder basically AN gates for each output: Out only True (one) if input In Out In In 2 3-input gates are fine. In theory, gates can have any # of inputs In practice >4 converted to multiple gates CS/ECE 25 58

ecoder Logic ecoder basically AN gates for each output: Out only True (one) if input Out In Out In In 2 Repeat for all outputs AN together correct sets of bits CS/ECE 25 59

Register File ecoder supports register addressing: Use decoder to convert register number into control signal Send write data to all registers Use one hot encoding to enable destination register Need to fix register read speed 32 input mux is not realistic For tractability, expand our world from {,} to {,, Z} CS/ECE 25 6

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = This wire is (it has no water) CS/ECE 25 6

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = This wire is (its full of water) CS/ECE 25 62

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose a gate drives a onto this wire rain the water CS/ECE 25 63

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose a gate drives a onto this wire rain the water CS/ECE 25 64

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose a gate drives a onto this wire rain the water CS/ECE 25 65

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose a gate drives a onto this wire rain the water CS/ECE 25 66

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose the gate now drives a Pump the water CS/ECE 25 67

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose the gate now drives a Pump the water CS/ECE 25 68

Water Analogy To understand Z, let s make an analogy Think of a wire as a pipe Has water = Has water = Suppose the gate now drives a Pump the water CS/ECE 25 69

Remember this rule? o not connect two outputs to the same wire a b c d BA! One gate drives. The other drives. One pumps water in. The other drains water out Except it s not water, it s electric charge Short circuit à lots of current à lots of heat CS/ECE 25 7

A third option: Z There is a third possibility: Z ( high impedance ) Neither pumping or draining charge Prevents charge from flowing through Gate that gives us Z : Tri-state E E - Z CS/ECE 25 7

Tri-State Buffers It s ok to connect multiple outputs together under one circumstance -- all but one must be outputting Z at any time n- n-2 E n- E n-2 E E CS/ECE 25 72

Mux with Tri-State Buffers Much more efficient for large #s of inputs (e.g., 32) ecoder ensures only one output 32 bit reg E 32 bit reg E 32 bit reg 5 ecoder CS/ECE 25 E 32 bit reg E 73

Ports Read Ports Ability to do one read per clock cycle May want more -- read two source registers per instruction Maybe even more if we do many instrs at once (later ) Could add more: need to replicate port Another decoder Another set of tri-states Another output bus (wire connecting the tri-states) Write Ports Ability to do one write/cycle Could add more: need to multiplex write values CS/ECE 25 74

Minor etail This is not how a register file is implemented in today s processors (Though it is how other things are implemented) Actually done with SRAM We ll see that later this semester CS/ECE 25 75