1 Survey of Computer Science CSCI 110, Spring 2011 Lecture 16 Digital Circuits, binary Numbers.
-
Upload
gavin-shaw -
Category
Documents
-
view
213 -
download
1
Transcript of 1 Survey of Computer Science CSCI 110, Spring 2011 Lecture 16 Digital Circuits, binary Numbers.
1
Survey of Computer Science
CSCI 110, Spring 2011Lecture 16
Digital Circuits, binary Numbers
2
Church-Markov-Turing Thesis
Any non-trivial computer language is apparently capable of computing no more and no fewer functions than all other non-trivial programming languages. So, all languages are equally powerful.
(There may be other reasons for choosing one language over another depending on the needs of the application).
3
Information on Computers
We use computers to represent many different kinds of information:
NumbersSymbols (letters, punctuation, etc.)PicturesSoundProgram instructionsEtc.
We divide this information into different categories.
The computer stores everything as 1's and 0's (binary representation).
4
Binary Information
Computers represent all information as 0's and 1's (Binary representation).
All the pictures, sounds, programs, etc. on your computer are stored as sets of 0's and 1's!
Why?Computers are built using digital circuits. The inputs and outputs of digital circuits can only be one of two values: true (high voltage) or false (low voltage). We represent these as 1 and 0.
By combining 1's and 0's in different patterns and sequences, we can represent complex information and compute solutions to some complex problems
5
Digital ElectronicsEach digital component can have only 1 of two states.
High Voltage (+ 5V) = 1Low Voltage (0 V) = 0
Basic components:Logic display (LED) => lights up when voltage high (1)
Doesn't light when voltage low(0)
Digital switch => Sends high voltage (1) when up Sends low voltage (0) when down
6
AND Gate
An AND Gate takes two inputs and produces 1 output.
Depending on the values of the inputs, s1 and s2, the LED will either light up or not.
Truth Table:s1 s2 output0 00 11 01 1output = s1 AND s2
= s1 s2
7
Other GatesOther useful gates:
OR Gate Inverter
NOR Gate NAND Gate
XOR (Exclusive OR) Gate
s1 V s2 s1
(s1 s2)(s1 V s2)
8
Combining Gates
A three input AND: Truth table:
a b c z
Practice: Draw a three input OR circuitand write out the truth table.
9
Counting in Base 10
In the decimal number system (base 10), we use 10 digits 0 - 9.
We count until we run out of digits, and then add a new place with value 10.
0 1 2 3 4 5 6 7 8 9 10
place value = 10place value = 1
We continue to count, adding 1 to the 10's place every 10th number. When we run out of digits for the 10's place, we add a new place with value 102 (or 100).
... 98 99 100
place value = 100
10
Counting in BinaryWith binary numbers, we have only 2 digits to work with (0 and 1), so we add places more frequently.
Each new place has a value that is a power of two.
Decimal Binary0 01 12 103 114 1005 1016 1107 1118 1000
Note: Each 1 or 0 is called a binary digit or bit.
11
Base 10 vs. Base 2
In base 10, each place represents a power of 10:
4173 = ?
4 x 103 + 1 x 102 + 7 x 10 + 3 x 100
In base 2, each place represents a power of 2:
10110 = ?
1 x 24 + 0 x 23 + 1 x 22 + 1 x 2 + 0 x 20 = 22
Practice:Convert 110110 from binary to decimal.
12
Converting from Decimal to Binary--Method 1
To convert from decimal to binary, we first find the largest power of 2 that divides our decimal number.
We divide by that number and put the result in the binary place associated with that power of two.
We then repeat with the remainder from the previous division.
Example: Convert 25 (base 10) to binary.The largest power of 2 that divides 25 is 16. 25/16 = 1 R = 9
9/8 = 1 R = 11/4 = 0 R = 11/2 = 0 R = 11/1 = 1 R = 0
Binary number = 11001
13
Converting from Decimal to Binary--Method 2
Method 2:Divide repeatedly by 2.Place remainders in order from right to left.
Example:25/2 = 12 R = 112/2 = 6 R = 06/2 = 3 R = 03/2 = 1 R = 11/2 = 0 R = 1Result = 11001
Practice: What is 43 written in base 2?
14
Hexadecimal NumbersHexadecimal numbers use base 16.To count in base 16, we use the letters A - F to stand for decimal equivalents of 11 - 15.
Base 10 Base 16 Base 10 Base 160 0 ... ...1 1 255 FF2 2 256 100... ...9 910 A11 B12 C13 D14 E15 F16 10
162 = 256
15
Converting from Binary to Hexadecimal
Every 4 bits represents 1 hexadecimal digit.
To convert from binary to Hexadecimal, group the bits into sets of four (from right to left) and find the corresponding hexadecimal digit for each set of 4 bits.
1011 0011 B 3
1101 0110 ? ?