COURSE CODE: CTE 222 TITLE: DIGITAL COMPUTER FUNDAMENTAL II LEVEL: ND 2 COMPUTER ENGINEERING Combinational logic circuits. Digital signals are processed by the digital system which can be built with various logic gates. These logic circuits are made of various logic gates, by connecting them in certain combinations, in order to produce the required output. Digital logic circuits are mainly classified into two types, sequential logic circuits and combinational logic circuits. This article gives a brief idea about the combinational logic circuits. Combinational Logic Circuits A combinational logic circuit is one in which the present state of the combination of the logic inputs decides the output. The term combination logic means combining of two or more logic gates to form a required function where the output at a given time depends only on the input. The logic gates are the fundamental building blocks of a combinational circuit. By using the combination of logic gates more complex combinational circuits can be implemented such as multiplexers and de-multiplexers, comparators, adders and subtractors, etc. A combinational circuit comprises of input variables, logic gates and output variables. The logic gates accepts the inputs and depending on the type of functioning of the logic gate, output signals are generated from them. The required output data is obtained from this process by transforming the binary information given at the input. The figure below shows the schematic representation of a generalized combinational logic circuit consisting of n input variable and m output variables. In the above figure, there are n input variables and hence there will be 2n possible combinations of bits at the input. By a Boolean expression of input variables, each output is expressed. So the result of above generalized combinational logic circuit can be expressed by m Boolean expressions. In the above figure, the circuit accepts the binary variables and depending on the logical combination of gates it generate outputs. Design Procedure of Combinational Logic Circuits A combinational circuit can be designed using the following steps. 1. Identification and determination of number of available input variables and required output variables. 2. Representing symbols (alphabets) for each and every input and output variables. 3. Expressing the input and output variable’s relationship. 4. Construction of truth table indicating the relationship between the input and output variables. 5. Obtaining the Boolean expression for each output variable in terms of input variables. 6. Minimizing the Boolean expressions of various output variables. 7. Obtaining the logic diagram by the implementation of minimized Boolean expressions. For minimizing Boolean expressions, various simplification techniques are available so that they reduce the number of gates, hence less implementation cost. These techniques include Boolean algebra theorems and identities, Karnaugh maps (K-maps), Quinne-McCluskey tabulation, etc. For hardware implementation of the combinational circuit, the following guidelines are mostly preferred. The implementation of the circuit should be in such that, it should have minimum number of gates, having a minimum number of inputs. The number of interconnections between the gates should be minimum and the propagation time should be shortest. There should be always a limitation on the driving capability of the gates. This is the simple, effective and traditional method of designing a combinational circuit for small circuit. If the circuit is more complex, number of gates required is more and also it requires more number of wires in between them. Hence, designing such circuits may be less reliable and time consuming. To overcome these problems, most of the combinational circuits are available in integrated circuits (ICs) which are extensively used in the design of the digital systems. Depends on the integration capability of gates, these ICs are classified into small, medium, large and very large scale ICs. For performing specific digital functions such as addition, multiplexing, demultiplexing, encoding, decoding, comparison, etc., mostly medium scale integrated (MSI) ICs are used in digital systems. Example of Combinational Logic Circuit Statement: Design a combinational logic circuit with three input variables such that it will produce logic 1 output when one or two the input variables are logic 1 but not all the three. Solution: Follow the above listed points to design the logic diagram as per the given statement. In the given statement there are three input variables and one output variable. As a second step, assign the input variables with letter symbols as A, B, C and output as Y. Next, the relationship between the input and output variables can be tabulated by constructing the truth table as given below. Now, the simplified Boolean expression for the above truth table for getting the output Y is obtained by using K-map simplification as By implementing the above Boolean equation we get the logic diagram as Classification of Combinational Logic Circuits Combinational circuits are used in a wide variety applications including calculators, digital measuring techniques, computers, digital processing, automatic control of machines, industrial processing, digital communications, etc. Different types of combinational logic circuits are used for various applications.Depending on the function of the logic circuit employed for, combinational logic circuits are mainly classified into three types, namely Arithmetic and logic circuits, data transmission circuits and code converter circuits. Arithmetic and Logic Circuits Arithmetic operations are one of the main functionalities of most computers and calculators. These operations are carried by the logic gates or simply combinational circuits which combines the several logic gates to perform the required function. These arithmetic functionalities of the combinational circuits include addition, subtraction, multiplication, etc. Some of the combinational circuits used for these operations are Half- adder, Fulladder, Half-subtractors, Full subtractors, Adder-subtractors, Comparators, PLDs (Programmable Logic Devices), etc. Data Transmission Circuits The most commonly used combinational circuits are multiplexers and demultiplexers. A multiplexer logic circuit accepts the several data inputs and passes one of them through the output at a time. These are used in data selection, parallel to series conversion, data routing applications in digital systems. A de-multiplexer circuit performs the reverse operation than that of the multiplexer. It accepts the single input and distributes it to multiple outputs. These are used in distributors as well as series to parallel converter applications. Other essential data transmission circuits include encoders and decoders. A decoder logic circuit converts n-bit binary input code into 2n output lines. Each output line is activated for only one of the possible combinations of the inputs. These are used in data de-multiplexing, digital to analog converters and digital display applications. An encoder digital circuit converts an active input signal into a coded output signal as reverse operation of the decoder. These are used in bit compression applications. Code Converter Circuits In some applications, it is required to interface two digital blocks of different coding systems. So a conversion circuit is used in between such circuits to convert the information. Some of these converters are binary to gray code, gray to binary, BCD to excess-3 code, Excess-3 to BCD code and seven segment code converter circuits. Logic gates Digital systems are said to be constructed by using logic gates. These gates are the AND, OR, NOT, NAND, NOR, EXOR and EXNOR gates. The basic operations are described below with the aid of truth tables. AND gate The AND gate is an electronic circuit that gives a high output (1) only if all its inputs are high. A dot (.) is used to show the AND operation i.e. A.B. Bear in mind that this dot is sometimes omitted i.e. AB OR gate The OR gate is an electronic circuit that gives a high output (1) if one or more of its inputs are high. A plus (+) is used to show the OR operation. NOT gate The NOT gate is an electronic circuit that produces an inverted version of the input at its output. It is also known as an inverter. If the input variable is A, the inverted output is known as NOT A. This is also shown as A', or A with a bar over the top, as shown at the outputs. The diagrams below show two ways that the NAND logic gate can be configured to produce a NOT gate. It can also be done using NOR logic gates in the same way. NAND gate This is a NOT-AND gate which is equal to an AND gate followed by a NOT gate. The outputs of all NAND gates are high if any of the inputs are low. The symbol is an AND gate with a small circle on the output. The small circle represents inversion. NOR gate This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The outputs of all NOR gates are low if any of the inputs are high. The symbol is an OR gate with a small circle on the output. The small circle represents inversion. EXOR gate The 'Exclusive-OR' gate is a circuit which will give a high output if either, but not both, of its two inputs are high. An encircled plus sign ( ) is used to show the EOR operation. EXNOR gate The 'Exclusive-NOR' gate circuit does the opposite to the EOR gate. It will give a low output if either, but not both, of its two inputs are high. The symbol is an EXOR gate with a small circle on the output. The small circle represents inversion. The NAND and NOR gates are called universal functions since with either one the AND and OR functions and NOT can be generated. Note: A function in sum of products form can be implemented using NAND gates by replacing all AND and OR gates by NAND gates. A function in product of sums form can be implemented using NOR gates by replacing all AND and OR gates by NOR gates. Table 1: Logic gate symbols Table 2 is a summary truth table of the input/output combinations for the NOT gate together with all possible input/output combinations for the other gate functions. Also note that a truth table with 'n' inputs has 2n rows. You can compare the outputs of different gates. Table 2: Logic gates representation using the Truth table What is a Diode? A diode is defined as a two-terminal electronic component that only conducts current in one direction (so long as it is operated within a specified voltage level). An ideal diode will have zero resistance in one direction, and infinite resistance in the reverse direction. Although in the real world, diodes can not achieve zero or infinite resistance. Instead, a diode will have negligible resistance in one direction (to allow current flow), and very high resistance in the reverse direction (to prevent current flow). A diode is effectively like a valve for an electrical circuit. Semiconductor diodes are the most common type of diode. These diodes begin conducting electricity only if a certain threshold voltage is present in the forward direction (i.e. the “low resistance” direction). The diode is said to be “forward biased” when conducting current in this direction. When connected within a circuit in the reverse direction (i.e. the “high resistance” direction), the diode is said to be “reverse biased”. The diode is said to be “forward biased” when conducting current in this direction. When connected within a circuit in the reverse direction (i.e. the “high resistance” direction), the diode is said to be “reverse biased”. A diode only blocks current in the reverse direction (i.e. when it is reverse biased) while the reverse voltage is within a specified range. Above this range, the reverse barrier breaks. The voltage at which this breakdown occurs is called the “reverse breakdown voltage”. When the voltage of the circuit is higher than the reverse breakdown voltage, the diode is able to conduct electricity in the reverse direction (i.e. the “high resistance” direction). This is why in practice we say diodes have a high resistance in the reverse direction – not an infinite resistance. A PN junction is the simplest form of the semiconductor diode. In ideal conditions, this PN junction behaves as a short circuit when it is forward biased, and as an open circuit when it is in the reverse biased. The name diode is derived from “di– ode” which means a device that has two electrodes. Diodes are commonly used in many electronics projects and are included in many of the best Arduino starter kits. A PN junction is the simplest form of the semiconductor diode. In ideal conditions, this PN junction behaves as a short circuit when it is forward biased, and as an open circuit when it is in the reverse biased. The name diode is derived from “di– ode” which means a device that has two electrodes. Diodes are commonly used in many electronics projects and are included in many of the best Arduino starter kits. Although in the real world, diodes can not achieve zero or infinite resistance. Instead, a diode will have negligible resistance in one direction (to allow current flow), and very high resistance in the reverse direction (to prevent current flow). A diode is effectively like a valve for an electrical circuit. Semiconductor diodes are the most common type of diode. These diodes begin conducting electricity only if a certain threshold voltage is present in the forward direction (i.e. the “low resistance” direction). The diode is said to be “forward biased” when conducting current in this direction. When connected within a circuit in the reverse direction (i.e. the “high resistance” direction), the diode is said to be “reverse biased”. The diode is said to be “forward biased” when conducting current in this direction. When connected within a circuit in the reverse direction (i.e. the “high resistance” direction), the diode is said to be “reverse biased”. A diode only blocks current in the reverse direction (i.e. when it is reverse biased) while the reverse voltage is within a specified range. Above this range, the reverse barrier breaks. The voltage at which this breakdown occurs is called the “reverse breakdown voltage”. When the voltage of the circuit is higher than the reverse breakdown voltage, the diode is able to conduct electricity in the reverse direction (i.e. the “high resistance” direction). This is why in practice we say diodes have a high resistance in the reverse direction – not an infinite resistance. A PN junction is the simplest form of the semiconductor diode. In ideal conditions, this PN junction behaves as a short circuit when it is forward biased, and as an open circuit when it is in the reverse biased. The name diode is derived from “di– ode” which means a device that has two electrodes. Diodes are commonly used in many electronics projects and are included in many of the best Arduino starter kits. Types of Diode The types of diode include: Zener diode PN junction diode Tunnel diode Varactor diode Schottky diode Photodiode PIN diode Laser diode Avalanche diode Light emitting diode Categories of Diodes Unbiased Diode Now let us see what happens when one n-type region and one p-type region come in contact. Here due to concentration differences, majority carriers diffuse from one side to another. As the concentration of holes is high in the p-type region and it is low in the n-type region, the holes start diffusing from the p-type region to the ntype region. Again the concentration of free electrons is high in the n-type region and it is low in the p-type region and due to this reason, free electrons start diffusing from the ntype region to the p-type region. The free electrons diffusing into the p-type region from the n-type region would recombine with holes available there and create uncovered negative ions in the ptype region. In the same way, the holes diffusing into the n-type region from the ptype region would recombine with free electrons available there and create uncovered positive ions in the n-type region. In this way, there would a layer of negative ions in the p-type side and a layer of positive ions in the n-type region appear along the junction line of these two types of semiconductors. The layers of uncovered positive ions and uncovered negative ions form a region in the middle of the diode where no charge carrier exists since all the charge carriers get recombined here in this region. Due to the lack of charge carriers, this region is called the depletion region. After the formation of the depletion region, there is no more diffusion of charge carriers from one side to another in the diode. This is due to the electric field appeared across the depletion region will prevent further migration of charge carriers from one side to another. The potential of the layer of uncovered positive ions in the n-type side would repeal the holes in the p-type side and the potential of the layer of uncovered negative ions in the p-type side would repeal the free electrons in the n-type side. That means a potential barrier is created across the junction to prevent further diffusion of charge carriers. Forward Biased Diode Now let us see what happens if a positive terminal of a source is connected to the p-type side and the negative terminal of the source is connected to the n-type side of the diode and if we increase the voltage of this source slowly from zero. In the beginning, there is no current flowing through the diode. This is because although there is an external electrical field applied across the diode, the majority charge carriers still do not get sufficient influence of the external field to cross the depletion region. As we told that the depletion region acts as a potential barrier against the majority charge carriers. This potential barrier is called forward potential barrier. The majority charge carriers start crossing the forward potential barrier only when the value of externally applied voltage across the junction is more than the potential of the forward barrier. For silicon diodes, the forward barrier potential is 0.7 volt and for germanium diodes, it is 0.3 volt. When the externally applied forward voltage across the diode becomes more than the forward barrier potential, the free majority charge carriers start crossing the barrier and contribute the forward diode current. In that situation, the diode would behave as a short-circuited path, and the forward current gets limited by only externally connected resistors to the diode. Reverse Biased Diode Now let us see what happens if we connect the negative terminal of the voltage source to the p-type side and positive terminal of the voltage source to the n-type side of the diode. At that condition, due to electrostatic attraction of the negative potential of the source, the holes in the p-type region would be shifted more away from the junction leaving more uncovered negative ions at the junction. In the same way, the free electrons in the n-type region would be shifted more away from the junction towards the positive terminal of the voltage source leaving more uncovered positive ions in the junction. As a result of this phenomenon, the depletion region becomes wider. This condition of a diode is called the reverse biased condition. At that condition, no majority carriers cross the junction, and they instead move away from the junction. In this way, a diode blocks the flow of current when it is reverse biased. As we already told at the beginning of this article that there are always some free electrons in the p-type semiconductor and some holes in the n-type semiconductor. These opposite charge carriers in a semiconductor are called minority charge carriers. In the reverse biased condition, the holes find themselves in the n-type side would easily cross the reverse-biased depletion region as the field across the depletion region does not present rather it helps minority charge carriers to cross the depletion region. As a result, there is a tiny current flowing through the diode from positive to the negative side. The amplitude of this current is very small as the number of minority charge carriers in the diode is very small. This current is called reverse saturation current. If the reverse voltage across a diode gets increased beyond a safe value, due to higher electrostatic force and due to higher kinetic energy of minority charge carriers colliding with atoms, a number of covalent bonds get broken to contribute a huge number of free electron-hole pairs in the diode and the process is cumulative. The huge number of such generated charge carriers would contribute a huge reverse current in the diode. If this current is not limited by an external resistance connected to the diode circuit, the diode may permanently be destroyed. Diode Symbol The symbol of a diode is shown below. The arrowhead points in the direction of conventional current flow in the forward biased condition. That means the anode is connected to the p side and the cathode is connected to the n side. We can create a simple PN junction diode by doping pentavalent or donor impurity in one portion and trivalent or acceptor impurity in the other portion of silicon or germanium crystal block. These dopings make a PN junction in the middle part of the block. We can also form a PN junction by joining a p-type semiconductor and n-type semiconductor together with a special fabrication technique. The terminal connected to the p-type is the anode. The terminal connected to the n-type side is the cathode. Working Principle of Diode A diode’s working principle depends on the interaction of n-type and p-type semiconductors. An n-type semiconductor has plenty of free electrons and a very few numbers of holes. In other words, we can say that the concentration of free electrons is high and that of holes is very low in an n-type semiconductor. Free electrons in the n-type semiconductor are referred to as majority charge carriers, and holes in the n-type semiconductor are referred to as minority charge carriers. A p-type semiconductor has a high concentration of holes and a low concentration of free electrons. Holes in the p-type semiconductor are majority charge carriers, and free electrons in the p-type semiconductor are minority charge carriers. Construction of AND or OR gates using Diode: If we need a OR gate we can use a 4071 OR CMOS IC or a TTL 7432 OR IC. If we need a AND gate we can use a 4081 AND CMOS IC or a TTL 7408 AND IC but sometimes it is easier to use diodes. Diode Logic uses the fact that diodes conduct only in one direction. (they behave like switches). It is recommended first to read: Logic Levels. Diode Logic OR gate (wired OR connection) If one or both inputs are at logic “1” (5 volts), the current will flow through one or both diodes. This current passes through the resistor and causes the appearance of a voltage across its terminals, thereby obtaining logic “1” on the output. We only get logic “0” (0 volts) on the output when both inputs are in logic “0”. In this case, the diodes do not conduct, there is no current through the resistor R and there is no voltage across its terminals. As a result the voltage at Vout is the same as ground (0 volts) Diode Logic AND gate (wired AND connection) When both inputs are at logic “1″, the two diodes are reverse biased and there is no current flowing to ground. Therefore the output is logic “1” because there is no voltage drop across the resistor R. If one of the inputs is logic “0”, the current will flow through the corresponding diode and through the resistor. Thus the diode anode (the output) will be logic “0”. This method works fine when the circuits are simple, but there are problems when you have to make interconnections with such gates. Interconnecting OR and AND gates We make a connection of 2 AND gates and 1 OR , as shown on the picture. If we analyze carefully the picture, we notice that one of the two AND gates outputs will be in logical “1” (high level), when the A and B inputs or the C and D inputs are in logical “1” (high level). These outputs serve as inputs for the OR gate. Analyzing the output of the OR gate and assuming that the values of the resistors are the same throughout the circuit, a voltage division has been created, then the output voltage will be approximately: Vout = (+V -Vd)/2. By replacing V and Vd with real values on the last formula we get: Vout = (50.7)/2 = 2.15 Volts. (We divide it by 2 because there are two resistors of equal value on the electric current flow) In the case in which all inputs (A, B, C, D) are on logical “1”, the two resistors of the AND gates would be in parallel, and they would be in series with the OR gate resistor. This would provide an output voltage of 2.85 Volts. This level is in the not allowed (prohibited) area for a logical “1”. If we put more gates in cascade the problem will be more serious, so this method is only used for simple gates. Note: Vd = Diode voltage drop = 0.7 volts. Data Flow: Dataflow is the movement of data through a system comprised of software, hardware or a combination of both. Dataflow is often defined using a model or diagram in which the entire process of data movement is mapped as it passes from one component to the next within a program or a system, taking into consideration how it changes form during the process. Dataflow design is done through specialized software called dataflow diagrams (DFD) which are specially designed to graphically map how data is transmitted throughout a system. The dataflow diagram is important in the architectural design of a system since it defines what kind of data is needed in order to start or complete a specific process. Using a dataflow diagram is part of the dataflow modeling process. DFD graphically representing the functions, or processes, which capture, manipulate, store, and distribute data between a system and its environment and between components of a system. The visual representation makes it a good communication tool between User and System designer. ERROR DETECTION Error is a condition when the output information does not match with the input information. During transmission, digital signals suffer from noise that can introduce errors in the binary bits travelling from one system to other. That means a 0 bit may change to 1 or a 1 bit may change to 0. Error-Detecting codes Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted. To avoid this, we use error-detecting codes which are additional data added to a given digital message to help us detect if an error occurred during transmission of the message. A simple example of error-detecting code is parity check. Error-Correcting codes Along with error-detecting code, we can also pass some data to figure out the original message from the corrupt message that we received. This type of code is called an error-correcting code. Error-correcting codes also deploy the same strategy as error-detecting codes but additionally, such codes also detect the exact location of the corrupt bit. In error-correcting codes, parity check has a simple way to detect errors along with a sophisticated mechanism to determine the corrupt bit location. Once the corrupt bit is located, its value is reverted (from 0 to 1 or 1 to 0) to get the original message. How to Detect and Correct Errors? To detect and correct the errors, additional bits are added to the data bits at the time of transmission. The additional bits are called parity bits. They allow detection or correction of the errors. The data bits along with the parity bits form a code word. Parity Checking of Error Detection It is the simplest technique for detecting and correcting errors. The MSB of an 8bits word is used as the parity bit and the remaining 7 bits are used as data or message bits. The parity of 8-bits transmitted word can be either even parity or odd parity. Even parity -- Even parity means the number of 1's in the given word including the parity bit should be even (2,4,6,....). Odd parity -- Odd parity means the number of 1's in the given word including the parity bit should be odd (1,3,5,....). Use of Parity Bit The parity bit can be set to 0 and 1 depending on the type of the parity required. For even parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is even. Shown in fig. (a). For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is odd. Shown in fig. (b). Flip-flop: Flip-flop is a basic memory element used in sequential circuits. The flip-flop has two stable states – logic 0 or logic 1. The flip-flop will either be in one of the two stable states after application of the input signals; it will remain to be in that state even if the inputs are removed. Flip-flops are also known as the latch or toggle. The RS flip-flop is the simplest flip-flop which can be constructed using NOR gates or NAND gates. Figure 8.1 shows the basic circuit of RS flip-flop constructed using NOR gates. In this circuit R & S are the two inputs and X & Y are the outputs which are being applied back to the input terminals of the NOR gates. The behaviour of this circuit may be analyzed by replacing each NOR gate by an ideal NOR gate and a delay factor represented by a rectangular as shown in figure 8.2. The delay factor is the propagation delay time of each gate which is supposed to be different for each gate. Let delay of one gate is D and that of other gate is d. Further it is assumed that x and y are outputs of ideal NOR gates, which is transferred to the final output after the delay of each gate. COUNTERS Counters are the important building block of digital systems. These are used to count the pulses. The clock pulses occur at regular and known intervals, so a counter can be used to measure time and consequently frequency and time period. So counters are sequential logic circuits that proceed through a well-defined sequence of states after application of clock pulses. The counters are constructed using flip-flops and logic gates. Counters are classified into two following broad categories. 1. Asynchronous or ripple counter 2. Synchronous counter In asynchronous counters, external clock is applied to the first flip-flop and other successive flip-flops are triggered by the outputs of the preceding flip-flops. However, in synchronous counters all the flip-flops are triggered simultaneously by the external clock pulses. In this chapter the design of these counters with up and down counting sequences will be discussed. ASYNCHRONOUS COUNTERS It is well known that if a clock of frequency f is applied to the clock input of a negative triggered T flip-flop, whose T input is connected to high (logic 1), it toggles at the trailing edge of each pulse (figure 10.1). The frequency of the output will be f / 2. If two flip-flops are connected in series as shown in figure 10.2, the output frequency obtained will be the division of input frequency by a factor of 4. This will have the four unique states 00, 01, 10, 11 (shown in timing diagram of figure 10.2a). The frequency division is basically a counter. This circuit is called as two bit asynchronous or ripple counter. In this wary any number of flip-flops may be connected in series. A counter with n number of flip-flops will have 2 n unique states which will count in natural sequence and the counter is called a modulus (short mod) 2 n counter. The modulus of a counter represents the total number of states through which the counter can move. The binary counter with one flipflop will have two states and the counter is called as Mod-2 or divideby-2 counter (ref. fig. 10.1). The counter with 2 flip-flops will have 4 (as 2 n = 4 ) states (including zero) and the counter is called as Mod-4 or divide-by-4 counter (ref. fig.10.2). It will have 00, 01, 10 and 11…..states. Similarly, Mod-8, Mod-16…counters may be discussed. In these asynchronous or ripple counters all the flip-flops are not synchronously controlled by the same clock pulse Exercise What the applications of flip flop Explain the operation of counter Differentiate between ripple counter and Synchronous counter