1. Digital Systems and Binary Numbers
1. Digital Systems and Binary Numbers
2
Signal
An information variable represented by physical quantity
For digital systems, the variable takes on discrete values
• Two level, or binary values are the most prevalent values
Binary values are represented abstractly by:
• digits 0 and 1
• words (symbols) False (F) and True (T)
• words (symbols) Low (L) and High (H)
• and words On and Off.
Binary values are represented by values or ranges of values
of physical quantities
3
Binary Numbers
• Decimal number (base or radix: 10) Coefficients (0, 1, 2,..9)
… a5a4a3a2a1a0.a1a2a3… aj
Decimal point
Place value
105 a5 104 a4 103 a3 102 a2 101 a1 100 a0 101 a1 102 a2 103 a3
Example:
7,329 7 103 3 102 2 101 9 100
4
Binary Numbers
Name Radix Digits
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
5
Binary Numbers
Example: Base-2 number (Binary)
(11010.11) 2 (26.75)10
1 24 1 23 0 22 1 21 0 20 1 2 1 1 2 2
Example: Base-5 number (Quinary)
(4021.2)5
4 53 0 52 2 51 1 50 2 51 (511.5)10
Example: Base-8 number (Octal)
(127.4)8
1 83 2 82 1 81 7 80 4 81 (87.5)10
Special Powers of 2
7
Binary Numbers
8
Binary Arithmetic
Arithmetic operations with numbers in base r follow the same rules as decimal numbers.
Addition
Rules of Binary Addition
Augend: 101101 0 + 0 = 0
Addend: +100111 0 + 1 = 1
1 + 0 = 1
Sum: 1010100 1 + 1 = 0, and carry 1 to the next higher significant bit
Subtraction 2
02 Rules of Binary Subtraction
Minuend: 101101 0 - 0 = 0
Subtrahend: 100111 0 - 1 = 1, and borrow from the next higher significant bit
1 - 0 = 1 (borrow in a given significant position adds 2
Difference: 000110 1 - 1 = 0 to a minuend digit)
9
Binary Arithmetic
• Practice
10
Binary Arithmetic
Multiplication
Multiplicand: 1011 Rules of Binary Multiplication
Multiplier: 101 0 x 0 = 0
0 x 1 = 0
1011 1 x 0 = 0
0000 1 x 1 = 1, and no carry or borrow bits
1011
Product: 110111
11
Number-Base Conversions
Example1.1
Convert decimal 41 to binary. The process is continued until the integer quotient
becomes 0.
12
Number-Base Conversions
The arithmetic process can be manipulated more conveniently as follows:
Conversion from decimal integers to any base r system is similar to this example,
except that division is done by r instead of 2.
13
Number-Base Conversions
Example 1.2
Convert decimal 153 to octal. The required base r is 8.
The conversion of a decimal fraction to binary is accomplished by a method similar to that used for
integers. However, multiplication is used instead of division, and integers instead of remainders are
accumulated.
14
Number-Base Conversions
Example1.3 Convert (0.6875)10 to binary.
The process is continued until the fraction becomes 0 or until the number of digits has
sufficient accuracy.
15
Number-Base Conversions
Example1.4
Convert (0.513)10 to octal.
16
Number-Base Conversions
17
Number-Base Conversions
Conversion from binary to octal can be done by positioning the binary
number into groups of three digits each, starting from the binary point and
proceeding to the left and to the right.
(10 110 001 101 011 . 111 100 000 110) 2 = (26153.7406)8
2 6 1 5 3 7 4 0 6
Conversion from binary to hexadecimal is similar, except that the binary
number is divided into groups of four digits:
18
Number-Base Conversions
19
Complements of Numbers
Complements are used in digital computers to simplify the subtraction
operation and for logical manipulation.
20
Complements of Numbers
■ Diminished Radix Complement (r - 1)’s complement
Given a number N in base r having n digits, the (r - 1)’s complement of N, i.e., its
•" diminished radix complement, is defined as (rn - 1) - N.
Example:
For decimal numbers, r = 10 and r – 1 = 9, 9's complement of N is (10n 1) – N.
(106 1) – 546700 = (1000000 1) – 546700 = 999999 – 546700
21
Complements of Numbers
■ Radix Complement r ’s complement
The r's complement of an n-digit number N in base r is defined as rn – N for N ≠ 0
and as 0 for N = 0. Comparing with the (r 1) 's complement, we note that the r's
complement is obtained by adding 1 to the (r 1) 's complement, since rn – N =
[(rn 1) – N] + 1.
Example: Base-10
“leaving all least significant 0’s unchanged,
The 10's complement of 012398 is 987602 subtracting the first nonzero least significant digit
The 10's complement of 246700 is 753300 from 10, and subtracting all higher significant digits
from 9”
Example: Base-2
“leaving all least significant 0’s and the first 1
The 2's complement of 1101100 is 0010100
unchanged and replacing 1’s with 0’s and 0’s with
The 2's complement of 0110111 is 1001001
1’s in all other higher significant digits”
22
Subtraction with Complements
23
Subtraction with Complements
Example 1.5: Using 10's complement, subtract 72532 – 3250. M N
24
Subtraction with Complements
Example 1.7
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.
25
Subtraction with Complements
Subtraction of unsigned numbers can also be done by means of the (r 1)'s
complement. Remember that the (r 1) 's complement is one less then the r's
complement.
Example 1.8 Repeat Example 1.7, but this time using 1's complement.
26
Signed Binary Numbers
In ordinary arithmetic, a negative number is indicated by a minus sign and a
positive number by a plus sign. Because of hardware limitations, computers must
represent everything with binary digits.
It is customary to represent the sign with a bit placed in the leftmost position of
the number.
The convention is to make the sign bit 0 for positive and 1 for negative.
Positive number representation
signed-magnitude representation:
0 0 0 0 1 0 0 1 +9
Sign bit Magnitude bits
Sign bit
Negative number representation
9
27
Signed Binary Numbers
In signed magnitude, 9 is obtained from +9 by changing only the sign bit in the
leftmost position from 0 to 1.
In signed 1’s-complement, 9 is obtained by complementing all the bits of +9,
including the sign bit.
The signed 2’s complement representation of 9 is obtained by taking the 2’s
complement of the positive number, including the sign bit.
signed-magnitude representation:
0 0 0 0 1 0 0 1 +9
9
28
29
Signed Binary Numbers Arithmetic
■ Addition
The addition of two signed binary numbers with negative numbers
represented in signed-2's-complement form is obtained from the addition of
the two numbers, including their sign bits.
A carry out of the sign-bit position is discarded.
The result is in signed form.
Example:
30
Signed Binary Numbers Arithmetic
■ Subtraction
Take the 2’s complement of the subtrahend (including the sign bit) and add it
to the minuend (including the sign bit).
( A) ( B) ( A) ( B)
A carry out of the sign bit position is discarded.
( A) ( B ) ( A) ( B)
Example:
31
Binary-Coded Decimal (BCD) code
We naturally live in a base 10 environment
Computer exist in a base 2 environment
So give the computer/digital system the task of doing the
conversions for us.
32
Binary-Coded Decimal (BCD) code
A number with k decimal digits will
require 4k bits in BCD.
Decimal 396 is represented in BCD
with 12 bits as 0011 1001 0110, with
each group of 4 bits representing one
decimal digit.
A decimal number in BCD is the same
as its equivalent binary number only
when the number is between 0 and 9.
A BCD number greater than 10 looks
different from its equivalent binary
number, even though both contain 1's
and 0's. Moreover, the binary
combinations 1010 through 1111 are not
used and have no meaning in BCD.
33
Binary-Coded Decimal (BCD) code
The BCD value has 12 bits to encode the characters of the decimal value, but
the equivalent binary number needs only 8 bits.
representation of a BCD number needs more bits than its equivalent binary
value
BCD numbers are decimal numbers and not binary numbers, although they
use bits in their representation.
34
Binary-Coded Decimal (BCD) code
■ BCD Addition
When the binary sum is equal to or less than 1001 (without a carry), the
corresponding BCD digit is correct.
However, when the binary sum is greater than or equal to 1010, the result is
an invalid BCD digit.
The addition of 6 = (0110)2 to the binary sum converts it to the correct digit
and also produces a carry as required.
This is because a carry in the most significant bit position of the binary sum
and a decimal carry differ by 16 - 10 = 6.
35
Binary-Coded Decimal (BCD) code
■ BCD Addition
Example:
Consider the addition of 184 + 576 = 760 in BCD:
The first, least significant pair of BCD digits produces a BCD digit sum of 0000 and a carry for
the next pair of digits. The second pair of BCD digits plus a previous carry produces a digit
sum of 0110 and a carry for the next pair of digits. The third pair of digits plus a carry
produces a binary sum of 0111 and does not require a correction.
36
Binary-Coded Decimal (BCD) code
■ Decimal Arithmetic
plus 0 0000
minus 9 1001
37
Other Decimal Codes
In a weighted code, each bit position is
assigned a weighting factor in such a way that
each digit can be evaluated by adding the
weights of all the 1’s in the coded
combination.
BCD and the 2421 code are examples of
weighted codes.
The 2421 and the excess‐3 codes are
examples of self‐complementing codes.
(9’s complement of a decimal number is
obtained directly by changing 1’s to 0’s and
0’s to 1’s)
Excess‐3 is an unweighted code in which
each coded combination is obtained from
the corresponding binary value plus 3.
The 8, 4, -2, -1 code is an example of
assigning both positive and negative
weights to a decimal code.
38
Gray Code
39
ASCII Character Code
40
ASCII Character Code
■ ASCII Character Code
41
Error‐Detecting Code
42
Error‐Detecting Code
Redundancy (e.g. extra information), in the form of extra bits,
can be incorporated into binary code words to detect and
correct errors.
A simple form of redundancy is parity, an extra bit appended
onto the code word to make the number of 1’s odd or even.
Parity can detect all single-bit errors and some multiple-bit
errors.
A code word has even parity if the number of 1’s in the code
word is even.
A code word has odd parity if the number of 1’s in the code
word is odd.
43
Binary Storage and Registers
■ Registers
A binary cell is a device that possesses two stable states and is capable of storing one of the
two states.
A register is a group of binary cells. A register with n cells can store any discrete quantity of
information that contains n bits.
n cells 2n possible states
• A binary cell
– two stable state
– store one bit of information
– examples: flip-flop circuits
• A register
– a group of binary cells
– AX in x86 CPU
44
Binary Storage and Registers
■ Register Transfer
45
Binary Storage and Registers
46
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 and 0,
There are three basic logical operations: AND, OR, and NOT.
47
Binary Logic
■ The truth tables for AND, OR, and NOT are given in Table 1.8.
48
Binary Logic
■ Logic gates
Graphic Symbols and Input-Output Signals for Logic gates:
Fig. 1.5
Input-Output signals
for gates
49
Binary Logic
■ Logic gates
The three input AND gate responds with logic 1 output if all three
inputs are logic 1. The output produces logic 0 if any input is logic 0.
The four input OR gate responds with logic 1 if any input is logic 1;
its output becomes logic 0 only when all inputs are logic 0.
50
Binary Logic
Electrical signals such as voltages or
currents exist as analog signals having
values over a given continuous range, say,
0 to 3 V, but in a digital system these
voltages are interpreted to be either of two
recognizable values, 0 or 1.
Voltage operated logic circuits respond to
two separate voltage levels that represent a
binary variable equal to logic 1 or logic 0.
For example, a particular digital system may
define logic “0” as a signal equal to 0 V and
logic “1” as a signal equal to 3 V.
In practice, each voltage level has an
acceptable range.
51
The End
Reference:
1. Digital Design (with an introduction to the Verilog HDL) 6th Edition, M. Morris Mano,
Michael D. Ciletti
Note: The slides are supporting materials for the course “Digital Circuits” at IIITDM Kancheepuram.
Distribution without permission is prohibited.
52