Chapternew1 1 1
Chapternew1 1 1
• Course Description
This course focuses on the fundamental constructs and concepts underlying computer
hardware and software which includes: number systems, binary arithmetic, codes,
Boolean algebra, gates, Boolean expressions
1. Digital Systems
2. Binary Numbers
3. Octal and Hexadecimal Numbers
4. Number‐Base Conversions
5. Arithmetic Operations
6. Complements of Numbers
7. Signed Binary Numbers
8. Binary Codes
9. Binary Storage and Registers
10. Binary Logic
Digital Systems
Analog system
The physical quantities or signals may vary continuously over a specified range.
Digital system
Base = 2
◆ 2 digits { 0, 1 }, called binary digits or “bits”
Weights
Position
◆ Weight = (Base)
Magnitude
◆ Sum of “Bit x Weight”
Formal Notation
Groups of bits
The Power of 2
Octal Number System
Base = 8
◆ 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights
◆ Weight = (Base) Position
Magnitude
◆ Sum of “Digit x Weight”
Formal Notation
Hexadecimal Number System
Base = 16
◆ 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights
◆ Weight = (Base)
Position
Magnitude
◆ Sum of “Digit x Weight”
Formal Notation
Number Base Conversions
1. Divide the decimal number to be converted by the value of the new base.
2. Get the remainder from Step 1 as the rightmost digit (least significant digit) of
new base number.
3. Divide the quotient of the previous divide by the new base.
4. Record the remainder from Step 3 as the next digit (to the left) of the new base
number.
5. Repeat Steps 3 and 4, getting remainders from right to left, until the quotient
becomes zero in Step 3.
Conversion form Decimal to any base system (Divide by base)
To convert a decimal integer into any base, keep dividing by r until the quotient is 0. Collect
the remainders in reverse order.
To convert a fraction, keep multiplying the fractional part by r until it becomes 0 or until we reach
the required accuracy. Collect the integer parts in forward order.
Decimal (Integer) to Binary Conversion
In general, the result of adding two digits each of weight w is two digits. One is the “Sum”
digit and the other is the “Carry” digit.
In binary system, if the weight of the sum bit is 2i, then the weight of
the carry bit is 2i+1. Thus, adding 1 + 1 in the binary system results in
a Sum bit of 0 and a carry bit of
Single Bit Binary Addition
Q. What is 1 + 1 + 1 = ?
A. The answer is 1 carry 1.
Another Example:
Q. What is1–1–1=?
A. The answer is 1 borrow 1.
Explanation: We perform the operation in 2 steps: 1 – 1 = 0
We then subtract 1 from the above result, i.e. 0 – 1 which is
1 borrow 1.
Q. What is 0 – 1 – 1 = ?
A. The answer is 0 borrow 1. Explanation: We perform the
operation 0 - 1= 1 borrow 1
We then subtract 1 from the above result, which yields 0
borrow 1.
Example :
Complements
11111111
Complements
OR Toggle all bits to the left of the first ‘1’ from the right( least significant 1)
Binary Subtraction Using 1’s Complements
The subtraction of two n bit unsigned binary numbers X –Y using the 1’s complement can be
done as follows:
• Take the 1’s complement of the subtrahend Y and add it to the minuend X.
❖ If X >= Y, the sum will produce and end carry at position 2n, which is added to LSB of the sum. This operation is
called end a round carry.
❖ If X < Y, the sum does not produce an end carry. To obtain the answer in a familiar form, take the 1’s complement
of the sum and place a negative sign in front.
Binary Subtraction Using 1’s Complement
Example:
Binary Subtraction Using 1’s Complement
Example :
Given the two binary numbers X = 1101 and Y = 10, perform the subtraction X – Y by using
1's complement.
1101 – 10 = 1011
Binary Subtraction Using 1’s Complement
• Take the 2’s complement of the subtrahend Y and add it to the minuend X.
• If X >= Y, the sum will produce and end carry at position 2n, which can be
discarded; what is left is the result X – Y.
• If X < Y, the sum does not produce an end carry. To obtain the answer in a familiar
form, take the 2’s complement of the sum and place a negative sign in front.
Binary Subtraction Using 2’s Complement
Example
◆Given the two binary numbers X = 1010100 and Y = 1000011, perform the
subtraction (a) X – Y ; and (b) Y − X, by using 2's complement.
Examples :
Q 1. Given the two binary numbers X = 1001 and Y = 0101, perform the
Q 2. Given the two binary numbers X = 1010010 and Y = 11100100, perform the
(a) X – Y
Registers are fast storage devices used inside processors Used to store computation
results of a running program
A Register consists of a fixed number of storage bits
◆Signed-2’s Complement representation: 11110111 All three use the left most bit to represent the sign:
» ‘0’ positive
» ‘1’ negative
• Example the different representations of -9 using 8 bit number:
Signed Binary Numbers
• Table 1.3 lists all possible four-bit signed binary numbers in the three representations.
Signed Magnitude Representation
• Digital systems represent and manipulate not only binary numbers, but also many other
discrete elements of information.
• Any discrete element of information that is distinct among a group of quantities can be
represented with a binary code (a pattern of 0’s and 1’s).
• The codes must be in binary because, in today’s technology, only circuits that represent and
manipulate patterns of 0’s and 1’s can be manufactured economically for use in computers
• Binary code will have some unassigned bit combinations if the number of
elements in the set is not a multiple power of 2.
Binary Codes
• How to represent characters, colors, etc? Define the set of all represented
elements.
• Assign a unique binary code to each element of the set. Given n bits, a binary code
is a mapping from the set of elements to a subset of the 2n binary numbers.
As a minimum, we need 3 bits to define 7 unique values. 3 bits define 8 possible combinations.
Orange 001
Yellow 010
Green 011
Blue 100
Indigo 101
Violet 110
Decimal Codes
• Binary number system is most natural for computers. But people are used to the
decimal system.
• Must convert decimal numbers to binary, do arithmetic on binary numbers, then
convert back to decimal.
• To simplify conversions, decimal codes can be used. Define a binary code for each
decimal digit.
• Since 10 decimal digits exit, a 4-bit code is used. But a 4-bit code gives 16 unique
combinations. 10 combinations are used and 6 will be unused.
Binary Coded Decimal
• A decimal number in BCD is the same as its equivalent binary number only when the
number is between 0 and 9.
• The binary combinations 1010 through 1111 (10 – 15) are not used and have no meaning
in BCD (i.e. invalid combinations)
Warning: Conversion or Coding?
Do NOT mix up conversion of a decimal number to a binary number with coding a decimal
number with a binary code
Single Digit BCD Addition
Note that the codes for 0 and 9, 1 and 8, etc. can be obtained from each
other by replacing the 0’s with the 1’s and vice-versa in the code words.
A register with n cells can store any discrete quantity of information that contains
n bits.
Binary Logic
• Binary logic consists of binary variables and a set of logical operations.
• The variables are designated by letters of the alphabet, such as A , B, C, x, y, z,
etc, with each variable having two and only two distinct possible values: 1 & 0,
• Three basic logical operations: AND, OR, and NOT.
Binary Logic
Definitions of logical operations may be listed in a compact form called truth tables. A truth
table is a table of all possible combinations of the variables, showing the relation between
the values that the variables may take and the result of the operation
Logic gates
Logic gates are electronic circuits that operate on one or more input signals to produce an
output signal.
Logic gates