binary calculators
Download
Report
Transcript binary calculators
Digital Systems and Binary
Numbers
Mano & Ciletti
Chapter 1
By Suleyman TOSUN Ankara University
Outline
Digital Systems
Binary Numbers
Number-Base Conversions
Octal and Hexadecimal Numbers
Complements
Signed Binary Numbers
Binary Codes
Binary Storage and Registers
Binary Logic
Digital Systems
Digital computer is the best-known example
of a digital system
Others are telephone switching exchanges,
digital voltmeters, digital calculators, etc.
A digital system manipulates discrete
elements of information
Discrete elements: electric impulses, decimal
digits, letters of an alphabet, any other set of
meaningful symbols
Digital Systems
In a digital system, discrete elements of
information are represented by signals
Electrical signals (voltages & currents) are the
most common
Present day systems have only two discrete
values (binary)
Alternative, many-valued circuits are less
reliable
A lot of information is already discrete and
continuous values can be quantized (sampled)
Digital Systems
Digital Systems
A digital computer is an interconnection of
digital modules
To understand each module, it is necessary
to have a basic knowledge of digital systems
Binary Numbers
7392 represents a quantity that is equal to
7 × 103 + 3 × 102 + 9 × 101 + 2 × 100
Decimal number system is of base (or radix)
10
In binary system, possible values are 0 and 1
and each digit is multiplied by 2𝑖
E.g. 11010.11 is
1 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20 + 1
× 2−1 + 1 × 2−2 = 26.75
Binary Numbers
Hexadecimal (base 16) numbers use digits 09 and letters A, B, C, D, E, F to represent
values 10-15
𝐵65𝐹 16 = 11 × 163 + 6 × 162 + 5 × 16 + 15
= 46687 10
Operations work similarly in all bases
Number-Base Conversions
Converting a number from base x to decimal
is simple (as shown before)
Decimal to base x is easier if number is
separated into integer and fraction parts
Convert 41 to binary
Divide 41 by 2, quotient is 20 and remainder is 1.
Continue dividing the quotient until it becomes 0.
Remainders give us the binary number as follows:
Number-Base Conversions
Number-Base Conversions
Conversion of a fraction is similar but the
number is multiplied by to instead of dividing
Octal and Hexadecimal Numbers
Conversions between binary, octal and
hexadecimal numbers are easier
Each octal digit corresponds to 3 binary digits
and each hexadecimal digit corresponds to 4
binary digits
Complements
Simplifies
the subtraction operation
Logical operations
Two types exist
The radix complement (r’s complement)
10’s complement, 2’s complement
The diminished radix complement ((r-1)’s
complement)
9’s complement, 1’s complement
Diminished Radix (r-1) complement
Given a number N in base r having n digits:
When r=10, (r-1)’s complement is called 9’s
complement.
10n-1 is a number represented by n 9’s.
9’s complement of 546700 is (n=6)
(r-1)’s complement of N is (rn-1)-N
999999-546700=453299
9’s complement of 012398 is (n=6)
999999-012398=987601
1’s complement
For binary numbers, r=2 and r-1=1.
1’s complement of N is (2n-1)-N
If n=4, 2n=10000. So, 2n-1=1111.
To determine the 1’s complement of a
number, subtract each digit from 1.
Or, bit flip!!! Replace 0’s with 1’s, 1’s with 0’s!!!
Example:
If N= 1011000, 1’s comp.= 0100111
If N= 010110, 1’s comp.= 101001
Radix (r’s) complement
Given a number N in base r having n digits:
When r=10, r’s complement is called 10’s
complement.
10’s complement of 546700 is (n=6)
r’s complement of N is rn-N
1000000-546700=453300
10’s complement of 012398 is (n=6)
1000000-012398=987602
2’s complement
For binary numbers, r=2, 2’s complement of N
is 2n-N
To determine the 2’s complement of a
number, determine 1’s complement and add 1
to it.
Example:
If N= 1011001, 1’s comp.= 0100110, 2’s
comp.=0100111
If N= 1101100, 2’s comp.= 0010100
Another way of finding 2’s comp.: Leave all least significant 0’s and the first 1
unchanged, bit flip the remaning digits.
Subtraction with Complements
Minuend:
101101
Subtrahend: 100111
Difference: 000110
1.
2.
3.
Add the minuend M to r’s complement of the subtrahend N.
M + (rn-N) = M - N+rn
If M>=N, the sum will produce an end carry. Discard it and what is
left is the result M-N.
If M<N, the sum does not produce an end carry and is equal to
rn-(N-M) . To obtain the answer in a familiar form, take the r’s
complement of the sum and place a negative sign in front.
Example
Example
Example
Signed Binary Numbers
Negative numbers is shown with a minus sign
in math.
In digital systems, the first bit decides the
sign of the number.
If the first bit 0, the number is positive.
If the first bit 1, the number is negative.
This is called signed magnitude convention.
Signed complement systems
To represent negative number, 1’s
complement and 2’s complements are also
used.
Example
Represent +9 and -9 in eight bit system
+9 is same for all systems: 00001001
-9
To determine negative number
Signed magnitute: Take the positive number,
change the most significant bit to 1
One’s complement: Take the one’s
complement of the positive number.
Two’s complement: Take the two’s
complement of the positive number. (Or add
1 to one’s complement)
Arithmetic Addition
Aritmetic subtraction
Take the 2’s complement of subtrahend.
Add it to the minuend.
Discard cary if there is any.
Examples: 10-5 (8 bits), -3-5, 18-(-9)
Binary Codes – BCD Codes
n bit can code
upto 2n
combinations.
BCD Addition
Example
Other Decimal Codes
Gray Codes
Only one bit changes when going from one
number to the next.
How to determine the gray code equivalent of
a number:
Add 0 to the left of number.
XOR every two neigboring pair in order.
The result is the gray code.
Example: 1 1 0 0 0 0 -> 0 1 1 0 0 0 0
101000
Error Detecting Codes
Add an extra bit (parity bit) to make the total
number of one’s either even or odd.
Binary logic
Truth tables
Gate sysbols
Timing diagrams
More than two inputs