12_logic0

12_logic0 - Logic Manipulation Transistors Digital Logic...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Logic Manipulation Transistors Digital Logic Computers UCSD: Physics 8; 2007 What does a computer do? Computers store and process information Information is represented digitally, as voltages Digital format avoids ambiguity below 1.5 V interpreted as 0 (5V CMOS logic) above 3.5 V interpreted as 1 (5V CMOS logic) Information can be manipulated in many ways: can be compared to other information mathematical operations define state of devices (display, speakers, motors, etc.) 2 UCSD: Physics 8; 2007 Transistors: The Main Building Block Transistors, as applied to logic designs, act as voltagecontrolled switches n-channel MOSFET is closed when positive voltage (+5 V) is applied, open when zero voltage p-channel MOSFET is open when positive voltage (+5 V) is applied, closed when zero voltage (MOSFET = metal-oxide semiconductor field effect transistor) drain gate source n-channel MOSFET gate p-channel MOSFET source + voltage 5V + voltage drain 5V 0V 5V 5V 0V Question.. 0V 0V <5V < 5 V3 Logic Gates All data manipulation is based on logic Logic follows strict rules UCSD: Physics 8; 2007 The output can always be exactly predicted from the input N = not + normal = opposite of the normal NAND = AND followed by NOT Show SimCir Java software simulator from http://www.d-project.com/simcir/ with these wired (c1NotAndNand.cml) NOT A C 0 1 1 0 AND AB 0 0 0 1 1 0 1 1 C 0 0 0 1 NAND AB 0 0 0 1 1 0 1 1 C 1 1 1 0 Logical Operation Truth table Symbol A A B C A B 4 3 Questions.. bubbles mean inverted (e.g., NOT AND NAND) OR Logic Gates OR AB 0 0 0 1 1 0 1 1 C 0 1 1 1 UCSD: Physics 8; 2007 NOR AB 0 0 0 1 1 0 1 1 C 1 0 0 0 A B A B E or X = exclusive = only one, not both (exclusive disjunction) Show SimCir Simulator with these wired up in java (c2Or.cml) XOR or EOR AB 0 0 0 1 1 0 1 1 C 0 1 1 0 XNOR or ENOR AB 0 0 0 1 1 0 1 1 C 1 0 0 1 A B A B 5 UCSD: Physics 8; 2007 Logic Gates The logic operations are carried out electronically by gates, represented by the symbols just introduced Gates are constructed out of transistors, typically 46 per gate Transistors simply act like switches, controlling data flow Gate response is typically ~1 nanosecond (1 billionth sec.) Can theoretically build an entire computer using only NAND (or NOR) gates... 6 UCSD: Physics 8; 2007 A NOT gate (inverter) from MOSFETS 5V 5V A NOT 5V A C 0 1 1 0 0V input output 0V 5V 5V 0V 0V 0V 0 V input turns OFF lower (n-channel) FET, turns ON upper (p-channel), so output is connected to +5 V 5 V input turns ON lower (n-channel) FET, turns OFF upper (p-channel), so output is connected to 0 V Net effect is logic inversion: 0 5; 5 0 Complementary MOSFET pairs = CMOS 7 UCSD: Physics 8; 2007 A NAND gate from scratch: 5V Both inputs at zero: lower two FETs OFF, upper two ON result is output HI IN A OUT C Both inputs at 5 V: lower two FETs ON, upper two OFF result is output LOW IN A at 5V, IN B at 0 V: upper left OFF, lowest ON upper right ON, middle OFF result is output HI IN B IN A at 0 V, IN B at 5 V: opposite of previous entry result is output HI NAND AB 0 0 0 1 1 0 1 1 8 0V A B C 1 1 1 0 UCSD: Physics 8; 2007 NAND-based gate construction NAND AB 0 0 0 1 1 0 1 1 C 1 1 1 0 NOT A C 0 1 1 0 AND AB 0 0 0 1 1 0 1 1 C 0 0 0 1 invert output (invert NAND) A B NOR OR AB 0 0 0 1 1 0 1 1 C 0 1 1 1 AB 0 0 0 1 1 0 1 1 C 1 0 0 0 invert both inputs Question...We just saw we.. invert inputs and output (invert OR) 9 UCSD: Physics 8; 2007 Arithmetic Example Let's add two binary numbers: 00101110 = 46 + 01001101 = 77 01111011 = 123 How did we do this? We have rules: 0 + 0 = 0; 0 + 1 = 1 + 0 = 1; 1 + 1 = 10 (2): (0, carry 1); 1 + 1 + (carried 1) = 11 (3): (1, carry 1) Rules can be represented by gates If two input digits are A & B, output digit looks like XOR operation... in next slide we deal with the carry operation XOR or EOR A B AB 0 0 0 1 1 0 1 1 C 0 1 1 0 10 UCSD: Physics 8; 2007 Truth table for Addition Cin 0 0 0 0 1 1 1 1 A 0 0 1 1 0 0 1 1 B 0 1 0 1 0 1 0 1 D Cout 0 0 1 0 1 0 0 1 1 0 0 1 0 1 1 1 XOR or EOR XNOR or ENOR AB 0 0 0 1 1 0 1 1 C 0 1 1 0 AB 0 0 0 1 1 0 1 1 C 1 0 0 1 A B A B Digits A & B are added, possibly accompanied by carry instruction from previous stage Output is new digit, D, along with carry value when Cin is 0, D looks like XOR (previous slide) of A & B when Cin is 1, D looks like XNOR of A & B Cout is 1 (new carry) if two or more of A, B, Cin are 1 11 UCSD: Physics 8; 2007 Binary Arithmetic in Gates A B Cin E D H A B Cin F G Cout + Cout D "Integrated" Chip Input Intermediate Output A B Cin E F H G D Cout 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 Each digit requires 5 gates (6 used here) Each gate has ~6 transistors ~36 transistors per digit Software: SimCir Simulator C3binaryadder.cml 12 UCSD: Physics 8; 2007 Binary 2 Bit Adder SimCir c4binary2digitadder shows this 2 bit adder: can add up to 3+3+(1 carry) = 7 Inputs are the upper 2 Toggle switched on the 2 stages: A and B Left most are 1s. Can have either one or both on Can have either one or both on Right block (near center) are the 2s Carry goes along the bottom, exiting in the OR gates One at end of the first stage is the 1s One on the right is the 2s Outputs are the EOR gates 01 +01 =10 10 +11 =101 1st bit (upper left) both A & B on, but no carry input (lower left Cin) get a 1 in the 2s, upper left EOR 1st bit (right most column here, left most in simulation), one toggle on 2nd bit (left here, and right in simulation) both toggles on get a 1 in the 1s and a carry from the 2s SimCir files c5, c6 have made the bit order in simulation same as written here. SimCir c7-10 show adders with more bits. The bottom row is the answer to the sum of the 2 rows above. The 16-bit adder adds up to: 65,535 + 65,535 Silicon wires can not cross in too many layers 4 layers common now hard to get rid of the heat coming from the wires. Heat is a major factor in CPU design 13 UCSD: Physics 8; 2007 8-bit binary arithmetic (cascaded) 0 0 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 + + + + + + + + 0 0 0 1 1 0 0 0 1 1 1 1 0 1 1 MSB 00101110 = 46 + 01001101 = 77 01111011 = 123 11 Carry-out tied to carry-in of next digit. adds two binary numbers Up to ~300 transistors for this basic function. Also need , , /, & lots more. LSB = Least Significant Bit 14 Integrated one-digit binary arithmetic unit (prev. slide) UCSD: Physics 8; 2007 Computer technology built up from pieces The foregoing example illustrates the way in which computer technology is built start with little pieces (transistors acting as switches) combine pieces into functional blocks (gates) combine these blocks into higher-level function (e.g., addition) combine these new blocks into cascade (e.g., 8-bit addition) blocks get increasingly complex, more capable Nobody understands Pentium chip inside-out Grab previously developed working blocks and re-use them Use computers to design the gate arrangements 15 UCSD: Physics 8; 2007 Data Storage Within the computer, data is stored in volatile memory (RAM) essentially charge held on a capacitor also possible to rig two NAND gates to hold one bit called a flip-flop volatile because it goes away when turned off Also store data permanently, usually on magnetic media (floppies, hard drives, tapes) or on optical discs (CD-ROMs, DVDs) information encoded as polarization of magnetic domains older technology used wire coils around ferrite cores (like transformer) to detect/generate magnetic fields What is ... 16 UCSD: Physics 8; 2007 Example: Flip-Flop Memory Input A: C Outputs NAND AB 0 0 0 1 1 0 1 1 C 1 1 1 0 flip-flop AB 0 0 0 1 1 0 1 1 CD 1 1 1 0 0 1 ? ? Input B: D This simple arrangement of two NAND gates retains a memory: Imagine A and B are in the high state (both 1) 2 choices: C = 0, D = 1 or C = 1, D = 0 can set the state by dropping A or B low momentarily to 0 when A and B are restored to high, the previous state is "remembered": e.g., B went low D sticks on 1 SimCir file c11FlipFlop.cml 17 Digital Data Everywhere Remote Controls Computer Communications UCSD: Physics 8; 2007 Most of today's information is digital Most of today's information is digital Computer communications Cell phone signals TV is moving this way TV remote controls Even our in-class infrared transmitters Today, we'll look at a number examples start with H-ITT transmitter also check out TV remote (actually for stereo) look at serial data communication 19 UCSD: Physics 8; 2007 The H-ITT Transmitter Signal When you click your transmitter button: AE: LED indicator comes on, and at same time, TWO bursts of infrared light come out: LED stays on even after transmission stops, until button is released * button: on release of button, LED flashes and two infrared bursts are sent 1st data packet 2nd data packet bursts last 53 milliseconds, are 9 ms apart, and have a bitperiod of about 0.5 ms (about 2000 bits per second) Let's look at it on scope... 20 UCSD: Physics 8; 2007 H-ITT Transmitter Protocol Transmitter 55573 sends an "A" first packet second packet Transmitter 55573 sends a "B" first packet second packet 21 UCSD: Physics 8; 2007 Comparison of A & B first packets Differences are minor, showing up only near beginning & end We will represent "high" states (light on) as 1's, and lows (off) as 0's Notice standard widths: choices are single- or double-width (both for the zeros and the ones) 22 UCSD: Physics 8; 2007 Decoding the A signal Sequence starts out: 01101001001101001001001001... Notice the 01 delimiters: 01101001001101001001001001... This gives the signal its choppy appearance (never see 3 1's or 0's in a row) Actual data appears between delimiters: 1's look fat, 0's look skinny 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 1 23 UCSD: Physics 8; 2007 Decoding the A signal Resulting bit-sequence for A signal (both packets) is: end delimiter 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 1 0 0 0 button code transmitter ID (normal and inverted) checksum 24 UCSD: Physics 8; 2007 The different buttons: first four bits A B C D E << 1001 001 1 first bit always 1 1010 010 2 1011 011 3 1100 100 4 1101 101 5 1110 110 6 25 UCSD: Physics 8; 2007 The Transmitter ID bytes Transmitter number is binary-coded in the usual sense: 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 0 0 0 0 0 0 0 01 1 0 1 1 0 0 1 0 0 0 1 0 1 0 1 Sum is: 32768 + 16384 + 4096 + 2048 + 256 + 16 + 4 + 1 = 55573 this exactly the number pasted behind the battery Second packet inverts all the bits to ensure data integrity 26 UCSD: Physics 8; 2007 What's with the Checksum? 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 1 button code transmitter ID (normal first-packet version) checksum Break data into chunks of 8 bits (1 = byte) segments, and add up: 1001 00000000 11011001 00010101 11110111 Checksums provide a "sanity check" on the data integrity 27 UCSD: Physics 8; 2007 Another example using newer remote 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 0 0 1 0 0 button code transmitter ID (normal first-packet version) checksum You can use this (first, non-inverted burst) data to verify your understanding Don't look at the answers if you want to challenge yourself first answers on last slide are: button code, transmitter ID, inverted packet contents also check that checksum adds up properly (ignore final "carry" digit) 28 UCSD: Physics 8; 2007 Stereo Remote Control Similar to H-ITT transmitters in principle: bursts of infrared light carrying digital information punctuated by delimiters so no long sequences of 1's or 0's Key differences: signal initiated by a WAKE UP! constant-on burst pattern that follows is repeated indefinitely until button is released I can never get fewer than three packets... packet is variable in length depending on button data packet data packet data packet 29 UCSD: Physics 8; 2007 Sample patterns for data packet POWER VOL + VOL - 1 2 3 4 5 6 7 remote ID? data 000000000 100000000 010000000 100000 010000 110001000 001001000 101001000 011001000 111001000 30 UCSD: Physics 8; 2007 A Different Code... The radio remote uses a different scheme: does not use the 01 delimiters like H-ITT did instead, uses 10 to represent zero, and 1000 to represent 1 sequence for the 5 button is: 100010001000100010001010100010001010001010... ID part 1 1 1 1 1 00 1 1 0 1 00 1 000 data part in data part, least significant bit (LSB) is first so the number part of "5" is 101001000 1010 least significant digit is first, so reverse order for more familiar form: 0101 = 5 31 UCSD: Physics 8; 2007 Serial Communication: Getting the Data Once the H-ITT receiver gets your IR signal, it must communicate this to the computer It does this through the serial port serial refers to the fact that data bits arrive in series (one at a time) alternative is parallel (one wire for each bit), where typically 8 bits (a byte) arrive simultaneously Most digital communications are of serial type IR transmitters! (only one "channel" for light) USB, Firewire ethernet, modems cell phones Parallel sometimes used for printers, but most notably on computer motherboards now 32-bit wide communications is the standard parallel is faster, but more complicated to pull off: lots of wires Many servers use 64 bits, good for large data bases 32 UCSD: Physics 8; 2007 A look at the H-ITT Serial Datastream E-button on H-ITT (first of two packets): 10101000011000000000101001101110101010001011110110 Serial datastream looks a lot different this one allows many zeros or ones in a row delimiters (called start bit and stop bit) bracket 8-bit data (1 byte) in this case, 0's are positive voltage, 1's are negative (backwards!) happens much faster than IR: in this case 19,200 bits/sec (baud) Packet breakdown: first packet: button number (5 E), with LSB first: 101000 next three packets are ID, also LSB first within each last packet is checksum type of verification H-ITT bursts 1st data packet serial bursts 2nd data packet 33 UCSD: Physics 8; 2007 Review Our world now runs on information and most of this is broken down to binary bit codes for transmission, manipulation, storage Digital advantages noise immunity very easy to tell a 1 from a 0, even in the presence of environmental noise Easily processed Easily stored B; 249035; 1010.11111100.00110011.00110100.01101101 34 ...
View Full Document

This note was uploaded on 04/10/2008 for the course PHYS 8 taught by Professor Tytler during the Spring '08 term at UCSD.

Ask a homework question - tutors are online