Concepts of Engineering and Technology Copyright © Texas Education Agency, 2012. All rights reserved. Basic Electricity and Electronics Module Three Microprocessor Basics Copyright © Texas Education Agency, 2012. All rights reserved. An Inverter Lets go back to our first transistor circuit: VCC RC VI VO VI = 0, the transistor is off, VO = VCC (+ 5 V) VI = 1, the transistor is on, VO = 0 (ground) ground Copyright © Texas Education Agency, 2012. All rights reserved. Copyright © Texas Education Agency, 2012. All rights reserved. An Inverter VCC Don’t like the inverter? Here is a circuit that does not invert VI Copyright © Texas Education Agency, 2012. All rights reserved. RE We have established the concept that voltage turns on or off transistors We use transistors to make the circuits that do what we need What circuit do we need to make a binary adder? First, let’s look at what the adder circuit has to do: Copyright © Texas Education Agency, 2012. All rights reserved. The OR gate When ANY input is high, the output goes high Does not perfectly match what we need, but gives us a starting point A B If EITHER input goes high, the transistor turns on This is called an OR gate Copyright © Texas Education Agency, 2012. All rights reserved. This circuit works better A B The diodes protect one input from the other The resistor limits current Copyright © Texas Education Agency, 2012. All rights reserved. Truth Table The truth table for the OR gate: A B Q A B Q 0 0 1 1 0 1 0 1 (Or X) 0 1 1 1 Schematic symbol When ANY input is high, the output is high Copyright © Texas Education Agency, 2012. All rights reserved. The AND Gate When BOTH inputs are high, we produce a carry We need a circuit that will turn on only when both inputs are on VCC A 0 0 1 1 B 0 1 0 1 Q 0 0 0 1 A B Q RE Copyright © Texas Education Agency, 2012. All rights reserved. Schematic symbol Schematic Symbols We have seen the schematic symbols for 2 gates: AND OR Here is the schematic symbol for the inverter: NOT With these three gates, you can make any logic circuit Copyright © Texas Education Agency, 2012. All rights reserved. Back to the Adder Here is how we make a binary adder: A B A B Σ (sum) 0 0 CO (carry) 1 1 0 1 0 1 All circuits are made physically with transistors, but represented by symbols Copyright © Texas Education Agency, 2012. All rights reserved. Σ Co 0 1 1 0 0 0 0 1 Digital Logic Digital logic is used for circuit design Also used for mathematical operations The English language use of the terms “and,” “or,” “not” do not always have the same meaning as the logical terms There are 7 total logic gates Called “Boolean Algebra” AND, OR, NOT, NAND, NOR, Exclusive-OR, Exclusive-NOR These gates are the building blocks for computers Copyright © Texas Education Agency, 2012. All rights reserved. Logic Circuit Applications A memory decoder A memory address is a unique number A 2-bit code unlocks one of 4 memory locations when D goes high A 4-bit code would unlock one of 16 memory locations when D goes high Most logic circuits are simple, as this example shows Copyright © Texas Education Agency, 2012. All rights reserved. 3 Bit Decoder Any 3 bit binary number enables one AND gate A0 A1 A2 D0 = 0 0 0 D1 = 0 0 1 D2 = 0 1 0 D3 = 0 1 1 D4 = 1 0 0 D5 = 1 0 1 D6 = 1 1 0 D7 = 1 1 1 Copyright © Texas Education Agency, 2012. All rights reserved. A3 A4 A5 A0 A1 A2 7 6 5 4 3 2 1 0 F E D C B A 9 8 1 7 1 F 2 7 2 F 1 6 1 E 2 6 2 E 1 5 1 D 2 5 2 D 1 4 1 C 1 3 1 B 2 4 2 C 2 3 2 B 1 2 1 A 2 2 2 A 1 1 1 9 2 1 2 9 3 7 3 F 3 6 3 E 3 5 3 D 3 4 3 C 3 3 3 B 3 2 3 A 3 1 3 9 1 0 1 8 2 0 2 8 3 0 3 8 6 address lines, 16 AND gates and 6 inverters enable 64 memory locations Copyright © Texas Education Agency, 2012. All rights reserved. Computer Basics A computer uses voltage on wires to communicate Communication involves data, addresses, and instructions Each of these are represented by binary numbers in a code A logic circuit similar to what we have just seen is used to decode each of these Copyright © Texas Education Agency, 2012. All rights reserved. A computer has several basic parts The input unit The output unit Monitor, printer, modem Memory Keyboard, mouse, modem, transducer RAM, hard drive, CD-ROM CPU Central processing unit Also called a microprocessor Copyright © Texas Education Agency, 2012. All rights reserved. The CPU The CPU is also called the microprocessor The brains of the computer Performs arithmetic and logic Has an internal ALU Works based on an internal program called microcode The primary job of a CPU is to execute instructions Copyright © Texas Education Agency, 2012. All rights reserved. Instructions Where do instructions come from? Humans write programs A program is made by a series of instructions Instructions are processed sequentially Program instructions get decoded An instruction set is used for a family of microprocessors Copyright © Texas Education Agency, 2012. All rights reserved. Most program instructions are simple: load, store, move, add The type of program a CPU understands is called machine code A higher level language like C or Java is compiled or interpreted into machine language Each instruction the computer understands is represented by a binary number Copyright © Texas Education Agency, 2012. All rights reserved. A logic circuit similar to what we have seen decodes the instruction into a particular sequence of internal operations To decode CD audio, a program runs in the computer The program describes how to read the data from the CD and what to do with the data when it is read The CD audio data is also a series of numbers Voltage on wires is used to represent the numbers (data, instructions, and addresses) Copyright © Texas Education Agency, 2012. All rights reserved. If you look at a motherboard, you can see all the wires that are used to communicate Wires are grouped and separated by function A group of wires is called a BUS For example, a 32 bit address bus is a group of 32 wires that connects chips CPU to RAM CPU to devices/expansion slots Copyright © Texas Education Agency, 2012. All rights reserved. Addresses go on an address bus Data goes on a data bus On a motherboard, the two are separate physically Other buses are: the control bus and the power bus Program instructions are a form of data Data and program instructions are sent at different times on the same wires Copyright © Texas Education Agency, 2012. All rights reserved. Examples of control signals Clock and timing signals Memory read or write Memory vs. other input/output types RAM vs keyboard/mouse Ready to send/clear to send/interrupt Enable/disable These are all on/off, controlled by voltage on a wire Copyright © Texas Education Agency, 2012. All rights reserved. The Clock The clock does two basic things: Tells when to start Like a starters pistol Starts on an edge of the clock signal Tells how long an operation lasts The duration A half hour show vs. a one hour show How long things take can determine clock rates Copyright © Texas Education Agency, 2012. All rights reserved. The Clock The clock signal is used to synchronize all microprocessor operations Start of next cycle or process Duration Start (One Clock Cycle) Time Elapses (Like ticks of a clock) Copyright © Texas Education Agency, 2012. All rights reserved. CPU Block Diagram Instruction Register Instruction Decoder Program Counter Input/ Output Data Bus Data Register 1001011101 10010111 Address Bus ALU 1001011101 Clock Stack Bus Controller Copyright © Texas Education Agency, 2012. All rights reserved. Memory Key Facts The data bus is bi-directional The address bus is uni-directional The program counter holds the address of the next memory location to be used The next address is the last address + 1 The stack holds the addresses of programs and data the CPU is not currently using Internal registers form a queue of program instructions and data Copyright © Texas Education Agency, 2012. All rights reserved. A Program Example Lets go through an example of the steps a CPU goes through to read CD data A program is a series of instructions A program loops over and over again What is the program doing while it loops? Waiting for user input Generating routine output Handshaking with devices Video output Copyright © Texas Education Agency, 2012. All rights reserved. Step One The address in the program counter gets put on the address bus This address is for a program instruction in RAM A read control signal is placed on the control bus The program instruction code from memory is placed on the data bus The program counter adds one to the old address The CPU reads the instruction and executes whatever is necessary to perform the instruction Copyright © Texas Education Agency, 2012. All rights reserved. Step 2 The next address (which is the old address plus 1) gets placed on the address bus A read control signal is placed on the control bus The program instruction at that address is placed on the data bus The program counter adds one to the old address The CPU reads the instruction, decodes it, and executes it This instruction tells the CPU to read data from the CD Copyright © Texas Education Agency, 2012. All rights reserved. Step 3 The address in the program counter is placed on the stack The CPU determines the next available free memory location, and places that address in the program counter This address is placed on the address bus A write control signal is placed on the control bus The CD drive reads data off the CD disk and loads the data into memory at the location in the PC A one (1) is added to the address in the program counter The next piece of data is loaded into the next memory location, etc. Copyright © Texas Education Agency, 2012. All rights reserved. Next Steps When the CPU wants to go back to running the program, the current data location is taken from the program counter and placed on the stack, the next program instruction is taken off the stack and loaded back into the program counter Data and program instruction memory locations are stored on the stack Only current program addresses (or data locations) are in the program counter Copyright © Texas Education Agency, 2012. All rights reserved. CD Data to Audio A CD that can read data at 52X can read data off the disk at 7.8 million bytes/sec CD audio data is recorded and reproduced at exactly 176,400 bytes/sec 1X is 150 KB/sec 44,100 samples/sec X 2 bytes/samples X 2 channels Excess data is buffered in memory Binary data is processed by converting each 16 bit number to a voltage with a signal amplitude given by the data numerical value The voltage is sent to the speaker, which produces sound Copyright © Texas Education Agency, 2012. All rights reserved.