mahdi nazmbojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · multibit alu ¨1-bit alus are...

16
ARITHMETIC AND LOGIC UNIT CS/ECE 3810: Computer Organization Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah

Upload: others

Post on 29-Apr-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

ARITHMETIC AND LOGIC UNIT

CS/ECE 3810: Computer Organization

Mahdi Nazm Bojnordi

Assistant Professor

School of Computing

University of Utah

Page 2: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Overview

¨ This lecture¤ How to design ALU

n Design rulesn Common logic blocksn Designing multi-function blocks

Page 3: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Design Rules

¨ Any Boolean function can be represented by a truth table and sum of products (two gate levels)

A B C E

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 1

1 1 1 0

E = (A.B.C) + (A.B.C) + (A.B.C)

Sum of Products

Page 4: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Common Logic Blocks

¨ An n-input decoder takes n inputs, based on which only one out of 2n outputs is activated

3-to-8Decoder

2-to-4

2-to-4Decoder

3-to-8 (using two 1-to-4 units)

Page 5: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Common Logic Blocks

¨ An n-input decoder takes n inputs, based on which only one out of 2n outputs is activated

2-to-4 3-to-8 (using two 1-to-4 units)

2-to-4Decoder

2-to-4Decoder

2-to-4Decoder

Page 6: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Common Logic Blocks

¨ A multiplexer (or selector) reflects one of n inputs on the output depending on the value of the select bits

2-to-1 4-to-1 (using there 2-to-1 units)

Page 7: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Common Logic Blocks

¨ A full adder generates the sum (S) and carry (Cout) for inputs A, B, and Cin.

Example Ckt 1: Example Ckt 2:

AB

CinS

Cout

AB

Cin

Cout

S

+

Page 8: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Multi-Function Blocks

¨ A 1-bit ALU with ADD, OR, and AND operations¤ A multiplexer selects between the operations

Page 9: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Multibit ALU

¨ 1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the next box

Page 10: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Incorporating Subtraction

¨ Must invert bits of B and add a 1¤ Include an inverter CarryIn for the first bit is 1

¨ The CarryIn signal (for the first bit) can be the same as the Binvertsignal

Page 11: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Incorporating NAND and NOR

¨ Must invert bits of A and B to realize NAND and NOR¤ Recall DeMorgan’s Laws

Page 12: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Incorporating Comparison

¨ For example: the slt instruction

¤ Perform a – b and check the sign

¤ New signal (Less) that is zero for ALU boxes 1-31

¤ The 31st box has a unit to detect overflow and sign – the sign bit serves as the Less signal for the 0th box

Page 13: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Incorporating Comparison

¨ For example: the beq instruction

¤ Perform a – b and confirm that the result is all zero’s

¤ What about bne?

¤ Control lines determine what operations to be done.

Page 14: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Incorporating Comparison

¨ For example: the beq instruction

¤ Perform a – b and confirm that the result is all zero’s

¤ What about bne?

¤ Control lines determine what operations to be done.

Ai Bn OpAND 0 0 00OR 0 0 01Add 0 0 10Sub 0 1 10SLT 0 1 11NOR 1 1 00

Page 15: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Carry Ripple Adder

¨ Simplest design by cascading 1-bit boxes¤ Each 1-bit box sequentially implements AND and OR¤ Critical path: the total delay is the time to go through

64 gates

¨ How to make a 32-bit addition faster?

… CinCout

S0S1S2S3S4S31

A0 B0A1 B1A2 B2A3 B3A4 B4A31 B31

Page 16: Mahdi NazmBojnordibojnordi/classes/3810/f20/slides/15-alu.pdf · Multibit ALU ¨1-bit ALUs are connected “in series” with the carry-out of 1 box going into the carry-in of the

Carry Ripple Adder

¨ Simplest design by cascading 1-bit boxes¤ Each 1-bit box sequentially implements AND and OR¤ Critical path: the total delay is the time to go through

64 gates

¨ How to make a 32-bit addition faster?¨ Recall: any logic equation can be expressed as the

sum of products (only 2 gate levels!)¤ Challenges: many parallel gates with very large inputs¤ Solution: we’ll find a compromise