1 Understand the examples again Overflow –When two positive numbers added together or a negative number subtracted from a positive number yields negative Underflow –When two negative numbers added together or a positive number subtracted from a negative number yields positive C/B A B Res CorrCorrOverUnderCorrCorrOverUnder ADD/SUB revisited
2 To change sign of a number In Sign and Magnitude –Just complement the sign 1’s Complement –Complement all bits 2’s Complement –Complement all bits and add 1 Adding 1 is expensive operation (Example: Add 1 to 0111) Alternate 2’s complement method –Scan the string from right –Retain all bits up to the first 1 –Then complement the remaining bits Negation
3 Positive numbers are well understood How to convert a negative decimal number to binary Method 1: –The magnitude of number must be less than 2 n-1 –Add -2 n-1 to the number –Convert the magnitude of this number as an n-bit string –Example -4 + (-8) = -12 (decimal) = 1100 (binary) Method 2 –Convert the magnitude to an n-bit string –Negate the number Converting negative number
4 So far we discussed arithmetic (yes, no multiply/divide) But what about a logic functions? A binary variable can be used to represent two logic value Answer to any question with two possible answers can be represented by a binary variable Examples: –Does the second section of 210 meet at 10AM? Answer represented by variable A, value A=1 (yes), value A=0 (no) –Is it worth attending class at that time? Answer represented by variable B, value B=1 (yes), value B=0 (no) So what about logic functions
5 We can combine variables to get more complex functions Functions of 1 variable XF1(X)F2(X)F3(X)F4(X) We have four possible operations upon 1 1-bit input value F1 is always 0, F2 is always 1, F3 is always X and F4 is always complement of X F4 is an important function and is called inversion It is also called NOT operation Inverse is denoted by X’ or X Functions of 1-bit variable
6 X YF0F1F2F3F4F5F6F X YF8F9F10F11F12F13F14F Functions of 2-bit variable
7 F1 is called a logical AND denoted by X.Y F6 is called an XORdenoted by X xor Y F7 is called OR denoted by X + Y F8 is NOR denoted by X + Y F14 is NAND denoted by X.Y Logic expressions allow us to implement function of binary inputs For each logic expression there is a logic gate See and practice logic circuit symbols for AND, OR, NAND, NOR, XOR, NOT… Interpretation of function
8 Basic logic circuits can be combined to get a bigger function Functions are written in truth table Each row in a truth table is one combination of logic variable Given the number of variables, n, we have 2 n different entries For example, for 1 variable there will 2 entries, for 4 variables there will be 16 entries, and so on Most circuits may have many more than 4 inputs However in class we will deal with only a few inputs For example a function of four variables could be –F = (A+B).(C+D) Combining logic circuits
9 An Example of Truth Table