ARCHITECTURE HARDWARE This course aims to give you an understanding of the operation of modern computers at the lowest level. It is intended to give you enough awareness of computer hardware to underpin your studies at higher levels; it is not intended to turn you into hardware experts. The course is “bottom-up”. It starts by reviewing the nature of electricity in order to introduce the movement of electrons in materials: the basic operation that drives electronic circuits. The operation of the basic digital circuits is then covered in terms of flow of electrons, after which transistors are introduced and their operation as simple electronic switches in digital circuits explained. The central part of the course covers 1-bit storage elements, their structure, operation and usage. The development of registers and memory devices from these is presented along with the role of busses in moving data between storage and processing elements. A key component in a central processing unit (CPU) is the logic that controls the sequencing of its operations, so the design and operation of these control circuits are presented; one method of implementing them is demonstrated. At this point all the components have been introduced that are necessary to explain the operation of a microprocessor: a simple one is covered in some. To complete the course, there is a brief coverage of input and output operations. Basic Electricity To understand the operation of digital electronic circuits, it is necessary to understand the flow of electrons in materials. Thus, we shall review electricity starting from the atom and its components. An atom consists of a central nucleus surrounded by electrons. The nucleus is a very small, compact collection of protons and neutrons: the hydrogen atom is the exception with just one proton in its nucleus. Electrons, as far anyone knows, are fundamental particles of nature, while protons and neutrons, which were once thought of as fundamental particles, are now considered to be made up of different kinds of quark. Not much is known about quarks, since they have never been observed. Both electrons and protons have a property called electrical charge, which is a fundamental property of nature. Electrical charge is observable by the force that it exerts on other bodies possessing an electrical charge. This force can be attractive or repulsive (unlike the force of gravity which has only ever been observed to be attractive). Between charged particles of the same type the electrical force is repulsive, thus electrons repulse other electrons, and protons repulse other protons. The force between an electron and a proton is attractive. The observation of these attractive and repulsive forces showed that there must be two forms of charge, which have been labelled positive and negative: electrons being labelled as having negative charge and protons as having positive charge. The magnitude of the two forms of charge are equal so that the charge of one electron can be exactly balanced by the charge of one proton. Neutrons are unaffected by the electric force and have no net charge. The number of protons in the nucleus of an atom defines its type, i.e. what element it is. The nucleus can be thought of as a bulging, pulsating sack of protons and neutrons held together by the Strong Nuclear force. The latter is a very strong, but short distance, attractive force between the protons and neutrons. It holds the nucleus together and overwhelms the repulsive electrical force between the protons. The protons give the nucleus an electric charge. This charge produces what is called an electric field, which extends outside the nucleus, and which exerts a force on any charged particle that enters the field. It is this force that pulls and holds electrons round the nucleus to form the atom. These electrons do not coalesce with the protons but can be thought of as orbiting the nucleus. Only a restricted number of orbits are allowed to electrons with a maximum of 2 electrons per orbit. Orbits have an associated energy: the energy required to remove an electron from the orbit and set it free from the atom. Different orbits have different energies. Orbits with a low energy are called outer orbits. It is easier for an electron to escape from an outer orbit than from the higher energy inner orbits. The nucleus is very small compared to region of the atom occupied by its electrons. No one knows ‘why’ the electrons don’t coalesce with the nucleus, although we have an ‘explanation’. 1 An atom with the same number of electrons as protons (a neutral atom) has no net electrical charge and it has no electrical effect on things a long way away. However, because the charges in a neutral atom are distributed and vary as the electrons move around the nucleus, a neutral atom exerts electrical forces in its near vicinity. These forces cause reactions between atoms so that the atoms of most elements prefer to join up with other atoms in a range of different structures. Thus, two oxygen atoms prefer to come together as a molecule, and huge numbers of mainly carbon, oxygen, hydrogen and nitrogen atoms can be formed into large molecules, such as proteins and DNA. It is the electrical force between atoms that holds solid materials together as in crystals and metals. From this behaviour comes the whole of chemistry, electricity and electronics. Our first interest is metals. Metals In a solid, the atoms are fixed in position by the electric forces exerted by surrounding atoms: they vibrate about this fixed position with a magnitude dependent on the temperature. In solid metals, the interactions between the atoms modify the energies of their outer electron orbits, so that effectively one electron from the outer orbit of each atom is set In quantum mechanical terms, the outer orbit of free to move around inside the material. This leaves each atom is de-localised and extends throughout each atom with a net positive charge. The electrons the material. Quantum mechanics is a do not escape from the material, but they are free to mathematical theory that has been demonstrated move around inside it, although the effect of forces to model very accurately the structure of atoms and materials among other things. It is however is such that they are generally evenly distributed. not an intuitively easy model to understand. Thus, within any piece of metal there is a swirling cloud, or sea, of electrons. It is possible to add or remove some electrons, giving the metal a net negative or positive charge. It is also possible to add electrons at one place and remove them at another place to get a flow of electrons through the metal: an electric current. Power supplies, such as chemical batteries found in torches or cars, or mechanical dynamos as found on bicycles and in power stations, provide the means to move electrons. In solid materials, it is always the electrons that move: the atoms remain fixed. Transient and Continuous Electric Currents Let us consider a battery. A battery will always have a positive terminal and a negative terminal. The negative terminal is a source of electrons, and there is associated with it an electrical force trying to push out electrons. The positive terminal is a sink of electrons, and there is associated with it an electrical force trying to trying to pull in electrons. It is usual to talk about an electric (force) field being produced by each terminal. This electric field permeates space around the terminal, and any electrical charge within the field will feel a force which varies with its position in the field. The fields of the terminals blend together. A positive charge in this field is pulled towards the negative terminal, while a negative charge is pulled towards the positive terminal. If a charged particle is free to move it will be accelerated towards a terminal, gaining speed and kinetic energy. This energy is transferred into the particle from the battery via the electric field. When the particle hits the terminal it stops and the kinetic energy is dissipated as heat and lost. Thus energy is lost from the battery. + + + + + + + + + + + current + + + + + + + + + + + If a metal wire is attached to a battery’s positive terminal, electrons are + + pulled out of the wire, leading to the wire becoming positively charged. This + ++ + + positive charge pulls upon the electrons in the wire and very quickly it - balances the force applied to the electrons by the terminal. At this point no - -- further electrons are removed and the - - - - - - - - - - - - - flow of electrons stops. A transient flow - - - - - - - - - - - of electrons occurs until the electric wire connected to battery Wires attached to both forces in the wire balance out and the terminals of battery electrons feel no net force. When the transient flow stops, the attached wire exerts the same electric time force on its surroundings as did the battery terminal. 2 Attaching a wire to the negative terminal of the battery, a transient flow of electrons again occurs, but in this case the electrons flow from the terminal into the wire, which becomes negatively charged. The repulsive force of this negative charge very quickly balances the force pushing the electrons from the terminal and the flow stops. Again at this point, the wire exerts the same electric force on its surroundings as did the battery terminal. Transient flows of this kind are very common in the logic of modern computer systems. Continuous Current Flow Connecting a wire (a wire is by definition made from a metal) to both terminals of a battery allows a continuous flow of electrons to occur: electrons are pushed into one end of the wire from the negative terminal, while electrons are pulled out from the other end of the wire by the positive terminal; electrons in the wire move to adjust to these effects. Another way to look at this is that the electric field produced by the terminals propagates through the wire and the free electrons in the wire move in response to the forces exerted by this field. As discussed above, with each electron that moves from the negative to positive terminal, energy is consumed from the battery. The rate of consumption of energy is dependent upon the number of electrons flowing and the energy lost per electron. The former depends upon the metal used in the wire and the latter on the battery. Whether the continuous flow will continue for very long depends upon the rate of energy consumption and the energy available from the battery. Electrical Properties and their Measures Voltage Although electrical effects are caused by the forces asserted by the electric charges, it is not convenient to measure this force, since the force varies with position. A much more convenient measure is the energy released when a charged particle moves between 2 points in the electric field of the charges. This turns out to be independent of the path traversed through the field. Thus for a battery, the energy released when one electron moves from the negative battery terminal to the positive is independent of the length of the wire or the type of wire (Note: these 2 factors do affect the rate at which electrons flows, thus controlling the rate that energy is extracted, i.e. the power consumption). Voltage is the unit used to measure the energy released per unit charge. If there is a 1 Volt difference between 2 points, then a unit positive charge (1 coulomb) moving from the more positive point to the more negative point will gain one Joule of energy from the electric field. The motion is in the opposite direction for negatively charged particles: a unit negative charge gains 1 Joule of energy moving from the more negative to the more positive point. For an electron with its charge of 1.602 10-19 coulombs the energy gain is 1.602 10-19 Joules when moving through a voltage difference of 1 Volt: this is very small and is commonly called 1 electron-Volt (1 eV). It is inconvenient to mark voltage differences on a circuit between points. It is easier to fix some point of a circuit as a reference point and to mark other points in the circuit with the voltage difference from the reference. In all our circuits the negative terminal of the power supply will be used as the reference point, but any other point can be the reference. Since there can no voltage difference between one point and itself, the reference point is marked with 0 Volts (0V). Because electrons have been assigned a negative charge, they move from the lower marked voltages towards higher voltages. In practice, it is usual to speak of the “voltage” of some part of the circuit, e.g. “this point is at 9 Volts” or “this point has a voltage of 9 Volts”, rather that to speak of the voltage difference with respect to the reference point. It must be remembered that there is no absolute scale of voltages: it is impossible to compare voltages in different electrical circuits unless there is some common reference to which they are connected (the Earth, the biggest thing around, is often used as this reference). The force (or the strength of the electric field) between 2 points is related to the voltage between the points, and inversely related to their distance apart, i.e. the force is greater the larger the voltage and the smaller the separation: 3 for 2 points with a voltage difference of 5 volts, the electric field is 5 Volts/metre if they are 1 metre a part; 5 106 Volts/metre if they are 1 micron apart. If there is no electric force between 2 points, then the voltage difference between them is zero. In the case of the wire attached to one terminal of a battery (see right), once the transient electron flow has stopped, there is + - + + + + + + + + + + + + + + + + + + + + + + + + + 5V 5V + + + 5V - - 0V 0V 0V - - - - - - - - - - - - - - - - - - - - - - - - no electric force between any points on the wire (otherwise electrons Voltages on wires after would move in response), and therefore there is no voltage difference transient currents die away between any points on the wire: all parts of the wire are said to have the same voltage, which is the same as that of the battery terminal. Thus the wires extend the battery’s terminals. Amperes (or Amps) The current, I, through a section in a circuit is the quantity of charge passing through per second. The Ampere or Amp is the usual measure of electric current flow. In terms of electron flow, the current is the product of the number, n, of free electrons per unit volume, the charge, e, on the particles, the average velocity, |v|, of the particles, and the cross-sectional area, A, of the material through which the current flow: I = n A e |v|. This is often written as : I = nl e |v|, where nl is the electron line density, the number of electrons per unit length in the direction of current flow, so that nl = n A. 1 Amp is equal to 1 coulomb of electric charge flowing through a section in a second. Since the charge of an electron is 1.602 10-19 coulombs, 1 Amp is equal to 6.23 1018 electrons flowing past a point in one second. There is a direction to current flow. Unfortunately current is defined to flow in the direction of movement of positive charges from higher voltages to lower voltages. Thus, in solid materials where currents are caused by moving negatively charged electrons, the current flow is defined to be in the opposite direction to the electron flow. Resistance For copper there are ≈1029 electrons per m3, so that in a wire with a cross-sectional area of 1 mm2 (10-6 m2 ) there are ≈1023 electrons per metre length and the electrons need only move with a drift velocity of 0.0623 mm/sec (6.23 10-5 m/sec) to produce a current of 1 Amp, while in a wire with a cross-sectional area of 0.01 mm2 (10-8 m2 ) there are only 1021 electrons per metre and the electrons need to travel at 6.23 mm/sec (6.23 10-3 m/sec) to provide a 1 Amp current. Electrons are whizzing about in all directions with speeds of the order of 1.6 106 m/s; the drift velocity is just a small bias in their motion. Electron current flow has been presented as a continuous process, but for all except super-conducting situations this is not quite the case. When a voltage difference is placed across a wire, a force is applied to the electrons in the wire, accelerating them to higher and higher velocities. Eventually the electrons collide with atoms in the material, and they lose their forward motion. The electrons are scattered in all directions, losing most of their kinetic energy of motion from the drift velocity to the atoms, which vibrate about their fixed position in the material: the atoms - the `material' - get hot. The scattered electrons are accelerated again, picking up speed until they again collide with other atoms: current flow looks smooth on a macroscopic scale, but individual electron motions are erratic on the small scale. The collisions restrict the flow of the electrons, the current, and are the source of resistance. Energy from the battery is transferred by the electric field into the motion of electrons, and then transferred by collisions into the oscillation of atoms, and heating of the material. This energy transfer can cause materials to become very hot, as happens in an electric fire's heating element, and also in the filament of an incandescent light bulb, where the filament gets so hot it shines brightly. I It is informative to look at the flow of electrons through materials with different values of electron line density, n, n1 n2 (the number of free electrons per unit length). In the diagram to the right there are 2 wires of different materials attached to each other and with an electric current flowing through them. The materials have different electron line densities, n1 and n2. The current, I, through each material is the same: if I was bigger through the left wire, w1, than through the right wire, w2, more electrons would be leaving the junction 4 through w1 than entering it through w2 depleted the electrons at the junction and the excess positive charge created would reduce the current through w1; if I was greater in w2, electrons would pile up at the junction, and the excess charge here would reduce the flow through w2: remember the electrons move in the opposite direction to the current. Let’s look at the different electron velocities in the 2 wires and also the different energy being transferred into the wires through collisions. Let’s label the electron velocities as v1 and v2, and the collision rates (collisions/sec) as c1 and c2. From the equation for the current I (I=nev), we have, since the current is the same in w1 and w2. = n1ev1 I = v1 and thus:- = ne ev 2 I and n1e v2 = I n2 e Comparing the velocities by dividing one by the other, we get: v1 v2 = n2 n1 and we see that the electrons flow more quickly in the material with the lower electron line density. The energy transfer rate, e, is: electron line density*collision rate*energy lost per collision. For our purposes it is sufficient to assume that the energy lost per electron collision is 1 mv 2 , so we have 2 2 e = ncmv 2 Comparing the energy transfer into the different wires by dividing one into the other gives:- e1 e2 [Replacing = v12 v 22 n1c1mv12 n 2 c 2 mv 22 by n 22 n12 = n1c1 mn 22 n 2 c 2 mn12 = c1n 2 c 2 n1 using the velocity ratio above.] For copper, which is a very good conductor, the electron density is ~1029 electrons/m3. For a resistive material, a much poorer conductor, the electron density might be ~1023 electrons/m3 or less. If we take wires with a cross-sectional area of 10-6 m2, the line densities of a copper wire is 1023 while that of a resistive wire is 1017. (electron density/area) If we put the same current through these wires, the electron velocity in the resistive wire is 106 times that in the copper wire (1023/1017). The energy transfer into the resistive wire is at least 106 times more since it is expected that the collision rate in the resistive wire is greater than that in the copper wire. Even more energy can be transferred into the resistive wire by making it thinner and reducing the electron line density – this is why incandescent light bulb wires are so thin. In the copper there are much larger number of electrons travelling slowly, with the energy lost per collision low because of the low velocity. In the resistive wire, there are far fewer electrons, so they are travelling very much faster, and on each collision there is a very, very much larger energy loss (proportional to the square of the velocity ratio). The text box to the right put some numbers into these equations. From the last equation, we can see that even if the collision rates are the same in each material, more energy will be transferred into the material with the lower electron line density, where the electrons are travelling much faster than in the material with the larger electron line density. For copper the mean electron speed (not the drift velocity) is 1.6 106 m/s, and the mean distance electrons travel between collisions is 4 10-8 metres, so that the time between collision is 2.5 10-14 secs, which inverting gives us the collision frequency 4 1013 collisions per sec per electron. For a line density of 1023 electrons/m, this gives 4 1036 electron collision per meter per second – not a small number. These equations explain why electricity can be transferred long distances from power stations without the wires on the way getting hot. Large diameter wires of a good conductor transport the electricity to where it is required, at which point a resistive element restricts the current flow. The restriction of the current flow makes the drift velocity in the copper supply wires extremely low and the energy lost into these wires similarly low. Essentially all the energy loss is in the resistive element. 5 Ohm’s Law There turns out to be a linear relationship between the current flow between two points and their voltage difference in terms of the ability of the material between the points to restrict the current flow. This is Ohms’ law:- V = IR where V is the voltage difference and I is the current between the points, and R is the total resistance of the material between the points measured in Ohms. It is illuminating to look at Ohms’ Law for those instances when V or I is zero between 2 points. For I = 0, no current flows between the points and from Ohm’s Law either V = 0 or R = ∞ (infinity): If there is a finite resistance between these points, i.e. R ≠ ∞, then a current would flow if there was an electric field present between the points. Therefore, for I to be 0, there can be no such field present and the points must have the same voltage, i.e. V = 0. If R = ∞, then no current will flow whatever the voltage difference between the points, and nothing can be said about the value of V: it can be any value. For V = 0 between the points, there is no voltage (i.e. no net electric force) between the points and from Ohm’s Law either I = 0 or R = 0: If there is no current flowing (I=0). then nothing can be said about the resistance, it can be any value (this is the same as the first case above). If there is a current flowing (I ≠ 0), then the resistance between the points must be zero. Otherwise, electrons would collide with the atoms of the material and stop, and there would have to be an electric force to keep the electrons moving: V then would not be 0. The last example shows that all points on a wire have the same voltage if no current is flowing or if the wire is a very good conductor, when the electrons flow through the material without interacting with it. In practice there are no perfect conductors (except for super-conductors), but connection wiring in circuits has a very low resistance, so that effectively there is no voltage drop across this wiring compared to other components in a circuit. If a connection wire has a resistance of a millionth of an Ohm (a reasonable value) and has a current of 1 Amp flowing in it (a rather high current in digital systems where currents of milli-Amps or micro-Amps are more common), it has a voltage difference or a voltage drop across it of a millionth of a Volt (not much when the voltage difference across the power supply is probably 5V). Power When an electron moves through a voltage difference, energy is released from the electric field. Thus, when a power supply drives a current through a circuit, energy is output by the power supply, going into heating of the material: energy can be extracted in other ways, but this is what happens when a current flows through a resistor. The energy transfer per second is the power. The power released into a circuit component, or alternatively the power that the circuit component consumes from the battery is simple to calculate. When an electron moves through a voltage difference of 1 Volt, a precise quantity of energy, 1 eV, is released. When a current flows in a circuit between 2 points with different voltages, the energy released per second between the 2 points is just the number of electrons passing through per second, n|v|, multiplied by the energy released per electron, eV:Power = Energy release/sec = n|v|eV = Vne|v| = VI 6 n is the number of electrons per unit length, |v| is their average velocity, e is the charge on an electron and ne|v| is the current, I. The power consumed is just the product of the voltage and the current: it has the units of Watts. Using Ohm’ Law, we can substitute for V or I in the power equation to produce 2 equivalent ways of calculating it: Power Consumed = VI = V2/R = I2R A voltage difference of 5 Volts across a resistance of 2 Ohms produces a current through the resistor of 2.5 Amps (5/2), and the power consumed is:5 * 2.5 (VI) = 5 * 5 / 2 (V2/R) = 2.5 * 2.5 * 2 (I2R) = 12.5 Watts Remember: energy is released into the circuit where the voltage drops occur and this power is provided by the power supply, or rather the voltage change occurs where the energy is released. Where a current flows through a good conductor, I ≠ 0 and R = 0, there is no voltage drop across the conductor (see earlier under Resistance) and no energy is released: VI = 0 * I = 0 I2R = I * I * 0 = 0 ; This allows electricity to be transported from one point to another without significant energy loss, e.g. in the mains supplies to houses and between components in an electrical circuit. It is however, only true when there is some component restricting the current flow to some reasonable value. If there is no such component, then a short-circuit condition can exist. Short-Circuits Short-circuits are a problem. Let’s consider what happens when a good conductor is connected across the terminals of a power supply with an output voltage of 1 Volt. This is called short-circuiting the power supply. The power supply accelerates electrons through the conductor. Since the electrons do not collide very often with the atoms in a good conductor, they reach very high speeds. For a 1 Volt difference, electrons can reach 5.9 105 m/sec (3000 Km/sec): see box. For a copper wire of cross-sectional area 0.01 mm2 there are ≈1021 electrons per metre and the current flow through the wire, if all electrons reached this speed, would be ∼108 Amps (using VI) and the power consumption would be ∼108 W or 100 MW. These are extremely large values and the current will never reach this value, something would prevent it. The force exerted on an electron in an electric field is just eE, where e is the electron’s charge and E the field strength. E is related to the voltage by E = V/d, where d is the distance over which the voltage is dropped, so that the force on the electron is eV/d. The acceleration, a, on the electron is the force divided by the electron’s mass, m, so that a = eV/md The final velocity, v, of the electron after passing through the voltage drop is related to the acceleration and the distance travelled:v2 = 2ad = 2eV/m ; v = √(2eV/m) For an electron, e = 1.609 10-19 coulombs and m = 9.108 10-31 Kg, so that v ≈ 5.6 105 √V m/s. For V = 1, v ≈ 5.9 105 m/s. So what does happen as the current rises in a short-circuit? • with a small torch battery, the battery has a large internal resistance which restricts the current flow to a small value, when the battery is short-circuited.. All the voltage drop and power release occurs inside the battery which may get warm, while the voltage drop across the battery terminals goes to zero. • with a car battery, there is only a small internal resistance, so that a much larger current flows and much more energy is released; the battery and wiring get very hot. If the short-circuit is not broken, e.g. by the wire breaking, serious damage to the battery can result: it can explode. 7 Electrical fires in cars are started through this effect. The total energy of a car battery is around 60 Amp hours, ∼2 106 Joules, which is a lot of energy to try and output in a short period, equivalent to 2 MW if output in 1 second. • with the mains power supply the situation is much worse, since a power station can produce huge amounts of power. In the house, fuses are installed to protect against the large current flows of a short circuit. A fuse is a weak point that opens in the circuit at a low current flow (<100 Amps usually), preventing a large current flowing. Early fuses in house electrical systems had a small resistance and just melted as the current increased; modern fuses are electromechanical sensing the current increase and opening a break in the circuit. Circuits In a circuit with a resistor or resistive element, all the voltage will be dropped across the resistor, very little voltage will be dropped across the low resistance wires connecting the power supply to the resistor. When there are a number of resistors in a circuit, energy will be released into each resistor, i.e. there will be voltage drops across each of the resistors with bigger voltage drops across the larger resistors. The total voltage drops are additive. In the circuit on the right, the 2 horizontal lines on the left are the symbol for a battery: the larger line represents the positive terminal, while the shorter represents the negative terminal. The negative terminal is used as the voltage reference and is labelled as being at 0 Volts. The battery provides a voltage V, so the positive terminal is marked as being at V Volts. The zigzag symbols on the right represent 2 resistors with resistance R1 and R2. The straight lines represent conducting wires connecting the other components. These wires are good conductors and are considered to have R = 0. As shown earlier, there can be no voltage drop across these wires, Circuit 1 so that the top of resistor R1 will be at V Volts, while the bottom of resistor R2 will be at 0 Volts. When an electron flows around the circuit from one battery terminal to the other, The circuit above is a voltage divider circuit. The voltage at M is somewhere between 0 Volts and V it will lose an amount of energy controlled by the Volts: it is in fact just the voltage drop across R2. voltage of the battery: some energy will be released in VM can be found by first defining the voltage drops resistor R2, and the rest in R1. The energy releases are across R1 and R2 in terms of the current through the additive, which is why the Voltage drops are additive. circuit: The current coming out of a power supply equals the current going into it, and the current is conserved through the circuit. If there is only one path from one end of the power supply to another, then the current will be the same at all points of the path. If there is more than one path, then the current will be divided between the paths, depending on the resistance of the paths (circuit analysis is more complex where there are multiple routes from one terminal to the other). 8 Voltage across R1 = I R1, Voltage across R2 = I R2 The sum of these voltage drops is the same as the battery voltage: V = I R1 + I R2 = I(R1 + R2) giving:- I = V / (R1 + R2) and:- VM = I R2 = V R2 / (R1 + R2) The operation of Circuit 1 can be changed by the addition of a switch. This is done in Circuit 2 on the right with the switch placed between the 2 resistors. When the switch is closed, the circuit is the same as above with a current flowing. When the switch is open, there is a break in this circuit path, and current can no longer flow between the battery terminals (I = 0). The circuit is now `open-circuit'. The break can be considered to have an infinite resistance at the voltages output by the battery and as shown earlier, any size of voltage drop can exist across an infinite resistance. Since there is no current flow, there can be no voltage drop across either R1 or R2 and so the bottom of R1 is at the same voltage as the top which is the same as that of the positive battery terminal, V Volts; similarly, the top of R2 is at 0 Volts. All the voltage from the battery falls across the break in the circuit as shown in the diagram. Circuit 2 Thus the voltage above and below the switch can be changed simply by altering the switch position between open and closed. This ability of a switch to change the voltage at some point in a circuit is the key to the operation of computers, as will be shown. First, it is interesting to consider the transient operation of circuit 2 as the switch is open and closed. In terms of electric charge the circuit with the switch open is as follows: • all the bottom parts of the circuit connected to the negative terminal have an excess negative charge preventing further electrons flowing out of the terminal. • the upper parts of the circuit connected to the positive terminal all have an excess of positive charge, produced by the terminal pulling in electrons. At the moment the switch is closed, excess electrons at the top of R2 rush across the closed switch cancelling the excess charge on the bottom of R1, and the voltage at M rapidly moves to the voltage, (V R2/(R1 + R2)), the steady state voltage of Circuit 1. During this process, voltage drops develop across the resistors which cause currents to flow through them; the current through the circuit rises to it steady value. When, after the circuit has reached a steady state, the switch is opened, both sides of the break are still at the same voltage, (V R2/( R1 + R2)), and current still continues to flow through each resistor. For R1 this removes electrons from the bottom of R1 so that excess positive charge develops at this point, while for R2 it adds electrons to the top of R2 so that excess negative charge develops here. As these excess charges develop, the voltages at these points change, increasing above the break and decreasing below, until they reach V volts and 0 Volts respectively: as the voltages change the currents through the resistors decrease exponentially until they disappear. 9 Logic Circuits Digital electronic logic circuits represent Boolean data by voltages and they perform Boolean operations by changing voltages through the actions of electrically-controlled switches. This is the role that transistors generally play in digital circuits. Before looking at transistor operation, logic circuits based on an idealised voltage controlled switch are examined to demonstrate the general principles. This idealised switch is shown above. The Switch Control input controls whether there is a connection between the main switch terminals A & B. In the circuits that follow: • 5 Volts on the switch control input closes the switch so that there is a very good connection between A & B, i.e. R ≈ 0 and electrons can flow between A & B. • 0 Volts on the switch control input opens the switch so that no current can flow between A & B, i.e. R ≈ ∞ across the switch. It should be noted that the switch control input is electrically isolated from A & B, i.e. R ≈ ∞ between the control and other parts of the switch.(In the same way that a light switch is isolated from the light circuit it controls.) Inverter Circuit 5V 5V 5V 0V 0V 5V 0V 0V The circuit to the left functions as an inverter. It contains an idealised switch with switch control P. One of the switch terminals is connected to the negative terminal of the power supply, 0V. This is not shown directly but is indicated by the triangle: this simplifies the diagram. The other switch terminal is connected to the positive power supply terminal through the resistor, R: again the full connection to the power supply is not shown but is indicated by the upper triangle. With P at 0V and the switch open, no current flows through the switch or through the resistor: no current ever flows through the switch control terminal, P, or through the output connection, Q. With no current flow through R, all the upper parts of the circuit and Q must be at the same voltage, 5V, as in lower figure right. With P at 5V the switch is closed and there is a connection through the circuit between the power supply terminals. A current flows through the switch and the resistor. Since the switch is a very good conductor all the voltage falls across the resistor and all parts of the circuit below the resistor have the same voltage, 0V: the voltage on the output is 0V (see lower figure left). There is constant current flow and power consumption when the switch is closed; this is a major disadvantage of this circuit. The truth table for the operation of the circuit is shown to the right, where 0V and 5V are represented by Boolean values 0 and 1 respectively. It can be easily seen that the circuit operates as a Boolean inverter. The resistor has an essential role in this circuit: to control the size of the current 10 when the switch is closed. If the resistor were to be replaced by a good conductor, closing the switch there would place a short circuit across the power supply, blowing its fuse or damaging the circuit. The standard symbol for an inverter on circuit diagrams is shown to the left, where the input is on the left and the output on the right. The triangle shows the direction of flow, while the circle indicates the inversion (NOT) operation. The power supply connections are never shown to reduce diagram complexity. The transient operation of the circuit can be examined as for the earlier switch circuit: • With the switch open, the upper circuit is positively charged and the lower negatively charged. When the switch is closed, electrons flow very rapidly across the switch which is a good conductor and Q rapidly switches to 0V. • With the switch closed and current flowing, Q = 0V. When the switch is opened, the lower part below the switch is already at 0V, since it has a very connecting path to the power supply, and current stops flowing almost immediately. In the upper part of the circuit Q is initially at 0V, and current continues to flow through the resistor pulling electrons from Q until the voltage at Q reaches 5V and the voltage difference between Q and the 5V battery terminal disappears, when the current disappears too, I=0. The time for Q to go from 0V to 5V on switch opening is much longer than the time to go from 5V to 0V on switch closing. This is because for the latter there is a good connection to the negative terminal to push in electrons to reduce the voltage, while for the former there is only a resistive path to the positive terminal to remove electrons. Thus the inverter switches asymmetrically: being faster to switch from 5V to 0V than from 0V to 5V. The 0V to 5V switching time can be improved by decreasing the size of the resistor R, but this increases the current flow when the switch is closed , and thus increases the power consumption of the circuit. Thus the choice of resistor value is a balance between low power consumption and slow switching, or high power consumption and fast switching. 2-Input NAND Circuit The circuit to the right is very similar to the inverter circuit but has 2 switches in series and its operation is also similar: the output C is at 5V when one or more of the switches is open and no current flows; only when both switches are closed is C at 0V, at this time current flows through the circuit. The reasons for this are exactly the same as for the inverter. The resistor has the same role and the circuit has the same faults of asymmetric switching times and continuous power consumption when current flows. The circuit implements the NAND (AND operation followed by NOT) on its inputs A and B, i.e. C is at logic 0 (0V) only when both inputs are at logic 1 (5V). The truth table for the circuit is shown above on the left, while the truth table in the middle shows the development of the NAND function from applying the AND function and then the NOT function. 11 The standard circuit symbol for a 2-input NAND gate is shown above on the right: the inputs on the left into the AND unit and the NOT operation denoted by the circle. The power supply connections are again not shown on the circuit symbol. 3-Input NOR Circuit The circuit to the right has 3 switches in parallel. The output H is at 5V when all 3 switches are open, i.e. all the inputs, D, E, F, are at 0V. Whenever one of the switches is closed there is connection between the power supply terminals: a current flows through R, and H is at 0V. The reasons are the same as for the inverter. The resistor has the same role and the circuit has the same faults of asymmetric switching times and continuous power consumption when current flows. The circuit implements the NOR (OR operation followed by NOT) on its inputs D, E and F, as shown in the truth table to the right. The standard circuit symbol for 3-input NOR gate is shown below, again the circle indicates the NOT function. 12