l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

Similar documents
CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of

Instruction Set Architecture

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e

(Refer Slide Time: 00:01:16 min)

Assembly Language: Function Calls" Jennifer Rexford!

Central Processing Unit (CPU)

Machine Programming II: Instruc8ons

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Computer organization

MICROPROCESSOR AND MICROCOMPUTER BASICS

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

LSN 2 Computer Processors

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Computer Organization and Architecture

CPU Organisation and Operation

CPU Organization and Assembly Language

CHAPTER 7: The CPU and Memory

Return-oriented programming without returns

PART B QUESTIONS AND ANSWERS UNIT I

Microprocessor & Assembly Language

Let s put together a Manual Processor

Machine-Level Programming II: Arithmetic & Control

Fetch. Decode. Execute. Memory. PC update

Intel 8086 architecture

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Instruction Set Architecture

Instruction Set Architecture (ISA)

Instruction Set Design

MACHINE ARCHITECTURE & LANGUAGE

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

X86-64 Architecture Guide

1 Classical Universal Computer 3

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s)

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Computer Organization and Components

An Overview of Stack Architecture and the PSC 1000 Microprocessor

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

Chapter 01: Introduction. Lesson 02 Evolution of Computers Part 2 First generation Computers

Chapter 4 Processor Architecture

Review: MIPS Addressing Modes/Instruction Formats

CS61: Systems Programing and Machine Organization

Building a computer. Electronic Numerical Integrator and Computer (ENIAC)

A s we saw in Chapter 4, a CPU contains three main sections: the register section,

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Lecture 27 C and Assembly

The WIMP51: A Simple Processor and Visualization Tool to Introduce Undergraduates to Computer Organization

Execution Cycle. Pipelining. IF and ID Stages. Simple MIPS Instruction Formats

EC 362 Problem Set #2

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

İSTANBUL AYDIN UNIVERSITY

8085 INSTRUCTION SET

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap Famiglie di processori) PROBLEMS

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

Register File, Finite State Machines & Hardware Control Language

CS352H: Computer Systems Architecture

The 104 Duke_ACC Machine

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

Administrative Issues

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Microprocessor/Microcontroller. Introduction

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture

Chapter 2 Logic Gates and Introduction to Computer Architecture

Solutions. Solution The values of the signals are as follows:

Microprocessor and Microcontroller Architecture

Chapter 7D The Java Virtual Machine

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

CPU Performance Equation

BASIC COMPUTER ORGANIZATION AND DESIGN

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1

A Tiny Guide to Programming in 32-bit x86 Assembly Language

Systems I: Computer Organization and Architecture

TIMING DIAGRAM O 8085

Chapter 5 Instructor's Manual

EECS 427 RISC PROCESSOR

INSTRUCTION LEVEL PARALLELISM PART VII: REORDER BUFFER

Compilers I - Chapter 4: Generating Better Code

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Design of Digital Circuits (SS16)

Chapter 9 Computer Design Basics!

PROBLEMS (Cap. 4 - Istruzioni macchina)

Where we are CS 4120 Introduction to Compilers Abstract Assembly Instruction selection mov e1 , e2 jmp e cmp e1 , e2 [jne je jgt ] l push e1 call e

Pipeline Hazards. Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by Arvind and Krste Asanovic

16-bit ALU, Register File and Memory Write Interface

Instruction Set Architecture. Datapath & Control. Instruction. LC-3 Overview: Memory and Registers. CIT 595 Spring 2010

High-speed image processing algorithms using MMX hardware

CSE 141L Computer Architecture Lab Fall Lecture 2

Computer Organization. and Instruction Execution. August 22

Introducción. Diseño de sistemas digitales.1

Programmer s Model = model of µc useful to view hardware during execution of software instructions

1 The Java Virtual Machine

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

Z80 Microprocessors Z80 CPU. User Manual UM Copyright 2014 Zilog, Inc. All rights reserved.

1 Computer hardware. Peripheral Bus device "B" Peripheral device. controller. Memory. Central Processing Unit (CPU)

Transcription:

198:211 Computer Architecture Topics: Processor Design Where are we now? C-Programming A real computer language Data Representation Everything goes down to bits and bytes Machine representation Language Very limited programming model Digital Logic Transistors g Gates g Circuits Circuits g { Memory, Registers, and Components} What are we going to do now. Processor Design Figure out how a small subset of the instruction set works in hardware Use Hardware blocks to describe data path Use control logic to ensure steps of the instruction flows smoothly Add instruction Type of add depends on where operands are located add reg1, reg2 Add contents of reg1 to reg2 and store result in reg2 add $constant, reg2 Add contents of memory immediately following the instruction to reg 2 and store result in reg2 add (effective-address), reg2 Add contents of effective address to reg2 and store result in reg2 Effective address could be relative; relative + offset; relative + offset, index; relative + offset, index*scaled 1

Instruction Example ADD-Add : note src, dst are reversed in the intel manual Addition Instruction Generic Form Encoded Representation addl %edx, %eax 0 3 rarb Add value in register %edx to that in register %eax Store result in register %eax Two-byte encoding First indicates instruction type Second gives source and destination registers In assembly language add src, dst means src + dst à dst Instruction Example in x86 Addition Instruction Generic Form Encoded Representation addl %edx, %eax 0 3 C 2 Opcode is 03 and src, dst are %edx, %eax from previous table (Table 2.2) code is C2 So, 03 C2 means add %edx, %eax 03 45 means add 8(%ebp), %eax 05 add $cons, %eax addl 8(%ebp), %eax 0 3 4 5 addl $4, %eax 0 5 000 4 2

Arithmetic and Logical Operations Instruction Code Subtract (ra from rb) And subl ra, rb Function Code 2 B rarb The second byte will vary based on type of operands Set condition codes as side effect Subtract operation- Instruction Set Reference andl ra, rb 2 3 rarb Exclusive-Or xorl ra, rb 3 3 rarb Lower 4 bits can vary depending upon the type Of operand 20 means 8 byte register transfer, Lower 4 bits can vary 30 means 8 byte register transfer, 3

Single cycle stages Fetch Instruction (IF) Decode Instruction (ID) Execute Instruction (EX) Memory access (MEM) Write back (WB) Update Program Counter (PC) Building Blocks Combinational Logic Compute Boolean functions of inputs Continuously respond to input changes Operate on data and implement control Storage Elements Store bits Addressable memories val src valb" srcb" Non-addressable registers Loaded only as clock rises B" B" fun" Register" file" MUX" B" A 1 =" S B valw" W" dstw" Clock" Clock Fetch Instruction Add instruction (add %edx, %eax) +" +" +4" IR %edx Register file %eax PC IR Fetch Instruction and increment Program counter Op code determines type of operation 03 C2 Operands are in registers They are fed to the adder (ALU) Result stored back in register Based On Instruction the signal to ALU can be +, -, * or / 4

Add instruction (add $4, %eax) + mov instruction (mov 8(%ebp), %eax) +" Data mem IR %eax Register file IR %ebp Register file %eax data address Op code is determines type of operation 03 05 One Operand is a register, the other is part of the instruction %eax, immediate value They are fed to the adder (ALU) Result stored back in register Op code is determines type of operation 8b 45 Load word from memory onto register %eax Address is 8 + (%ebp) R/W mov instruction (mov %eax, 8(%ebp)) +" Data mem IR %ebp Register file %eax data address Op code determines type of operation 89 45 Store word from register %eax onto memory Address is 8 + (%ebp) R/W 5

SEQ Hardware Structure PC Write back newpc vale, valm valm SEQ Stages PC Write back newpc vale, valm valm State Program counter register (PC) Condition code register (CC) Register File Memories Access same memory space Data: for reading/writing program data Instruction: for reading instructions Instruction Flow Read instruction at address specified by PC Process through stages Update program counter Memory Execute Decode Fetch icode, ifun ra,rb valc Instruction memory Addr, Data Bch CC alua, alub srca, srcb dsta, dstb Data memory valp vale ALU vala, valb PC increment Register A B M file E Fetch Read instruction from instruction memory Decode Read program registers Execute Compute value or address Memory Read or write data Write Back Write program registers PC Update program counter Memory Execute Decode Fetch icode, ifun ra,rb valc Instruction memory Addr, Data Bch CC alua, alub srca, srcb dsta, dstb Data memory valp vale ALU vala, valb PC increment Register A B M file E PC PC Instruction Decoding Optional Optional Executing Arith./Logical Operation OPl ra, rb 6 fn" rarb icode ifun ra rb valc Instruction Format 5 0 r rb" D" Instruction byte icode:ifun Optional register byte ra:rb Optional constant word valc Fetch Read 2 bytes Decode Read operand registers Execute Perform operation Set condition codes Memory Do nothing Write back Update register PC Update Increment PC by 2 6

Stage Computation: Arith/ Log. Ops Fetch Decode Execute OPl ra, rb icode:ifun M 1 [PC] ra:rb M 1 [PC+1] valp PC+2 vala R[rA] valb R[rB] vale valb OP vala Set CC Memory Write R[rB] vale back PC update PC valp Read instruction byte Read register byte Compute next PC Read operand A Read operand B Perform ALU operation Set condition code register Write back result Update PC Executing popl popl ra 8 F ra 8 Fetch Memory Read 2 bytes Read from old stack pointer Decode Write back Read stack pointer Update stack pointer Execute Write result to register Increment stack pointer by 4 PC Update Increment PC by 2 Formulate instruction execution as sequence of simple steps Use same general form for all instructions POP Instruction Stage Computation: popl Fetch Decode Execute popl ra icode:ifun M 1 [PC] ra:rb M 1 [PC+1] valp PC+2 vala %esp valb %esp vale valb + 4 Read instruction byte Read register byte Compute next PC Read stack pointer Read stack pointer Increment stack pointer Memory valm M 4 [vala] Read from stack Write R[%esp] vale back R[rA] valm PC update PC valp Use ALU to increment stack pointer Must update two registers Popped value New stack pointer Update stack pointer Write back result Update PC 7

Executing Jumps jxx Dest 7 fn" Dest" fall thru: XX XX Not taken Stage Computation: Jumps jxx Dest icode:ifun M 1 [PC] Read instruction byte target: XX XX Fetch Read 5 bytes Increment PC by 5 Decode Do nothing Execute Determine whether to take branch based on jump condition and condition codes Taken Memory Do nothing Write back Do nothing PC Update Set PC to Dest if branch taken or to incremented PC if not branch Fetch Decode valc M 4 [PC+1] valp PC+5 Compute both addresses Read destination address Fall through address Execute Bch Cond(CC,ifun) Take branch? Memory Write back PC update PC Bch? valc : valp Update PC Choose based on setting of condition codes and branch condition Executing call call Dest E 8 Dest" return: XX XX target: XX XX Fetch Read 5 bytes Increment PC by 5 Decode Read stack pointer Execute Decrement stack pointer by 4 Memory Write incremented PC to new value of stack pointer Write back Update stack pointer PC Update Set PC to Dest 8

Stage Computation: call call Dest icode:ifun M 1 [PC] Read instruction byte Call Opcodes in X86 Fetch Decode Execute valc M 4 [PC+1] valp PC+5 valb R[%esp] vale valb + 4 Read destination address Compute return point Read stack pointer Decrement stack pointer Memory M 4 [vale] valp Write return value on stack Write R[%esp] vale back PC update PC valc Update stack pointer Set PC to destination Use ALU to decrement stack pointer Store incremented PC Executing ret ret C 3 return: XX XX Stage Computation: ret ret icode:ifun M 1 [PC] Read instruction byte Fetch Fetch Read 1 byte Decode Read stack pointer Execute Increment stack pointer by 4 Memory Read return address from old stack pointer Write back Update stack pointer PC Update Set PC to return address Decode Execute Memory Write back PC update vala R[%esp] valb R[%esp] vale valb + 4 valm M 4 [vala] R[%esp] vale PC valm Read operand stack pointer Read operand stack pointer Increment stack pointer Read return address Update stack pointer Set PC to return address Use ALU to increment stack pointer Read return address from memory 9

10