Download presentation
Presentation is loading. Please wait.
Published byAusten Turner Modified over 6 years ago
1
3 – Boolean Logic and Logic Gates 4 – Binary Numbers
CS 1 Introduction to Computers and Computer Technology Rick Graziani Fall 2017
2
BIT – BInary digiT ON OFF
Bit (Binary Digit) = Basic unit of information, representing one of two discrete states. The smallest unit of information within the computer. The only thing a computer understands. Abbreviation: b Bit has one of two values: 0 (off) or 1 (on) 0 (False) or 1 (True) ON OFF Rick Graziani
3
Bits The boxes illustrate a position where magnetism may be set and sensed; pluses (red) indicate magnetism of positive polarity (1 bit), interpreted as “present” and minuses (blue) (0 bit). 1 1 1 1 1 1 1 1 Two patterns are known as the state of the bit. For example, magnetic encoding of information on tapes, floppy disks, and hard disks are done with positive or negative polarity. Rick Graziani
4
Bits Bits are really only symbols.
Used to display the one of two different, discrete states. Bits are used as: Storing data Numbers Text characters Images Sound Etc. Processing data Rick Graziani
5
Boolean Operations Integrated Circuits (microchips) are used to store and manipulate (process) bits. This is done using Boolean operations (in honor of mathematician George Boole, ). Boolean Operation: An operation that manipulates one or more true/false values Specific operations AND OR XOR (exclusive or) NOT Using Truth Tables we can uses different sets of logic operations to store, add, subtract, and more complicated operations with bit. Rick Graziani
6
Boolean Algebra and logical expressions (Addendum)
Boolean algebra (due to George Boole) - The mathematics of digital logic Useful in dealing with binary system of numbers. Used in the analysis and synthesis of logical expressions. Logical expressions – Expressions constructed using logical-variables and operators. Result is: True or False Boolean algebra – In mathematics a variable uses one of the two possible values: 1 or 0 May also be represented as: Truth or Falsehood of a statement On or Off states of a switch High (5V) or low (0V) of a voltage level Rick Graziani
7
Used in electronics (Addendum)
Electrical circuits are designed to represent logical expressions Known as logic circuits. Used to make important logical decisions in household appliances, computers, communication devices, traffic signals and microprocessors. Three basic logic operations as listed below: OR operation AND operation NOT operation Rick Graziani
8
Logic gates A logic gate is an electronic circuit/device which makes the logical decisions based on these operations. Logic gates have: one or more inputs only one output The output is active only for certain input combinations. Logic gates are the building blocks of any digital circuit. Rick Graziani
9
Boolean Operations - AND
TRUE TRUE AND = TRUE Truth tables (simple ones) AND operation Both input values must be TRUE for output to be TRUE Kermit is a frog AND Miss Piggy is an actress Inputs to AND operation represent truth of falseness of the compound statement. Rick Graziani
10
Boolean Operations Gate: A device that computes a Boolean operation
A device that produces the output of a Boolean operation when given the operation’s input values. Gates can be: Gears Relays Optic devices Electronic circuits (microchips) Rick Graziani
11
Boolean Operations – AND Gate
Truth Table Inputs Output 1 1 1 0 = FALSE 1 = TRUE AND operation Both input values must be TRUE for output to be TRUE 1 1 1 Rick Graziani
12
Off (False) Off (False) On (True)
To build an AND gate: Two transistors connected together Two inputs (transistors A and B) and one output Transistor A: Off (False) Transistor B: On (True) Output: Off (False) Rick Graziani
13
On (True) On (True) On (True) Transistor A: On (True)
Transistor B: On (True) Output: On (True) Rick Graziani
14
Boolean Operations - OR
TRUE OR True = TRUE Truth tables (simple ones) OR operation Only one input values must be TRUE for output to be TRUE In Rick likes to surf OR Rick likes to go dancing. Taking both courses will also TRUE. Rick Graziani
15
Boolean Operations – OR Gate
Truth Table Inputs Output 1 1 1 1 1 1 0 = FALSE 1 = TRUE OR operation At least one input value must be TRUE for output to be TRUE 1 1 1 1 Rick Graziani
16
Two inputs (transistors A and B) and one output
Transistor A: Off (False) Transistor B: Off (False) Output: Off (False) Rick Graziani
17
Two inputs (transistors A and B) and one output
Transistor A: Off (False) Transistor B: On (True) Output: On (True) Rick Graziani
18
Two inputs (transistors A and B) and one output
Transistor A: On (True) Transistor B: On (True) Output: On (True) Rick Graziani
19
Boolean Operations - XOR
TRUE XOR False = TRUE Truth tables (simple ones) XOR operation One and ONLY one input value can be TRUE for output to be TRUE At noon Rick is going to surf the Hook XOR surf Liquor Stores (this is a surf spot) Both cannot be true, as I cannot surf both spots at the same time. Rick Graziani
20
Boolean Operations – XOR Gate
Truth Table Inputs Output 1 1 1 1 1 1 0 = FALSE 1 = TRUE XOR operation Only one input value is TRUE for output to be TRUE 1 1 Rick Graziani
21
Rick Graziani graziani@cabrillo.edu
22
Rick Graziani graziani@cabrillo.edu
23
Rick Graziani graziani@cabrillo.edu
24
Boolean Operations – NOT Gate
Truth Table 1 Inputs Output 1 1 1 0 = FALSE 1 = TRUE NOT operation Only one input Opposite of input NOT FALSE = TRUE NOT TRUE = FALSE Rick Graziani
25
Current To build an NOT gate: One transistor One input and one output
Transistor A: On (True) Current flows to ground wire and none to output, so output is Off (False) Rick Graziani
26
Current Transistor A: Off (False)
Current flows to ground wire and none to output, so output is Off (False) Rick Graziani
27
Rick Graziani
28
Another way to write it…
0 = FALSE; 1 = TRUE Rick Graziani
29
Binary Numbers
30
Binary = Of two states Rick Graziani
31
Binary Math Rick Graziani
32
Base 10 (Decimal) Number System
Digits (10): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Number of: 10,000’s 1,000’s 100’s 10’s 1’s 1 2 3 9 Rick Graziani
33
Base 10 (Decimal) Number System
Digits (10): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Number of: 10,000’s 1,000’s 100’s 10’s 1’s Rick Graziani
34
Rick’s Number System Rules
All digits start with 0 A Base-n number system has n number of digits: Decimal: Base-10 has 10 digits Binary: Base-2 has 2 digits Hexadecimal: Base-16 has 16 digits The first column is always the number of 1’s Each of the following columns is n times the previous column (n = Base-n) Base 10: 10, , Base 2: Base 16: 65, , Rick Graziani
35
Counting in Decimal (0,1,2,3,4,5,6,7,8,9) 1,000’s 100’s 10’s 1’s 1 2 3
1 2 3 ... 9 1 0 1 1 1 8 1 9 2 0 2 1 2 2 1,000’s 100’s 10’s 1’s . . . 2 9 3 0 3 1 ... 9 9 Rick Graziani
36
Counting in Binary (0, 1) 8’s 4’s 2’s 1’s 1 1 0 1 1 Dec 8’s 4’s 2’s 1’s Dec 9 1 10 2 3 11 4 12 5 6 13 7 14 8 15 Rick Graziani
37
Binary Math (more later)
> 1000 …… Rick Graziani
38
Base 2 (Binary) Number System
Digits (2): 0, 1 Number of: 128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s Dec. 17 70 130 255 Rick Graziani
39
Base 2 (Binary) Number System
Digits (2): 0, 1 Number of: 128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s Dec. Rick Graziani
40
Converting between Decimal and Binary
Digits (2): 0, 1 Number of: 128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s Dec. 172 192 Rick Graziani
41
Converting between Decimal and Binary
Digits (2): 0, 1 Number of: 128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s Dec. Rick Graziani
42
0 1 Computers do Binary Bits have two values: OFF and ON
0 1 Bits have two values: OFF and ON The Binary number system (Base-2) can represent OFF and ON very well since it has two values, 0 and 1 0 = OFF 1 = ON Understanding Binary to Decimal conversion is critical in computer science, computer networking, digital media, etc. Rick Graziani
43
Rick’s Program Rick Graziani
44
Rick’s Program Rick Graziani
45
Rick’s Program Rick Graziani
46
Decimal Math - Addition
10,000’s 1,000’s 100’s 10’s 1’s 1 1 1 3 3 1 5 Rick Graziani
47
Binary Math - Addition 1 1 1 1 1 1 1 1 Double check using Decimal.
64’s 32’s 16’s 8’s 4’s 2’s 1’s Dec 1 1 1 1 58 + 27 ----- 1 1 1 1 85 Double check using Decimal. Rick Graziani
48
Half Adder Gate – Adding two bits
XOR Inputs: A, B S = Sum C = Carry AND A + B = 2’s 1’s Rick Graziani
49
Half Adder Gate – Adding two bits
XOR Inputs: A, B S = Sum C = Carry AND C S + 0 ---- A + B = 2’s 1’s = Rick Graziani
50
Half Adder Gate – Adding two bits
XOR Inputs: A, B S = Sum C = Carry 1 1 AND C S + 1 ---- A + B = 2’s 1’s = 1 1 Rick Graziani
51
Half Adder Gate – Adding two bits
XOR 1 Inputs: A, B S = Sum C = Carry 1 AND C S 1 + 0 ---- A + B = 2’s 1’s = 1 1 Rick Graziani
52
Half Adder Gate – Adding two bits
XOR 1 Inputs: A, B S = Sum C = Carry 1 1 AND C S 1 + 1 ---- A + B = 2’s 1’s = 1 1 0 Rick Graziani
53
Marble Adding Machine Rick Graziani
54
Rick Graziani graziani@cabrillo.edu
55
Rick Graziani graziani@cabrillo.edu
56
Rick Graziani graziani@cabrillo.edu
57
Text
58
Digitizing Text Earliest uses of PandA (Presence and Absence) was to digitize text (keyboard characters). We will look at digitizing images and video later. Assigning Symbols in United States: 26 upper case letters 26 lower case letters 10 numerals 20 punctuation characters 10 typical arithmetic characters 3 non-printable characters (enter, tab, backspace) 95 symbols needed Rick Graziani
59
ASCII-7 In the early days, a 7 bit code was used, with 128 combinations of 0’s and 1’s, enough for a typical keyboard. The standard was developed by ASCII (American Standard Code for Information Interchange) Each group of 7 bits was mapped to a single keyboard character. 0 = 1 = 2 = 3 = … 127 = Rick Graziani
60
Byte Byte = A collection of bits (usually 7 or 8 bits) which represents a character, a number, or other information. More common: 8 bits = 1 byte Abbreviation: B Rick Graziani
61
Bytes 1 byte (B) Kilobyte (KB) = 1,024 bytes (210)
“one thousand bytes” 1,024 = 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 Megabyte (MB) = 1,048,576 bytes (220) “one million bytes” Gigabyte (GB) = 1,073,741,824 bytes (230) “one billion bytes” Rick Graziani
62
Wikipedia Rick Graziani
63
ASCII-8 IBM later extended the standard, using 8 bits per byte.
This was known as Extended ASCII or ASCII-8 This gave 256 unique combinations of 0’s and 1’s. 0 = 1 = 2 = 3 = … 255 = 1 Rick Graziani
64
ASCII-8 Rick Graziani
65
Try it! 1 Write out Cabrillo College (Upper and Lower case) in bits (binary) using the chart above. … C a Rick Graziani
66
The answer! 1 C a b r i l l o space C o l l e g e Rick Graziani
67
Unicode Although ASCII works fine for English, many other languages need more than 256 characters, including numbers and punctuation. Unicode uses a 16 bit representation, with 65,536 possible symbols. Unicode can handle all languages. Rick Graziani
68
3 – Boolean Logic and Logic Gates 4 – Binary Numbers
CS 1 Introduction to Computers and Computer Technology Rick Graziani
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.