Lecture 6: Logic Gates - Computer Science - 2024-2023
Document Details
Uploaded by CherishedFable5623
الجامعة الأسمرية الإسلامية
2024
يمن مختار ارميص,صالح الهادي جوان,مفتاح محمد الكزاغلي,عبدالله مسعود الارقط
Tags
Summary
These lecture notes cover logic gates, including AND, OR, and NOT gates. They explain basic concepts, truth tables, and logical functions. The material is part of a computer science course offered in the 2024-2023 academic year at the جامعة األسمرية اإلسالمية.
Full Transcript
المحاضرة السادسة الجامعة األسمرية اإلسالمية كلية العلوم زليتن القسم العلوم الطبية (الفصل االول للسنة التمهيدية ) علوم الحاسـوب د.ايمن مختار ارميص أ.صالح الهادي جوان أ.مفتاح محمد الكزاغلي أ.عبدهللا مسعود االرقط ` ال...
المحاضرة السادسة الجامعة األسمرية اإلسالمية كلية العلوم زليتن القسم العلوم الطبية (الفصل االول للسنة التمهيدية ) علوم الحاسـوب د.ايمن مختار ارميص أ.صالح الهادي جوان أ.مفتاح محمد الكزاغلي أ.عبدهللا مسعود االرقط ` العام الجامعـي 2024—2023م 1 Logic Gates Basic Concepts 1-) Logic Gates(. Logic gates are an essential component of any digital system, as they are in the form of a simple electronic circuit found in computers represented by the binary system: (Binary Number) based on 1 and 0. Logic gates are divided into two main types; Basic logic gates (OR, AND, NOT) and derived logic gates (XNOR, XOR, NOR, NAND). 2- ( Logic Function) It is a relationship between a set of values representing the income, in order to obtain the output. The main difference between the Boolean function and the traditional mathematical function is that all the input and output values of the Boolean function will be Boolean values, i.e. (0, 1).. 3- (Table Truth) The truth table is the arrangement of the possible input values of a logical function with its possible output values. If we take the simplest possible logical function, which is the function of negation, we can describe the output of the function as the inverse of any input. If the input is “1”, the output will be “0”, and if the input is “0”, the output will be “1”. The following truth table: input output 1 0 0 1 2 If we take a Boolean function: it has two inputs (at least) like the Boolean function, we will do the following: We will call the first input X and the second input Y and the output is the logical product of X and Y Since we have two inputs, 2 the number of possible outputs is 2 i.e. 4 possible values for the output. The order of this characterization within the truth table would be as follows: X Y F=X.Y 0 0 0 0 1 0 1 0 0 1 1 1 The last table represents the truth table of the AND function, and in order to write the truth table of any Boolean function. (Whether it is a basic function or a composite function), what we need to know is The number of logical input variables Boolean Function Equation It is important to know that logical functions are not always simple functions, and the basic logical functions that we reviewed earlier are the basis of logical operations, as it is possible to write a logical function equation that includes several various logical operations at the same time. In this case the truth table will be larger. 3 Anyway, we should always remember which output of any logical combination will be either “0” or “1” When talking about any logical gate, we should talk about the following things: Logic gate code. The logical function of the logical gate. The truth table of the logic gate. Logic gate architecture. We will now review the gates in full with their parameters : Basic logic gates 1- The AND gate : The AND gate is one of the basic gates that are included in the construction of most logical functions. The AND gate has two or more inputs and one output. This gate leads to what is called Logical Multiplication. This gate can be represented by a number of keys connected in series. In an electrical circuit where the switches (B,A) represent two variables (Two Binary Variables), the value of any variable of them is equal to (0) when the switch is open and equal to (1) when the switch is closed. How to build a truth table: You determine the number of input possibilities for the gate by using the relation: 1- The number of possibilities, where n is the number of entrances to the gate. If we have, for example, three entrances, then the number of possible output cases is 8. 2-At each input state, we specify the corresponding output state. 4 The following table shows the truth table for this gate A B OUTPUT(Y) 1 0 0 0 1 0 0 0 0 1 1 1 Therefore, from the above, the outputs of the basic logical (AND) gate are as follows: It gives an output of 1 when the value of the two inputs is only 1. It gives an output value of 0 when the value of one or both of the inputs is 0, and the following figure shows the logic diagram of the gate. (AND) 2- The OR gate The OR gate is one of the basic gates used in the construction of most logical functions. It has two or more inputs and one output, and this gate performs what is called Logical Addition, and this gate can be represented by a number of keys connected in parallel in an electrical circuit, where the two keys (B, A) represent two binary variables (Two Binary Variables.) As in the AND gate, the two keys B and A, the value of any variable of them is equal to (0) when the key is open and equal to (1) when the key is closed. (Closed). The following table shows the truth table for this portal: A B OUTPUT(Y) 0 0 0 0 1 1 1 0 1 1 1 1 5 We note from the table that the output is equal to (1), i.e. real when either or both of the two inputs are at level (1), and that the output is not real, i.e. (0) when all inputs are at level (0). The following figure shows the logical diagram of a gate. (OR) 3-The NOT a gate or ( inverter gate ) The inverter or NOT gate performs a process called inversion or completion, and the inverter considers the logical level of the input to its inverse, so if the input is (1) it changes it in the output to (0) and if the input is (0) it changes it to (1) and thus It has one exit and one income. The following table shows the truth table for this portal: INPUT(A) OUTPUT(Y) 0 1 1 0 The logical code used for the inverter gate is: Uses of logic gates The benefits of logic gates are innumerable, as they are involved in many technological industries, the most prominent of which are the following: 1- Building processors for electronic devices. 2 -Computer programming. 3-Manufacture of medical devices and equipment 4-Manufacture of digital watches and timer 6 Logic gates priorities There are special priorities that must be followed when finding the output of logical gates for sentences that contain more than one logical gate. The following is the order of priorities from highest to lowest: 1- The brackets. ( ). 2-NOT 3-AND 4-OR. 5- If the priorities are equal, you must start from the left of the equation to the right of it. Examples of priority logic gates There are many examples of logic gate priority statements, and to find the output you must consider the priorities to get the correct result. Example 1 a Find the result of the following operation 1 OR 0 AND 1. The solution Determine the priority, the priority is given to the AND gate since the statement is devoid of parentheses. Find the result of the statement 0 AND 1 = 0 Find the product of the statement 1OR 0 Output = 1. Example 2 Find the result of the following operation : NOT 0 AND (NOT 1 OR 0 )The solution Find the result inside the parentheses, provided that the NOT gate is given priority, then the OR gate. Finding an output outside the brackets, provided that the NOT gate is given priority then AND. NOT 0 AND (0 OR 0) NOT 0 AND 0 1 AND 0 Output = 0. 7 Find the value of (Q) if (A=0, B=1, C=1) Find the value of (Q) if (A=0, B=1, C=1) Find the value of (C, D , E,Z ) if (A=0, B=1) 8 Find the value of (Z ) if (A= 1, B= 0) 9