Combinational networks I Digital Systems M 1 Digital
Combinational networks- I Digital Systems M 1
Digital Systems Some examples • Computer • Cameras • Mobile phones • Automobiles (injection, ABS. . ) • . . 2
Digital systems Physical systems using quantized values to represent, compute and transfer informations Signal: A physical value whose time behaviour represents the information to transmit Analog signal: a signal which can assume all values within its definition interval Digital signal: a signal which can assume only some defined values within its definition interval 3
Analog and digital signals “noise” • Analog signal • Digital signal (quantized) • Binary signal. H and L values are convenzionally indicated as 1 and 0 (bit – logic not numerical meaning!!!) H L 4
Switch • Digital systems consist of switches • ON/OFF devices • Example + Vcc Cause Ii Ii: {Imin, 0} Vu Effect Vu: {0, Vcc}
An example: car petrol measurement (ON/OFF) sensor Binary variable (Bit) 4/4 3/4 2/4 Reserve ? 1 bit (0/1) – 2 levels 2 1/4 bit (00/01/10/11 – 4 levels 8/8 7/8 6/8 5/8 4/8 3/8 2/8 1/8 3 bit (000/001/010/011/100/101/ 110/111) - 8 levels
Conversions A/D D/A Ex: steam pressure Ex: valve position Computer Analog to Digital and Digital to Analog conversion 7
Information coding Real picture Sensor acquired image Quantized numerical values R {0, 1, 2, . . , 254, 255} G {0, 1, 2, . . , 254, 255} B {0, 1, 2, . . , 254, 255} 8
Numbers and codes • A positional numerical system (i. e. that used in the computers) is a set of symbols each representing a numerical quantity (i. e. 5, 7, 3 etc. ) and whose actual value depends on its position 3547 = 3 x 103 + 5 x 102 + 4 x 101 + 7 x 100 N. B. There are NON positional numerical systems: i. e. the roman numbers (XXIII => 2310) • A code is a set of symbols whose combinations single out different objects. For instance the Morse code (point and dash, the colours and their positions of a flag), the bar code etc. • A binary code is a code which uses only two symbols (i. e. a and b or H(igh) and L(ow) or 0 and 1 etc. ). A set of n of these symbols can characterise 2 n different objects ( i. e. with three bits – 0 and 1 - 8 objects) 000 001 010 011 100 101 110 111 • A ternary code uses three symbols (i. e. a and b and g ). With n of these symbols 3 n objects can be identified and so on …. . • Nothing to do with numbers !!! • Using a binary code in order to code N objects (where N is not a power of 2) we need at least Z binary symbols where Z is the first integer greater 9 than log 2(N) => |log 2(N)|
Binary codes • Very often (almost always) the two symbols used for a binary code are 0 and 1, in this case absolutely without any numerical meaning (they are equivalent to low/high, red/green, open/close, a/b etc. ). In this context in a supermarket 100101 string could refer to the bread and 110101 string to the milk. 0 and 1 symbols are called bit (that is binary digit) • There are redundant codes (for instance the code 1 out of N where each configuration has only one bit equal to 1). In this case with N bit N objects are identified (ex: 010000, 000010 etc. ) • There is also a positional binary numerical system where the same symbols 0 and 1 have a numerical meaning. In this context for instance 100101 indicates 1001012 = 1 x 25 + 0 x 24 + 0 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 32 + 4 + 1 = 3710 • Within the binary numerical system it is possible to execute all arithmetical operations 10
Binary numbers • The power of 2: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 must be known by heart !!!! • In case of binary numerical values 0 e 1 too the word bit is used (somehow confusing…) • With n bit we can represent 2 n numbers that is we cover the range 0…. 2 n-1 (never forget the zero …). With 16 bit the range is 0 to 6553510 (= 6553610 -1) • Alfanumerical codes: i. e. ASCII code 7 bit (see later) 11
Elementary operations with binary numbers 1 1 0 1 0 1 1 + 0 1 1 1 0 = --------1 0 0 1 0 2 2 0 0 0 1 1 1 0 = --------0 1 1 0 0 0 1 Carry-over 1 0 7 + 5 8 = ----1 6 5 0 10 10 1 0 7 5 8 = -------4 9 Borrow 12
Elementary operations with binary numbers 101101 x 1011 ------101101= 000000== 101101=== ------11110111110 101 0101 00010 45 x 11 ------45 45= ------495 101 1100 62: 5= 12 with remnant 2 13
Negative binary numbers • Many different coding systems: 2’ complement is almost always used • Given a binary positive number its 2’s complement (negative equivalent) can be obtained by substituting the 1 s with 0 s and viceversa (bit complement operation) and adding then 1. Same procedure for converting 2’s complement negative numbers into positive numbers • The 2’s complement negative numbers have a “ 1” as most significant bit in a relative numbers context and those positive (including the zero which is a “particular” number – is a «not» number) have a “ 0” as most significant bit. • The elementary operations with 2’s complement numbers produce 2’s complement numbers (very simple for sums and subtractions, more complex for moltiplications and divisions – Booth algorithm) 0100101 => 1011010 + 1 = 1011011 => 0100100 + 1 = 0100101 +37 => -37 => +37 14
Negative binary numbers 1011011+ 0010010= ------1101101 => 0010010 + 1= 0010011 -37+ 18= ---19 1100+ 1101= ---11001 • In case of a carry beyond the MSB the carry must be discarded implemented in the computers for physical reasons ) 1011011 + 1010010 = ------10101101 Careful !! ERROR – OVERFLOW -4+ -3= --7 (automatically -37 + -46 = ---83 |-83| > 63!! By summing two negative numbers we have obtained a positive number !!! “Overflow” error in the computers The 2’s complement provide correct results within the definition range (in our case with 7 bit – 6 bit plus sign – the numbers from -6410 that is 1000000 up to +6310 that is 0111111). In general with n bit the range is -2 n-1 to +2 n-1 -1 (because of the zero. . ). 15 Example 4 bit (3 bit + sign ) range from 1000 -> -8 to 0111 -> +7
Negative binary numbers • With N bit numbers (that is N-1 data bit plus sign) the numbers range is -2 N-1 --- 2 N-1 -1. Ex. With 8 bit (7 + 1 bit) -> 2 N-1 = 27 = 12810 -> -2 N-1 = -128 and 2 N-1 -1 = 127 • The zero remains unchanged (0000 => 1111+1 => 0000 discarding the last bit) • Non integer number arithmetic is extremely complex (floating point numers) 16
Base 5 arithmetic Base 5 1 0 1 4 1 2 + 2 1 3 = --------1 1 3 0 Base 10 0 1 Carry-over 1 0 7 + 5 8 = ----1 6 5 11305 = 1 x 125 + 1 x 25 +3 x 5 + 0= 16510 Base 5 5 5 4 1 2 2 1 3 = --------1 4 4 Base 10 0 10 10 1 0 7 5 8 = -------4 9 1445 = 1 x 25 + 4 x 5 + 4 = 4910 Borrow
Hexadecimal codes and numbers • Very often the binary strings are too long for being represented. For instance: 001011110100101010 • This string is too long to be remembered. It is used therefore a Hexadecimal notation by grouping by four the string Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Hexadecimal (HEX) 0 1 2 3 4 5 6 7 8 9 A B C D E F 18
Hexadecimal strings The string: 001011110100101010 can be also rewritten as (grouping by four the bits ) 0 0101 0010 1111 0100 1011 0010 1010 and therefore in hexadecimal notation the string is: 052 F 4 B 2 A. If the hexadecimal notation represents a number arithmetical operations are possible 1000 carry (when 1610 is reached) A 57 B + B 342 = -----158 BD 19
ASCII code Here non western characters (arabs, polish, cyrillic, hindi etc. ) are missing. 20 Unicode is a 16 bit code (65536 combinations) which allows to represent all alfanumeric symbols
Gray code • Adjacent configurations differ by a single bit 011 Gray 010 001 010 111 100 110 Bin 000 001 010 011 100 101 110 111 Transient 000 or 011 White => 0 Black => 1 Very usefult for representing the position of an engine shaft (conductor disk with brushes). There are no «discontinuities» . For the conversion between the binary and Gray codes see later. 21
Parity • There are codes which allow to identify in a transmission or in one datum a single error: the most common is the parity (or disparity) bit which is added to the code so that the total number of 1’s is always even (or odd). For instance (even parity) 1001011 0000000 1111110 • Obviously a parity bit protects against single errors and not double or multiple errors. Trasmitted 1001011 (even parity) Received 1001111 Single error (green bit ) !! 1011001 Double error NOT detected! • If it is accepted that a transmission is not too noisy (that is a single bit error is the most likely) parity is a simple and very effective method. 22
Error correcting codes A “distance” in a code is the number of bits which separate two allowed configurations. For instance in a 5 bit code the two values 01011 e 01111 have a distance one while the two values, 01011 e 01101 have distance two etc. Codes with distance 3 allow not only the detection but also the correction of single errors Correct values (distance 3 – 3 bit – only 2 correct values) 000 111 If 001 is received the only «near» correct configuration is 000 and therefore if we assume a single error it can be corrected. The same applies for 101 (supposed transmitted code 111) but in case of double error the correct configuration was 000. In this case therefore we can correct single errors and detect double errors. Let see what happens with distance 4 ? If the only two allowed configurations are 0000 and 1111 we can detect single, double and triple errors. If 1110 is received we can assume that the correct configuration is 1111 (correction) but if 0110 is received we can detect the error but we are unable to correct it (same distance from 0000 and 1111). CRC codes (Cyclic Redundant Codes see later) 23
Code conversion • The conversion of a binary numerical code into a decimal one is straightforward (positional codes). • The conversion from decimal to binary can be achieved through successive divisions by 2 considering the remnants Base 2 Remnant 75| 2 1 37| 2 1 18| 2 0 9| 2 1 10010112 => 7510 4| 2 0 2| 2 0 1| 2 1 Base 5 Remnant 165| 5 0 33| 5 3 11305 => 16510 6| 5 1 1| 0 1 24
Binary Coded Decimals • Decimal numbers code where each digit is made of its binary equivalent • “Packed” notation : each digit (decimal number) consists of 4 bit decimal 1 7 3 9 BCD 0001 0111 0011 1001 • In the “packed” notation two decimal digits are stored in a “byte” (8 bit ) • In a computer the same number would consist of two bytes 00010111 (17) ; 00111001 (39) • “Unpacked”notation: one byte per each decimal digit. The previous number (1739) would consist of 4 bytes 00001 00000111 00000011 00001001 1 7 3 9 25
7 segments matrix (example) b e a d g i z With 7 bit => 27 = 128 combinations (16 only are meaningful) What is the relation between the number to be displayed and the luminous segments ? (1 on – 0 off) Number Hex Bin (xyzw) ab g d e z i 00 0 0000 1 1 0001 0 0 02 2 0010 1 0 03 3 0011 1 0. . . . 09 9 1001 1 1 10 A 1010 1 1. . . . 14 E 1110 1 1 15 F 1111 1 1 1. 0 0 1 1 1 0. 0 1. 1 1. 0 0 1 1. 1 0 a d g i z b e a d i NB 6 (six) and b (b) are differently represented having 6 (six) the segment «a» ON N. B. a, b, c, d, e, z, i are 7 functions of the binary bits xyzw. For instance how can we determine the segment g = fg(x, y, z, w) ? How can we sinthesize fg ? 29
How can we design a circuit (of any technology) able to implement arithmetical operations on binary numbers Keyboard Conv Arithmetical Logical Network Electronic Hydraulic Mechanic ………… Conv Display Design? 30
Combinational networks • The previous 7 segments table is an example of a truth table which is the basic structure for synthesizing the combinational networks that is networks whose outputs depend on the inputs only and NOT on the time. These networks differ from the sequential networks whose outputs depend on the time too that is on the past history of the network (which will be analysed later). . • Given n binary input variables, the number of different functions which can be implemented is 2**2**n • For instance with one input we can implement four combinational functions only I f 0 f 1 f 2 f 3 0 01 0 1 1 0 Not considering the identity function (f 2 – which electrically is a wire), and the constants (f 0 and f 1) we have only one important function (f 3) which is called negate, inversion or NOT and which is represented by the following symbol: I f 3 In the expressions (see later) the inversion is normally indicated with a line over the variable which is difficult to print so we use the exclamation point before the variable or an asterisc after the variable. Example f 3 = !I or f 3 = I* 31
Two variables functions There are 16 different functions I 1 I 0 0 0 1 1 0 1 f 0 f 1 f 2 f 3 f 4 f 5 f 6 f 7 f 8 f 9 f 10 f 11 f 12 f 13 f 14 f 15 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 1 The combinational functions are represented by truth tables. Important functions in red Not considering the constants and the identities there are the following characteristical two variable functions f 14 function OR f 8 f 1 f 7 f 6 f 9 function AND function NOR Symbol function NAND Symbol x y z z x y z function EXOR Symbol x y z function EQUIV Symbol x y z (+) (. ) (Å) These symbols correspond to a physical implementation where there is always a delay. variations of the between the inputs and the variation of the output which depends on the technology The EXOR operator (exclusive or OR) is also named as “module 2 adder ” since its output binary value can be interpreted as the sum of the inputs interpreted as numerical binary values 32
Mechanical implementation X Voltage OR Z y X y AND Z NOT Voltage Switch closed => 1 Switch open => 0 Z X 33
Combinational Algebra • How can we transform a truth table into a logical network which uses the elementary circuits previously described and viceversa ? Synthesis Truth table Logical scheme Analysis combinational Algebra • The combinational algebra is used to describe the functions of binary variables. It is an algebra (BOOle algebra) which can be used to represent the physical behaviour of the circuits (but for the unavoidable physical delays). An algebra consists of symbols, operations and postulates Symbols: [0, 1] Operations: logical sum (+), logical product (. ), complement (!) Postulates : 0+0=0 0. 0=0 !0=1 0+1=1 1+0=1 1+1=1 0. 1=0 1. 0=0 1. 1=1 !1=0 The point is the symbol of the logical product (always omitted) Operations on SYMBOLS , NOT on numbers/bit !!!! 34
Combinational Algebra • Constant: symbols 1 and 0 • Variables (binary): a literal which can assume the symbols 1 and 0 (very often the word «values» is used) • Function: f(x 1, x 2, …. xn) of n binary variables: a correspondence between a set of literals (inputs) and a literal (output). It can be represented by a truth table • Expression: a combination of literals and operations. i. e. : (((X+Y). !Z). !0) where X, Y and Z are binary variables • Evaluation: the computation of the binary value of an expression using the operations and the postulates of the algebra and giving to the n-tuple of the inputs all possible values. For instance for a n-tuple of 3 variables there are 8 possible combinations. An example of function F is XYZ 000 001 010 011 100 101 110 111 F 0 0 1 0 1 0 • Equivalent expressions: two expressions whose evaluations produce the same truth table • Properties: reflexive, simmetrical and transitive are valid 35
Combinational algebra and logical operators Analysis • The postulates of the combinational algebra correspond to the behaviour of the AND, OR and NOT operators. An evaluation example X Y F F=(((X+Y). !Z). !0) 0 Z XYZ 000 001 010 011 100 101 110 111 F 0 0 1 0 1 0 • It can be derived that an expression corresponds to a logical scheme and viceversa • Let’s evaluate this scheme X Y Z F F=((X+Y). !Z) The same truth table: equivalent !! Less complex circuit XYZ 000 001 010 011 100 101 110 111 F 0 0 1 0 1 0 36
Some properties of the combinational algebra (verified through the evaluation) X+Y=Y+X X. Y=Y. X X+Y+Z=(X+Y)+Z X. Y. Z=(X. Y). Z X. (Y+Z)= (XY)+ (X. Z) X+(Y+Z)=(X+Y)+(X+Z) X+X=X X. X=X (idempotence - both) X+0=X X. 0=0 X+1=1 X. 1=X X+(X. Y)=X X. (X+Y)=X !(!X)=X X+!X=1 X. !X=0 A. X+A. !X=A (A+X). (A+!X)=A !(X. Y) = !X+!Y !(X+Y)=!X. !Y (De Morgan laws – very important !!) X. Y+Y. Z+ !X. Z= X. Y+!XZ (X+Y). (Y+Z). (!X+Z)=(X+Y). (!X+Z) X+!XY = X + Y (regularly forgotten …. ) NB: in the combinational algebra we use the same priority rules of the mathematical algebra Prior(!) > Prior(+) The parenthesis can be used to alter this order. The logical product point is always omitted 37
Dual Expressions • A dual expression is obtained by replacing 0 with 1 and the and operator with or, and viceversa (the inversion remains unchanged) F=(((X+Y). !Z). !0) => Fdual= (((X. Y)+!Z)+!1) • Easily verified (F dual)dual=F • If two expressions are equivalent also the dual expressions are equivalent if (((X+Y). !Z). !0) is equivalent to =((X+Y). !Z) (verify !!) then (((X. Y)+!Z)+!1) is equivalent to ((X. Y)+!Z) (verify by means of the truth table) 38
Combinational algebra and logic operators XYZ F synthesis 000 0 001 010 011 100 101 110 111 • How can we derive a circuit from the truth table? • combinational circuits: circuits where the outputs depend only from the inputs and NOT from the time, that is its previous history • From the truth table. The lines where the function value is 1 must be selected and logical products with all the variables (1 if true, 0 if complemented) called minterms must be formed. 1 1 0 1 1 !X!YZ !XY!Z X!Y!Z XYZ X!Y!Z All minterms must be logically summed !X!YZ F= !X!YZ + !XY!Z + X!Y!Z + XYZ Each minterm is 1 for a single combination only of the inputs. Their logical sum «covers» all the 1’s of the function Canonical expression as sum-of-products (SP) Two levels expression (the NOT is not considered). X !XY!Z Y Z F XY!Z XYZ 39
Combinational algebra and logic operators synthesis • As an alternative the lines where the function is 0 must be selected and logical sums with all the variables (0 if true, 1 if complemented) must be formed. All logical sums (maxterms) must be logically anded. F= (X+Y+Z)(X+!Y+!Z)(!X+Y+!Z) Each maxterm is 0 for a single input combination. Each sum «covers a « 0» of the function Canonical expression as product-of-sums (PS) Two levels expression (the NOT is not considered). XYZ 000 001 010 011 100 101 110 111 F 0 X+Y+Z 1 1 0 X +!Y +!Z 1 0 !X + Y +!Z 1 1 Important !!!!!! Any combinational logical network can be ALWAYS synthesized as a two levels circuit (SP or PS)! A property very often forgotten !!! X+Y+Z X X+!Y+!Z Y F (PS) Z !X+Y+!Z The two canonical synthesys (SP and PS) lead in general to circuits of different complexity 40
An example XYZ 000 001 010 011 100 101 110 111 F 1 1 1 0 0 1 1 0 Fsp= !X!Y!Z + !X!YZ + !XY!Z + X!YZ + XY!Z FPS= (X+!Y+!Z)(!X+Y+Z)(!X+!Y+!Z) 41
Expansion • A SP (PS) expression (non canonical) can be «expanded» so as to become a sum of minterms (product of maxterms) if we remember that X. 1=X, X+!X=1, X+X=X and X. X=X Idempotence a+b!c = a(b+!b)(c+!c) + (a+!a)b!c= abc+ab!c+a!b!c+ab!c+!ab!c= abc+ab!c+a!b!c+!ab!c • Very often a combinational function is not completely specified, that is some input combinations never occur (don’t cares). i. e. : mechanical constraints of two keys This is important for the synthesys. The analisys (evaluation) of a circuit provides always (obviously) a completely specified truth table. F= !X!YZ + !XY!Z + X!Y!Z + XYZ + !XYZ + XY!Z = = !XZ(!Y+Y) + !XY(!Z+Z) + X!Z(!Y+Y)= = !XZ + !XY + X!Z = !XZ + Y + X!Z XYZ 000 001 010 011 100 101 110 111 F 0 1 1 ? 1 0 ? 1 (the don’t cares can be used - thanks for instance to the idempotence- to simplify the expression of a function) 42
Exercise Analyse this circuit, write the corresponding function and derive its SP canonical form AB 0 !((AB)(B+C+D)) B+C+D 1 !(B+C+D) 0 !(D+E) !(B+C+D)+!(D+E) De Morgan Absorption Z=!(!((AB)(B+C+D)) + (!(B+C+D)+!(D+E)) )= !(!(AB + ABC + ABD) + !((B+C+D)(D+E))) Absorption De Morgan Z= !(!(AB) +!( BD+BE+CD+CE+D+DE)) = AB (D+CE+BE) = ABD + ABCE + ABE = ABD + ABE Can we derive the canonical expression? Z= ABD + ABE = ABD(C+!C)(E+!E) + ABE (C+!C)(D+!D)= = ABCDE + AB!CDE + ABCD!E + AB!CD!E + ABCDE + AB!CDE + ABC!DE + AB!C!DE = = ABCDE + AB!CDE + ABCD!E + AB!CD!E + ABC!DE + AB!C!DE canonical 43
Transcoding: Binary to Gray and viceversa • Observing the gray code we have g 0 = !b 2!b 1 b 0 + !b 2 b 1!b 0 + b 2!b 1 b 0 + b 2 b 1!b 0 = = ( !b 2!b 1 b 0 + b 2!b 1 b 0) + (!b 2 b 1!b 0 + b 2 b 1!b 0) = = !b 1 b 0 + b 1!b 0 = b 0 Å b 1 g 1 = !b 2 b 1!b 0 + !b 2 b 1 b 0 + b 2!b 1!b 0 + b 2!b 1 b 0 = = (!b 2 b 1!b 0 + !b 2 b 1 b 0) + (b 2!b 1!b 0 + b 2!b 1 b 0) = = !b 2 b 1 + b 2!b 1 = b 2 Å b 1 g 2 = b 2 gn = bn Å bn+1 (N. B. bn+1 for the MSB is obviously 0. In fact g 2 = b 2 ) Bin Gray b 2 b 1 b 0 g 2 g 1 g 0 000 001 010 011 => 010 100 110 101 111 100 • Gray to binary. A truth table can be used (try as exercise) or we can use an algebric algorithm gn = bn Å bn+1 Let’s ex-or sum bn+1 to both members of the expression bn+1 Å gn = (bn+1 Å bn+1) Å bn = (0) Å bn = bn and therefore bn = bn+1 Å gn [with n bit bn+1 = 0] In our case b 2 = g 2 , b 1 = b 2 Å g 1 and b 0 = b 1 Å g 0
Binary DCBA 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 truth table in red where Canonical synthesys of function fe of the 7 segments (0 -F) Integrated circuit 7446 which doesn’t implement the letters A->F a f g e b c d N. B. A segment is lighted if the circuit output has low voltage. This synthesys is made as if the output should be high (for analogy with the previous synthesys). The obtained value must be obvously then inverted 0 1 2 3 4 5 6 7 8 9 A B C D E F (Hex values) Red => on Blu => off fe=1 fe = !D!C!BA + !D!CBA + !DC!B!A + !DC!BA + !DCBA + D!C!BA + D!CBA + DC!B!A + DC!BA + DCBA 1 3 4 5 7 9 11 12 13 15 fe = (D+C+B+A) (D+C+!B+A) (D+!C+!B+A) (!D+C+B+A) (!D+!C+!B+A) (PS) 0 2 6 8 10 14 (SP) 46 11 gates (10 x 4 inputs AND 1 x 10 inputs OR) 7 gates (6 x 4 inputs OR 1 x 6 inputs AND)
- Slides: 42