ecen 248 lab 4: multiplexer based arithmetic logic unit dept. of electrical and computer engineering

10
ECEN 248 ECEN 248 Lab 4: Multiplexer Based Lab 4: Multiplexer Based Arithmetic Logic Unit Arithmetic Logic Unit Dept. of Electrical and Dept. of Electrical and Computer Engineering Computer Engineering

Upload: valentine-copeland

Post on 02-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

ECEN 248ECEN 248

Lab 4: Multiplexer Based Lab 4: Multiplexer Based Arithmetic Logic UnitArithmetic Logic Unit

Dept. of Electrical and Dept. of Electrical and Computer EngineeringComputer Engineering

Page 2: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Lab 4 in BriefLab 4 in Brief

Design a 4-bit arithmetic logic unit which Design a 4-bit arithmetic logic unit which does elementary computation like:does elementary computation like: AdditionAddition SubtractionSubtraction Bit-wise ANDBit-wise AND

Use a multiplexer based control to choose Use a multiplexer based control to choose between the operationsbetween the operations

Page 3: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

This is used for unsigned numbers (i.e., This is used for unsigned numbers (i.e., positive and negative are not defined)positive and negative are not defined)

Unsigned Number Unsigned Number RepresentationRepresentation

Page 4: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Used to represent both Used to represent both positive and negative (signed) positive and negative (signed) integersintegers

Positive numbers are Positive numbers are represented by their ordinary represented by their ordinary binary representationbinary representation

Negative numbers are Negative numbers are represented by the two’s represented by the two’s complementcomplement

TwoTwo’’s Complements Complement

Page 5: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Converting to TwoConverting to Two’’s s ComplementComplement

Step 1: Start with the ordinary binary representation of the numberStep 1: Start with the ordinary binary representation of the number Ex: If we want to convert -3 to Two’s Complement, we start with Ex: If we want to convert -3 to Two’s Complement, we start with

representing 3 as 011representing 3 as 011

Step 2: Invert all the bits of the numberStep 2: Invert all the bits of the number Ex: Inverting all the bits of 011 results in 100Ex: Inverting all the bits of 011 results in 100

Step 3: Add 1 to the resulting valueStep 3: Add 1 to the resulting value Ex: 100 + 1 = 101Ex: 100 + 1 = 101 If the addition results in an overflow, ignore it.If the addition results in an overflow, ignore it.

Taking the Two’s Complement of the result will give you the positive Taking the Two’s Complement of the result will give you the positive number back!number back!

Page 6: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Multiplexers (Mux)Multiplexers (Mux)

A device which selects a single input from a series of A device which selects a single input from a series of inputs and passes its value to the outputinputs and passes its value to the output

The selection is done based on data fed to the control The selection is done based on data fed to the control lines (S) of the muxlines (S) of the mux

2:1 Multiplexer 4:1 Multiplexer

Page 7: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)

Performs arithmetic and logic operationsPerforms arithmetic and logic operations Fundamental building block of a CPUFundamental building block of a CPU Inputs to the ALU:Inputs to the ALU:

Two numbers (operands)Two numbers (operands) Control bits to control what operation the ALU is Control bits to control what operation the ALU is

performingperforming Outputs of the ALU:Outputs of the ALU:

The computed resultThe computed result An indication if the operation has resulted in an An indication if the operation has resulted in an

overflowoverflow

Page 8: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)

Page 9: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

Specifics and Design HintsSpecifics and Design Hints Components to design the ALU:Components to design the ALU:

One 2:1 Multiplexer block (Four 2:1 Multiplexers with One 2:1 Multiplexer block (Four 2:1 Multiplexers with same select line (C0))same select line (C0))

One XOR Chip (Four XOR Gates)One XOR Chip (Four XOR Gates) One 4-Bit Adder BlockOne 4-Bit Adder Block 5 LEDs to show Outputs5 LEDs to show Outputs

Hints for the design of the ALU:Hints for the design of the ALU: Multiplexer Select Line Input is C0Multiplexer Select Line Input is C0 C1 decides whether addition or SubtractionC1 decides whether addition or Subtraction For subtraction when C1=1, use XOR gates to invert For subtraction when C1=1, use XOR gates to invert

the inputs and Cin of the full adder to add ‘1’(i.e. C0) the inputs and Cin of the full adder to add ‘1’(i.e. C0) for the 2’s complement of the 2for the 2’s complement of the 2ndnd operand. operand.

Four bit adder block does addition and subtraction.Four bit adder block does addition and subtraction.

Page 10: ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit Dept. of Electrical and Computer Engineering

TodayToday Work on Lab 4Work on Lab 4

Next WeekNext Week Lab 4 Post-Lab dueLab 4 Post-Lab due Lab 5 Pre-Lab: no deliverablesLab 5 Pre-Lab: no deliverables

DeadlinesDeadlines