Week 6: Processor Components

Similar documents
Announcements. This week: no lab, no quiz, just midterm

CPE 335. Basic MIPS Architecture Part II

LECTURE 6. Multi-Cycle Datapath and Control

Topic #6. Processor Design

Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

ECE369. Chapter 5 ECE369

Processor: Multi- Cycle Datapath & Control

RISC Processor Design

CSE 2021 COMPUTER ORGANIZATION

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

REGISTER TRANSFER LANGUAGE

CC 311- Computer Architecture. The Processor - Control

Chapter 5: The Processor: Datapath and Control

Multicycle conclusion

Mapping Control to Hardware

Points available Your marks Total 100

RISC Design: Multi-Cycle Implementation

Chapter 5 Solutions: For More Practice

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

CSE 2021 COMPUTER ORGANIZATION

Control Unit for Multiple Cycle Implementation

Processor (I) - datapath & control. Hwansoo Han

ECE260: Fundamentals of Computer Engineering

RISC Architecture: Multi-Cycle Implementation

Systems Architecture I

Computer Architecture and Organization: L04: Micro-operations

Major CPU Design Steps

Lets Build a Processor

RISC Architecture: Multi-Cycle Implementation

ENE 334 Microprocessors

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation

The Processor: Datapath & Control

Midterm. Sticker winners: if you got >= 50 / 67

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Boolean Unit (The obvious way)

ECE 341 Midterm Exam

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

Alternative to single cycle. Drawbacks of single cycle implementation. Multiple cycle implementation. Instruction fetch

Systems Architecture

Multiple Cycle Data Path

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

UNIT-III REGISTER TRANSFER LANGUAGE AND DESIGN OF CONTROL UNIT

Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan)

Arithmetic Circuits. Design of Digital Circuits 2014 Srdjan Capkun Frank K. Gürkaynak.

Contents. Chapter 9 Datapaths Page 1 of 28

Two-Level CLA for 4-bit Adder. Two-Level CLA for 4-bit Adder. Two-Level CLA for 16-bit Adder. A Closer Look at CLA Delay

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

Microprogramming. Microprogramming

ECE 341 Midterm Exam

Final Project: MIPS-like Microprocessor

Binary Arithmetic Intro to Assembly Language CS 64: Computer Organization and Design Logic Lecture #3

Multicycle Approach. Designing MIPS Processor

Multi-cycle Approach. Single cycle CPU. Multi-cycle CPU. Requires state elements to hold intermediate values. one clock cycle or instruction

Using a Hardware Description Language to Design and Simulate a Processor 5.8

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Arithmetic Logic Unit. Digital Computer Design

Real Digital Problem Set #6

Lecture 5: The Processor

EECE 417 Computer Systems Architecture

Chapter 4 The Processor (Part 2)

Tailoring the 32-Bit ALU to MIPS

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

Problem 4 The order, from easiest to hardest, is Bit Equal, Split Register, Replace Under Mask.

Winter 2002 FINAL EXAMINATION

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

Design Example: 4-bit Multiplier

Computer Architecture V Fall Practice Exam Questions

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

Single vs. Multi-cycle Implementation

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

CMOS VLSI Design. MIPS Processor Example. Outline

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Binary Multiplication

Number Systems and Computer Arithmetic

EE457. Note: Parts of the solutions are extracted from the solutions manual accompanying the text book.

Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium Tuesday, April 18 7:00pm to 10:00pm

CS 5803 Introduction to High Performance Computer Architecture: Arithmetic Logic Unit. A.R. Hurson 323 CS Building, Missouri S&T

CS 2506 Computer Organization II Test 1. Do not start the test until instructed to do so! printed

Cpr E 281 FINAL PROJECT ELECTRICAL AND COMPUTER ENGINEERING IOWA STATE UNIVERSITY. FINAL Project. Objectives. Project Selection

CSEN 601: Computer System Architecture Summer 2014

The Need of Datapath or Register Transfer Logic. Number 1 Number 2 Number 3 Number 4. Numbers from 1 to million. Register

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

Arithmetic-logic units

DC57 COMPUTER ORGANIZATION JUNE 2013

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Initial Representation Finite State Diagram. Logic Representation Logic Equations

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

Register Transfer and Micro-operations

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

ECE 3056: Architecture, Concurrency and Energy of Computation. Single and Multi-Cycle Datapaths: Practice Problems

CS232 Final Exam May 5, 2001

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Transcription:

Week 6: Processor Components

Microprocessors So far, we ve been about making devices, such such as adders, counters and registers. The ultimate goal is to make a microprocessor, which is a digital device that processes input, can store values and produces output, according to a set of onboard instructions.

Microprocessors These devices are a combination of the units that we ve discussed so far: ú Registers to store values. ú Adders and shifters to process data. ú Finite state machines to control the process. Microprocessors are the basis of all computing since the 1970 s, and can be found in nearly every sort of electronics.

To get to this Assembly Language Processors Arithmetic Logic Units Devices Finite State Machines Flip-flops Circuits Logic Gates Transistors We built these

The Final Destination PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite Control Unit Opcode PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Shift left 2 0 1 2 PC 0 1 Address Write data Memory Memory data Instruction [31-26] Instruction [25-21] Instruction [20-16] Instruction [15-0] Instruction Register Memory data register 0 1 0 1 Registers Read reg 1 Read Read reg 2 data 1 Write reg Write data Sign extend Read data 2 A B Shift left 2 4 0 1 0 1 2 3 A B Zero ALU result ALU ALU Out

Deconstructing processors Processors aren t so bad when you consider them piece by piece: Controller Thing Storage Thing Arithmetic Thing

The Arithmetic Thing aka: the Arithmetic Logic Unit (ALU)

Arithmetic Logic Unit The first microprocessor applications were calculators. ú Recall the unit on adders and subtractors. ú These are part of a larger structure called the arithmetic logic unit (ALU). This larger structure is responsible for the processing of all data values in a basic CPU.

ALU inputs The ALU performs all of the arithmetic operations covered in this course so far, and logical operations as well (AND, OR, NOT, etc.) C in,s ú The select bits indicate which operation is being performed (S2 is a mode select bit, indicating whether the ALU is in arithmetic or logic mode). ú The carry bit C in is used in operations such as incrementing an input value or the overall result. A G B VCNZ

ALU outputs In addition to the input signals, there are output signals V, C, N & Z which indicate special conditions in the arithmetic result: ú V: overflow condition C in,s The result of the operation could not be stored in the n bits of G, meaning that the result is incorrect. ú C: carry-out bit ú N: Negative indicator ú Z: Zero-condition indicator A G B VCNZ

The A of ALU To understand how the ALU does all of these operations, let s start with the arithmetic side. Fundamentally, this side is made of an adder / subtractor unit, which we ve seen already: Y 3 Y 2 Y 1 Y 0 Sub X 3 X 2 X 1 X 0 C out FA C 3 FA C 2 FA C 1 FA C in S 3 S 2 S 1 S 0

ALU block diagram In addition to data inputs and outputs, this circuit also has: ú outputs indicating the different conditions, ú inputs specifying the operation to perform (similar to Sub). Data input A Data input B Carry input Operation & Mode select...... A 0 A 1 A n-1 B 0 B 1 B n-1 C in S 0 S 1 S 2 n-bit ALU G 0 G 1 G n-1... C out V N Z Data output G Carry output Overflow indicator Negative indicator Zero indicator

Arithmetic components C in A B S 0 n n B input logic n X Y n-bit parallel adder G n G = X + Y + C in S 1 C out In addition to addition and subtraction, many more operations can be performed by manipulating what is added to input A, as shown in the diagram above.

Arithmetic operations If the input logic circuit on the left sends B straight through to the adder, result is G = A+B What if B was replaced by all ones instead? ú Result of addition operation: G = A-1 What if B was replaced by B? ú Result of addition operation: G = A-B-1 And what if B was replaced by all zeroes? ú Result is: G = A. (Not interesting, but useful!) à Instead of a Sub signal, the operation you want is signaled using the select bits S 0 & S 1.

Operation selection Select bits S 1 S 0 Y input Result Operation 0 0 All 0s G = A Transfer 0 1 B G = A+B Addition 1 0 B G = A+B Subtraction - 1 1 1 All 1s G = A-1 Decrement This is a good start! But something is missing Wait, what about the carry bit?

Full operation selection Select Input Operation S 1 S 0 Y C in =0 C in =1 0 0 All 0s G = A (transfer) G = A+1 (increment) 0 1 B G = A+B (add) G = A+B+1 1 0 B G = A+B G = A+B+1 (subtract) 1 1 All 1s G = A-1 (decrement) G = A (transfer) Based on the values on the select bits and the carry bit, we can perform any number of basic arithmetic operations by manipulating what value is added to A.

The L of ALU We also want a circuit that can perform logical operations, in addition to arithmetic ones. How do we tell which operation to perform? ú Another select bit! A B 4-to-1 mux If S 2 = 1, then logic circuit block is activated. Multiplexer is used to determine which block (logical or arithmetic) goes to the output. S 0 S 1 0 1 2 3 G

ALU block diagram In addition to data inputs and outputs, this circuit also has: ú outputs indicating the different conditions, ú inputs specifying the operation to perform (similar to Sub). Data input A Data input B Carry input Operation & Mode select...... A 0 A 1 A n-1 B 0 B 1 B n-1 C in S 0 S 1 S 2 n-bit ALU G 0 G 1 G n-1... C out V N Z Data output G Carry output Overflow indicator Negative indicator Zero indicator

Single ALU Stage C i A i B i C C i+1 i V A i N Z B i Arithmetic circuit G i S 0 S 1 S 0 S 1 0 G i 1 A i B i S 0 S 1 Logic circuit G i S 2

What about multiplication? Multiplication (and division) operations are always more complicated than other arithmetic (plus, minus) or logical (AND, OR) operations. Three major ways that multiplication can be implemented in circuitry: ú Layered rows of adder units. ú An adder/shifter circuit ú Booth s Algorithm

Break

Multiplication Multiplier circuits can be constructed as an array of adder circuits. This can get a little expensive as the size of the operands grows. Is there an alternative to this circuit?

Multiplication Revisiting grade 3 math 123 x 456 1 2 3 x 456 1368 912 12 3 x 456 1368 1 23 x 456 1368 912 456 123 x 456 1368 912 456 56088

Multiplication And now, in binary 101 x 110 1 0 1 x 110 110 000 10 1 x 110 110 1 01 x 110 110 000 110 101 x 110 110 000 110 11110

Booth s Algorithm Devised as a way to take advantage of circuits where shifting is cheaper than adding, or where space is at a premium. ú Based on the premise that when multiplying by certain values (e.g. 99), it can be easier to think of this operation as a difference between two products. Consider the shortcut method when multiplying a given decimal value X by 9999: ú X*9999 = X*10000 X*1 Now consider the equivalent problem in binary: ú X*001111 = X*010000 X*1

Booth s Algorithm This idea is triggered on cases where two neighboring digits in an operand are different. ú If digits at i and i-1 are 0 and 1, the multiplicand is added to the result at position i. ú If digits at i and i-1 are 1 and 0, the multiplicand is subtracted from the result at position i. The result is always a value whose size is the sum of the sizes of the two multiplicands.

Booth s Algorithm Example: 01010010 x 00011110 B A Add B here 01010010 + 111110101110 0100110011100 Subtract B from here Sign extend this before adding

Booth s Algorithm We need to make this work in hardware. ú Option #1: Have hardware set up to compare neighbouring bits at every position in A, with adders in place for when the bits don t match. Problem: This is a lot of hardware, which Booth s Algorithm is trying to avoid. ú Option #2: Have hardware set up to compare tw0 neighbouring bits, and have them move down through A, looking for mismatched pairs. Problem: Hardware doesn t move like that. Oops.

Booth s Algorithm Still need to make this work in hardware ú Option #3: Have hardware set up to compare tw0 neighbouring bits in the lowest position of A, and looking for mismatched pairs in A by shifting A to the right one bit at a time. Solution! This could work, but the accumulated solution P would have to shift one bit at a time as well, so that when B is added or subtracted, it s from the correct position.

Booth s Algorithm Note: unlike the accumulator, the bits here are being shifted to the right! Steps in Booth s Algorithm: 1. Designate the two multiplicands as A & B, and the result as some product P. 2. Add an extra zero bit to the right-most side of A. 3. Repeat the following for each original bit in A: a) If the last two bits of A are the same, do nothing. b) If the last two bits of A are 01, then add B to the highest bits of P. c) If the last two bits of A are 10, then subtract B from the highest bits of P. d) Perform one-digit arithmetic right-shift on both P and A. 4. The result in P is the product of A and B.

Booth s Algorithm Example Example: (-5) * 2 Steps #1 & #2: ú A = -5 à 11011 Add extra zero to the right à A = 11011 0 ú B = 2 à 00010 ú -B = -2 à 11110 ú P = 0 à 00000 00000

Booth s Algorithm Example Step #3 (repeat 5 times): ú Check last two digits of A: 1101 10 ú Since digits are 10, subtract B from the most significant digits of P: P 00000 00000 -B +11110 P 11110 00000 ú Arithmetic shift P and A one bit to the right: A = 111011 P = 11111 00000

Booth s Algorithm Example Step #3 (repeat 4 more times): ú Check last two digits of A: 1110 11 ú Since digits are 11, do nothing to P. ú Arithmetic shift P and A one bit to the right: A = 111101 P = 11111 10000

Booth s Algorithm Example Step #3 (repeat 3 more times): ú Check last two digits of A: 1111 01 ú Since digits are 01, add B to the most significant digits of P: P 11111 10000 +B +00010 P 00001 10000 ú Arithmetic shift P and A one bit to the right: A = 111110 P = 00000 11000

Booth s Algorithm Example Step #3 (repeat 2 more times): ú Check last two digits of A: 1111 10 ú Since digits are 10, subtract B from the most significant digits of P: P 00000 11000 -B +11110 P 11110 11000 ú Arithmetic shift P and A one bit to the right: A = 111111 P = 11111 01100

Booth s Algorithm Example Step #3 (final time): ú Check last two digits of A: 1111 11 ú Since digits are 11, do nothing to P: ú Arithmetic shift P and A one bit to the right: A = 111111 P = 11111 10110 Final product: P = 111110110 = -10

Reflections on multiplication A popular version of this algorithm involves copying A into the lower bits of P, so that the testing and shifting only takes place in P. ú Also good for maintaining the original value of A. Multiplication isn t as common an operation as addition or subtraction, but occurs enough that its implementation is handled in the hardware, rather than by the CPU. Most common multiplication and division operations are powers of 2. For this, the shift register is used instead of the multiplier circuit.

Shifter unit D3 D2 D1 D0 S0 S1 3 1 0 S1 S0 2 3 2 1 0 S1 S0 3 2 1 0 S1 S0 3 2 1 0 S1 S0 4-to-1 MUX 4-to-1 MUX 4-to-1 MUX 4-to-1 MUX Barrel shifter acts alongside ALU to shift data elements according to S 0 and S 1. ú ú Y3 S1S0 = 00 : Y3Y2Y1Y0 = D3 D2 D1 D0 S1S0 = 01 : Y3 Y2 Y1 Y0 = D2 D1 D0 D3 Y2 Y1 Y0

Function Unit A B Constant in 1 0 MuxB select n Address out Data out G select A B B V,C,N,Z S 2:0,C in ALU G H select I R Shifter H I L n n 1 0 MuxF select F So where do A and B come from?

The Storage Thing aka: the register file and main memory More on this next time