jpc#8 foundation of computer science

Post on 22-May-2015

114 Views

Category:

Education

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Foundation of Computer Science

Junior Programmer Camp #8

Chapter 1: Number Systems & Radix Number

Radix Numbers

• Base 2 (Binary)- 0, 1

• Base 8 (Octal)- 0, 1, 2, 3, 4, 5, 6, 7

• Base 10 (Decimal)- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

• Base 16 (Hexadecimal)– 0, 1, 2, 3 , …, 8, 9, A, B, C, D, E, F

Base Conversion

Base X to Base 10 (Decimal)– Starting from the last digit, multiply

that digit by X0

– Increase the power of X by 1 and repeat until you have done all digits

– Sum up the results

Base Conversion (cont.)

Example:Convert 110112, 5467, 878 to base 10

Result : 2727971

Base Conversion (cont.)

Base 10 (Decimal) to any base X– Divide the number by X.– Write down the remainder.– Repeat the previous two steps until

the result is 0.– The actual result is the digit sequence

of the remainders from the last to first.

Base Conversion (cont.)

Example:Convert 34510 to base 2,3,16

Result: 1010110012

11021203

15916

Base Conversion (cont.)

Base 2 (Binary) to Base 8 (Octal)– Group 3 digits from the right side– Convert each group to its octal

representationDo you think that number in base 2 can

also be converted to Base 16 (Hexadecimal) directly somehow?

Binary Arithmetic

• Addition:0 + 0 = 0 1 + 0 = 1 0 + 1 = 1 1 + 1 =

10

• Subtraction:0 – 0 = 0 1 – 0 = 1 0 – 1 = 1 1 - 1 =

0

• Multiplication:0 x 0 = 0 1 x 0 = 0 0 x 1 = 0 1 x 1 =

1

Binary Arithmetic (Try it!)

Example:

101001101 + 1111101011001001011 - 1101110111101 x 11001

Chapter 2: Logic Gates & Circuits

Gates and Circuits Simulator

http://logic.ly/demo/

NOT Gate

Boolean expression : A’Truth table: Input Output

0 1

1 0

AND & NAND Gate

Boolean expression : A ∙ B [AND](A ∙ B)’

[NAND]Truth table:

Input OutputA B AND NAND

0 0 0 1

0 1 0 1

1 0 0 1

1 1 1 0

OR & NOR Gate

Boolean expression : A + B [OR](A + B)’ [NOR]

Truth table: Input OutputA B OR NOR

0 0 0 1

0 1 1 0

1 0 1 0

1 1 1 0

XOR & XNOR Gate

Boolean expression : A B [XOR](A B)’ [XNOR]

Truth table: Input Output

A B XOR XNOR

0 0 0 1

0 1 1 0

1 0 1 0

1 1 0 1

Circuits

A circuit is a combination of gates.

Boolean expression

Boolean expression is D = (A + B)’ NOT (A OR B)E = B ∙ C B AND CQ = D + E D OR E

= (A + B)’+(B ∙ C) (NOT (A OR B)) OR (B AND C)

Truth tableInput Output

A B C D (A + B)’

E (B ∙ C )

Q((A + B)’+(B ∙ C) )

0 0 0 1 0 1

0 0 1 1 0 1

0 1 0 0 0 0

0 1 1 0 1 1

1 0 0 0 0 0

1 0 1 0 0 0

1 1 0 0 0 0

1 1 1 0 1 1

Give it a try!

Find the Boolean expression and the truth table of this circuit.

Give it a try!

Draw a circuit this Boolean expression:X = ((A B) + (C’∙ D))’

E

top related