Snick  snack A Working Computer Slides based on work by Bob Woodham and others.

Slides:



Advertisements
Similar presentations
Stored Program Architecture
Advertisements

ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
CSE115: Introduction to Computer Science I
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
The Analytical Engine Module 6 Program Translation.
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic Combinational logic elements and design (DeMorgan’s Law)
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Stored Program Concept: The Hardware View
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Overview The von Neumann Machine - the programmable digital computer Introducing the LC-3 Computer - A “toy” computer for us to learn from Computer machine.
Chapter 12 CPU Structure and Function. Example Register Organizations.
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
Computer ArchitectureFall 2007 © Sep 10 th, 2007 Majd F. Sakr CS-447– Computer Architecture.
More Basics of CPU Design Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Introduction to Computer Architecture and System
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Cosc 2150: Computer Organization
Computer Systems Organization CS 1428 Foundations of Computer Science.
IT253: Computer Organization Lecture 10: Making a Processor: Control Signals Tonga Institute of Higher Education.
Chapter 4 MARIE: An Introduction to a Simple Computer.
How Computers Work … and how you can work them. Art 315 Lecture 03 Dr. J Parker Fall 2010.
1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)
Computer Architecture And Organization UNIT-II General System Architecture.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
1 i206: Lecture 4: The CPU, Instruction Sets, and How Computers Work Marti Hearst Spring 2012.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Computer Systems - Processor. Objectives To investigate and understand the structure and role of the processor.
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.)
Stored Programs In today’s lesson, we will look at: what we mean by a stored program computer how computers store and run programs what we mean by the.
Electronic Analog Computer Dr. Amin Danial Asham by.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Our programmer needs to do this !
CompSci Today’s topics Machine Architecture The basic machine Basic programming Assembler programming Upcoming Language Translation Reading Great.
CS 1308 Exam 2 Review. Exam Format 110 Total Points 24 Points Short Answer 28 Points Fill in the Blank 16 Points T/F 36 Points Multiple Choice The above.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
CBP 2002ITY 270 Computer Architecture1 Module Structure Whirlwind Review – Fetch-Execute Simulation Instruction Set Architectures RISC vs x86 How to build.
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Chapter 1 An Overview of Computers and Programming Languages.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Chapter 20 Computer Operations Computer Studies Today Chapter 20.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ read/write and clock inputs Sequence of control signal combinations.
CPU (Central Processing Unit). The CPU is the brain of the computer. Sometimes referred to simply as the processor or central processor, the CPU is where.
Today’s Agenda Exam 2 Part 2 (11:15am-12:30pm)
Architecture Review Instruction Set Architecture
Morgan Kaufmann Publishers
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
CSCE Fall 2013 Prof. Jennifer L. Welch.
CSCE Fall 2012 Prof. Jennifer L. Welch.
A Discussion on Assemblers
CPU Structure CPU must:
A Level Computer Science Topic 5: Computer Architecture and Assembly
A Top-Level View Of Computer Function And Interconnection
Computer Systems An Introducton.
Chapter 4 The Von Neumann Model
Presentation transcript:

snick  snack A Working Computer Slides based on work by Bob Woodham and others

Learning Goals: In-Class By the end of this unit, mostly from the lab, you should be able to: –Trace execution of an instruction through our computer: the basic fetch-decode-execute instruction cycle and the data flow to/from the arithmetic logic unit (ALU), the main memory, the Instruction Register (IR) and the Program Counter (PC) under control of the microController, down to individual wires and gates. 2

Where We Are in The Big Stories Theory How do we model computational systems? Now: Not really a theory show… Hardware How do we build devices to compute? Now: Done! A full working computer! 3

Computer Strategy Instead of a new DFA circuit for each problem: 1.Make a DFA with “instructions” as input. 2.Design a set of instructions that combine to solve many problems 3.Solve new tasks with new instructions, not a new circuit. With appropriate instructions, this design is “universal”: it can perform any conceivable computation. (We won’t prove this, but we did see it implement basic Java instructions!)

A “Normal” DFA as a Sequential Circuit DFA with a bunch of states and with output on arcs Sequence of inputs Sequence of outputs clk

Ultra-High-Level CPU View: Fetch, Decode, Execute Cycle, as DFA DFA with LOTS of states and output on arcs Sequence of outputs clk A stored-program computer includes data and code in its memory. Load memory with code/data and start the machine, and it “acts out” its program. Load new code/data, and restart, and it “acts out” a totally different program! A stored-program computer can simulate any other computer that we can now practically or theoretically envision!

Ultra-High-Level CPU View: Fetch, Decode, Execute Cycle Memory: code and data Program Counter (PC) Accumulator (ACC) Next instruction and data Address of next instruction Data to store back in memory Data to use in next instruction Updates to address and new data ACC and PC are “registers”: extra little pieces of fast memory. Combinational Circuitry, esp. ALU and controller

CPSC 121’s “circuits story” From the bottom up... we can build digital logic in physical devices (remember the water computers and switches?) we can use logic gates to organize our digital circuits we can organize logic gates into combinational circuits that calculate any logical function of their inputs (any truth table) we can use feedback to create sequential circuits that remember values and act on events we can implement any DFA using a sequential circuit we can build a working computer: a DFA with configurable memory that determines its own next instruction, which can perform any conceivable computation Wow! Too bad it’s a pain in the butt to program in our computer’s language! If only...

CPSC 111’s “programming story” From the top down: we can design algorithms to solve an enormous variety of computational problems we can encode those algorithms into programs in high-level programming languages compilers and interpreters can automatically transform those programs into low-level programming languages Any guesses what those low-level programming languages might look like? Here’s one we already saw...

Java Byte Code Part of our Java code: // Let's do something a hundred times. int i = 100; do { // Make i one smaller. i--; } while (i > 0); Here’s a typical “hex” view of ~1/5 th of the program’s byte code. 10

CPSC 111’s + 121’s Story... High-level languages all the way down to physical devices that compute. What’s left? HUGE TREMENDOUS AMAZING AMOUNTS OF STUFF: Software engineering: implementing incredibly complex systems as programs and helping programmers manage that complexity. Human-computer interaction: understanding how people work with computers and designing interfaces that are effective for them. Systems: building structures on top of the machine that knit computers together and let people and programs communicate and collaborate effectively. Artificial intelligence: recognizing, extracting, and acting on high-level patterns in complex and meaningful ways. Theory: analyzing the capabilities and limitations of computing systems to accomplish all of these tasks. Computer engineering: redesigning the machine to more efficiently (in terms of speed, power consumption, size, memory usage, etc.) execute programs. (And so on...)

Learning Goals: In-Class By the end of this unit, mostly from the lab, you should be able to: –Trace execution of an instruction through our computer: the basic fetch-decode-execute instruction cycle and the data flow to/from the arithmetic logic unit (ALU), the main memory, the Instruction Register (IR) and the Program Counter (PC) under control of the microController, down to individual wires and gates. 12

snick  snack Extra Slides

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } SOMETHING that can run on a bare bones computer??

Java Memory Model  Hardware Memory ??? in a memory that is just a numbered list of locations. 5 x (int) 1 y (int)

Java Memory Model  Hardware Memory Pick “slots” for x and y, say memory locations 0x100 and 0x101 : 0x000 0x001. 0x0FF 0x100 0x x (int) 1 y (int)

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Start translating ??

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Start translating // Note: x is in 100 // Note: y is in 101 ??

Available Instructions ADD addr: ACC = ACC + M[addr] SUB addr: ACC = ACC - M[addr] MUL addr: ACC = ACC * M[addr] DIV addr: ACC = ACC / M[addr] MOD addr: ACC = ACC % M[addr] LOAD addr: ACC = M[addr] STORE addr: M[addr] = ACC JUMP addr: go to line addr BRANCH addr: if ACC == 0, go to line addr else, go to next line And.. that’s it. Note: we will usually call “addr” an “immediate” or “imm”. ACC stands for “accumulator”. It’s a little extra piece of memory called a “register”. Think of it as the place where we store scratch work.

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate x = 5. // Note: x is in 100 // Note: y is in 101 ??

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate x = 5. // Note: x is in 100 // Note: y is in 101 // Start w/5 in 200. LOAD 200 STORE 100 ?? Most computers have an instruction that makes this easier like: LOADI imm: ACC = imm

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate y = 1. // Note: x is in 100 // Note: y is in 101 // Start w/5 in 200. LOAD 200 STORE 100 ??

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate y = 1. // Note: x is in 100 // Note: y is in 101 // Start w/5 in 200. // Start w/1 in 201. LOAD 200 STORE 100 LOAD 201 STORE 101 ??

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate “while”. // Note: x is in 100 // Note: y is in 101 // 5 in 200, 1 in 201. LOAD 200 STORE 100 LOAD 201 STORE 101 ??

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate “while”. // Note: x is in 100 // Note: y is in 101 // 5 in 200, 1 in x0 LOAD 200 0x1 STORE 100 0x2 LOAD 201 0x3 STORE 101 0x4 ?? 0x5 ?? 0x6 ?? 0x7 ?? Let’s start by translating the end. What happens at the end of a loop?

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate “while”. // Note: x is in 100 // Note: y is in 101 // 5 in 200, 1 in x0 LOAD 200 0x1 STORE 100 0x2 LOAD 201 0x3 STORE 101 0x4 ?? 0x5 ?? 0x6 ?? 0x7 JUMP 4 At the end of a loop, we jump back to the start.

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate “while”. // Note: x is in 100 // Note: y is in 101 // 5 in 200, 1 in x0 LOAD 200 0x1 STORE 100 0x2 LOAD 201 0x3 STORE 101 0x4 ?? 0x5 ?? 0x6 ?? 0x7 JUMP 4 Now the beginning. How do we make a choice?

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate “while”. // Note: x is in 100 // Note: y is in 101 // 5 in 200, 1 in x0 LOAD 200 0x1 STORE 100 0x2 LOAD 201 0x3 STORE 101 0x4 BRANCH 8 0x5 ?? 0x6 ?? 0x7 JUMP 4 Choose based on whether x equals 0... But what’s wrong with this?

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate the rest. // Note: x is in 100 // Note: y is in 101 // 5 in 200, 1 in x0 LOAD 201 0x1 STORE 101 0x2 LOAD 200 0x3 STORE 100 0x4 BRANCH 8 0x5 ?? 0x6 ?? 0x7 JUMP 4 BRANCH chooses based on what’s in the accumulator. With the loads for x and y switched, what’s in the ACC is now x.

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate the rest. // Note: x is in 100 // Note: y is in 101 // Put 5 in 200, 1 in x0 LOAD 201 0x1 STORE 101 0x2 LOAD 200 0x3 STORE 100 0x4 BRANCH A 0x5 LOAD 101 // 101 is y 0x6 MUL 100 // x 0x7 STORE 101 // back in y 0x8 ?? 0x9 JUMP 4 To multiply x and y, we load in y and multiply in x. Then, we store the result back into y.

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate the rest. // Note: x is in 100 // Note: y is in 101 // Put 5 in 200, 1 in x0 LOAD 201 0x1 STORE 101 0x2 LOAD 200 0x3 STORE 100 0x4 BRANCH A 0x5 LOAD 101 // 101 is y 0x6 MUL 100 // x 0x7 STORE 101 // back in y 0x8 ?? 0x9 JUMP 4

Java Program  Machine Program // Put 5! in y. int x; int y; x = 5; y = 1; while (x != 0) { y = y * x; x = x - 1; } // Translate the rest. // Note: x is in 100 // Note: y is in 101 // Put 5 in 200, 1 in x0 LOAD 201 0x1 STORE 101 0x2 LOAD 200 0x3 STORE 100 0x4 BRANCH C 0x5 LOAD 101 // 101 is y 0x6 MUL 100 // x 0x7 STORE 101 // back in y 0x8 LOAD 100 // x 0x9 SUB 201 // 1 0xA STORE 100 // back in x 0xB JUMP 4 Same style as the last step. Note that we already had the constant 1 stored in address 201.

Java Program  Machine Memory 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007 0x008 0x009 0x00A 0x00B. 0x100 0x101. 0x200 0x201 // Put 5! in y. int x; int y; x = 5; y = 1; do { y = y * x; x = x - 1; } while (x != 0); 0x x x x x C 0x x x x x x x x x x The opcode references gives us the first two hex digits of each instruction. The rest is just the hex numbers we already had.