Arithmetic Logic Unit


Instructions:

Follow this LINK. In the new browser window, select EDIT | SELECT ALL from the menu. Then select EDIT | COPY. Now open up Microsoft Word and paste the document into the word document so you can save and edit the assignment. You can close the 2nd window of browser once the sheet has been placed in WORD.

The Simulations below are created using SimCirJS.


Purpose:

To become familiar with the operation of the Arithmetic Logic Unit inside the CPU by setting up and executing a number of mathematical and logical operations.


Background (from http://en.wikipedia.org/wiki/ALU):

The arithmetic logic unit (ALU) of a computer's CPU is a part of the execution unit, a core component of all CPUs. ALUs are capable of calculating the results of a wide variety of basic arithmetical computations.

Virtually all modern computer ALUs use the two's complement binary number representation (whereas some early computers used either one's complement or sign-magnitude format).

ALU operations

Most ALUs will perform the following operations:

  • integer arithmetic operations (addition, subtraction, multiplication)
  • bitwise logic operations (and, not, or, xor)
  • bit-shifting operations (shifting or rotating a word by a specified number of bits to the left or right, with or without sign extension)

    A standard ALU typically does not handle integer division or any floating point operations. Optional methods for these types of calculations include:
  • software emulation, commonly implemented in hand-written assembly code and placed in a library for use by other programs (slowest)
  • microcode programs using the ALU to emulate the missing operations ("medium speed")
  • Separate hardware components, such as dividers and floating point units (FPUs), sometimes in the form of arithmetic coprocessors (fastest)

    Inputs and outputs
    The ALU takes as input the data to be operated on (called operands) and a code from the control unit indicating which operation to perform. The output is the result of the computation.

    In many designs the ALU also takes/generates as inputs/outputs a set of condition codes from/to a status register; typically these codes are used to indicate cases such as carry-in or carry-out, overflow, divide-by-zero, etc.




    Truth Table

    Click on image to enlarge / print

    Note: Since this is a TRUTH TABLE, all symbols are BOOLEAN Operators, Arithmetic operators are spelled out (e.g. PLUS is addition, + is OR)





    { "width":1400, "height":800, "showToolbox":false, "toolbox":[ {"type":"In"}, {"type":"Out"}, {"type":"Joint"}, {"type":"DC"}, {"type":"LED"}, {"type":"PushOff"}, {"type":"PushOn"}, {"type":"Toggle"}, {"type":"BUF"}, {"type":"NOT"}, {"type":"AND"}, {"type":"AND","numInputs":3}, {"type":"AND","numInputs":4}, {"type":"NAND"}, {"type":"OR"}, {"type":"OR","numInputs":3}, {"type":"OR","numInputs":4}, {"type":"OR","numInputs":8}, {"type":"NOR"}, {"type":"EOR"}, {"type":"ENOR"}, {"type":"OSC"}, {"type":"7seg"}, {"type":"16seg"}, {"type":"4bit7seg"}, {"type":"RotaryEncoder"}, {"type":"BusIn"}, {"type":"BusOut"}, {"type":"RS-FF"}, {"type":"JK-FF"}, {"type":"T-FF"}, {"type":"D-FF"}, {"type":"8bitCounter"}, {"type":"HalfAdder"}, {"type":"FullAdder"}, {"type":"4bitAdder"}, {"type":"2to4BinaryDecoder"}, {"type":"3to8BinaryDecoder"}, {"type":"4to16BinaryDecoder"}, {"type":"DSO"}, {"type":"Delay"}, {"type":"Transmitter"}, {"type":"74181"}, {"type":"8_input_OR"} ], "devices":[ {"type":"74181","id":"dev0","x":888,"y":104,"label":"74181"}, {"type":"DC","id":"dev1","x":168,"y":8,"label":"DC"}, {"type":"Joint","id":"dev2","x":232,"y":16,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev3","x":424,"y":16,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev4","x":360,"y":16,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev5","x":296,"y":16,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev6","x":280,"y":104,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev7","x":344,"y":120,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev8","x":408,"y":136,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev9","x":472,"y":152,"label":"Joint","state":{"direction":0}}, {"type":"Toggle","id":"dev10","x":248,"y":48,"label":"S3","state":{"on":false}}, {"type":"Toggle","id":"dev11","x":312,"y":48,"label":"S2","state":{"on":false}}, {"type":"Toggle","id":"dev12","x":376,"y":48,"label":"S1","state":{"on":false}}, {"type":"Toggle","id":"dev13","x":440,"y":48,"label":"S0","state":{"on":false}}, {"type":"DC","id":"dev14","x":160,"y":232,"label":"DC"}, {"type":"Joint","id":"dev15","x":232,"y":240,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev16","x":296,"y":240,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev17","x":360,"y":240,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev18","x":424,"y":240,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev19","x":280,"y":168,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev20","x":344,"y":184,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev21","x":408,"y":200,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev22","x":472,"y":216,"label":"Joint","state":{"direction":0}}, {"type":"Toggle","id":"dev23","x":248,"y":272,"label":"B3","state":{"on":false}}, {"type":"Toggle","id":"dev24","x":312,"y":272,"label":"B2","state":{"on":false}}, {"type":"Toggle","id":"dev25","x":376,"y":272,"label":"B1","state":{"on":false}}, {"type":"Toggle","id":"dev26","x":440,"y":272,"label":"B0","state":{"on":false}}, {"type":"Joint","id":"dev27","x":680,"y":232,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev28","x":696,"y":248,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev29","x":720,"y":264,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev30","x":744,"y":280,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev31","x":728,"y":408,"label":"Joint","state":{"direction":0}}, {"type":"DC","id":"dev32","x":160,"y":464,"label":"DC"}, {"type":"Toggle","id":"dev33","x":440,"y":504,"label":"A0","state":{"on":false}}, {"type":"Toggle","id":"dev34","x":376,"y":504,"label":"A1","state":{"on":false}}, {"type":"Toggle","id":"dev35","x":312,"y":504,"label":"A2","state":{"on":false}}, {"type":"Toggle","id":"dev36","x":248,"y":504,"label":"A3","state":{"on":false}}, {"type":"Joint","id":"dev37","x":472,"y":408,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev38","x":704,"y":392,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev39","x":408,"y":392,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev40","x":680,"y":376,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev41","x":344,"y":376,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev42","x":664,"y":360,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev43","x":280,"y":360,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev44","x":296,"y":472,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev45","x":232,"y":472,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev46","x":360,"y":472,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev47","x":424,"y":472,"label":"Joint","state":{"direction":0}}, {"type":"DC","id":"dev48","x":160,"y":616,"label":"DC"}, {"type":"DC","id":"dev49","x":160,"y":696,"label":"DC"}, {"type":"Toggle","id":"dev50","x":248,"y":616,"label":"M","state":{"on":false}}, {"type":"Toggle","id":"dev51","x":248,"y":696,"label":"Cn","state":{"on":false}}, {"type":"NOT","id":"dev52","x":344,"y":696,"label":"NOT"}, {"type":"Joint","id":"dev53","x":856,"y":312,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev54","x":824,"y":296,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev55","x":840,"y":704,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev56","x":808,"y":624,"label":"Joint","state":{"direction":0}}, {"type":"LED","id":"dev57","x":1152,"y":408,"label":"A=B"}, {"type":"Joint","id":"dev58","x":976,"y":152,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev59","x":992,"y":80,"label":"Joint","state":{"direction":0}}, {"type":"LED","id":"dev60","x":1144,"y":72,"label":"X"}, {"type":"LED","id":"dev61","x":1144,"y":120,"label":"Y"}, {"type":"Joint","id":"dev62","x":1016,"y":128,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev63","x":1000,"y":168,"label":"Joint","state":{"direction":0}}, {"type":"LED","id":"dev64","x":1144,"y":176,"label":"Cn+4"}, {"type":"4bit7seg","id":"dev65","x":1144,"y":232,"label":"F"}, {"type":"Joint","id":"dev66","x":1040,"y":232,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev67","x":1024,"y":248,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev68","x":984,"y":232,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev69","x":1000,"y":264,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev70","x":1048,"y":264,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev71","x":1064,"y":248,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev72","x":1096,"y":264,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev73","x":1080,"y":216,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev74","x":1112,"y":280,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev75","x":1096,"y":200,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev76","x":968,"y":264,"label":"Joint","state":{"direction":0}}, {"type":"Joint","id":"dev77","x":984,"y":416,"label":"Joint","state":{"direction":0}}, {"type":"NOT","id":"dev78","x":1040,"y":176,"label":"NOT"} ], "connectors":[ {"from":"dev0.in0","to":"dev6.out0"}, {"from":"dev0.in1","to":"dev7.out0"}, {"from":"dev0.in2","to":"dev8.out0"}, {"from":"dev0.in3","to":"dev9.out0"}, {"from":"dev0.in4","to":"dev19.out0"}, {"from":"dev0.in5","to":"dev20.out0"}, {"from":"dev0.in6","to":"dev21.out0"}, {"from":"dev0.in7","to":"dev22.out0"}, {"from":"dev0.in8","to":"dev27.out0"}, {"from":"dev0.in9","to":"dev28.out0"}, {"from":"dev0.in10","to":"dev29.out0"}, {"from":"dev0.in11","to":"dev30.out0"}, {"from":"dev0.in12","to":"dev54.out0"}, {"from":"dev0.in13","to":"dev53.out0"}, {"from":"dev2.in0","to":"dev1.out0"}, {"from":"dev3.in0","to":"dev4.out0"}, {"from":"dev4.in0","to":"dev5.out0"}, {"from":"dev5.in0","to":"dev2.out0"}, {"from":"dev6.in0","to":"dev10.out0"}, {"from":"dev7.in0","to":"dev11.out0"}, {"from":"dev8.in0","to":"dev12.out0"}, {"from":"dev9.in0","to":"dev13.out0"}, {"from":"dev10.in0","to":"dev2.out0"}, {"from":"dev11.in0","to":"dev5.out0"}, {"from":"dev12.in0","to":"dev4.out0"}, {"from":"dev13.in0","to":"dev3.out0"}, {"from":"dev15.in0","to":"dev14.out0"}, {"from":"dev16.in0","to":"dev15.out0"}, {"from":"dev17.in0","to":"dev16.out0"}, {"from":"dev18.in0","to":"dev17.out0"}, {"from":"dev19.in0","to":"dev23.out0"}, {"from":"dev20.in0","to":"dev24.out0"}, {"from":"dev21.in0","to":"dev25.out0"}, {"from":"dev22.in0","to":"dev26.out0"}, {"from":"dev23.in0","to":"dev15.out0"}, {"from":"dev24.in0","to":"dev16.out0"}, {"from":"dev25.in0","to":"dev17.out0"}, {"from":"dev26.in0","to":"dev18.out0"}, {"from":"dev27.in0","to":"dev42.out0"}, {"from":"dev28.in0","to":"dev40.out0"}, {"from":"dev29.in0","to":"dev38.out0"}, {"from":"dev30.in0","to":"dev31.out0"}, {"from":"dev31.in0","to":"dev37.out0"}, {"from":"dev33.in0","to":"dev47.out0"}, {"from":"dev34.in0","to":"dev46.out0"}, {"from":"dev35.in0","to":"dev44.out0"}, {"from":"dev36.in0","to":"dev45.out0"}, {"from":"dev37.in0","to":"dev33.out0"}, {"from":"dev38.in0","to":"dev39.out0"}, {"from":"dev39.in0","to":"dev34.out0"}, {"from":"dev40.in0","to":"dev41.out0"}, {"from":"dev41.in0","to":"dev35.out0"}, {"from":"dev42.in0","to":"dev43.out0"}, {"from":"dev43.in0","to":"dev36.out0"}, {"from":"dev44.in0","to":"dev45.out0"}, {"from":"dev45.in0","to":"dev32.out0"}, {"from":"dev46.in0","to":"dev44.out0"}, {"from":"dev47.in0","to":"dev46.out0"}, {"from":"dev50.in0","to":"dev48.out0"}, {"from":"dev51.in0","to":"dev49.out0"}, {"from":"dev52.in0","to":"dev51.out0"}, {"from":"dev53.in0","to":"dev55.out0"}, {"from":"dev54.in0","to":"dev56.out0"}, {"from":"dev55.in0","to":"dev52.out0"}, {"from":"dev56.in0","to":"dev50.out0"}, {"from":"dev57.in0","to":"dev77.out0"}, {"from":"dev58.in0","to":"dev0.out0"}, {"from":"dev59.in0","to":"dev58.out0"}, {"from":"dev60.in0","to":"dev59.out0"}, {"from":"dev61.in0","to":"dev62.out0"}, {"from":"dev62.in0","to":"dev63.out0"}, {"from":"dev63.in0","to":"dev0.out1"}, {"from":"dev64.in0","to":"dev78.out0"}, {"from":"dev65.in0","to":"dev66.out0"}, {"from":"dev65.in1","to":"dev71.out0"}, {"from":"dev65.in2","to":"dev72.out0"}, {"from":"dev65.in3","to":"dev74.out0"}, {"from":"dev66.in0","to":"dev67.out0"}, {"from":"dev67.in0","to":"dev0.out6"}, {"from":"dev68.in0","to":"dev0.out5"}, {"from":"dev69.in0","to":"dev68.out0"}, {"from":"dev70.in0","to":"dev69.out0"}, {"from":"dev71.in0","to":"dev70.out0"}, {"from":"dev72.in0","to":"dev73.out0"}, {"from":"dev73.in0","to":"dev0.out4"}, {"from":"dev74.in0","to":"dev75.out0"}, {"from":"dev75.in0","to":"dev0.out3"}, {"from":"dev76.in0","to":"dev0.out7"}, {"from":"dev77.in0","to":"dev76.out0"}, {"from":"dev78.in0","to":"dev0.out2"} ] }