Docsity

pMIPS ALU Laboratory Assignment: Understanding the 32-bit Arithmetic Logic Unit, Assignments of Microprocessors

Partial preview of the text

Download pMIPS ALU Laboratory Assignment: Understanding the 32-bit Arithmetic Logic Unit and more Assignments Microprocessors in PDF only on Docsity!

LABORATORY ASSIGNMENT # 4 pMIPS 32-bit Arithmetic Logic Unit (ALU)

SPRING 2009

ECE 371: Microprocessor Systems Department of Electrical and Computer EngineeringSchool of Engineering, Mathematics, and Science

Purdue University – Calumet

Arithmetic Logic Unit (ALU) • digital system that performs arithmetic, logical, and shiftoperations on two operands.• contains a set of control signals that choose whichoperation to perform• produces certain flag bits required by a microprocessor.^ – Zero (Z) flag^ •^

asserted when the result is zero

  • Carry (C) flag^ •^

asserted when arithmetic result produces a carry

  • Overflow (V) flag^ •^

asserted when the a signed arithmetic operation overflows

The pMIPS ALU Operation Codes OperationType

ALU Operation Code
Description

ALUOp[3]

ALUOp[2]

ALUOp[1]

ALUOp[0]

Logical
Bitwise Logical AND (
AND )
Bitwise Logical OR (
OR )
Bitwise Logical XOR (
XOR )
Bitwise Logical NOR (
NOR )
Unsigned Addition (
ADDU )
2 ’s^ Complement
Addition
( ADD )
Arithmetic
2 ’s^ Complement
Addition
( ADD )
Unsigned Subtraction (
SUBU )
2’s Complement Subtraction (
SUB )
Comparison
NOT USED
NOT USED
Unsigned Set On Less Than (
SLTU )
Signed Set on Less Than (
SLT )
Shift
Bitwise Shift Left Logical (
SLL )
NOT USED
Bitwise Shift Right Logical (
SRL )
Bitwise Shift Right Arithmetic (
SRA )

The pMIPS ALU Organization • Decomposed into four sub-components – Boolean Logic Unit (BLU)^ • Performs

AND ,^

OR ,^ XOR

,^ NOR

  • Logarithmic Shift Unit (LSU)^ •^

Performs

SLL ,^

SRL , and

SRA

-^ Performs

SLL ,^

SRL , and

SRA

  • Addition Subtraction Unit (ASU)^ • Performs

ADD ,^

ADDU ,

SUB ,^

SUBU

  • Comparison Logic Unit (CLU)^ • Performs

SLT ,^

SLTU

32-bit Boolean Logic Unit OperationType

ALU Operation Code

Description

ALUOp[3]

ALUOp[2]

ALUOp[1]

ALUOp[0]

Logical

Bitwise Logical AND (

AND )

Bitwise Logical OR (

OR )

Bitwise Logical XOR (

XOR )

Bitwise Logical NOR(

NOR )

The 32-bit pMIPS ALU^ The Addition Subtraction Unit (ASU)The Addition Subtraction Unit (ASU)

{ADD

,^ ADDU

,^ SUB

,^ SUBU

The Addition/Subtraction Unit MIPS Specific Carry-Out and Overflow Logic

-^ MIPS indicates that signed overflow is never reported (de-asserted)unless performing signed arithmetic.•^ MIPS indicates that carry-out is never reported (de-asserted) unlessperforming any arithmetic operation.•^ New logic for overflow and carry-out:

Overflow Carry Unit (OCU)

OperationType

ALU Operation Code

ModifiedOverflow

ModifiedCarry-Out

ALUOp[3]

ALUOp[2]

ALUOp[1]

ALUOp[0]

Overflow

Cout

Logical^

X^
X^

Comparison

X^
X^

Shift^

X^
X^

Arithmetic

CLACout

ODUOutput

CLACout

CLACout

ODUOutput

CLACout

The Addition/Subtraction Unit

OperationType

ALU Operation Code

Description

ALUOp[3]

ALUOp[2]

ALUOp[1]

ALUOp[0]

Arithmetic

Unsigned Addition (

ADDU )

2’s Complement Addition (

ADD )

Unsigned Subtraction (

SUBU )

2’s Complement Subtraction (

SUB )

Note : The

modified

Overflow Carry Unit (OCU) will be integrated into the top

level 32-bit pMIPS ALU implementation

The Logarithmic Shift Unit (LSU)

Left Shift Logical (LSL) Circuit

The Logarithmic Shift Unit (LSU)

Right Shift Logical (RSL) Circuit

The Logarithmic Shift Unit (LSU) OperationType

ALU Operation Code

Description

ALUOp[3]

ALUOp[2]

ALUOp[1]

ALUOp[0]

Shift

Shift Left Logical (

SLL )
NOT USED

Shift Right Logical (

SRL )

Shift Right Arithmetic (

SRA )

The 32-bit pMIPS ALU^ The Comparison Logical Unit (CLU)The Comparison Logical Unit (CLU)

{SLT

,^ SLTU

The Comparison Logic Unit (CLU)

Formulating the Design Specifications

-^ After the ASU subtracts, the additional logic requires these signals:•^

Cout:

carry-out from the 32-bit ASU,

-^ SumSign:

sign bit from the 32-bit ASU result

-^ ASign

&^ Bsign

: sign-bits from two input operands

-^ ALUOp[1:0]

: the lower two-bits from the ALU operation code.

-^ When the

ALUOp[1:0] = 00

or^ ALUOp[1:0] = 01

, the ASU is

performing addition, so the output of the CLU should be FALSE. ComparisonType

ALUOp[1:0]

ASign

BSign

SumSign

Cout^

CompareOut[31:0]

NOT USED

x^

x^

x^

x^ 0x

NOT USED

x^

x^

x^

x^ 0x

The Comparison Logic Unit (CLU)

Formulating the Design Specifications

-^ Focus on Set-On-Less Than (SLT)•^

Must perform signed subtraction (

ALUOp[1:0] = 11

)

-^ Four combinations of operands:^ •^

A <0,^ B

>0: A^ must be less than

B, so output is TRUE

-^ A >0,

B <0: B

must be less than

A, so output is FALSE

-^ A >0,

B >0: Can’t overflow since we are performing subtraction

-^ A >0,

B >0: Can’t overflow since we are performing subtraction • If^ SumSIgn

is 1, A - B < 0; output TRUE

,^ else output FALSE

-^ A <0,

B <0: Can’t overflow since we are performing subtraction • If^ SumSign

is 1, A - B < 0; output TRUE

,^ else output FALSE

ComparisonType^

ALUOp[1:0]

ASign

BSign

SumSign

Cout

CompareOut[31:0]

Set OnLess Than( SLT )

x^

0x

x^

0x

x^

0x

x^

0x

x^

x^

0x

x^

x^

0x