670 likes | 918 Views
Combinational Logic Design Design using SSI chips Arithmetic Circuits Code Convertor. Combinational Logic Circuits. The term "combinational" comes to us from mathematics which means an unordered set where nobody cares which order the items came in
E N D
Combinational Logic Design Design using SSI chips Arithmetic Circuits Code Convertor
Combinational Logic Circuits • The term "combinational" comes to us from mathematics which means an unordered set where nobody cares which order the items came in • With combinational logic, the circuit always produces the same output solely by a given set of inputs , regardless of the order the inputs are changed • If there are m outputs and n inputs then there are m Boolean functions, one describing each outputs • The inside of a combinational circuit is made of logic gates and it does not store any information (i.e. memoryless) • There are circuits which depend on inputs and previous outputs. These circuits are called sequential logic where we will discuss in later chapter • Combinational logic circuits are important components of digital systems
Combinational vs. Sequential Logic (a) Combinational (b) Sequential Output = F (In) Output = F (In, Previous In)
Designing Combinational Circuits • In general we have to do following steps: • From the specifications of the circuit, determine the required number of inputs and outputs and assign a letter symbol to each • Derive the truth table that defines the relationship between inputs and outputs • Obtain the simplified Boolean functions for each output as a function of the input variables • Draw the logic diagram • Verify the correctness of the design
Arithmetic Circuits • Arithmetic circuits are the ones which perform arithmetic calculations on binary numbers like addition, subtraction, multiplication, and division etc. • Arithmetic circuits can be built using logic circuits and they are excellent examples of combinational logic design • We will build arithmetic circuits by using the design procedure as stated previously
Adder • Adders are the basic building blocks of all arithmetic circuits • Adders add two binary numbers and give out sumand carry as output • In modern computers adders reside in the arithmetic and logic unit (ALU) where other operations are performed • Basically we have two types of adders • Half Adder • Full Adder
X 0 0 1 1 Y 0 1 0 1 S 0 1 1 0 C-out 0 0 0 1 Half Adder Truth Table Outputs Inputs X Half Adder S C-OUT Y Half Adder • Adding two single-bit binary values, X, Y produces a sum S bit and a carry out C-out bit • This operation is called half addition and the circuit to realize it is called a half adder S(X,Y) = S (1,2) S = X Y C-out(X,Y) = S (3) C-out = XY X Y Sum S C-out
Adding two single-bit binary values, X, Y with a carry input bit C-in produces a sum bit S and a carry out C-out bit Sum S X X XY XY 00 01 11 10 00 01 11 10 C-in C-in 1 1 6 6 0 0 2 2 4 4 0 1 0 1 1 1 3 3 5 5 7 7 1 1 C-in C-in Carry C-out Y Y 1 1 1 1 Full Adder The S function is the three-bit XOR function (Odd Function): S = X Y (C-in) C-out = XY + X(C-in) + Y(C-in)
Full Adder Circuit using XOR and Basic Gates • Logical Implementation
Full Adder implemented by Two Half Adders and an OR Gate • A ‘Full Adder’ can also be implemented using two half adders and an ‘OR’ Gate as follows: The sum S = X Y (C-in) The carry out
Therefore and Block diagram representation of a full adder using two half adders Full Adder implemented by Two Half Adders and an OR Gate (Cont.)
We want to add two 4-bit binary numbers We use a series of half and full adders Since there is no carry into the first stage, we can use a half adder there For each other stage we use a full adder and just carry in from the previous stage The carry out at the end indicates that the sum is too large to be represented by 4 bits Adding Two Binary Numbers
If we want to do subtraction, the circuit is very similar Looking at the truth table for A - B The only difference between a half adder and a half subtractor is the borrow In order to perform this subtraction a digit has to be borrowed from the next highest column of the subtraction When it borrows, it gets a 2 and the operation then becomes 2 - 1 = 1 The Borrow output is set to indicate that borrow operation is required Subtraction
Half Subtractor • Subtracting a single-bit binary value Y from anther X (i.e. X - Y) produces a difference bit D and a borrow out bit B-out • This operation is called half subtraction and the circuit to realize it is called a half subtractor D(X,Y) = (1,2) = X'Y + XY' Thus, D = X Y B-out(X,Y) = (1) Thus, B-out = X'Y Symbol
Half Subtractor circuit • Again, we shall represent the half subtractor using a box • Since the two inputs of a subtractor are different, we indicate the subtrahend with a ‘-’
Subtracting two single-bit binary values, Y, B-in from a single-bit value X produces a difference bit D and a borrow out B-out bit This is called full subtraction Full Subtrator D = X Å Y Å(B-in) B-out = X'Y + X'(B-in) + Y(B-in) = X'Y + B-in(X Y)' (In the same way as we did with the full adder) Note: D= X – Y – B-in D(X,Y, B-in) = S (1,2,4,7) B-out(x, y, B-in) = S (1,2,3,7)
Full Subtractor Circuit Implementation X-OR gate implementation of half subtactor Full subtractor using two half subtractors and an OR gate
Parallel Adder IC • As shown in the pin layout diagram, the IC 7483 • Accepts two 4-digit numbers A4A3A2A1, B4B3B2B1 and a carry-in Ci as inputs • Produces a 4-digit sum output 4321and a carry-out Co • If the SUM of the two inputs plus the carry-in is between 0 and 15, the SUM appears in the outputs and the carry-out is '0‘ • If the SUM is between 16 and 31, carry-out C0 becomes ‘1‘ and the outputs are 16 less than the SUM • Example (not using 2’s complement) • A4A3A2A1 = 0111, B4B3B2B1 = 1010, Ci = 1 So, result should be 10010 (18) • As expected, the ICs produces Co = 1 and
X4X3X2X1 X8X7X6X5 Y8Y7Y6Y5 Y4Y3Y2Y1 Cascading the 74283 ICs • A 74283 IC only accept 4-bits Boolean variables at its input • So, how to do addition which involve 5-bits or more • Find another suitable IC! Or, by cascading 74283 ICs • To add two 8 bit numbers X8X7X6X5X4X3X2X1 and Y8Y7Y6Y5Y4Y3Y2Y1 , connect two 74283 as below 2nd stage produce MSB 1st stage produce LSB
n-bit Subtractors • An n-bit subtracor used to subtract an n-bit number Y from another n-bit number X (i.e. X - Y) can be built by using an n-bit adder and n inverters: • Find two’s complement (1's complement plus 1) of Y by: Inverting all the bits of Y using the n inverters • Adding 1 by setting the carry in of the least significant position to 1 • The original subtraction (X - Y) now becomes an addition of X to two’s complement of Y using the n-bit adder
Since the circuits are so similar, it is reasonably easy to combine them together into a single circuit, with a control line used to select either addition or subtraction The only difference between the half adder and the half subtractor is the NOT The above table gives a truth table of what we require What logic gate can fulfill this truth table? Adding and Subtracting
Adding a Control Line • If we define a 0 on our control signal to mean Add then the input to the AND Gate should be the same as our A signal • When the control signal is 1, we want to do a subtraction, so we require the input to the AND Gate to be the NOT A signal • We make our full adder/subtractor just as before, with all the control inputs tied together
When the switch is closed, 74283 is an adder A '0' is applied to Ci and the EX-OR gates So, there is no Carry-in and Addend pass through the EX-OR unchanged (1 0 = 1, 0 0 = 0) When the switch is opened, 74283 becomes a subtractor A ‘1' is applied to Ci and the EX-OR gates So, there is a Carry-in (adding 1) and Addend pass through the EX-OR inverted (1 1 = 0, 0 1 = 1) So, 74283 acts as an subtractor, by adding (2’s complement of Y4Y3Y2Y1) instead of (Y4Y3Y2Y1) Y4Y3Y2Y1 X4X3X2X1 Adder and Subtractor Using 74283 IC
BCD Adder • When the sum of two digits is less than or equal to 9 then the ordinary 4-bit adder can be used • But if the sum of two digits is greater than 9 then a correction must be added “I.e adding 0110” • We need to design a circuit that is capable of doing the correct addition
Examples :1. CASE I : Sum <= 9 & carry = 0. Add BCD digits 3 & 4 1. 0 0 1 1 + 0 1 0 0 --------- 0 1 1 1 • Answer is valid BCD number = (7)BCD & so addition of 0110 is not added.
2. CASE II : Sum > 9 & carry = 0. Add BCD digits 6 & 5 1. 0 1 1 0 + 0 1 0 1 ----------- 1 0 1 1 • Invalid BCD (since sum > 9) so 0110 is to be added 2. 1 0 1 1 + 0 1 1 0 ----------- 1 0 0 0 1 (1 1)BCD • Valid BCD result = (11) BCD
3. CASE III : Sum < = 9 & carry = 1. Add BCD digits 9 & 9 1 0 0 1 + 1 0 0 1 ----------- 1 0 0 1 0 • Invalid BCD ( since Carry = 1 ) so 0110 is to be added 1 0 0 1 0 + 0 1 1 0 ------------ 1 1 0 0 0 (1 8)BCD • Valid BCD result = (18) BCD
Design of BCD Adder • Design of BCD adder : • To execute first step i. e. binary addition of two 4 bit numbers we will use IC 7483 ( with Cin = 0 ), which is 4 bit binary adder. • We need to design a digital circuit which will sense sum & carry of IC 7483 & if sum exceeds 9 or carry = 1, this digital circuit will produce high output otherwise its output will be zero.
Design of BCD Adder • The cases where the sum of two 4-bit numbers is greater than 9 are in the following table:
BCD Adder • Whenever S4=1 (sums greater than 15) • Whenever S3=1 and either S2 or S1 or both are 1 (sums 10 to 15) • The previous table can be expressed as: X = S4 + S3 ( S2 + S1) So, whenever X = 1 we should add a correction of 0110 to the sum.
Inputs:[A]=0101, [B]= 0011, Co=0 0011 0101 0 1 0 0 0 0 0 0 1000 1 1 0 0 0 0000
Inputs:[A]=0111, [B]= 0110, Co=0 0110 0111 0 1 1 0 1 1 1 1 1101 1 0 0 1 1 0110
BCD Adder BCD Adder BCD Adder Cascading BCD Adders • The previous circuit is used for adding two decimal digits only. That is, “ 7 + 6 = 13”. • For adding numbers with several digits, a separate BCD adder for each digit position must be used. • For example: • 2 4 7 + 5 3 8 -------------------- ?
Example • Determine the inputs and the outputs when the above circuit is used to add 538 to 247. Assume a CARRY IN = 0 • Solution: • Represent the decimal numbers in BCD 247 = 0010 0100 0111 538 = 0101 0011 1000 Put these numbers in registers [A] and [B] [A] = 0010 0100 0111 [B] = 0101 0011 1000
0 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0111 1000 0101 0 1 0 1 0 0 1 1 1 0 0 0 Example
BCD Subtractor • Rules for BCD subtraction : 1. Find 9’s complement of the subtrahend. a) To find 9’s complement first find 1’s complement of subtrahend. b) Add (10)10 i.e. (1010)2 to it. 2. Add 9’s complement of the subtrahend to the minuend using BCD rules of addition. 3. After BCD addition if MSD is 0, result is negative expressed in 9’s complement form to get it in natural form find 9’s complement of the LSD of the result. 4. But after BCD addition if MSD is 1 it indicates that result is positive expressed in natural form & add ( 1 )10 i. e. ( 0001 )2 to it.
CASE I : carry = 1, answer is positive Subtract BCD digit 2 from 8. • 1. 9’s complement of (2)10 i.e. (0010)2 a) 1’s complement of (2)10 1 1 0 1 b) add (1010)2 + 1 0 1 0 --------- 1 0 1 1 1 (discard carry). • 2. 1 0 0 0 (8)10 + 0 1 1 1 9’s comp. of (2)10 ---------- 1 1 1 1 Invalid BCD so (0110)2 is added 1 1 1 1 + 0 1 1 0 ---------- 1 0 1 0 1 • Since MSD after BCD addition is 1, answer is positive expressed in natural form & to get final answer carry is added at the end . 0 1 0 1 + 1 ----------- 0 1 1 0 i. e. (6)10
CASE II : carry = 0, answer is negative Subtract BCD digit 9 from 6. • 1. 9’s complement of (9)10 i.e. (1001)2 a) 1’s complement of (9)10 0 1 1 0 b) add (1010)2 + 1 0 1 0 --------- 1 0 0 0 0 (discard carry). • 2. 0 1 1 0 (6)10 + 0 0 0 0 9’s comp. of (9)10 ---------- 0 0 1 1 0 valid BCD with carry = 0 • Since MSD after BCD addition is 0, answer is negative expressed in 9’s compliment form & to get final answer, 9’s compliment of answer is taken . a) 1’s complement of answer 1 0 0 1 b) add (1010)2 + 1 0 1 0 ---------- 1 0 0 1 1 (discard carry). So final answer is –(3)10 i.e.- (0011)
Design of BCD Subtractor • 1. To execute first step i. e. to find 9’s compliment of subtrahend a) First we find 1s compliment of subtrahend. b) Then add (10)10 i.e. (1010)2 to 1’s compliment of subtrahend. We use inverter to get 1’s compliment of subtrahend since subtrahend is 4 bit we need 4 inverters and to add this to (1010)2, 4 bit binary adder IC 7483 is used. • 2. Circuit for BCD addition of 9’s compliment of subtrahend and minuend we will use already designed BCD adder • 3. Circuit to get answer in correct form. If MSD after BCD addition is 0, answer is negative expressed in 9’s compliment form & to get answer in correct form we have to find 9’s compliment of the result. If MSD after BCD addition is 1, answer is positive expressed in natural form & to get final answer carry is added to the earlier answer.
t1 t2 Logic Gate max (t1, t2, ..., tn ) + t : : tn CIRCUIT DELAYS (1/5) • Given a logic gate with delay t. If inputs are stable at times t1, t2, …, tn, then the earliest time in which the output will be stable is: max( t1, t2, …, tn ) + t • To calculate the delays of all outputs of a combinational circuit, repeat above rule for all gates.
0 X Y 0 S C 0 Z CIRCUIT DELAYS (2/5) • As a simple example, consider the full adder circuit where all inputs are available at time 0. Assume each gate has delay t.
Y4 X4 Y3 X3 Y2 X2 Y1 X1 C4 C3 C2 0 0 0 0 0 0 0 0 0 C1 FA FA FA FA C5 S4 S3 S2 S1 CIRCUIT DELAYS (3/5) • More complex example: 4-bit parallel adder.
where Xi, Yi are stable at 0t, while Ci is assumed to be stable at mt. Xi Yi Ci 0 Si Ci+1 Full Adder 0 mt 0 max(0,0)+t = t Xi Yi max(t,mt)+t 0 Si max(t,mt)+t t max(t,mt)+2t Ci+1 mt Ci CIRCUIT DELAYS (4/5) • Analyse the delay for the repeated block. • Performing the delay calculation:
CIRCUIT DELAYS (5/5) • Calculating: When i=1, m=0; S1 = 2t and C2 = 3t When i=2, m=3; S2 = 4t and C3 = 5t When i=3, m=5; S3 = 6t and C4 = 7t When i=4, m=7; S4 = 8t and C5 = 9t • In general, an n-bit ripple-carry parallel adder will experience the following delay times: Sn = ? Cn+1 = ? • Propagation delay of ripple-carry parallel adders is proportional to the number of bits it handles.
FASTER CIRCUITS • Three ways of improving the speed of circuits: • Use better technology (eg. ECL faster than TTL gates) BUT • Faster technology is more expensive, needs more power, lower-level of integrations • Physical limits (eg. speed of light, size of atom) • Use gate-level designs to two-level circuits! (use sum-of-products/product-of-sums) BUT • Complicated designs for large circuits • Product/sum terms need MANY inputs! • Use clever look-ahead techniques BUT • There are additional costs (hopefully reasonable).
Pi Xi Yi Si Gi Ci+1 Ci LOOK-AHEAD CARRY ADDER (1/6) • Consider the FA, where intermediate signals are labelled as Pi and Gi: Pi = Xi Yi Gi = Xi ∙Yi • The outputs Ci+1, Si, in terms of Pi, Gi, Ci are: Si = Pi Ci … (1) Ci+1 = Gi + Pi∙Ci … (2) • Looking at equation (2): Gi = Xi ∙Yiis a carry generate signal, and Pi = Xi Yiis a carry propagate signal.