Computing via Look-up Tables: Combinational Logic Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup To COMPUTE, what does it mean? • Computing = Processing Information • A computing system transforms information presented on its inputs to a result, which it generates on its outputs fåéìíë Comp 101 - Spring 2008 ô Computational System or Block 1/21/08 õ lìíéìíë L04 - Computing via Table Lookup What is Digital? • Computing systems can be either “discrete” or “continuous” • Inputs and outputs of a continuous system can take be any of an infinite number of values {ex. a + b = c} a b + c • “Discrete” implies that all inputs and outputs can take on one value of a finite number of values (ex. digits of a decimal number can take on one of 10 discrete values {0,1,2,3,4,5,6,7,8,9}) • “Digital” implies a that inputs and outputs can take on one of two possible binary values 0 or 1. Comp 101 - Spring 2008 1/21/08 Why Digital? L04 - Computing via Table Lookup Representing Continuous Information Let’s use old fashion B&W “Analog” Television as an example. Each picture is transmitted as a series of left-to-right scan lines where each point (x, y) is represented as a voltage between 0 and 1 volts: 0 volts: 1 volt: 0.37 volts: etc. BLACK WHITE 37% Gray Frames are transmitted at a rate of 30 frames per second, and each is divided into 525 scanlines, where roughly 480 are visible. The details are slightly more complicated. Comp 101 - Spring 2008 1/21/08 How much information at each point? L04 - Computing via Table Lookup Information Processing = Computation First, let’s introduce some processing blocks: Comp 101 - Spring 2008 v Copy v v INV 1-v 1/21/08 L04 - Computing via Table Lookup Let’s build a system! input Copy INV Copy INV Copy INV Copy INV (In(Reality) Theory) ? output Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Why Did Our System Fail? Why doesn’t reality match theory? 1. COPY Operator doesn’t work right 2. INVERSION Operator doesn’t work right 3. Theory is imperfect 4. Reality is imperfect 5. Our system architecture stinks ANSWER: all of the above! Noise and inaccuracy are inevitable; we can’t reliably reproduce infinite information-- we must design our system to tolerate some amount of error if it is to process information reliablyK Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup The Key to System Design A SYSTEM is a structure that is guaranteed to exhibit a specified behavior, assuming all of its components obey their specified behaviors. How is this achieved? Contracts Every system component will have clear obligations and responsibilities. If these are maintained we have every right to expect the system to behave as planned. If contracts are violated all bets are off. Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup The Digital Panacea ... Why DIGITAL? … because it keeps the contracts SIMPLE! What is the price we pay for this robustness? 0 or 1 All the information that we transfer between components is only 1 crummy bit! But, in exchange, we get a guarantee of a reliable system. Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup The Digital Abstraction “Ideal” Digital World Real World 0/1 Manufacturing Variations Bits Noise Volts or Electrons or Ergs or Gallons Remember, the world is not digital, we engineer it to behave that way. We use real physical phenomena to implement digital designs! Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Computing Discretely • How does our decision to compute using a discrete, digital, information representation impact what we can compute? • Do *you* have any previous experience computing in a discrete world? Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Grade School Arithmetic • Despite the fact that you know how to perform arithmetic on any number, you *learned* to perform arithmetic using discrete tricks. • In fact, most of what you know about math originated from memorizing a few tables, which, even today, form the basis for your ability to do arithmetic • Computers use tables too. Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup 1st Grade Review • The first table that you learned was a table for adding any digit to any other digit • This table can be represented as a computational system digitA digitB Comp 101 - Spring 2008 + carry digitC 1/21/08 + 0 1 2 3 4 5 6 7 8 9 0 0 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 10 2 2 3 4 5 6 7 8 9 10 11 3 3 4 5 6 7 8 9 10 11 12 4 4 5 6 7 8 9 10 11 12 13 5 5 6 7 8 9 10 11 12 13 14 6 6 7 8 9 10 11 12 13 14 15 7 7 8 9 10 11 12 13 14 15 16 8 8 9 10 11 12 13 14 15 16 17 9 9 10 11 12 13 14 15 16 17 18 L04 - Computing via Table Lookup Composing Tables • You learned add larger numbers, with more digits by reapplying the table that you had committed to memory digitA10 digitB10 digitA1 digitB1 Comp 101 - Spring 2008 + + digitC100 + digitC10 54 +78 12 12 132 digitC1 1/21/08 L04 - Computing via Table Lookup Multiplication • Another table, another box... digitA digitB x B C A X D X X + + + digitC10 digitC1 + + B X AB X CD DB DA CB CA PPPP x 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 1 0 1 2 3 4 5 6 7 8 9 2 0 2 4 6 8 10 12 14 16 18 3 0 3 6 9 12 15 18 21 24 27 4 0 4 8 12 16 20 24 28 32 36 5 0 5 10 15 20 25 30 35 40 45 6 0 6 12 18 24 30 36 42 48 54 7 0 7 14 21 28 35 42 49 56 63 8 0 8 16 24 32 40 48 56 64 72 9 0 9 18 27 36 45 54 63 72 81 Product bits Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup A Digital Processing Element • A combinational device is a circuit element that has Ó one or more digital inputs Ó one or more digital outputs A B C Y Ó a functional specification that details the value of each output for every possible combination of valid input values (A lookup table) 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 input A input B input C Comp 101 - Spring 2008 Output a “1” if at least 2 out of 3 of my inputs are a “1”. Otherwise, output “0”. output Y 1/21/08 L04 - Computing via Table Lookup Digital Processing Elements Some digital processing elements occur so frequently that we give them special names and symbols A A B I will copy and restore my input buffer to my output I will only output a ‘1’AND if all my inputs are ‘1’ A B Comp 101 - Spring 2008 Y A A Y B I will only output a ‘1’ if an XOR odd number of my inputs are ‘1’ 1/21/08 I will output the complement of my input inverter I will output a ‘1’ if any OR of my inputs are ‘1’ Y Y Y L04 - Computing via Table Lookup Digital Processing Elements Some digital processing elements occur so frequently that we give them special names and symbols A Y buffer A B AND B inverter A B Y A Comp 101 - Spring 2008 A XOR 1/21/08 OR Y Y Y In honor of the richest man in the world we will henceforth refer to digital processing elements as “GATES” L04 - Computing via Table Lookup A Slight Diversion Are we sure we have all the gates we need? How many two-input gates are there? OR NAND NOR SURGE AND Hum… all of these have 2-inputs (no surprise) … 2 inputs have 4 permutations, giving 22 output cases 24 How many permutations of 4 outputs are there? ___ 2N Generalizing, there are 2 , N-input gates! Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup There Are Only So Many Digital Gates There are only 16 possible 2-input gates … some we know already, others are just silly What are the most common gates, used by computers? The answer might surprise you. Nope. After all, we describe them all using AND, OR, and NOT. Do we need all of these gates? Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup A Binary Adder Binary addition used by computers is similar to the the addition you learned in grade school, except the tables are simpler. 1 1 0 1 Adding two N-bit numbers produces an (N+1)-bit result A: 1101 B:+ 0101 10010 Carries from previous column A CO B FA CI S Let’s start by building a block that adds one column: Then we can cascade them to add two numbers of any size… A3 B3 A2 B2 A1 B1 A0 B0 A CO A CO A CO A CO B FA CI S S4 S3 Comp 101 - Spring 2008 B FA CI S S0 B FA CI S S1 B FA CI S S0 1/21/08 L04 - Computing via Table Lookup A Binary Adder Implementation A binary adder’s function, as given by its truth table, can be implemented “Carry” using the simpler Logic functions, AND, OR, and XOR. CO A CO AB CI S B FA CI “Sum” Logic S Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Binary Multiplication The multiplication table for binary is much simpler, than the decimal one. A multiplier for one bit can be implemented with a single gate. “Binary” Multiplication Table X 0 1 0 0 0 1 0 1 A B Y AND Moreover, every result generates only one output bit (digit). Recall that multiplying two decimal digits might result in a two digit result. For example, 6 x 7 = 42. Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Adding Up Product Terms In binary multiplication, multiplying the bits is the easy part. The more difficult part Binary multiplication is implemented using the same basic is adding up all of the longhand algorithm that you learned in grade school. terms resulting from A A A A B B B x B the digit-by-digit A B A B AB A B A B is a “partial product” multiplications. A B A B AB A B 3 2 1 0 3 2 1 0 2 0 1 0 0 0 2 1 1 1 0 1 A3B2 A2B2 A1B2 A2B3 A1B3 A0B3 A0B2 3 0 j i 3 1 + A 3B 3 Multiplying N-digit number by M-digit number gives (N+M)-digit result Easy part: forming partial products (just an AND gate since BI is either 0 or 1) Hard part: adding M, N-bit partial products Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Implementing Tables The BIG lesson: A large fraction of “computation”, in both humans and computers, is carried out using tables. How are tables implemented? Gates Memory In fact, there is a very general purpose gate, called a memory. Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup A General Purpose Gate Every possible 2-input gate can be implemented using the following logic. All that one needs to do is to set the appropriate memory value, {M00, M01, M10, M11} to the desired output. This design is not necessarily efficient, but it will perform any 2-input function. Decoder M Selector A Moreover, it is 0 B M easy to generalize A 1 Y this design to any B M A number of inputs. 2 00 A decoder generates all possible product terms for a set of inputs Such, reconfigurable gates are called memories. 01 10 B A B M11 3 RAMs and ROMs are two types. Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup Summary 1. Computer’s process information that takes on discrete values - If the number of discrete values is limited to 2, the system is called “digital” or “binary” - Limiting computation to discrete values makes the system more robust and reliable - Fewer discrete values that we have to discriminate between, leads to the simplest and most reliable systems 2. A large fraction of computation is done using simple table look up - Humans also learned to compute using tables that we memorized in childhood - Because data is represented as discrete values, we are able to enumerate every possible input, and store every possible output in a look-up table - Much of the logic in a computer is merely implementing look-up tables Comp 101 - Spring 2008 1/21/08 L04 - Computing via Table Lookup
© Copyright 2025 Paperzz