44
EKT 221 : Chapter 4 Computer Design Basics

EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths Introduction Datapath Example Arithmetic Logic Unit (ALU) Shifter

Embed Size (px)

Citation preview

Page 1: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

EKT 221 : Chapter 4Computer Design Basics

Page 2: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Chapter Overview Part 1 – Datapaths

Introduction Datapath Example Arithmetic Logic Unit (ALU) Shifter Datapath Representation Control Word

Part 2 – A Simple Computer Instruction Set Architecture (ISA) Single-Cycle Hardwired Control

Instruction Decoder Sample Instructions Single Cycle Computer Issues

Multiple Cycle Hardwired Control Sequential Control Design

Digital 2 will focus on Part 1

Part 2 will be covered in Computer Architecture & Microprocessor. however prior reading is encourage.

Page 3: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Part 1 : Datapath

Computer Specification

Instruction Set Architecture (ISA) The specification of a computer's appearance to a

programmer at its lowest level. It describe all the available instruction set in the computer,

where it is kept (address) and how to use it (read).

Computer Architecture A high-level description of the hardware implementing the

computer derived from the ISA

Page 4: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Part 1 : Datapath

The architecture usually includes additional specifications such as speed, cost, and reliability.

Simple computer architecture comprise of: Datapath for performing operations Control unit for controlling datapath operations

A datapath is specified by:a. A set of registers

b. The microoperations performed on the data stored in the registers

c. A control interface

Page 5: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Datapaths :

Guiding principles for basic datapaths (Typical):

The set of registers Collection of individual registers A set of registers with common access resources called a

register file A combination (individual & set of reg.) of the above

Microoperation implementation One or more shared resources for implementing microoperations Buses - shared transfer paths Arithmetic-Logic Unit (ALU) - shared resource for implementing

arithmetic and logic microoperations Shifter - shared resource for implementing shift microoperations

Page 6: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Datapath

The combination of:

A set of registers with a shared ALU, and interconnecting paths.

Page 7: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Block Diagram of a Generic Datapath

• Four parallel-load registers• Two mux-based register

selectors• Register destination decoder• Mux B for external constant

input• Buses A and B with external

address and data outputs• ALU and Shifter with Mux F

for output select (Function Unit)

• Mux D for external data input• Logic for generating status

bits V, C, N, Z

Page 8: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Block Diagram of a Generic Datapath

Example:R1 R2 + R3

A Select Place contents of R2 into Bus A

10

B Select Place contents of R3 into the input of MUX B

11

MB Select Place the 0 input of MUX B into Bus B

0

G Select Provide the arithmetic operation A + B

???? (4bits)

MF Select Place the ALU o/p on MUX F o/p

0

MD Select Place the MUX F o/p onto Bus D

0

Destination Select

To select R1 as the destination of the data on Bus D

01

Load enable

To enable a register R1 = HIGH

Note : G Select must refer to Function Table of Arithmetic Circuit (refer next 3 slides)

Page 9: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

The Arithmetic/ Logic Unit

(ALU)

Page 10: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Arithmetic Logic Unit (ALU) ALU Comprise of:

An arithmetic circuit (add, subtract)

A logic circuit (bitwise operation)

A selector to pick between the two circuits

1

2

3

Page 11: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Arithmetic Logic Unit (ALU) ALU Comprise

of: An arithmetic

circuit An n-bit

parallel adder A block of

input logic with 2 selectors S1 and S0

G Select(4-bits)

* Mode Select (S2) distinguishes between arithmetic and logic operations which actually construct item

1

3

Page 12: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

ALU

Is a combinational circuit that performs a set of basic microoperations on:

Arithmetic, and Logic

Has a number of selection lines used to determine the operations to be performede.g. n selection lines can specify up to 2n types of

operations.

Page 13: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

An n-bit ALU n data inputs of A are combined with n data inputs of B, to generate the result of an operation at the G outputs.

S2=0 Arithmetic operations (8). Which one – is specified by S1, So and Cin.

S2=1 Logic operations (4). Which one – specified by So and Cin.

Page 14: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Question

1. What are the 8 arithmetic operations?

2. What are the 4 logic operations?

Page 15: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

How to design the ALU?

1. Design the arithmetic section

2. Design the logic section

3. Combine both sections

Page 16: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

To be designed… One Stage of ALU

S2 = 0 for ArithmeticS2 = 1 for Logic

Page 17: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Arithmetic Circuit Design

Given …

Page 18: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Arithmetic Circuit Design

Note : X = A

Analyse the Circuit:

Use G = A + Y + Cin

Eg. We can verify for n = 4 bit:A = 1010B = 0101

For S1 and S0 = 00, thenG = A + 0 + 0G = A

1

Page 19: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Building the B input Logic

Input = S1, S0 and BOutput = Y

• Obtain the K-Map• Get the Boolean Expression

Y = BS0 + BS1

Page 20: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Building the B input LogicY = BS0 + BS1

Y

Example of a 4-bit Arithmetic Circuit

Any other alternative?

Page 21: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Use Multiplexer

0

B

B

1

Page 22: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Building the Logic Circuit The Logic Circuit performs bitwise operation Commonly : AND, OR, XOR and NOT

One Stage of Logic CircuitNote : if 4 bit is wanted, then we have to arrange it in array

2

Page 23: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Building the Selector for choosing Arithmetic or Logic Unit

3

One Stage of ALU

S2 = 0 for ArithmeticS2 = 1 for Logic

Refer also Fig. 10.2

Page 24: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Exercise Draw the complete diagram of the ALU,

which consists of:

The Arithmetic Circuit The Logic Circuit The Selector circuit

For:1. A bit-slice (one stage) circuit2. A 4-bits circuit

Page 25: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

G Select Provide the arithmetic operation A + B

???? (4bits)

G Select(4-bits)

Example:R1 R2 + R3

Therefore;S2 = 0 for Arithmetic operationS1 = 0S0 = 1Cin = 0

0010Answer : 0010

MSB

LSB

Page 26: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

The ShifterThe Shifter Shifts the value on

Bus B, placing the result on an input of MUX F

The Shifter can:o Shift Righto Shift Left

It is obvious that the shifter would be a bidirectional shift register with parallel load

Page 27: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

4 Bit Basic Shifter

S Operation

00 Parallel Load B (B to be passed thru the shifter unchanged)

01 Shift Right

10 Shift Left

Page 28: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Barrel Shifter

Sometimes the data need to be shifted ore rotated more than one bit position or in a single clock cycle

A Barrel Shifter can perform this by using MUX

2n input requires 2n MUX

Page 29: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

4-Bit Barrel Shifter

• A rotate is a shift in which the bits shifted out are inserted into the positions vacated• The circuit rotates its contents left from 0 to 3 positions depending on Selector S.

Note that a left rotation by three (3) position the same as a right rotation by one position in this 4 bit barrel shifter

Page 30: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Datapath Representation

SimplifiedBlock

Diagram

Register File

Function Unit

Page 31: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Datapath Representation

Notice that the G, H and MF Select are combined as FS

Boolean Equations: MF = F3.F2 Gi = Fi Hi = Fi

Page 32: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Control Word

The datapath has many control inputs The signals driving these inputs can be defined and

organized into a control word To execute a microinstruction, we apply control

word values for a clock cycle. For most microoperations, the positive edge of the clock cycle is needed to perform the register load

The datapath control word format and the field definitions are shown on the next slide

Page 33: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

The Control Word Fields

Fields : DA – D Address AA – A Address BA – B Address MB –Mux B FS – Function Select MD –Mux D RW – Register Write The connections to datapath are shown in the next slide

Control Word

(3-bit) (3-bit) (3-bit) (4-bit)

(1-bit)

Total : 16-bit

Page 34: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter
Page 35: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Control Word Encoding

Page 36: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Example 1

Field : DA AA BA MB FS MD RW Binary :Symbolic :

Given the 16-bit Control Word as 0010100110010101

001 010 011 0 0101 0 1R1 R2 R3 Reg F=A+B+1 Function Write

Answer : R1 R2 + R3 + 1Refer to Control Word Encoding Table

Page 37: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Example 2

Field : DA AA BA MB FS MD RW Binary :Symbolic :

Given the 16-bit Control Word as 1000101100111001

100 010 110 0 1110 0 1R4 R2 R6 Reg F=sl B Function Write

Answer : R4 sl R6Refer to Control Word Encoding Table

Page 38: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Example 3

Field : DA AA BA MB FS MD RW Binary :Symbolic :

Given the 16-bit Control Word as 0100000110011000

010 000 011 0 0110 0 0R2 R0 R3 Reg F = A-1 Data_In No_Write

Answer : Data Out R3Refer to Control Word Encoding Table

Address B is selected because MB = 0 (Refer to block Diagram on Slide 7)

Page 39: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Example 4

Field : DA AA BA MB FS MD RW Binary :Symbolic :

Given the 16-bit Control Word as 1000000110011011

100 000 011 0 0110 1 1R4 R0 R3 Reg F = A-1 Data_In Write

Answer : R4 Data InRefer to Control Word Encoding Table

Address D is selected because MD = 1 (Refer to block Diagram on Slide 7)

Page 40: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Example 5

Field : DA AA BA MB FS MD RW Binary :Symbolic :

Given the 16-bit Control Word as 1010000110001001

101 000 011 0 0010 0 1R5 R0 R3 Reg F = A+B Function Write

Answer : R5 R0 + R3Refer to Control Word Encoding Table

Page 41: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Example 5 continue……

Given the 16-bit Control Word as 1010000110001001

Answer : R5 R0 + R3

Assume : Registers are 8-bit and the value given are in hex, Find:

1. The new value of register content if R0 = 5 and R3 = 32. The new value of register content if R0 = 7 and R3 = 1C

Answers in 8-bit binary.

0000 0101+ 0000 0011 0000 1000

1. 0000 0111+ 0001 1100 0010 0011

2.

Page 42: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Other Examples of Control Word

Page 43: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

Assignment Folder Questions

10 – 3, 4, 5, 6, 7

Page 44: EKT 221 : Chapter 4 Computer Design Basics. Chapter Overview Part 1 – Datapaths  Introduction  Datapath Example  Arithmetic Logic Unit (ALU)  Shifter

THANK YOU