Logic Circuits Lecture - Hochschule Rosenheim PDF

Document Details

AccommodativeFactorial9455

Uploaded by AccommodativeFactorial9455

Technische Hochschule Rosenheim

2023

Marcel Tilly

Tags

logic circuits boolean algebra computer science digital electronics

Summary

These are lecture notes on Logic Circuits from Prof. Dr. Marcel Tilly, Faculty of Computer Science, Cloud Computing at the Technische Hochschule Rosenheim. The lecture covers boolean algebra, truth tables, switching functions, logic gates, and half and full adders. It also goes through simplification of switching networks and truth tables.

Full Transcript

Modul - IT Systems (IT) Bachelor Programme AAI 02 - Lecture: Logic Circuits Prof. Dr. Marcel Tilly Faculty of Computer Science, Cloud Computing © Technische Hochschule Rosenheim Vers. 31.10.2023 Agenda We will look at the following in this session: Boolean al...

Modul - IT Systems (IT) Bachelor Programme AAI 02 - Lecture: Logic Circuits Prof. Dr. Marcel Tilly Faculty of Computer Science, Cloud Computing © Technische Hochschule Rosenheim Vers. 31.10.2023 Agenda We will look at the following in this session: Boolean algebra Boolean functions Truth tables Switching functions Logic gates Half and full adders © Technische Hochschule Rosenheim 2 / 42 Objectives Students...... know how to use Boolean algebra... can calculate simple logical circuits... can determine a Boolean function for a given logic circuit © Technische Hochschule Rosenheim 3 / 42 What has happened so far? But how do they calculate at all or better asked: How does a computer calculate? © Technische Hochschule Rosenheim 4 / 42 Initial Situation The electronics in a computer work digital. What does digital mean? in digital electronic it works with only two voltage levels that's why computers use '0' and '1' to transmit information a binary system exactly fulfills the requirements of the digital electronic (abstract) '0' and '1' are the complementary or inverse values of each other © Technische Hochschule Rosenheim 5 / 42 Boolean Algebra The basis of the processing of information on the bit level is Boolean algebra. (Origin: George Boole (1815-1864)) Purpose. To determine true and false statements. Boolean algebra operates on the two truth values: true (true) and false (false). Note. Boolean algebra is closely related to logic. Two states false and true → two-valued (binary). These can also be described by 0 and 1. © Technische Hochschule Rosenheim 6 / 42 Electronics In the application (digital electronics), Boolean algebra is also called switching algebra. T (True), H (High), 1 (Bit set) F (False), L (Low), 0 (Bit not set) © Technische Hochschule Rosenheim 7 / 42 Logic Operations In Boolean algebra, one deals with links of truth values by logical operators whose results are in turn truth values. Basic logical operations: connection name notation not a negation ¬a a and b conjunction a ∧ b a or b disjunction a ∨ b if a then b ⇒b implication a an exactly if b equivalence a ⇔ b © Technische Hochschule Rosenheim 8 / 42 Boolean Algebra - Formal Definition An algebra is determined by a set of values, by its operations on this set of values, and by the associated laws of computation. Boolean algebra is based on the binary set {0, 1} and the operations ∨, ∧ and ¬. An operation is composed of the operator that specifies which activity is performed and the operands to which the operation refers. The operations of Boolean algebra are defined as follows: One-place operator ¬, with only one operand (here a): bit a ¬a (negation) 0 1 1 0 © Technische Hochschule Rosenheim 9 / 42 Boolean Algebra - Formal Definition Two-digit operators ∧ and ∨, with two operands (here a and b): bit a bit b a ∧ b (AND) a ∨ b (OR) 1 0 0 1 1 1 1 1 0 0 0 0 0 1 0 1 Note: The AND operation (∧) has priority over the OR operation (∨). So: a ∨ b ∧ c = a ∨ ( b ∧ c ) © Technische Hochschule Rosenheim 10 / 42 Boolean Algebra - Formal Definition In Boolean algebra, the following laws of arithmetic apply: ∨ (OR) ∧ (AND) commutative law a ∨ b = b ∨ a a∧b=b∧a associative law (a∨b)∨c=a∨(b∨c) (a ∧ b) ∧ c = a ∧ (b ∧ c) distributive law a∧(b∨c)=(a∧b)∨(a∧c) a∨(b∧c)=(a∨b)∧(a∨c) absorption law a∨(a∧b)=a a∧(a∨b)=a neutral element 0∨a=a 1∧a=a inverse element a∨¬a = 1 a∧¬a = 0 © Technische Hochschule Rosenheim 11 / 42 Proof How can these laws be proved? Commutative law: a ∨ b = b ∨ a Associative law: ( a ∨ b ) ∨ c = a ∨ ( b ∨ c ) Neutral element: 0 ∨ a = a Let's try it out! © Technische Hochschule Rosenheim 12 / 42 Truth Functions 𝑛 Definition: A function 𝑓 : 𝐵 𝑛 − > 𝐵 is called an n-digit Boolean function. There exist 22 n digit functions. Example : n=1 (one-digit function) , 𝑦 = 𝑓0 (𝑥),... , 𝑓3 (𝑥) Combining all possible assignments of arguments and results in the following 22 = 4 one-digit truth functions a constant 0 identity a negation ¬a constant 1 0 0 0 1 1 1 0 1 0 1 f0 f1 f2 f3 © Technische Hochschule Rosenheim 13 / 42 Truth Functions and for n=2 the 24 = 16 two-digit truth functions: a,b 0,0 0,1 1,0 1,1 notation designation f1 0 0 0 0 0 Constant 0 f2 0 0 0 1 a∧b conjunction (AND) f3 0 0 1 0 a ∧ ¬b negation of implication f4 0 0 1 1 a identity a f5 0 1 0 0 ¬a ∧ b negation of implication f6 0 1 0 1 b identity b © Technische Hochschule Rosenheim 14 / 42 Truth Functions a,b 0,0 0,1 1,0 1,1 Spelling Designation f7 0 1 1 0 ???? antivalence (XOR) f8 0 1 1 1 a∨b disjunction (OR) f9 1 0 0 0 ¬(a∨b) non-or (NOR) f10 1 0 0 1 ???? equivalence f11 1 0 1 0 ¬b negation of b f12 1 0 1 1 ¬(¬a∧b) implication f13 1 1 0 0 ¬a negation of a f14 1 1 0 1 ¬(a∧¬b) implication f15 1 1 1 0 ¬(a∧b) Not-And (NAND) f16 1 1 1 1 1 constant 1 © Technische Hochschule Rosenheim 15 / 42 Truth Functions a,b 0,0 0,1 1,0 1,1 Spelling Designation f7 0 1 1 0 (a∧¬b)∨(¬a∧b) antivalence (XOR) f8 0 1 1 1 a∨b disjunction (OR) f9 1 0 0 0 ¬(a∨b) non-or (NOR) f10 1 0 0 1 (a∧b)∨(¬a∧¬b) equivalence (XNOR) f11 1 0 1 0 ¬b negation of b f12 1 0 1 1 ¬(¬a∧b) implication f13 1 1 0 0 ¬a negation of a f14 1 1 0 1 ¬(a∧¬b) implication f15 1 1 1 0 ¬(a∧b) Not-And (NAND) f16 1 1 1 1 1 constant 1 © Technische Hochschule Rosenheim 16 / 42 Task 1 Two-digit logical operations By combining the operations conjunction, disjunction, and negation, all possible one-digit and two-digit logical operations can be expressed. Example: f1: a ∧ ¬a = 0 f6: b ∧ 1 = b ⇒ f14: a b =¬a b ∨ f16: a∨¬a = 1 Can you prove this? © Technische Hochschule Rosenheim 17 / 42 Laws of Boolean Algebra All rules for calculating with logical operations result from the definition of Boolean algebra: de Morgan's laws Involutive law ¬(¬a) = a ¬(a ∧ b) = ¬a ∨ ¬b ¬(a∨b) = ¬a ∧ ¬b Merge rules Idempotence law ¬a ∨ a ∧ b = ¬a ∨ b a ∨ ¬a ∧ b = a ∨ b a∨a=a a ∧ (¬a ∨ b) = a ∧ b a∧a=a ¬a ∧ (a ∨ b) = ¬a ∧ b © Technische Hochschule Rosenheim 18 / 42 Boolean Function f Previous: 1 input (a) or 2 inputs (a and b) and one output. Generalization: n inputs and 1 output. Note: A boolean function assigns a binary output variable y to n binary input variables 𝑥1 ,.. , 𝑥𝑛. 𝑦 = 𝑓 (𝑥1 , 𝑥2 ,.. 𝑥𝑛 ) with 𝑦 ∈ 0, 1 and 𝑥𝑖 ∈ 0, 1 © Technische Hochschule Rosenheim 19 / 42 Truth Tables Boolean functions can be expressed by truth tables. bit a bit b bit c f(a,b,c) 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 © Technische Hochschule Rosenheim 20 / 42 Boolean Normal Form Purpose: Using the theorem of Boolean normal form, one can construct a Boolean expression from a truth table of the Boolean function. In this case, the switching function is expressed only by the 3 base operators (¬,∨,∧): bit a bit b bit c f(a,b,c) find the solution for 0 0 0 0 f(a,b,c) =... ∨... ∨... 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 © Technische Hochschule Rosenheim 21 / 42 Normal Forms The truth table is a unique definition of a boolean function However, there are infinitely many different realizations using logic gates or descriptions in the form of a boolean expression Normal forms (also canonical forms): Standard representation for a Boolean expression in a unique algebraic form. © Technische Hochschule Rosenheim 22 / 42 Minterm Given a Boolean function 𝑦 = 𝑓 (𝑥𝑛 ,... , 𝑥1 , 𝑥0 ) and the literals 𝑥𝑖. minterm: (𝑥𝑛 ∧ ⋯ ∧ 𝑥2 ∧ 𝑥1 ∧ 𝑥0 ) The minterm evaluates to 1 for exactly one particular configuration of the variable 𝑥𝑖 and 0 otherwise More precisely, the minterm evaluates to 1 if for all negated variables 𝑥𝑖 = 0 and all non-negated variables 𝑥𝑖 = 1. Example of a minterm: 𝑦 = ¬𝑥2 ∧ ¬𝑥1 ∧ 𝑥0 © Technische Hochschule Rosenheim 23 / 42 Maxterm Given a Boolean function 𝑦 = 𝑓 (𝑥𝑛 ,... , 𝑥1 , 𝑥0 ) and the literals 𝑥𝑖. maxterm: (𝑥𝑛 ∨ ⋯ ∨ 𝑥2 ∨ 𝑥1 ∨ 𝑥0 ) The maxterm evaluates to 1 for exactly one particular configuration of the variable 𝑥𝑖 and 0 otherwise. More precisely: The maxterm evaluates to 0 if for all negated variables 𝑥𝑖 = 1 and all not negated 𝑥𝑖 = 0. Example of a minterm: 𝑦 = ¬𝑥2 ∨ ¬𝑥1 ∨ 𝑥0 © Technische Hochschule Rosenheim 24 / 42 Disjunctive Normal Form A disjunctive normal form (DNF) is an OR-operation ("or", ∨) of minterms all configurations of minterms in which 𝑦 = 𝑓 (𝑥𝑛 ,... , 𝑥1 , 𝑥0 ) = 1 must occur, and all literals are connected by conjunctions ∧ ("and"). Example: f(a,b,c)= (a ∧ b ∧ c) ∨ (¬a ∧ b ∧ c) ∨ (a ∧ ¬b ∧ c) ∨... (¬a ∧ b ∧ ¬c) © Technische Hochschule Rosenheim 25 / 42 Start from the value table (disjunction) each line of the value table corresponds to a full conjunction terms with function value "0" do not contribute to the function result a b f(a,b) form full conjunction for rows with function value "1 0 0 0 none for f(a,b) = 0 0 1 1 line 2: ¬a ∧ b 1 0 1 line 3: a ∧ ¬b 1 1 0 Result: f(a,b)= (¬a ∧ b) v (a ∧ ¬b) © Technische Hochschule Rosenheim 26 / 42 Conjunctive Normal Form A conjunctive normal form (CNF) is an AND-connection of maxterms. All configurations of maxterms in which 𝑦 = 𝑓 (𝑥𝑛 ,... , 𝑥1 , 𝑥0 ) = 0 must occur a b f(a,b) form full conjunction for rows with function value "0 0 0 0 none for f(a,b) = 1 0 1 1 line 1: a v b 1 0 1 line 4: ¬a v ¬b 1 1 0 Result: f(a,b)= (a v b) ∧ (¬a v ¬b) © Technische Hochschule Rosenheim 27 / 42 Example So what does this mean for our example? Disjunction or conjunction? bit a bit b bit c f(a,b,c) f(a,b,c) = 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 © Technische Hochschule Rosenheim 28 / 42 Example So what does this mean for our example? Disjunction or conjunction? bit a bit b bit c f(a,b,c) f(a,b,c) = (a ∧ b ∧ c) ∨ (a ∧ ¬b ∧ ¬c) ∨ (¬a ∧ ¬b ∧ c) 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 © Technische Hochschule Rosenheim 29 / 42 Shannon's Theorem Definition The negation of a logical formula composed only of the three basic operations (¬,∨,∧), variable names ( a,b,..), and constants (0, 1) is obtained by replacing all variables and constants with their complement (1 → 0, 0 → 1, x → ¬x) and interchanging the operations ∧ and ∨. It is important to note that one must completely parenthesize before substitution and interchange, and the parentheses are preserved. It is valid: ¬(f(a,b,..,∧,∨,0,1)) = f(¬a,¬b,..,∨,∧,1,0) © Technische Hochschule Rosenheim 30 / 42 Switching Functions Previously: Boolean functions, i.e. only 1 output. Switching functions uniquely assign a binary sequence at the output to a binary sequence at the input: 𝑓𝑠 : 0, 1𝑛 → 0, 1𝑚 © Technische Hochschule Rosenheim 31 / 42 Logical Gates Switching networks and switching functions are built up from a few basic components or logical gates. Common logical gates are (American symbols and DIN 40700 [since 1976]): © Technische Hochschule Rosenheim 32 / 42 Logical Gates - Example Any switching functions and switching networks can be composed of logical gates. Example: y = a ∧ ( b ∨ c) What does this circuit do? © Technische Hochschule Rosenheim 33 / 42 Logical Gates - Example Truth table bit a bit b bit c b ∨ c a ∧ ( b ∨ c) 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 © Technische Hochschule Rosenheim 34 / 42 Truth Table → Boolean Expression In practice, switching functions(networks) are obtained by: Representing desired behavior as a truth table Constructing the switching functions from the truth table (cf. Boolean normal form). Using the laws of Boolean algebra to transform and simplify the switching functions. © Technische Hochschule Rosenheim 35 / 42 Simplification of Switching Networks Example: Distributive law: (a ∧ b) ∨ ( a ∧ c) = a ∧ (b ∨ c) © Technische Hochschule Rosenheim 36 / 42 Decoder The decoder has n-inputs and 2𝑛 = 𝑚 outputs, where for each input combination there is exactly one output which is true. 2-to-4 decoder: e1 e2 ¬e1 ¬e2 a1 a2 a3 a4 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0 0 1 Example: From BCD (Binaray Coded Decimal) to Decimal (00 -> 0, 01 -> 1, 10 -> 2, 11 -> 3) © Technische Hochschule Rosenheim 37 / 42 Encoder The inverse function to the decoder is the encoder. From 2𝑛 inputs, exactly one of which is true, it produces an n-bit output. 4-to-2 Encoder: i1 i2 i3 i4 a1 a2 What could such an encoder look like? - Exercise! 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 1 © Technische Hochschule Rosenheim 38 / 42 Half Adder A half adder (HA) is a switching network that adds two single-digit dual numbers without considering previous carries (carry) and returns the sum (S) and possibly a carry (C). The resulting carry is generated separately. The truth table of a half-adder: x_i y_i s_i c_i 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 © Technische Hochschule Rosenheim 39 / 42 Full Adder The full adder differs from the half adder in that the previous carry is taken into account. Truth table of a full adder: x-i y_i c_i s_i c_i 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 © Technische Hochschule Rosenheim 40 / 42 Full Adder With the help of the full adder two n-digit dual numbers can be added to the computer. For this one uses a chain of n full adders. - At the first addition (i=0) the incoming carry (𝑐− 1) is set to 0. Other types of calculations can also be realized with the full adder. The subtraction can be traced back to addition with the two's complement. With the help of additional circuits (shift registers), it is also possible to multiply and divide with adder circuits. © Technische Hochschule Rosenheim 41 / 42 Summary We looked at the following in detail: Boolean algebra Boolean functions Switching functions Logic gates Half and full adders © Technische Hochschule Rosenheim 42 / 42