+ CS 325: CS Hardware and Software Organization and Architecture Exam 1: Study Guide
+ Computer Architecture and Organization Computer Architecture Attributes of the computer that are visible to the programmer. Instruction set Techniques for addressing memory Computer Organization Hardware details transparent to the programmer Control signals Bus interfaces Memory type
+ Basic Structure of Computers
+ CPU – controls the operation of the computer and performs its data processing functions Main Memory – stores data I/O – moves data between the computer and its external environment System Interconnection – some mechanism that provides for communication among CPU, main memory, and I/O There are four main structural components of the computer:
+ Number Systems Number Representation Decimal Binary Hexadecimal Decimal vs. Hexadecimal vs. Binary Number Conversions Dec Bin, Dec Hex Bin Dec, Bin Hex Hex Dec, Hex Bin
+ Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 4923 = (4x10 3 ) + (9x10 2 ) + (2x10 1 ) + (3x10 0 )
+ Binary Numbers: Base 2 Digits: 0, 1 Example: = (1x2 5 ) + (0x2 4 ) + (1x2 3 ) + (0x2 2 ) + (1x2 1 ) + (1x2 0 ) = What about a base that converts to binary easily?
+ Hexadecimal Numbers: Base 16 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Decimal digits + A – F Example: 12E = (1x16 2 ) + (2x16 1 ) + (Ex16 0 ) = ABCDEF
+ Decimal vs. Hexadecimal vs. Binary DECHEXBIN A B C D E F1111 DECHEXBIN A B C D E F
+ Number Conversion: Dec Bin Converting from base 10 to base 2: Continue dividing decimal number by 2 and keep the remainder Example: /2171LSB 17/281 8/240 4/220 2/210 1/201MSB
+ Number Conversion: Dec Hex Converting from base 10 to base 16: Example: /1623LSB 2/1602MSB
+ Number Conversion: Bin Dec Converting from base 2 to base 10: Example: (1x2 4 ) + (1x2 3 ) + (0x2 2 ) + (1x2 1 ) + (0x2 0 ) = MSBLSB
+ Number Conversion: Bin Hex Converting from base 2 to base 16: Example: Hex digit represents 16 Decimal values 4 Binary digits represent 16 Decimal values 1 Hex digit replaces 4 Binary digits D D6
+ Number Conversion: Hex Dec Converting from base 16 to base 10: Example: 8E3 16 (8x16 2 ) + (Ex16 1 ) + (3x16 0 ) =
+ Number Conversion: Hex Bin Converting from base 16 to base 2: Example: 9A2E MSB A E1110LSB
+ The Transistor A controlled switch. Collector – positive lead Emitter – negative lead Base – control lead A binary “1” represents an active transistor.
+ Representing Signed Numbers 3 ways for handling negative numbers Sign and Magnitude 1’s Complement 2’s Complement
+ Sign and Magnitude Easiest solution: Define leftmost bit to be the sign bit. 0 positive number, 1 negative number Other bits represent numerical value of number 32-bit example: -1 10
+ Convert Decimal to Sign and Magnitude: S&N requires two things: Sign: 0 positive, 1 negative Magnitude: value to be represented 16-bit Example: bit Example:
+ Convert Sign and Magnitude to Decimal: 8-bit Example: , Another Example: Produces: -0 and +0 problems with this?
+ 1’s Complement 4-bit Example: 1’s comp representation of a 4 bit number 2 n-1 -1 positive numbers 2 n-1 -1 negative numbers PosNeg
+ Converting Decimal to 1’s Comp Example 8-bit: First, convert to Binary 8-bits: Next, compliment the bits:
+ Converting 1’s Comp to Decimal Example 8-bit: MSB is 1 so compliment the bits: Next, convert to Base 10: Since the MSB is 1, the Base 10 value is negative:
+ 2’s Complement Number Line 2 N-1 -1 Pos Nums 2 N-1 Neg Nums 1 zero Must specify width 8-bits, 16-bits, 32-bits Overflow? More on this later
+ 2’s Complement 2 4 bits 2’s CompDecimal
+ Converting Decimal to 2’s Comp Example 8-bit: First, convert to Binary 8-bits: Next, 1s comp: Add 1 to 1s comp value:
+ Converting from 2s Comp to Decimal Algorithm for Converting 2s Comp to Decimal: If the MSB is 1, perform 1s comp and add 1. If the MSB is 0, go to next step. Convert the result to Base 10. This value should be positive. If the MSB was 1, add the negative sign to the Base 10 number.
+ Converting 2’s Comp to Decimal Example 8-bit: MSB is 1 so compliment the bits: And add 1: Since the MSB is 1, the Base 10 value is negative:
+ 2’s Comp Overflow Rules for detecting 2s Comp overflow: If the sum of two Pos numbers yields a Neg result, the sum has overflowed. If the sum of two Neg numbers yields a Pos result, the sum has overflowed. Otherwise, the sum has not overflowed.
+ 2’s Comp Overflow Examples = Carryout without overflow. Sum is correct
+ 2’s Complement Binary Subtraction Example: Subtract 7 from 2 (2 – 7): Convert to 4-bit 2s comp: 7 0010 Perform 2s comp on 7: 0111 1001 Now add: The value 1011 represented in 2’s comp converts to -5 10
+ Unsigned Binary Multiplication Quite Easy. Rules to remember: 0 * 1 = 0 1 * 1 = 1 Same as logical “and” operation Multiplying an m-bit number by and n-bit number results in an n+m-bit number. This n+m-bit width ensures overflow cannot occur. Simple Example: m = n = 2 2x3 = x 11 2 = Largest 2-bit value: 11 or x 11 2 = or 9 10
+ Unsigned Binary Multiplication Example: x ______
+ 2’s Complement Binary Multiplication Still Easy: Only difference between 2’s comp multiply and unsigned multiply: Sign extend both values to twice as many bits. Ex: x x The result will be stored in m+n least significant bits.
+ 2’s Complement Binary Multiplication – Booth’s Algorithm Multiplication by bit shifting and addition. Removes the need for multiply circuit Requires: A way to compute 2’s Complement Available as fast hardware instructions X86 assembly instruction: NEG A way to compare two values for equality How to do this quickly? Exclusive Not OR (NXOR) Gate Compare all sequential bits of bit string A and bit string B. Values are equal if the comparison process produces all 1s. A way to shift bit strings. Arithmetic bit shift, which preserves the sign bit when shifting to the right arithmetic shift right x86 assembly instruction: SAR ABA NXOR B
+ 2’s Complement Binary Multiplication – Booth’s Algorithm If the LSB of X is 1, and X-1 is 0, we subtract Y from U. If LSB of X is 0, and X-1 is 1, then we add Y to U. If both LSB of X and X-1 are equal, do nothing and skip to shifting stage.
+ 2’s Complement Binary Multiplication – Booth’s Algorithm UVXX-1 0: : : : : Result of 7 x -4: UV
+ Sign Extension Convert 2’s comp number using N bits to more than N bits (int to long int): Replicate the MSB (sign bit) of the smaller number to fill new bits. 2’s comp positive number has infinite 0s 2’s comp negative number has infinite 1s Ex: 16bit to 32-bit:
+ Combinational Logic Translates a set of N input variables(0 or 1) by a mapping function. Uses Boolean operations to produce a set of M output variables (0 or 1).
+ Boolean Functions
+ Boolean Function from Truth Table ABX
+
+ Digital Logic Sum of Products (SOP) Fan-in, Fan-out Cascading to Reduce Inputs Boolean Algebra Laws Gate Reduction using Boolean Algebra
+ Logic Gate Fan-n and Fan-out
+ Gate Cascading to Reduce Inputs Implementing 3-input AND and OR functions with 2-input gates ABC = (AB)C A+B+C = (A+B)+C Implementing a 3-input NAND function with 2-input gates. NO! Correct
+ Basic Laws of Boolean Algebra Boolean Algebra follows many algebra rules which can be used to make simpler circuits. Example: AB + ACThree gates = A(B + C), Distributive LawTwo gates NameAND FormOR Form Identity Law Null Law Idempotent Law Commutative Law Associative Law Distributive Law Absorption Law De Morgan’s Law
+ Gate Reduction AB + ACThree gates = A(B + C), Distributive LawTwo gates
+ Functionally Complete Sets of Gates Not all gate types are typically implemented in circuit design. Simpler if only 1 or 2 types of gates are used. A functionally complete set of gates means that any Boolean function can be implemented using only the gates in that set. Examples of functionally complete sets: AND, OR, NOT AND, NOT OR, NOT NAND NOR
+ Simplification
+ Checking Logic for Correctness
+ Another Example
+ Converting Boolean Functions to Standard SOP
+
+ Sum-of-Products ABC
+ Product-of-Sums ABC
+ Karnaugh Maps Special form of a given truth table. Useful for reducing logic functions into minimal Boolean expressions. B A ABX
+ Karnaugh Maps 4-Variables Convert the following 4-variable truth table to its Karnaugh map equivalent: CD AB ABCDX