The Universal Machine (UM) Implementing the UM Noah Mendelsohn Tufts University Web:

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

CH10 Instruction Sets: Characteristics and Functions
Introduction to Machine/Assembler Language Noah Mendelsohn Tufts University Web:
Machine Instructions Operations
Copyright 2014 – Noah Mendelsohn Assemblers, Macros and The UM Macro Assembler (UMASM) Noah Mendelsohn Tufts University
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
Machine/Assembler Language Putting It All Together Noah Mendelsohn Tufts University Web:
Chapter 2.
Khaled A. Al-Utaibi  Computers are Every Where  What is Computer Engineering?  Design Levels  Computer Engineering Fields  What.
Room: E-3-31 Phone: Dr Masri Ayob TK 2123 COMPUTER ORGANISATION & ARCHITECTURE Lecture 5: CPU and Memory.
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic Combinational logic elements and design (DeMorgan’s Law)
Computer System Overview
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Microprocessors Introduction to RISC Mar 19th, 2002.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CPU Computer Hardware Organization (How does the computer look from inside?) Register file ALU PC System bus Memory bus Main memory Bus interface I/O bridge.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
Computer Architecture and Organization Introduction.
Computer Systems Organization CS 1428 Foundations of Computer Science.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Chapter 4 MARIE: An Introduction to a Simple Computer.
RISC Architecture RISC vs CISC Sherwin Chan.
Chapter 16 Micro-programmed Control
Lecture 14 Today’s topics MARIE Architecture Registers Buses
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.
Important Concepts  Parts of the CPU  Arithmetic/Logic Unit  Control Unit  Registers  Program Counter  Instruction Register  Fetch/Decode/Execute.
Computer Organization CSC 405 (VSC) Very Simple Computer.
Chapter 2 Data Manipulation. © 2005 Pearson Addison-Wesley. All rights reserved 2-2 Chapter 2: Data Manipulation 2.1 Computer Architecture 2.2 Machine.
Computer Architecture EKT 422
Crosscutting Issues: The Rôle of Compilers Architects must be aware of current compiler technology Compiler Architecture.
Computer Architecture Lecture 03 Fasih ur Rehman.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
Building Your Own Machine The Universal Machine (UM) Introduction Noah Mendelsohn Tufts University Web:
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
9/20/6Lecture 2 - Prog Model1 MicroBaby A simple micro-controller encompassing all the basics Start this class by organizing into groups.
What is a program? A sequence of steps
Ass. Prof. Dr Masri Ayob TK 2123 Lecture 14: Instruction Set Architecture Level (Level 2)
Computer Organization Instructions Language of The Computer (MIPS) 2.
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
M211 – Central Processing Unit
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
New-School Machine Structures Parallel Requests Assigned to computer e.g., Search “Katz” Parallel Threads Assigned to core e.g., Lookup, Ads Parallel Instructions.
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.
PROGRAMMABLE LOGIC CONTROLLERS SINGLE CHIP COMPUTER
Assembly Language for Intel-Based Computers, 5th Edition
Overview Introduction General Register Organization Stack Organization
Prof. Sirer CS 316 Cornell University
MARIE: An Introduction to a Simple Computer
Morgan Kaufmann Publishers The Processor
Chapter 5: Computer Systems Organization
von Neumann Architecture CPU
ECEG-3202 Computer Architecture and Organization
August 29 New address for Fang-Yi
ECEG-3202 Computer Architecture and Organization
Prof. Sirer CS 316 Cornell University
Course Outline for Computer Architecture
CPU Structure CPU must:
A Level Computer Science Topic 5: Computer Architecture and Assembly
William Stallings Computer Organization and Architecture
Information Representation: Machine Instructions
COMP755 Advanced Operating Systems
Chapter 10 Instruction Sets: Characteristics and Functions
Chapter 4 The Von Neumann Model
Presentation transcript:

The Universal Machine (UM) Implementing the UM Noah Mendelsohn Tufts University Web: COMP 40: Machine Structure and Assembly Language Programming (Fall 2015)

© 2010 Noah Mendelsohn Review: Overview of the UM

© 2010 Noah Mendelsohn UM Highlights  8 32 bit registers (no floating point)  14 RISC-style (simple) instructions  Load/store architecture: all manipulation done in registers  Segmented memory –Executing code lives in segment 0 –Programs can create and map new zero-filled segments –Any segment can be cloned to be come the new code segment (0)  Simple byte-oriented I/O  Does not have explicit: –Jump/branch –Subtract –Shift 3

© 2010 Noah Mendelsohn 14 UM Instructions  Arithmetic and data  Add, multiply, divide (not subtract!)  Load value  Conditional move  Logical  Bitwise nand (~and)  Memory management  Map/unmap segment  Segmented load/store  Load program  I/O  Input (one byte), Output (one byte)  Misc  Halt 4

© 2010 Noah Mendelsohn 14 UM Instructions  Arithmetic and data  Add, multiply, diviicde (not subtract!)  Load value  Conditional move  Logical  Bitwise nand (~and)  Memory management  Map/unmap segment  Segmented load/store  Load program  I/O  Input (one byte), Output (one byte)  Misc  Halt 5 Add: $r[A] := ($r[B] + $r[C]) mod 2 32 Documented in the form of assignment statements (register transfer langauge – RTL)

© 2010 Noah Mendelsohn Instruction Format 14 UM Instructions  Arithmetic and data  Add, multiply, diviicde (not subtract!)  Load value  Conditional move  Logical  Bitwise nand (~and)  Memory management  Map/unmap segment  Segmented load/store  Load program  I/O  Input (one byte), Output (one byte)  Misc  Halt 6 RCRC OP RBRB RARA Add: $r[A] := ($r[B] + $r[C]) mod 2 32

© 2010 Noah Mendelsohn 14 UM Instructions  Arithmetic and data  Add, multiply, diviicde (not subtract!)  Load value  Conditional move  Logical  Bitwise nand (~and)  Memory management  Map/unmap segment  Segmented load/store  Load program  I/O  Input (one byte), Output (one byte)  Misc  Halt 7 RCRC 3 RBRB RARA Instruction Format 4 bits to select one of 14 operations Add: $r[A] := ($r[B] + $r[C]) mod 2 32

© 2010 Noah Mendelsohn 14 UM Instructions  Arithmetic and data  Add, multiply, diviicde (not subtract!)  Load value  Conditional move  Logical  Bitwise nand (~and)  Memory management  Map/unmap segment  Segmented load/store  Load program  I/O  Input (one byte), Output (one byte)  Misc  Halt 8 RCRC OP RBRB RARA Instruction Format 3 bits to select one of 8 registers Add: $r[A] := ($r[B] + $r[C]) mod 2 32

© 2010 Noah Mendelsohn What’s different from AMD64?  Very few instructions – can we do real work?  Pointers to words not bytes  Segmented memory model  AMD/Intel has I/O, but we did not study it  No floating point 9

© 2010 Noah Mendelsohn Emulators

© 2010 Noah Mendelsohn Emulators  Hardware or software that implements another machine architecture  Great way to learn about machines: –The emulator you write will do in software the same thing machines do in hw  Terrific tool for –Testing code before hardware is ready –Performance analysis (e.g. our testcachesim ) –Evaluating processor/memory design before committing to build chip –Moving systems to a new architecture (e.g. Apple move from PowerPC to Intel) 11

© 2010 Noah Mendelsohn Very simplified view of computer 12 Cache Memory

© 2010 Noah Mendelsohn Very simplified view of UM 13 Cache Memory

© 2010 Noah Mendelsohn Very simplified view of UM 14 Memory

© 2010 Noah Mendelsohn Instructions fetched and decoded 15 Memory Add instruction Nand (not and) instruction

© 2010 Noah Mendelsohn Instructions fetched and decoded 16 Memory ALU Arithmetic and Logic Unit executes instructions like add and shift updating registers.

© 2010 Noah Mendelsohn Questions?  How would you implement an emulator for the UM?  Specific questions: –What state must your emulator program keep and update? –What logic must it perform? –What external interfaces does it have? –What is the initial state of the machine and what must be available in the environment (e.g. where does the program come from?)  Remember: you’ll have two programs running at once! 1.Your emulator is a C program 2.It is simulating the execution of a UM program 17

© 2010 Noah Mendelsohn Segmented Memory

© 2010 Noah Mendelsohn Why segmented memory?  Advantages –Allows programs with small pointers to address lots of memory –Illustrates a model that was popular when circuits were limited –For class: gives you an interesting programming challenge  Disadvantages –Simple is better: segmented memories are more complex to use –Few modern machines and operating systems use segmented architectures 19

© 2010 Noah Mendelsohn Traditional memory 20 0Last addr mov (%rbp), %rax Some address rbp Value rax Value

© 2010 Noah Mendelsohn Segmented memory in UM 21 r7 := m[r1][r5] 2 r1 r7 0 Value Segment 0 Segment 1 Segment 2 Segment 3 4 r5

© 2010 Noah Mendelsohn Segmented memory in UM 22 r7 := m[r1][r5] 2 r1 r7 0 Value Segment 0 Segment 1 Segment 2 Segment 3 4 r5 Identify segment

© 2010 Noah Mendelsohn Segmented memory in UM 23 r7 := m[r1][r5] 2 r1 r7 0 Value Segment 0 Segment 1 Segment 2 Segment 3 4 r5 Identify segment Address in segment

© 2010 Noah Mendelsohn Segmented memory in UM 24 r7 := m[r1][r5] 2 r1 r7 0 Value Segment 0 Segment 1 Segment 2 Segment 3 4 r5 Identify segment Address in segment

© 2010 Noah Mendelsohn Thinking about segmented memory 25 r7 := m[r1][r5] 2 r1 r7 0 Value Segment 0 Segment 1 Segment 2 Segment 3 4 r5 Identify segment Address in segment A Segmented Memory Acts Like A Machine with Multiple Memories To address data you need a [segid, offset] pair Value

© 2010 Noah Mendelsohn Your program controls segment creation Map segment instruction Segment 0 Segment 1 Segment 2 Segment 3

© 2010 Noah Mendelsohn Your program controls segment creation Segment 0 Segment 1 Segment 2 Segment Map segment instruction $r[C] gives length for new segment

© 2010 Noah Mendelsohn Your program controls segment creation Map segment instruction $r[C] gives length for new segment Segment 0 Segment 1 Segment 2 Segment 3 0 (new!)Segment 4 Length set from $r[C] System puts ID of new segment in $r[B]

© 2010 Noah Mendelsohn Where do these segments really live? 29 Segment 0 Segment 2 Segment 1

© 2010 Noah Mendelsohn Where do these segments really live? 30 0 Segment 0 Segment 1 Segment 2 Real memory of the machine In real machines, the hardware and operating system together keep track of which segment is where…hardware usually has registers that can hold start address and length of segments the program is using.

© 2010 Noah Mendelsohn How Segments are Used in the UM

© 2010 Noah Mendelsohn How segments are used in the UM  Running code is always in segid zero –The emulator arranges for initial code image to be in segment zero –Copies of other segments can be swapped in to replace segment zero, thus changing what code is running  Programs can create (map), use, and release (unmap) other segments to hold data, etc.  The emulator keeps track of: –Which segment ids map to what actual data –Which segment ids are available as names for new segments –Keeping track of all this is a significant part of the work you will do in your emulator –You can malloc space for new segments when needed 32

© 2010 Noah Mendelsohn Summary

© 2010 Noah Mendelsohn What we learned today  Review the UM: simple 14 instruction RISC machine  Emulators: an important and powerful concept –Testing code before machines are ready –Proving machine designs work –Performance evaluation of machines and programs –Great way to learn about machines  To build an emulator: –Consider: state, logic, and external interfaces –Emulators often match the structure of real hardware implementations  Segmented memories –Used when main memory is too large to address with pointers in registers –Segment ids select what appear to be multiple smaller memories, each addressed from zero –OS and hardware work together to map segments to flat underlying memory 34