1 - Number System and Digital Logic
1 - Number System and Digital Logic
0
Zero
Null
1
One
I
2
Two
II
3
Three
III
4
Four
IIII
5
Five
IIIII
6
7
8
Six Seven Eight
IIIII
IIIII
IIIII
I
II
III
9
Nine
IIIII
IIII
Page 1
To count more than nine we repeat the above symbol and the number grows
form single digit to multiple digit. For multi-digit numbers the rightmost digit
changes with the increase of count keeping the left one fixed. Thus the second
right most digit increase when the right most digit ends to the last symbol 9.
Following example shows the use of the above ten symbol presenting decimal
numbers greater than nineDigit-1
Digit-2
Number
1
0
10
1
1
11
1
2
12
1
1
1
1
3
4
5
6
13 14 15 16
Digit-2 increase
1
7
17
1
8
18
1
9
19
2
2
2
2
0
1
2
3
20 21 22 23
Digit-1 increase
In the decimal number system 0 alone can not represent any quantity, but it
increase the weight ten times (x10) every time it added in the right position, such
as 10 represent ten, 100 represents 10x10, which is called hundred.
Mathematically this increase of weight is represented asN
1
10
100
1000
10000
100000
1000000
1000000000
N
0
1
2
3
4
5
6
9
Weight
One
Ten
Hundred
Thousand
Ten thousand or Myriad
Hundred Thousand or Lakh
Million
Billion
So, the position of the symbol in a number carries different weight. Following
example shows the weight of the symbols in a number-
Page 2
Symbol
Digit-number
Weight
Value
3
1
5
x10
300000
4
2
4
x10
40000
5
3
3
x10
5000
6
4
2
x10
600
7
5
1
x10
70
8
6
0
x10
8
Page 3
11
10
10
2
1024
10
9
9
2
512
9
8
8
7
2
128
2
256
7
6
6
2
64
6
5
5
2
32
5
4
4
2
16
4
3
3
2
8
3
2
2
2
4
2
1
1
2
2
1
0
0
2
1
So, the number represented by the 8-digit binary number 11101010 can be find
out-
Symbol
Position
(N-1)
Weight
Value
1
8
7
x128
128
1
7
6
x64
64
1
6
5
x32
32
0
5
4
x16
0
1
4
3
x8
8
0
3
2
x4
0
1
2
1
x2
2
0
1
0
x1
0
128 + 64 + 32 + 0 + 8 + 0 + 2 + 0 = 234
0
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9 A B C D E F
9 10 11 12 13 14 15
So, any number greater than 15 needs more than one digit to be represented.
Position of every digit from the right to left has higher weight of 16 times (x16),
i.e.,
(N-1)
16
Page 4
Following table shows the weight of the digits of the hexadecimal number.
Position
(N-1)
Weight
4
3
3
16
4096
3
2
2
16
256
2
1
1
16
16
1
0
0
16
1
A
4
3
x4096
40960
B
3
2
x256
2816
C
2
1
x16
192
D
1
0
x1
13
Symbol
Position
(N-1)
Weight
Value
4
4
3
3
x8
4x512=2048
5
3
2
2
x8
5x64=320
6
2
1
1
x8
6x8=48
7
1
0
0
x8
7x1=7
Page 5
Number System
Decimal
Binary
Hexadecimal
Octal
Notation
x10 or d
x2 or b
x16 or h
x8 or o
Example
150x10 or 150d
10010110x2 or 10010110b
96x16 or 96h
226x8 or 226o
Oct
0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
Dec
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Hex
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Page 6
4
4
3
2
2
x16
4x256=1024
B
11
2
1
1
x16
11x16=176
3
3
1
0
0
x16
3x1=3
2
2
3
2
2
x8
2x64=128
3
3
2
1
1
x8
3x8=24
4
4
1
0
0
x8
4x1=4
128 + 24 + 4 = 156
Binary to decimal conversion: Convert 11011011 to decimal.
Solution:
Symbol
Position
(N-1)
Weight
Value
1
8
7
x128
128
1
7
6
x64
64
0
6
5
x32
0
1
5
4
x16
16
1
4
3
x8
8
0
3
2
x4
0
1
2
1
x2
2
1
1
0
x1
1
128 + 64 + 0 + 16 + 8 + 0 + 2 + 1 = 219
Page 7
315/2 =
157/2 =
78/2 =
39/2 =
19/2 =
9/2 =
4/2 =
2/2 =
1/2 =
Quotient Remainder
157
1
78
1
39
0
19
1
9
1
4
1
2
0
1
0
0
1
315 = 100111011
Decimal to octal conversion: Convert the decimal number 315 to octal number.
Page 8
Solution:
315/8 =
39/8 =
4/8 =
Quotient Remainder
39
3
4
7
0
4
315 = 473
Dec
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Oct
0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
Hex
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Bin
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
0001 0000
0001 0001
0001 0010
0001 0011
0001 0100
0001 0101
Page 9
BCD number system is mainly used for HW interfacing with 7-segment display
module. As the 7-segment display module can display from 0 to 9 so only BCD
number system can be used to display the decimal number using 7-segment
display unit. There is another conversion required to make the BCD number
visible in a 7-segment display module, which will be described in the coming
sections.
1.2 Mathematics
Similar to decimal mathematics simple addition, subtraction, multiplication and
division can be done for binary, hex, octal and BCD numbers. For simplicity only
addition and subtraction of binary and hex numbers will be described.
1 5 1 Number
nd
+ 1 8 2 Number
---------3
1 as overflow
+1
---------33
st
nd
Page 10
as 12 is greater than 9, only the first digit (here 3) of the result will be the
digit-1 of the result and second digit of the result (here 1) will be added
with the digit-2 of the first number.
digit-1 of the result is 3
overflow is 1
st
nd
number)
2+1=3
digit-2 of result is 3
So, the complete result is 3 3
Now we will do the same for the binary representation of the above 2 numbers.
st
1 5 = 1 1 1 1 (1 number)
nd
1 8 = 1 0 0 1 0 (2 number)
st
1111
+ 10010
--------------1
0
+
1
--------------001
+ 1
--------------0001
+1
--------------100001
nd
--- 1 as overflow
--- 1 as overflow
--- 1 as overflow
33 in decimal
Page 11
st
nd
st
Step-2: The 2 digit of the result will be, overflow of previous step + digit-2 (1
nd
number) + digit-2 (2 digit) = 0 + 1 + 1 = 1 0, where 0 is the digit-2 of the
result and 1 is the overflow.
Applying the same rule of step-2, the digit-3 of result will be, overflow of previous
st
nd
step + digit-3 (1 number) + digit-3 (2 number) = 1 + 1 + 0 = 1 0, where 0 is the
result and 1 is the overflow.
For the fourth digits, 1 + 1 + 0 = 1 0, 0 is the result and 1 is the overflow
For the fifth digits, 1 + __ + 1 = 1 0, as there is no more digit to left in the
numbers to add, result of this step is 1 0.
So, the complete result is, 1 0 0 0 0 1 (which is 33 in decimal).
A
B
C
D
E
F
10
11
12
13
14
15
16
17
18
19
B
C
D
E
F
10
11
12
13
14
15
16
17
18
19
1A
C
D
E
F
10
11
12
13
14
15
16
17
18
19
1A
1B
D
E
F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
E
F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
Page 12
Following example shows the addition of two hex numbers step by step.
2ABC
+ED53
---------------F
0
+ 1
---------------80F
+1
---------------1180F
st
(1 number)
nd
(2 number)
--- 1 as overflow
+ 1 overflow with digit-3
--- 1 as overflow
st
nd
nd
st
Similarly for the 3 digits, overflow of previous step + digit-3 (1 digit) + digit-3
nd
(2 digit) = 1 + A + D = ( 1 + A ) + D = B + D = 1 8, where 8 is the digit-3 of result
and 1 is the overflow.
st
nd
And for the fourth digits, overflow of previous step + digit-4 (1 digit) + digit-4 (2
digit) = 1 + 2 + E = ( 1 + 2 ) + E = 3 + E = 1 1, as there is no more digits left in the
numbers, 1 1 is the result without any overflow.
So, the complete result = 1 1 8 0 F.
In the above examples we see that we get only 1 as overflow, but it can be more
than 1 while adding more than 2 numbers.
Page 13
st
with the present digit of the the 1 number and add 1 with the next digit of the 2
number. We also need to know the following basic rules for binary subtraction-
nd
00=0
11=0
10=1
10 1 = 1
Following example shows the subtraction of a number from a larger number.
110101
- 101100
--------------------1
0
0
--------------------10
1
--------------------1001
--------------------11
- 11
-------------------01001
0
------------------001001
st
( 1 number, decimal 53 )
nd
( 2 number, decimal 44 )
th
st
st
st
Decimal 9
For hex subtraction, if any digit of the 1 number is smaller than the same digit of
nd
st
the 2 number, we need to add 10 hex (decimal 16) with that digit of the 1
nd
number and 1 hex with the next digit of the 2 number. Following example
shows subtraction of two hex numbers step by step.
Page 14
CDA3
2BF2
---------------1
---------------1A
F
---------------B1
---------------CD
- 2C
---------------1B1
A
---------------A1B1
st
st
st
st
Page 15
Gate
NOT Gate
OR Gate
AND Gate
Input (A,B)
0
1
00
01
10
11
00
01
10
11
AND Gate
Logical operation
Y = A
Y = A or B
Y=A+B
Y = A and B
Y = A.B
OR Gate
NAND Gate
Output (Y)
1
0
0
1
1
1
0
0
0
1
NOR Gate
XOR Gate
There are three logic gates which are derived from the three basic gates. These
are NOR, NAND, XOR (exclusive-or) and XNOR gate.
NAND gate and NOR gate are also called universal gate because we can derive
any logic using only NAND gates or NOR gates. OR, NOR, AND and NAND
gates can be of two or more than two inputs.
The Exclusive-OR, or XOR function is an interesting and useful variation on the
basic OR function. Verbally, it can be stated as, "Either A or B, but not both." The
XOR gate produces a logic 1 output only if its two inputs are different. If the
Page 16
inputs are the same, the output is a logic 0. Unlike other gates XOR and XNOR
can have only two inputs.
These derived gates and their logical operations are shown in the following table-
Gate
Derived from
NOR Gate
OR > NOT
NAND Gate
XOR Gate
Multiple Gate
XNOR Gate
00 = 0
10 = 0
01 = 0
11 = 1
A0 = 0
A1 = A
AA = A
AA' = 0
Page 17
OR Operations (+):
0+0 = 0
1+0 = 1
0+1 = 1
1+1 = 1
A+0 = A
A+1 = 1
A+A = A
A+A' = 1
0' = 1
1' = 0
A'' = A
Associative Law:
Distributive Law:
Commutative Law:
AB = BA
A+B = B+A
Precedence:
AB = AB
AB+C = (AB) + C
A+BC = A + (BC)
Timer-Counter
Decoder
Shift-register
Multiplexer
Encoder
A list of different type of digital logic and functional ICs is given in appendix A.
Page 18
1.4.1 Flip-flop
Flip-flop changes the output state based on the input state and (if any) clockpulse. Symbol and the characteristic tables for different flip-flops are shown
bellow.
Set-Reset Flip-flop (SR F/F): SR flip-flop is a simple latch, where S and R stand
for set and reset respectively. It can be constructed from a pair of cross-coupled
NAND or NOR logic gates. The stored bit is present on the output marked Q and
its complement Q. If S is pulsed high while R is held low, then the Q output is
forced high, and stays high even after S returns low; similarly, if R is pulsed high
while S is held low, then the Q output is forced low, and stays low even after R
returns low.
Symbol
S-R
0-0
0-1
1-0
1-1
Action
No change
Q=0
Q=1
Undefined/
Race condition
Q (t)
0
0
1
Q(t+1)
0
1
0
Toggle Flip-flop (T-F/F): If the T input is high, the T flip-flop changes state
("toggles") whenever the clock input receives a pulse. If the T input is low, the
flip-flop holds the previous value. When T is held high, the toggle flip-flop divides
the clock frequency by two; that is, if clock frequency is 4 MHz, the output
frequency obtained from the flip-flop will be 2 MHz. This 'divide by' feature has
application in various types of digital counters. A T flip-flop can also be built using
a JK flip-flop (J & K pins are connected together and act as T) or D flip-flop (T
input and Q is connected to the D input through an XOR gate).
Symbol
T
0
0
1
1
Q (t)
0
1
0
1
Q(t+1)
0
1
1
0
Action
No change
No change
Toggle
Toggle
Page 19
J-K Flip-flop (JK F/F): The JK flip-flop augments the behavior of the SR flip-flop
(J=Set, K=Reset) by interpreting the S = R = 1 condition as a "flip" or toggle
command. Specifically, the combination J = 1, K = 0 is a command to set the flipflop; the combination J = 0, K = 1 is a command to reset the flip-flop; and the
combination J = K = 1 is a command to toggle the flip-flop, i.e., change its output
to the logical complement of its current value. Setting J = K = 0 does NOT result
in a D flip-flop, but rather, will hold the current state. To synthesize a D flip-flop,
simply set K equal to the complement of J. The JK flip-flop is therefore a
universal flip-flop, because it can be configured to work as an SR flip-flop, a D
flip-flop, or a T flip-flop. This flip flop is positive edge triggered (Clock Pulse).
Symbol
J-K
0-0
Action
Hold
Q (t)
0
Q(t+1)
0
0-1
Reset
1-0
Set
1-1
Toggle
D Flip-flop (D F/F): The Q output always takes on the state of the D input at the
moment of a rising clock edge (or falling edge if the clock input is active low). It is
called the D flip-flop for this reason, since the output takes the value of the D
input or Data input, and Delays it by one clock count. The D flip-flop can be
interpreted as a primitive memory cell, zero-order hold, or delay line.
Symbol
Clock
Q (t)
Rising
Rising
Non Rising
No change
Q (t-1)
Page 20
by the first or master D latch (the inverted clock signal) is high (logical 1). This
allows the master latch to store the input value when the clock signal transitions
from low to high. As the clock signal goes high (0 to 1) the inverted enable of
the first latch goes low (1 to 0) and the value seen at the input to the master latch
is locked. Nearly simultaneously, the twice inverted enable of the second or
slave D latch transitions from low to high (0 to 1) with the clock signal. This
allows the signal captured at the rising edge of the clock by the now locked
master latch to pass through the slave latch. When the clock signal returns to
low (1 to 0), the output of the "slave" latch is "locked", and the value seen at the
last rising edge of the clock is held while the master latch begins to accept new
values in preparation for the next rising clock edge.
Symbol
>
Q(t+1)
Falling
Falling
1.4.2 Counter
Counter is a device which stores (and sometimes displays) the number of times a
particular event or process has occurred, often in relationship to a clock signal.
Counters can be implemented quite easily using flip-flop, and a wide variety of
designs exist i.e.;
Asynchronous (ripple) counter, Synchronous counter
Binary counter, Decade counter, BCD Counter
Updown counter
Preset able/ programmable counter
Ring counter, Johnson counter, Cascaded counter
Counters can be of 4-bit, 8-bit or more than 8-bit. Counters are used as
frequency divider also.
Page 21
On the other end, a de-multiplexer (or demux) is a device taking a single input
signal and selecting one of many data-output-lines, which is connected to the
single input. A multiplexer is often used with a complementary de-multiplexer on
the receiving end.
1.4.4 Decoder
Decoder can take the form of a multiple-input, multiple-output logic circuit that
converts coded inputs into coded outputs, where the input and output codes are
n
different. Such as, an n-to-2 type binary decoders, which converts binary
information from 'n' coded inputs to a maximum of 2n unique outputs. Decoding
is necessary in applications such as data multiplexing, BCD to 7 segment display
and memory address decoding. Following figure shows a 2 line to 4 line decoder,
which can be used for address decoding of computer system memory.
Page 22
1.4.5 Shift-register
The term register refers to a group of flip-flops operating as a unit to hold data. A
counter can be viewed as a specialized kind of register, which counts events and
thereby generates data, rather than just holding the data. Shift register shifts data
through it, from flip-flop to flip-flop. Based on shift nature shift register are of two
kinds;
- Serial to Parallel Shift Register or Serial in Parallel Out Shift register (SIPO)
- Parallel to Serial Shift Register or Parallel in Serial Out Shift register (PISO)
If we apply one byte (8 bits) of data to the initial data input one bit at a time at the
input of an SIPO registe, and apply one clock pulse to the circuit after setting
each bit of data, we will find the entire byte present at the flip-flop outputs in
parallel format.
Page 23
PISO register transfer the parallel data to its single output bit by bit for each clock
pulse.
1.4.6 Buffer-Register
Buffers are normally used for physical isolation and / or to increase the driving
capability to support more inputs at a time. Some time it can be used for logic
level shifting also, such as 5v logi to 3v logic. Buffer can also hold one byte data
for temporary use.
Page 24
power consumption, propagation delay etc. The 74 series (54 series is the
military version of 74 series) is mainly TTL and 4000 Series is CMOS, however
some 74 series have CMOS-TTL combination for better performance. Different
types of 74 series are listed in the following table.
L
S
Low power
Schottky
H
LS
High speed
Low power Schottky
BCT
BTL
AS
ALS
Advanced Schottky
Advanced Low power Schottky
HC
HCT
LV
LVC
Low Voltage
LV CMOS
FCT
AC
LVT LV TTL
LVTZ Low Voltage TTL High Impedance power-up
ACT
ACQ
LCX
VCX
Page 25
Page 26
However the difference in input logic switching level does impact the design, the
TTL output does not correctly switch a CMOS input. The switching difference
between a TTL IC output and a CMOS IC input has to be accounted for. The
mixed CMOS/TTL (ACT, HCT, AHCT, FCT) logic devices have TTL logic input
switching levels and CMOS output switching levels. The mixed TTL/CMOS
devices are CMOS devices which just happen to have TTL input trigger levels,
but they are CMOS ICs.
So the rule is, if we use a CMOS IC for reduced current consumption (for
example), and a TTL IC feeds the CMOS chip, then we need to either provide a
voltage translation or use one of the mixed CMOS/TTL devices.
Page 27
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
0000
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
0001
1
17
33
49
65
81
97
113
129
145
161
177
193
209
225
241
0010
2
18
34
50
66
82
98
114
130
146
162
178
194
210
226
242
0011
3
19
35
51
67
83
99
115
131
147
163
179
195
211
227
243
0100
4
20
36
52
68
84
100
116
132
148
164
180
196
212
228
244
0101
5
21
37
53
69
85
101
117
133
149
165
181
197
213
229
245
0110
6
22
38
54
70
86
102
118
134
150
166
182
198
214
230
246
0111
7
23
39
55
71
87
103
119
135
151
167
183
199
215
231
247
1000
8
24
40
56
72
88
104
120
136
152
168
184
200
216
232
248
1001
9
25
41
57
73
89
105
121
137
153
169
185
201
217
233
249
1010
10
26
42
58
74
90
106
122
138
154
170
186
202
218
234
250
1011
11
27
43
59
75
91
107
123
139
155
171
187
203
219
235
251
1100
12
28
44
60
76
92
108
124
140
156
172
188
204
220
236
252
1101
13
29
45
61
77
93
109
125
141
157
173
189
205
221
237
253
1110
14
30
46
62
78
94
110
126
142
158
174
190
206
222
238
254
1111
15
31
47
63
79
95
111
127
143
159
175
191
207
223
239
255
Page 28
For example decimal 150 corresponds the 1001 from the first column and 0110
from the first row, so the binary representation of 150 is 1001-0110.
Sometimes bit is noted by the letter b in small, and byte is noted by the letter B
in capital.
Binary Number
0111-1111
0000-1111
0000-0000
1000-0000
1111-1111
Unsigned
127
15
0
128
255
Signed
+127
+15
0
-0
-127
There are two more ways to represent signed number; Ones (1s) complement
and Twos (2s) complement.
Ones complement: The ones' complement form of a negative binary number is
the bitwise NOT applied to it; the complement of its positive counterpart. As an
Page 29
Signed Binary
Binary
Decimal
00000000
0
00000001
1
01111110
126
01111111
127
10000000
-0
10000001
-1
11111110
-126
11111111
-127
1s complement
Binary Decimal
00000000
+0
00000001
1
01111110
126
01111111
127
01111111 -127
01111110 -126
00000001
-1
00000000
-0
2s complement
Binary Decimal
00000000
0
00000001
1
01111110
126
01111111
127
10000000 -128
01111111 -127
00000010
-2
00000001
-1
Un-signed
Decimal
0
1
126
127
128
129
254
255
Page 30
We can count more than 64k by multiple round of counting as given in the
following tablebits
16
Pinky
2
Ring
6
Middle
Pointer
scale
32 128 256 512 1M 2M 4M 8M 16M 32M 64M 128 256 512 1G 2G 4G M-G
48 8G 16G 32G 64G 128 256 512 1T 2T 4T 8T 16T 32T 64T 128 256 G-T
Page 31
However, depending on many factors, these inputs can act as an antenna, and
pick up NOISE which can cause mischief to the circuit. The worst case is, the
device will act as an uncontrolled intermittent OSCILLATOR.
Therefore, all unused inputs of TTL logic devices IDEALLY should be returned to
either a logic ONE or logic ZERO. Certain devices 74XX and earlier 74LS the
logic 1 (Vcc) should be a 1k resistor to Vcc; or alternatively, connected directly to
ground (0). Most/all other logic devices, the resistor is UNNECESSARY.
In the case of CMOS devices, there is NO input DEFAULT; CMOS input
impedance is on the order of thousands of MEGOHMS and will cause EXTREME
FAILURES if allowed to FLOAT.
To make this point: if you put your finger or a scope probe on or NEAR an unterminated CMOS input, it can cause a logic CHANGE!! If allowed to float, some
CMOS devices can oscillate so fast, that it exceeds the device power rating and
will literally destroy itself.
Tri-state: Tri-state means three states. We know that digital devices can have
two states; 0 and 1. However, tri-state digital outputs have one more state which
is called hi-impedance or open. This tri-state output pin can be easily understand
from the following figure, where a single pole 3-throw switch can connect its pole
to +5 volt, ground (or 0v) and no-voltage.
Page 32
Open collector and open drain: Push-pull (also called totem pole) type output
has two complementary BJTs or MOSFETs connected with the Vcc and ground.
However, open collector and open drain outputs has only one BJT or MOSFET
connected with the ground.
If these types of output have no internal pull-up resistor, we can connect multiple
outputs with a single external pull-up as shown in the figure. These outputs then
act as single ORed output.
Page 33
NEVER EVER USE the original generic 7400 DEVICE. INSTEAD: Use
anything else, e.g., 74LS, 74ALS, etc.
The older devices require five to ten times the drive power and force very
LARGE amounts of NOISE on to the Vcc rail! This is NOT GOOD!
Remember, the newer the technology the happier the circuit will be well
almost!
Review Questions:
1.
2.
3.
4.
5.
6.
7.
Design experiment:
1. Design a circuit using digital ICs (CMOS and/or TTL) that will turn on and
off a light at two particular times, like ON at 7pm and OFF at 11pm. This
time should the changeable.
Page 34