
CS3350B Computer Organization Chapter 2: Synchronous Circuits Prelude Alex Brandt Department of Computer Science University of Western Ontario, Canada Thursday January 24, 2019 Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 1 / 12 Outline 1 Everything on a Computer is a Number Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 2 / 12 Radix Representations Radix is the base number in some numbering system. In a radix 푟 representation digits (푑푖) are from the set 0, 1, . , 푟 1 푛 1 푛 2 1 0 푥 푑푛 1 푟 푑푛 2 푟 푑1 푟 { 푑0 푟 − } − − = − × + − × + ⋅ ⋅ ⋅ + × + × 푟 10 decimal, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 푟 2 binary, 0, 1 = Ô⇒ { } 푟 8 octal, 0, 1, 2, 3, 4, 5, 6, 7 = Ô⇒ { } 푟 16 hexadecimal, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 푎, 푏, 푐, 푑, 푒, 푓 = Ô⇒ { } = Ô⇒ { } Refresh: Decimal to Binary 1 0 13 10 1 10 3 10 3 2 1 0 1101( ) 2 = (1 × 2 ) + 1( ×2 ) 0 2 1 2 8 4 0 1 13 10 Alex( Brandt) = ( × Chapter) + ( 2: Synchronous× ) + Circuits,( × Prelude) + ( × ) =Thursday+ January+ + 24, 2019= ( )3 / 12 Unsigned Binary Integers Unsigned Integers the normal representation An 푛-bit number: Ô⇒ 푛 1 푛 2 1 0 푥 푥푛 12 푥푛 22 푥12 푥02 − − = − + − + ⋯ + + Has a factor up to 2푛 1. Has a range: 0 to 2푛− 1 Example ( − ) 0000 0000 0000 0000 0000 0000 0000 10112 0 1 23 0 22 1 21 1 20 0 8 0 2 1 1110 = + ⋯ + × + × + × + × Using 32 bits:= 0+ to ⋯ +4,294,967,295 + + + + = Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 4 / 12 Signed Binary Integers (1/2) How to encode a negative sign? One’s Compliment: Invert unsigned representation to get negative. Get value by inverting all bits then multiply by 1. Leading bit decides if negative or not. − All positive numbers have the same representation as unsigned. In one’s compliment: 0101 2 = 0101 2 = 5 1101 2 = 1 0010 2 = 2 ( ) ( ) 0000 2 = 0000 2 = 0 ( ) − × ( ) − 1111 2 = 1 0000 2 = 0 ???? ( ) ( ) One’s( compliment) − is× rarely( ) used:− Signed zero. Weird borrowing required in arithmetic. Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 5 / 12 Signed Binary Integers (2/2) How to encode a negative sign? Two’s Compliment: Invert all the bits with respect to 2푛 Same as treating leading bit as negative in expansion. Leading bit decides if negative or not. All positive numbers have the same representation as unsigned. In two’s compliment: 0101 2 = 0101 2 = 5 1101 = 1 23 0101 = 8 5 = -3 ( )2 ( ) 2 0000 = 0000 = 0 ( )2 − × 2+ ( ) − + 1111 = 1 23 0111 = 1 ( )2 ( ) 2 ( ) − × + ( ) − Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 6 / 12 Two’s Compliment Advantages: Arithmetic is the same whether positive or negative: 0101 2 5 1101 3 ( )2 = 0010 2 (Throw away carry bit) + ( )2 = − ( ) = No signed 0. One extra value represented with same number of bits. For an 푛-bit number: Range of values is 2푛 1 to 2푛 1 1 − − − − Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 7 / 12 Same Bits Different Numbers It is important to realize that the same bit pattern can represent different numbers. 1001 1010 2 154 10 interpretted as unsigned 102 interpretted as two’s compliment ( ) Ô⇒ ( ) 10 Ô⇒ (− ) Can be disastrous in programming! unsigned int a = (1 << 31); // a = 2147483648 int b = a; // b = -2147483648 Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 8 / 12 Signed Negation In two’s compliment, bit-wise complement then add 1. 3 2 1 0 6 0110 2 0 2 1 2 1 2 0 2 = ( ) =compliment( × ) + ( × ) + ( × ) + ( × ) 1001 1 23 0 22 0 21 1 20 8 1 ⇓2 add one ( ) = (− × ) + ( × ) + ( × ) + ( × ) = − + 1001 0001 1010 8 0 4 0 6 2 ⇓2 2 ( ) + ( ) = ( ) = − + + + = − Also works in reverse! (from negative to positive) ë Still, compliment then add 1. ë 6 1010 2 0101 2 1 0110 2 6 − = ( ) ⇒ ( ) + ⇒ ( ) = Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 9 / 12 Signed Extension Signed Extension: Represent a number using more bits but keep numerical value. Very easy in two’s compliment! Copy the signed bit to the left until desired number of bits. Examples: 8-bit to 16-bit 2:0000 0010 0000 0000 0000 0010 -2:1111 1110 1111 1111 1111 1110 ⇒ -10:1111 0110 1111 1111 1111 0110 ⇒ Note: Truncation (representing⇒ a number using less bits) is tricky and you must know what you’re doing. Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 10 / 12 Logical Shift Logical Shift: Shift the bits left or right a specified number of times. Fills the vacancies with 0s on shift left and shift right. Throw away any bits that flow out. (shift left) and (shift right) in C (unsigned). Examples<< (in 8 bits): >> 2 3 = (0000 0010) 3 = (0001 0000) = 16. 8 2 = (0000 1000) 2 = (0000 0010) = 2. << << -4 1 = (1111 1100) 1 = (0111 1110) = 126. >> >> ë This last one is ambiguous if it is logical or arithmetic shift. In >>high-level programming>> languages the right shift operator is usually an arithmetic shift... Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 11 / 12 Arithmetic Shift Arithmetic Shift: Shift the bits left or right a specified number of times. Fills the vacancies with 0s on shift left. Fills the vacancies with 1s on shift right if number is negative. Fills the vacancies with 0s on shift right if number is positive. Throw away any bits that flow out. (shift left) and (shift right) in C (signed). Examples<< (in 8 bits): >> 2 3 = (0000 0010) 3 = (0001 0000) = 16. 8 2 = (0000 1000) 2 = (0000 0010) = 2. << << -4 1 = (1111 1100) 1 = (1111 1110) = -2. >> >> >> >> Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday January 24, 2019 12 / 12 CS3350B Computer Organization Chapter 2: Synchronous Circuits Part 1: Gates, Switches, and Boolean Algebra Alex Brandt Department of Computer Science University of Western Ontario, Canada Tuesday January 29, 2019 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 1 / 28 Outline 1 Introduction 2 Logic Gates 3 Boolean Algebra Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 2 / 28 Layers of Abstraction After looking at high-level CPU and Memory we will now go down to the lowest level (that we care about). Circuit Design vs Digital (Logic) Design ë Design of individual circuits vs Using circuits to implement some logic. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 3 / 28 Circuit Design Why do we care? Appreciate the limitations of hardware. Understand why some things are fast and some things are slow. Need circuit design to understand logic design. Need logic design to understand CPU Datapath. If you are ever working with: Assembly, ISAs, Embedded Systems and circuits, Specialized computer/logic systems, you will need circuit and logic design. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 4 / 28 Digital Circuits Everything is digital: represented by discrete, individual values. ë No gray areas or ambiguity. Must convert an analog – continuously variable – signal to digital. For us, the analog signal is electricity (voltage). ë “High” voltage 1 ë “Low” voltage 0 ⇒ ⇒ Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 5 / 28 Physicality of Circuits In the end, everything is a switch. “Input” A “Output” Z ⇒ ⇒ If A is 0/false then switch is open. If A is 1/true then switch is closed. This circuit implements: A Z ≡ Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 6 / 28 Transistors: Electrically Controlled Switches MOS-FET: Metal-Oxide-Semiconductor Field-Effect Transistor Has a source (S), a drain (D), and a gate (G). Applying voltage to G allows current to flow between S and D. In reality, transistors, logic gates, SRAM, use CMOS (Complimentary-MOS). But we don’t care about transistors really... Flipping a transistor is much faster than moving a physical switch. ë Speed of switching a transistor directly related to speed of a CPU Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 7 / 28 Outline 1 Introduction 2 Logic Gates 3 Boolean Algebra Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 8 / 28 Logic as Circuits Propositional Logic: A set of propositions (truth values) combined by some logical connectives. Truth values Binary digital signal Logical connectives Logic gates ≡ ≡ Logic Gate: A circuit implementing some logical expression/function. The basics: AND ( ), OR ( ), NOT ( ). ∧ ∨ ¬ Arity of a function/gate is the number of inputs. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 9 / 28 Gates as Switches Both A and B must be true/1 to get the circuit to complete. Either A or B can be true/1 to get the circuit to complete. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 10 / 28 Logic Gates In Detail: AND Truth Table for AND A C B A B A B C 0 0 0 0 1 ∧ 0 ≡ A B C 1 0 0 1 1 1 A ∧ B ≡ C ⋅ ≡ Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 11 / 28 Logic Gates In Detail: OR Truth Table for OR A C B A B A B C 0 0 0 0 1 ∨ 1 ≡ A B C 1 0 1 1 1 1 A ∨ B ≡ C + ≡ Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 12 / 28 Logic Gates In Detail: NOT Truth Table
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages105 Page
-
File Size-