Date post: | 15-Jan-2016 |
Category: |
Documents |
View: | 218 times |
Download: | 3 times |
CSC 110 –Intro to Computing
Lecture 14:
Midterm Review
Announcements
Reminder: Midterm is this ThursdayCovers all material discussed so farYou will be given 75 minutes, arithmetic tables,
logical propertiesEssay must be completed in class, but topic
given at end of class Service learning logs due March 23
Note slight change of date
Important Bases’ Digits
Binary (base-2) uses 2 digits: 0, 1
Octal (base-8) uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 7
Decimal (base-10) uses 10 digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimal (base-16) uses 16 digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Decimal Positional Notation
Formal equation for a number dn...d3d2d1d0
d0 is digit in ones place, d1 is in tens place, …
d0 * 100
d1 * 101
d2 * 102
d3 * 103
…
+ dn * 10n
Converting To Decimal
Use positional notation to any number dn...d3d2d1d0 from base-b to decimal:
+ dn * bn
…
d2 * b2
d3 * b3
d1 * b1
d0 * b0
Converting Binary to Decimal
1000112 = 1 *
1 *
0 *
0 *
0 *
+ 1 *
Converting Octal to Decimal
1078 =
Convert Hexadecimal To Decimal
AF16=
3716=
Converting From Decimal
Converting from decimal to any base-b
While the decimal number is not 0Divide the decimal number by bMove remainder to left end of
answerReplace decimal number with
quotient
33510 =
Converting Binary to Octal
Special relationship between these basesOctal uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 73 binary digits (bits) represent 1 octal digit:
0002 = 08 1002 = 48
0012 = 18 1012 = 58
0102 = 28 1102 = 68
0112 = 38 1112 = 78
Every 3 bits is equal to one octal digitMakes conversion easy
Converting Binary to Octal
Starting from the right, split number into groupings of 3 bits
For each group from right to leftConvert each group from binary to decimalAdd digit to left end of result
Converting Binary to Octal
Convert from binary to octal:11110011002
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 41002 = 0 * 20 = 0 * 1 = 0
0 * 21 = 0 * 2 = 0
1 * 22 = 1 * 4 = + 4
4
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 1 40012 = 1 * 20 = 1 * 1 = 1
0 * 21 = 0 * 2 = 0
0 * 22 = 0 * 4 = + 0
1
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 7 1 41112 = 1 * 20 = 1 * 1 = 1
1 * 21 = 1 * 2 = 2
1 * 22 = 1 * 4 = + 4
7
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 1 7 1 4 12 = 1 * 20 = 1 * 1 = 1
Converting Binary to Octal
That’s all there us to it!
11110011002 = 17148
Converting Octal To Binary
For each digit (working from right to left)Convert the digit from decimal to binaryAdd 0s to left of the binary to fill 3 bitsAdd binary number to left-end of solution
Finally, remove any 0s padding leftmost digit
Converting Octal to Binary
Convert from octal to binary:3168
Binary to powers-of-two bases
Special relationship between binary and any power-of-two (2, 4, 8, 16, 32…) baseOctal is base-8
23 = 8 Use groupings of 3 bits converting to/from octal
Hexadecimal is base-16 24 = 16 Use groupings of 4 bits converting to/from octal
Conversion Quick Guide
When converting to decimal… …use positional notation
When converting from decimal… …divide by base being converted into
When converting between binary and power-of-two base……use groupings of bits of appropriate size
Addition Algorithm
To add 2 numbers in base-b:
For each position from right to leftCompute sum of the digitsIf sum > b then
sum = sum- bCarry the 1
EndRecord sum at position
Adding Octal Numbers
For each position from right to left
1 2 68
+ 7 2 28
Adding Octal Numbers
Record sum at position
1
1 2 68
+ 7 2 28
08
Adding Octal Numbers
For each position from right to left
1
1 2 68
+ 7 2 28
5 08
Adding Octal Numbers
For each position from right to left
1 1
1 2 68
+ 7 2 28
0 5 08
Adding Hex Numbers
For each position from right to left
B A 616
+ E 0 216
Boolean Negation: NOT
NOT is simplest operationReturns the negation of the input
1 when a is 0; 0 when a is 1
Written as a
0 1
1 0
aaa
Boolean Operation: OR
OR takes two values as inputsWritten as Returns 1 when either value is 1
1 when either a OR b are 1; 0 otherwise
0 00 11 01 1
a b a b
a b
a
b
Boolean Operation: AND
AND also takes two inputsWritten asReturns 1 when both values are 1
1 when a AND b are 1; 0 otherwise
0 00 11 01 1
a b a b
a b
a
b
Boolean Operation: XOR
First slightly unfamiliar idea: XORXOR computes “exclusive or” Written as 1 when a or b, but not both, are 1
0 00 11 01 1
a b a b
a b
a
b
Boolean Operation: NAND
NAND computes NEGATIVE ANDWritten as
Combines notation for AND & NOT
1 when either value is 0 Equivalent to negation of AND
0 0 10 1 11 0 11 1 0
a b a b
a b
a
b
Boolean Operation: NOR
Last operation is NEGATIVE ORWritten as 1 when both values are 0
Also equal to negation of OR
0 0 10 1 01 0 01 1 0
a b a b
a b
a
b
Creating Truth Tables
There is a secret to making the inputs1st input – Alternate one 0 and one 12nd input – Repeat two 0s then two 1s3rd input – Repeat four 0s then four 1s4th input – Repeat eight 0s then eight 1s
Start with row of all 0s Stop when you reach a row with all 1s
Create the Truth Table
( ) ( ) c a a b
Drawing Logic Diagrams
Often use results from one gate as input into another gate
Show by connecting wire from first gate’s output to second gate’s inputE.g., result from used in ( ) a b cb c
b
c
a
Computing Propagation Delay
Set initial delay for circuit inputs to 0For each gate whose input’s delays are known
Find the input with the longest delay Add 1 to this delay time
Set gate’s delay to this new time
Keep going until delay for entire circuit is known
Draw the Circuit
( ) ( ) c a a b
More About Boolean Properties
Properties identify equivalent circuitsE.g., circuits with identical truth table results
Many ways we use these propertiesReduce delays by doing more work in parallelSimplify circuits by removing useless gates
0 1 0
1 0 1
aa a
Using Boolean Properties
Circuit Property Used(c·d)+(d+c) Identity(c·d)+(d·c) DeMorgan’s(c·d)+(d·c) Double Negation(c·d)+(c·d) Commutative
c·(d+d) Distributivec·1 Complementc Identity
Reduce to c:
Adder Circuits
How to know a circuit is equivalent to half-adder or full-adderCircuits are equivalent to if both truth tables
have identical outputEquivalence can be found in two ways:
Memorize circuit and its truth Memorize circuit and its truth tabletable
Check that the carry out and result match the carry, result of adding inputs together
Full-Adders
Full-adder adds two input bits and the carry bit from adding previous bitOutputs result bit and another carry bit
Include new full-adder to add each bit except least significant bit
Adders
Half-adder Full adder
Result
Carry Out
Result
Combining Adders
Circuit adding two 2-bit numbers together
C0
Carry Out
C1
C2
A1
B1
A0
B0
Computer Components
Input Unit Device through which data are entered into the computer
Output Unit Device through which data stored within computer made available to outside world
Secondary Storage Device Device which reads and writes information into computer memory
von Neumann Computer Connections
Harvard Computer Connections
Program
Data
Palgo Loop Selection
Each of Palgo’s loops serves different purpose repeat
Executing the commands a specific number of times for
Remembering the number of times that we are executing the instructions in a loop
Very useful for lists! while
Executing a loop for as long as needed to meet a specific condition
Midterm Essay
Electronic computers have gotten easier to use since they were first developed. Discuss improvements to input, output, and secondary storage devices, and software that have made these machines easier to use.For full credit, you must discuss improvements
including at least 1 input device, at least 1 output device, and at least 1 secondary storage device or program.