0% found this document useful (0 votes)
12 views

Computer Science Topic 2.1.11-2.1.13

Uploaded by

rohocarro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Computer Science Topic 2.1.11-2.1.13

Uploaded by

rohocarro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

IBDP Computer Science Topic 2: Simple logic gates.

Simple logic gates


Topic- 2.1.11 Boolean operators: Define the Boolean operators: AND, OR, NOT,
NAND, NOR and XOR.

Assessment Objective 1: Demonstrating knowledge and understanding relevant facts and


concepts and computer science terminology.
Students will be able to:
• Define the Boolean operators: AND, OR, NOT, NAND, NOR and XOR.
• Develop truth tables for the Boolean operators: AND, OR, NOT, NAND, NOR and XOR.

AND gate:
The AND gate is an essential building block of digital logic. It is classified as a two-input
gate, meaning it accepts two binary input signals and produces a single output based on
a predefined logic rule. The key feature of the AND gate is that its output is only active (1
or "True") when both input signals are active. This implies that the output is "True" only
if both inputs are simultaneously active.

Here's how the AND gate operates:

If both input A and input B are set to '0', the AND gate's output will be '0'.

When one input is '0' and the other is '1', the AND gate's output remains '0'.

The AND gate produces an output of '1' only when both inputs A and B are '1'.

Visually, the AND gate is represented in logic circuit diagrams using symbols for inputs
(usually 'A' and 'B') and a single line for the output. The AND symbol (∧) is used to depict
the logical operation being performed.

Figure 1: AND gate

Refer Core Computer Science Textbook page 103-104

Topic-2 notes 6 hours Page 1 of 12.


OR gate:

The OR gate holds a pivotal position within digital electronics, serving as a foundational
logic gate that amalgamates and assesses binary inputs. Categorized as a gate with two
inputs, the OR gate processes a pair of input signals, each manifesting as a binary value
(0 or 1). Its role involves generating a sole output signal, determined by a specific logical
criterion. What sets the OR gate apart is its innate ability to yield an output of '1' (True)
whenever at least one of the input signals assumes the value '1'. In essence, it
encompasses the notion of inclusiveness, marking the presence of '1' in the inputs as
significant.

The OR gate's operation follows these principles: If both input A and input B are
configured as '0', the resulting output from the OR gate is '0'.

When one input assumes the value '1' while the other is '0', the OR gate's output remains
'1', symbolizing the existence of '1'.

The OR gate exclusively yields an output of '1' when both inputs A and B stand as '0',
signaling the absence of '1' in either input.

A visual representation of the OR gate's behavior can be grasped through a logic circuit
diagram. In this diagram, the inputs are iconized (typically represented as 'A' and 'B'),
and the output is depicted linearly. The symbol (∨) assumes the role of representing the
logical OR operation within the circuit diagram.

Figure 2: OR gate

Refer Core Computer Science Textbook page 104-105.

Topic-2 notes 6 hours Page 2 of 12.


NOT gate:

The NOT gate, an elemental component in digital logic design, plays a pivotal role in
transforming input signals. With a singular input and a corresponding output, it carries
out a fundamental operation: inversion. When it receives an input signal, it generates the
logical opposite as output. If the input signal is at a logical high state (1), the NOT gate
produces a low output (0), and conversely, when the input is low (0), the output becomes
high (1). This inversion process is symbolically represented as follows: if 'A' is the input
and 'Q' is the output, then Q = NOT(A).

Figure 3: NOT gate

Refer Core Computer Science Textbook page 105.

NAND gate:

The NAND gate, often referred to as the universal gate, exhibits exceptional versatility in
digital logic circuitry. It's essentially a combination of the NOT and AND gates, embodying
the principles of negation and conjunction. Comprising multiple inputs and a single
output, the NAND gate generates an inverted AND operation outcome.

When both of its inputs are at a logical high state (1), the NAND gate produces a low
output (0). In all other scenarios, it generates a high output (1). This fundamental gate
holds remarkable significance as it can be employed to construct various logical
functions, offering a vital tool for designing complex digital systems.

Topic-2 notes 6 hours Page 3 of 12.


Figure 4: NAND gate

Refer Core Computer Science Textbook page 106.

NOR gate:

Much like the NAND gate, the NOR gate is a universal gate with multifaceted capabilities.
It combines elements of the NOT and OR gates, embodying both negation and disjunction.
With multiple inputs and a sole output, it generates the inverse of the OR operation
outcome.

In the context of the NOR gate, a low output (0) is produced when any of its inputs are at
a high state (1). Only when all inputs are at a low state (0) does the NOR gate generate a
high output (1). This gate's versatility is evident in its ability to facilitate the construction
of diverse logical functions, making it a cornerstone of digital logic design.

Figure 5: NOR gate

Refer Core Computer Science Textbook page 107.

Topic-2 notes 6 hours Page 4 of 12.


XOR gate:

The XOR gate, signifying exclusive OR, stands as a cornerstone in digital logic due to its
ability to process multiple inputs and deliver outcomes of logical significance. Operating
with two or more inputs, it yields an output based on the parity of true inputs. When the
number of true inputs is odd, the XOR gate produces a true output (1); when the count is
even, it generates a false output (0). This gate's importance lies in its capacity to discern
input variations.

For instance, consider two inputs, 'A' and 'B'. If 'A' is true (1) and 'B' is false (0), or if 'A' is
false (0) and 'B' is true (1), the XOR gate outputs true (1). Conversely, if both 'A' and 'B'
are either true (1) or false (0), the XOR gate produces a false output (0). Mathematically,
this gate encapsulates the concept of "one or the other, but not both."

Figure 6: XOR gate

Refer Core Computer Science Textbook page 107.

Various symbols for the logic gates:

Refer Core Computer Science Textbook page 108.

Topic-2 notes 6 hours Page 5 of 12.


2.1.12 Truth tables using Boolean Operators: Construct truth tables using the
above operators.

Assessment Objective 3: Construct, analyse, evaluate and formulate appropriate techniques


within a specified solution.
Students will be able to:
• Convert sentences to Boolean expressions.
• Develop and evaluate Boolean expressions using truth tables.
• Develop truth tables by combining the various Boolean operators: AND, OR, NOT, XOR,
NAND NOR.

A truth table is a systematic representation of the possible outcomes of a logical


expression or a combination of inputs in terms of true (1) or false (0) values. It serves as
a visual tool to showcase the relationship between various input combinations and their
corresponding outputs in logical operations. Truth tables are commonly used in the fields
of logic, mathematics, computer science, and electronics to analyze and understand the
behavior of logical expressions, functions, and circuits.

In a truth table, each row corresponds to a specific combination of input values, and the
corresponding output value is displayed in a separate column. The number of rows in a
truth table depends on the number of input variables involved in the expression. For a
truth table with 'n' input variables, there will be 2^n rows, covering all possible binary
combinations of inputs.

One input Truth table

Input Output
0 (False) 0 (False)
1 (True) 1 (True)

Topic-2 notes 6 hours Page 6 of 12.


Two inputs Truth table

Inputs
Input 1 Input 2
0 0
0 1
1 0
1 1

Three inputs Truth table

Inputs
Input 1 Input 2 Input 3
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Two inputs Truth table for AND, OR, NAND, NOR and XOR.
Inputs Output
Input 1 Input 2 A AND B A OR B A NAND B A NOR B A XOR B
(A) (B)
0 0 0 0 1 1 0
0 1 0 1 1 0 1
1 0 0 1 1 0 1
1 1 1 1 0 0 0

Topic-2 notes 6 hours Page 7 of 12.


Three inputs Truth table for AND, OR, and XOR.

Inputs Output
Input 1 Input 2 Input 3 A AND B AND C A OR B OR C A XOR B XOR C
(A) (B) (C)
0 0 0 0 0 0
0 0 1 0 1 1
0 1 0 0 1 1
0 1 1 0 1 0
1 0 0 0 1 1
1 0 1 0 1 0
1 1 0 0 1 0
1 1 1 1 1 1

Three inputs Truth table for NAND, NOR

Inputs Output
Input 1 Input 2 Input 3 A NAND B NAND C A NOR B NOR
(A) (B) (C) C
0 0 0 1 1
0 0 1 1 0
0 1 0 1 0
0 1 1 1 0
1 0 0 1 0
1 0 1 1 0
1 1 0 1 0
1 1 1 0 0
Refer Core Computer Science Textbook page 109-116.

2.1.13 Logic diagram using Boolean Operators: Construct a logic diagram using
AND, OR, NOT, NAND, NOR and XOR gates.

A logic diagram is a graphical representation of a logical expression or a circuit that uses


logic gates to perform specific logical operations on input signals. Logic diagrams are a
visual way to illustrate how various inputs are combined using logic operators to produce

Topic-2 notes 6 hours Page 8 of 12.


an output result. Logic diagrams are commonly used in fields like digital electronics,
computer science, and formal logic to design and analyze logical systems and circuits.

Logic diagrams use standardized symbols to represent different logic gates and their
connections. Here's an explanation of some common logic operators and their
representations in logic diagrams:

AND Gate: The AND gate takes multiple inputs and produces a single output that is true
(1) only if all inputs are true (1). In a logic diagram, the AND gate is represented as a
rectangle with multiple inputs on the left side and a single output on the right side.

OR Gate: The OR gate takes multiple inputs and produces a single output that is true (1)
if at least one input is true (1). In a logic diagram, the OR gate is also represented as a
rectangle with multiple inputs on the left side and a single output on the right side.

NOT Gate: The NOT gate takes a single input and produces the logical opposite of that
input as the output. In a logic diagram, the NOT gate is represented as a triangle with the
input on one side and the output on the other side.

XOR Gate: The XOR gate (exclusive OR) takes two inputs and produces a true (1) output
if exactly one of the inputs is true (1), but not both. In a logic diagram, the XOR gate is
often represented using a plus sign (+) inside a circle.

NAND Gate: The NAND gate (NOT-AND) is the negation of the AND operation. It produces
the opposite output of the AND gate. In a logic diagram, the NAND gate is represented as
an AND gate with a circle at its output.

NOR Gate: The NOR gate (NOT-OR) is the negation of the OR operation. It produces the
opposite output of the OR gate. In a logic diagram, the NOR gate is represented as an OR
gate with a circle at its output.

Example: 1

A AND B OR C

Topic-2 notes 6 hours Page 9 of 12.


Example: 2

Refer to the examples given in the Core Computer Science Textbook page 119-121.

Topic-2 notes 6 hours Page 10 of 12.


Application based questions:

1. If John has finished his work and the weather is good, he will go for a walk.
Express this using logical operators and draw truth table and logic diagram
for the same.
2. If the lights are off and the TV is on, the electricity bill will be higher. Express
this using logical operators and draw truth table and logic diagram for the
same.
3. Sarah will only buy a new phone if it's on sale or if her old phone is not
working. Express this using logical operators and draw truth table and logic
diagram for the same.
4. If it's not raining and the ground is dry, the soccer match will take place.
Express this using logical operators and draw truth table and logic diagram
for the same.
5. If it's either sunny or rainy, but not both, Amy will go for a walk. Express this
using logical operators and draw truth table and logic diagram for the same.
6. If neither the TV is on nor the radio is playing, the room will be quiet. Express
this using logical operators and draw truth table and logic diagram for the
same.
7. Lily will go shopping if she has either a discount coupon or enough cash, but
not both. Express this using logical operators and draw truth table and logic
diagram for the same.
8. If neither the light is red nor the pedestrian signal is on, it's safe to cross the
road. Express this using logical operators and draw truth table and logic
diagram for the same.
9. Sarah will attend the party if it's either her best friend's birthday or a costume
party. Express this using logical operators and draw truth table and logic
diagram for the same.
10. If the movie is action-packed or has great special effects, Maya will watch it.
Express this using logical operators and draw truth table and logic diagram
for the same.

Topic-2 notes 6 hours Page 11 of 12.


Citations:

http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/and.html
https://computerengineeringforbabies.com/blogs/engineering/or-gate
https://www.build-electronic-circuits.com/not-gate/
https://stackoverflow.com/questions/59480912/how-is-the-nand-gate-implemented-
conceptually
http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/nor.html
https://www.allaboutcircuits.com/textbook/digital/chpt-7/the-exclusive-or-function-
xor/
https://www.hobbyprojects.com/combination_logic/boolean_expressions.html

Topic-2 notes 6 hours Page 12 of 12.

You might also like