1 Foundations of Software Design Lecture 2: How Computers Work Marti Hearst Fall 2002.

Slides:



Advertisements
Similar presentations
Microprocessors A Beginning.
Advertisements

Sequential Logic ENEL 111. Sequential Logic Circuits So far we have only considered circuits where the output is purely a function of the inputs With.
Flip-Flops Computer Organization I 1 June 2010 © McQuain, Feng & Ribbens A clock is a free-running signal with a cycle time. A clock may be.
1 Fundamentals of Computer Science Sequential Circuits.
Digital Logic Chapter 5 Presented by Prof Tim Johnson
Chapter 1 — Computer Abstractions and Technology — 1 Lecture 7 Carry look ahead adders, Latches, Flip-flops, registers, multiplexors, decoders Digital.
October 16, 2002Flip-flops1 Summary : Latches A sequential circuit has memory. It may respond differently to the same inputs, depending on its current.
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
1 Microprocessor History. 2 The date is the year that the processor was first introduced. Many processors are re- introduced at higher clock speeds for.
ECE 331 – Digital System Design Flip-Flops and Registers (Lecture #18) The slides included herein were taken from the materials accompanying Fundamentals.
Computer Organization Boolean Logic and the CPU i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
1 Foundations of Software Design Lecture 3: How Computers Work Marti Hearst Fall 2002.
Instruction Counter Address [3..0] CLK Instruction ROM 0000: : : : : Inst [6..0] Control Unit.
Memory; Sequential & Clocked Circuits; Finite State Machines COS 116: 3/25/2008 Sanjeev Arora.
Lecture 4: Computer Memory
Fall 2007 L16: Memory Elements LECTURE 16: Clocks Sequential circuit design The basic memory element: a latch Flip Flops.
A presentation on Counters
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
How circuits acquire memory: Sequential & Clocked Circuits. COS 116, Spring 2011 Sanjeev Arora.
ENGSCI 232 Computer Systems Lecture 5: Synchronous Circuits.
Some Useful Circuits Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Engineering Lecture 3 Digital Electronics by Jaroslaw Karcz.
COE 202: Digital Logic Design Sequential Circuits Part 1
Flip Flop
Quiz # 2 Chapters 4, 5, & 6.
Practical PC, 7th Edition Chapter 17: Looking Under the Hood
Memory; Sequential & Clocked Circuits; Finite State Machines
ECE 101 An Introduction to Information Technology Digital Logic.
CS1Q Computer Systems Lecture 9 Simon Gay. Lecture 9CS1Q Computer Systems - Simon Gay2 Addition We want to be able to do arithmetic on computers and therefore.
Computer Systems Organization CS 1428 Foundations of Computer Science.
1 DIGITAL ELECTRONICS. 2 OVERVIEW –electronic circuits capable of carrying out logical (boolean) and arithmetic operations on information stored as binary.
COM181 Computer Hardware Ian McCrumRoom 5B18, Lecture 2: Circuits.
Computer Architecture Lecture 4 Sequential Circuits Ralph Grishman September 2015 NYU.
Finite State Machines (FSMs) and RAMs and CPUs COS 116, Spring 2011 Sanjeev Arora.
מבנה מחשב תרגול 2. 2 Boolean AND Operation Truth Table Equivalent Gate Different notations:
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits II.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
1 i206: Lecture 4: The CPU, Instruction Sets, and How Computers Work Marti Hearst Spring 2012.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
IT253: Computer Organization Lecture 9: Making a Processor: Single-Cycle Processor Design Tonga Institute of Higher Education.
Computer Architecture 2 nd year (computer and Information Sc.)
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Microarchitecture. Outline Architecture vs. Microarchitecture Components MIPS Datapath 1.
Sequential Logic Computer Organization II 1 © McQuain A clock is a free-running signal with a cycle time. A clock may be either high or.
Concepts of Engineering and Technology Copyright © Texas Education Agency, All rights reserved.
CO5023 Latches, Flip-Flops and Decoders. Sequential Circuit What does this do? The OUTPUT of a sequential circuit is determined by the current output.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
How does the CPU work? CPU’s program counter (PC) register has address i of the first instruction Control circuits “fetch” the contents of the location.
Digital Logic Design Basics Combinational Circuits Sequential Circuits Pu-Jen Cheng Adapted from the slides prepared by S. Dandamudi for the book, Fundamentals.
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
1 i206: Lecture 3: Boolean Logic, Logic Circuits Marti Hearst Spring 2012.
Chapter 1_0 Registers & Register Transfer. Chapter 1- Registers & Register Transfer  Chapter 7 in textbook.
Chapter Microcontroller
REGISTER TRANSFER LANGUAGE (RTL) INTRODUCTION TO REGISTER Registers1.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
FLIP FLOPS Binary unit capable of storing one bit – 0 or 1
The 8085 Microprocessor Architecture
The 8085 Microprocessor Architecture
Flip-flops Inputs are logically disconnected from the output in time.
THE CPU i Bytes 1.1.
ECE Digital logic Lecture 16: Synchronous Sequential Logic
Instructor: Alexander Stoytchev
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Basics Combinational Circuits Sequential Circuits Ahmad Jawdat
A451: Computer Systems and Programming
Instructor: Alexander Stoytchev
Boolean Logic Boolean Logic is considered to be the basic of digital electronics. We know that a computer’s most basic operation is based on digital electronics.
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
The 8085 Microprocessor Architecture
Digital Circuits and Logic
Presentation transcript:

1 Foundations of Software Design Lecture 2: How Computers Work Marti Hearst Fall 2002

2 How Do Computers Work? We are going bottom-up, with digressions Bits & BytesBinary Numbers Number Systems Orders of MagnitudeGates Boolean Logic Circuits CPUMachine Instructions Assembly Language Programming Languages Address Space Code vs. Data

3 Boolean Logic Truth Tables Images from

4 XOR TRUE only if just one of its inputs is TRUE We can use it in computer graphics to make objects look like they are moving.

5 AND and XOR for Image Manipulation Also called Masking –Think of the image as a grid of pixels –Compare position (0,0) in first image to (0,0) in second –Compare position (10,3) in the first to (10,3) in the second –Etc. –The truth table tells you what to do Images from

6 Overlaying Images using Boolean Logic Say we have a sprite: We want to put it on this background: First we make a MASK in which the shape of the desired image is black and the background is white: Images from

7 Masking with AND If we do an AND of the pixels, this is what happens: Black acts like 0, White acts like 1 –ANDing Black with anything gives Black –ANDing White with anything gives that color 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1 (this is where masking is a bit different) Images from

8 Masking with XOR Now we want to paint the sprite into the hole Definition of XOR: TRUE only if just one of its inputs is TRUE 0 XOR 0 = 0If both black, leave black 1 XOR 1 = 0If both non-black, turn black 0 XOR 1 = 1If one is non-black, assign the color Images from (Note: this requires that the image have a black background)

9 Boolean Logic Relationships A BC D Union (OR) Intersection (AND) Venn Diagram

10 Show this in logic gates (the power of invertors/not) A B = A B This is why you mainly see NAND gates in real circuits – everything is convertible.

11 Chips Contain Gates & Connectors Images from

12 LEDs (light-emitting diodes) Images from The circuit can turn the LED on or off.

13 Interactive demo of logic gates re/Lessons/Gates/index.html

14 LEDs (light-emitting diodes) Images from How are the LEDS for the digital clock controlled?

15 7 Segment LEDs How to set the digits Images from Need a circuit that implements this truth table!

16 7 Segment LEDs How to turn on only one digit at a time? Images from

17 2-bit Decoder: Uses NOTs (invertors) to convert 2 inputs to turn on one (and only one) of 4 outputs Images from Notice where the invertors are. They look like the inputs of a truth table.

18 Circuits for Addition Images from

19 NAND Latch Set and remember a value Images from This is tricky to understand without animation – view it online

20 Memory – a series of latches Images from This can store a byte.

21 NAND Latch: The Rules Both inputs are normally at logic 1 level. Changing an input to a logic 0 level will force that output to a logic 1. The same logic 1 will also be applied to the second input of the other NAND gate, allowing that output to fall to a logic 0 level (because of the rules of NAND). This 0 in turn feeds back to the second input of the original gate, forcing its output to remain at logic 1. Applying another logic 0 input to the first gate will have no further effect on this circuit. However, applying a logic 0 to the second gate will cause the same reaction in the other direction, thus changing the state of the latch circuit the other way. Image from

22 NAND Latch: The Problems Small problem: –Need to invert the inputs to make sense. Big problem: –If inputs change values rapidly, the one that sets the value of the latch is the last one seen. –If both inputs go to logic 1 simultaneously, the final state of the latch cannot be determined ahead of time. This is called: A Race Condition: the result depends on which input got changed first. Nondeterministic: Not being able to predict what will happen with certainty. bad –Nondeterminism is very, very bad from the perspective of computer science (most of the time).

23 Clocked D Latch Solves both problems: NANDs invert the input Clock line allows the system to control when to read the inputs. BUT only allows for one input. Image from

24 Clocked R-S NAND Latch (Partly) solves both problems: NANDs invert the input Clock line allows the system to control when to read the inputs. BUT Doesn’t stop S & R from changing while the clock is active Doesn’t stop S & R from being set to 1 simultaneously Image from

25 Edge-triggered flip-flop Input Latch Image from The invertor on the clock line ensures only 1 latch active at a time. When CLK=0, both inputs are disconnected from the input latch. When CLK becomes 1, activates input latch; disconnects output latch. When CLK falls to 0, disconnects input latch again; allows output latch to change. Then both latches are frozen. BUT still doesn’t solve the problem of both inputs going to 1 at once. Output Latch

26 JK Flip-Flop Image from Very similar to R-S flip-flop, EXCEPT One of the two inputs A and B is always disabled (because it is either connected to Q its inverse (not-Q)). If J and K are both set to 1, the flip-flop toggles in a predictable way between 0 and 1. To see this, say Q = 1, J = 1, and K = 1. When CLK becomes 1, the output of A will be 1, and B will be 0. When the CLK falls to 0, this will cause Q to become 0. At the next clock cycle, A will be 0, B will be 1, and so at the end of the cycle Q will become 1. And so on. Input LatchOutput Latch A B

27 Clock cycles Logic gates introduce propagation delays as the signal goes through them. Therefore, a clock cycle is introduced into the circuit. It connects up to all the circuits that need it, so they can all be told to update at the same time. The clock cycle can be no faster than the slowest set of logic gates. The clock keeps the circuit running in a predictable fashion, by making sure every part of the circuit gets changes to input at the same time.

28 This sounds familiar … Where have you heard about this clock before? –Cps (cycles per second): the measure of how frequently an alternating current changes direction. This term has been replaced by the term hertz (Hz). –gigahertz (GHz): A unit of frequency denoting 10 9 Hz. From last year’s New York Times: –

29 Now you know what it really means… “The Intel Corporation today began selling versions of its Pentium 4 chips that run at two gigahertz, or two billion cycles a second…” … Drew Prairie … accused Intel of ratcheting up clock speed without sharply improving the performance of the system. He said his company's fastest Athlon chips, at 1.4 gigahertz, run software as well as Intel's newest product. "They have a lead in megahertz, but in terms of raw performance I think it's neck and neck," Mr. Prairie said. But … what is the difference between clock speed and system performance? From “Intel Selling Two-Gigahertz Chips”, NYTimes, Aug 28, 2001, by Chris Gaither

30 The CPU

31 The CPU Registers –Are basically rows of latches –Store values –Can be used to hold values of variables Some special registers –PC (program counter) –Instruction Register –Accumulator

32 The CPU ALU (Arithmetic Logic Unit) –Made of a long series of adder units –Addition, Subtraction (Mult, Div) –Lots of gates, so often the slowest circuit in the CPU Image from

33 A key computer science concept: Code and data can be represented in the same way.