computer programming skills revision prepared by: ghader kurdi
Post on 23-Dec-2015
229 Views
Preview:
TRANSCRIPT
Computer Programming Computer Programming Skills Revision Skills Revision
Prepared by: Ghader KurdiPrepared by: Ghader Kurdi
Chapter 1Chapter 1Number SystemsNumber Systems
ContentsContents
Number Systems Number Systems Conversion Among BasesConversion Among Bases Binary Addition and MultiplicationBinary Addition and Multiplication
Number SystemsNumber Systems
System Base
Symbols Examples
Decimal
10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
101, 33, 108, 987
Binary 2 0, 1 101, 1110, 10, 1, 0
Octal 8 0, 1, 2, 3, 4, 5, 6, 7
101, 33, 777, 642
Hexa-decima
l
16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
A, B, C, D, E, F
101, 33, 108, 1AF
ABDF, 35FF, 10A
Conversion Among BasesConversion Among Bases
Conversion Among BasesConversion Among Bases
Divide the number by base and write the remainders.
Continue downwards, dividing each new quotient by base and writing the remainders.
Stop when the Stop when the quotient is 0.quotient is 0.
Conversion Among BasesConversion Among Bases
Start at the right Break the binary
numeral into groups of three digits
Replace each 3-digits binary numeral with it’s 1-digit octal equivalent
Replace each octal digit with it’s 3-digits binary equivalent
Combine all binary equivalent into a single binary numeral.
Octal Binary
Octal Binary
Conversion Among BasesConversion Among Bases
Start at the right Break the binary
numeral into groups of four digits
Replace each 4-digits binary numeral with it’s 1-digit hexadecimal equivalent
Replace each hexadecimal digit with it’s 4-digits binary equivalent
Combine all binary equivalent into a single binary numeral.
hexadecimal
Binary hexadecimal
Binary
Conversion Among BasesConversion Among Bases
Binary Addition and Binary Addition and MultiplicationMultiplication
Binary additionBinary addition
To add 3 or more numbers:To add 3 or more numbers:Add the first two numbers. Add the first two numbers. Then, add the third Then, add the third number to the result and so number to the result and so on.on.
ExamplesExamples
Binary Addition and Binary Addition and MultiplicationMultiplication
Binary MultiplicationBinary Multiplication
To multiply 3 or more To multiply 3 or more numbers:numbers:Multiply the first two Multiply the first two numbers. numbers. Then, multiply the result by Then, multiply the result by the third number and so on.the third number and so on.
ExampleExample
Chapter 2Chapter 2Digital Logic DesignDigital Logic Design
Digital Logic DesignDigital Logic Design
Logic gatesLogic gates Logic FunctionsLogic Functions Derivation of logical expressions Derivation of logical expressions
sum-of-products (SOP) formsum-of-products (SOP) form product-of-sums (POS) formproduct-of-sums (POS) form
Logical EquivalenceLogical Equivalence Truth table methodTruth table method Algebraic manipulation methodAlgebraic manipulation method
Logical Expression SimplificationLogical Expression Simplification Boolean AlgebraBoolean Algebra Karnaugh Map MethodKarnaugh Map Method
Logic gatesLogic gates
Logic gatesLogic gates AND OR NOT NANDNAND NORNOR XORXOR Precedence (NOT > AND > OR)Precedence (NOT > AND > OR)
You must know:You must know: The function and truth table of each gateThe function and truth table of each gate The graphical representation of each gateThe graphical representation of each gate The logical representation of each gateThe logical representation of each gate
Logic FunctionsLogic Functions Logical functions can be expressed in several ways:Logical functions can be expressed in several ways:
Truth tableTruth table Logical expressionsLogical expressions Graphical formGraphical form
You must know how to:You must know how to: Use a graphical representation to derive a logical expression.Use a graphical representation to derive a logical expression. Use a graphical representation to derive a truth table.Use a graphical representation to derive a truth table. Use a logical expression to derive a graphical representation.Use a logical expression to derive a graphical representation. Use a logical expression to derive a truth table.Use a logical expression to derive a truth table. Use a truth tables to derive a logical expression (SOP & POS)Use a truth tables to derive a logical expression (SOP & POS)
Derivation of logical Derivation of logical expressions expressions
An An SOP expression SOP expression when two or more when two or more product terms are product terms are summed by Boolean summed by Boolean addition.addition.
In an SOP form, a In an SOP form, a single overbar cannot single overbar cannot extend over more than extend over more than one variableone variable ExampleExample
But notBut not
An An POS expression POS expression When two or more sum When two or more sum terms are multiplied terms are multiplied by Boolean by Boolean multiplication.multiplication.
In a POS form, a single In a POS form, a single overbar cannot extend overbar cannot extend over more than one over more than one variable variable ExampleExample
But notBut not
DCABDCBACDBA
DCABDCBACDBA
))()(( DCBADCBADCBA
))()(( DCBADCBADCBA
Derivation of logical Derivation of logical expressions expressions
To determine the SOP expression represented by a truth table.Instructions:
Step 1: List the binary values of the input variables for which the output is 1.
Step 2: Convert each binary value to the corresponding product term by replacing:
each 1 with the corresponding variable, and
each 0 with the corresponding variable complement.
Example: 1010
To determine the POS expression represented by a truth table.Instructions:
Step 1: List the binary values of the input variables for which the output is 0.
Step 2: Convert each binary value to the corresponding product term by replacing:
each 1 with the corresponding variable complement, and
each 0 with the corresponding variable.
Example: 1001
DCBA DCBA
POSSOP
Derivation of logical Derivation of logical expressions from a Truth expressions from a Truth
Table (example)Table (example)I/PI/P O/PO/P
AA BB CC XX
00 00 00 00
00 00 11 00
00 11 00 00
00 11 11 11
11 00 00 11
11 00 11 00
11 11 00 11
11 11 11 11
There are There are four four 1s1s in the output in the output and the and the corresponding corresponding binary value binary value are 011, 100, are 011, 100, 110, and 111.110, and 111.
ABC
CAB
CBA
BCA
111
110
100
011
There are There are four four 0s0s in the output in the output and the and the corresponding corresponding binary value binary value are 000, 001, are 000, 001, 010, and 101.010, and 101.
CBA
CBA
CBA
CBA
101
010
001
000
ABCCABCBABCAX
))()()(( CBACBACBACBAX
Converting SOP and POS Converting SOP and POS Expressions to Truth Table Expressions to Truth Table
FormatFormat Recall the fact:Recall the fact:
An SOP An SOP expression expression corresponds to 1 output.corresponds to 1 output.
Constructing a truth table:Constructing a truth table: Step 1:Step 1: List all possible List all possible
combinations of binary combinations of binary values of the variables in values of the variables in the expression.the expression.
Step 2:Step 2: Place a 1 in the Place a 1 in the output column (X) for output column (X) for each binary value that each binary value that makes the makes the SOPSOP expression expression a 1 and place 0 for all the a 1 and place 0 for all the remaining binary values. remaining binary values.
Recall the fact:Recall the fact: A POS expression A POS expression
corresponds to 0 output.corresponds to 0 output. Constructing a truth table:Constructing a truth table:
Step 1:Step 1: List all possible List all possible combinations of binary combinations of binary values of the variables in values of the variables in the expression.the expression.
Step 2:Step 2: Place a 0 in the Place a 0 in the output column (X) for each output column (X) for each binary value that makes the binary value that makes the POSPOS expression a 0 and expression a 0 and place 1 for all the place 1 for all the remaining binary remaining binary values. values.
Converting SOP Converting SOP Expressions to Truth Table Expressions to Truth Table
Format (example)Format (example) Develop a truth Develop a truth
table for the table for the standard SOP standard SOP expressionexpression
ABCCBACBA
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00
00 00 11
00 11 00
00 11 11
11 00 00
11 00 11
11 11 00
11 11 11
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00
00 00 11
00 11 00
00 11 11
11 00 00
11 00 11
11 11 00
11 11 11
CBA
CBA
ABC
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00
00 00 11 11
00 11 00
00 11 11
11 00 00 11
11 00 11
11 11 00
11 11 11 11
CBA
CBA
ABC
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00 00
00 00 11 11
00 11 00 00
00 11 11 00
11 00 00 11
11 00 11 00
11 11 00 00
11 11 11 11
CBA
CBA
ABC
Converting POS Converting POS Expressions to Truth Table Expressions to Truth Table
Format (example)Format (example) Develop a truth Develop a truth
table for the table for the standard SOP standard SOP expressionexpression
))((
))()((
CBACBA
CBACBACBA
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00
00 00 11
00 11 00
00 11 11
11 00 00
11 00 11
11 11 00
11 11 11
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00
00 00 11
00 11 00
00 11 11
11 00 00
11 00 11
11 11 00
11 11 11
)( CBA
)( CBA
)( CBA
)( CBA
)( CBA
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00 00
00 00 11
00 11 00 00
00 11 11 00
11 00 00
11 00 11 00
11 11 00 00
11 11 11
)( CBA
)( CBA
)( CBA
)( CBA
)( CBA
InputsInputs OutputOutput Product Product TermTermAA BB CC XX
00 00 00 00
00 00 11 11
00 11 00 00
00 11 11 00
11 00 00 11
11 00 11 00
11 11 00 00
11 11 11 11
)( CBA
)( CBA
)( CBA
)( CBA
)( CBA
Implementation of SOP Implementation of SOP & POS & POS
Implementation Implementation of an SOPof an SOP
Implementation Implementation of a POSof a POS
A
B
BA
A
B
X
A
B
B
A
A
B
ABBABA ))()(( BABABA
Logical EquivalenceLogical Equivalence
Truth table Truth table methodmethod Derive the logical Derive the logical
expressionexpression Derive truth tables Derive truth tables
for each expression. for each expression. If both expressions If both expressions
yield the same yield the same output, they are output, they are equivalent. equivalent. Otherwise, they are Otherwise, they are not.not.
Algebraic Algebraic manipulation manipulation methodmethod Derive the logical Derive the logical
expressionsexpressions Simplify each expression Simplify each expression
using boolean laws.using boolean laws. If both expressions yield If both expressions yield
the same simplified the same simplified expression, they are expression, they are equivalent. Otherwise, equivalent. Otherwise, they are not.they are not.
Logical Expression Logical Expression SimplificationSimplification
Boolean AlgebraBoolean Algebra
Need boolean identities Need boolean identities (Laws)(Laws)
Start with an Start with an expression and apply expression and apply Boolean laws to derive Boolean laws to derive the simplest (minimum) the simplest (minimum) expression possible.expression possible.
Karnaugh Map MethodKarnaugh Map Method
A K-map is a graphical A K-map is a graphical method for simplifying method for simplifying Boolean expressions Boolean expressions and, if properly used, and, if properly used, will produce the simplest will produce the simplest (minimum) expression (minimum) expression possible.possible.
The size of k-map The size of k-map depends on the number depends on the number of variables.of variables.
Simplification using Simplification using Boolean AlgebraBoolean Algebra
Simplification using Simplification using Boolean Algebra (cont.)Boolean Algebra (cont.)
Simplification using K-MapSimplification using K-Map
The process of simplification The process of simplification ((minimization):minimization): Mapping the expression into k-mapMapping the expression into k-map Grouping the 1sGrouping the 1s Determining the minimum SOP Determining the minimum SOP
expression from the mapexpression from the map
Grouping the 1s (rules)Grouping the 1s (rules)
1.1. A group must contain either 1,2,4, or 8 cells A group must contain either 1,2,4, or 8 cells (depending on number of variables in the (depending on number of variables in the expression)expression)
2.2. Each cell in a group must be adjacent to Each cell in a group must be adjacent to one or more cells in that same group.one or more cells in that same group.
3.3. Always include the largest possible number Always include the largest possible number of 1s in a group in accordance with rule 1.of 1s in a group in accordance with rule 1.
4.4. Each 1 on the map must be included in at Each 1 on the map must be included in at least one group. least one group.
5.5. The 1s already in a group can be included in The 1s already in a group can be included in another group as long as the overlapping another group as long as the overlapping groups include non common 1s.groups include non common 1s.
ABAB
CC0000 0101 1111 1010
00
11
Cell AdjacencyCell Adjacency
CC
ABAB00 11
0000
0101
1111
1010
Simplification using K-MapSimplification using K-Map(full example)(full example)
The expression: The expression:
CBACABCBACBA 000 001 110 100
1 1
1
1
DCBADCBADCABABCDDCABDCBACDBA
CBACBABCA
ABCCABCBACBA
Practice:
Simplification using K-MapSimplification using K-Map(full example)(full example)
CC
ABAB00 11
0000
0101
1111
1010 B
1 1
0 0
1 0
11
CAB
CA
التوفيق لكم الله التوفيق اسأل لكم الله اسألوالسدادوالسداد
كردي. غدير كردي. أ غدير أ
top related