You are on page 1of 22

Digital Circuit Design

18B11EC215
Lecture 5
Codes and Boolean Algebra

1
Outline

■Excess-3 Codes
■Gray Codes

■Alphanumeric codes

▪ Digital Circuits
▪ Boolean Algebra
▪ Two –Valued Boolean Algebra
▪ Boolean Algebra Postulates

2
Excess-3 Codes[2]
■ This is another form of BCD Code , in which each decimal digit is coded into
a 4-bit binary code.
■ The code for each decimal digit is obtained by adding decimal 3 to the BCD
code of the digit.
■ Decimal 2 is coded as 0010 + 0011= 0101
■ It is not a weighted code.
■ It is a self complementing code, which means 1’s complement of the coded
number yields 9’s complement of the number it self.
■ Example : Excess 3 code for decimal 5 is 8 i.e., 1000 ,its 1’s complement is
0111,which is excess 3 code for decimal 4, which is 9’s complement of
decimal 5 itself.

3
Example[2]

■ Represent (342)10 in Excess-3.


■ 3 4 2

(3+3) (4+3) (2+3)


6 7 5

( 0110 0111 0101)Excess 3

4
Example[2]

■ Convert the Excess-3 code (110010000011) into its decimal equivalent.


1100 1000 0011

(12-3) (8-3) (3-3)

(9 5 0)10

5
Gray Code[2,3]
■ It is a very useful code in which a decimal number is represented in binary form in such
a way so that each gray code number differs from the preceding and the succeeding
numbers by a single bit.
■ It is not a weighted code.
■ It is a reflected code.
■ A 1-bit gray code has two code words 0 and 1 representing decimal numbers 0 and 1.

6
Examples

■ 1 Bit Gray Code


Decimal Number Gray Code
0 0
1 1
■ 2 Bit Gray Code
0 0 0
1 0 1
2 1 1
3 1 0

7
More Examples

■ 3- bit Gray Code


Decimal Number Gray Code
0 0 0 0
1 0 0 1
2 0 1 1
3 0 1 0
4 1 1 0
5 1 1 1
6 1 0 1
7 1 0 0

8
Conversion From Binary to Gray[2]
leftmost bit
■ Start with the most significant bit of the binary number.

■ Copy this bit as the MSB of the gray code number.

■ Add the MSB of the binary to the next bit of the binary number.

■ The sum (ignoring carry) is the next bit of the gray code number.

■ Continue adding each bit of the binary to the next bit to its right to get the gray
code for that position as shown in the next slide

9
Conversion From Binary to Gray Cont…

10
Conversion From Gray to Binary[2]
■ Start with the most significant bit of the Gray number.

■ Add each binary digit generated, to the Gray digit in the next adjacent position .

■ Discard the carry.

■ Repeat the same to cover all the bits.

11
Example[2]
Convert (11011)Gray to (?)2.

1 1 0 1 1

1 0 0 1 0
Ans : (10010)2

12
Example
■ Represent the decimal number 39 in
(i) Binary code
(ii) BCD code
(iii) Excess-3 code
(iv) Octal code
(v) Hexadecimal code
(vi) Gray code

Ans : (i) (100111)2


(ii)(00111001)BCD
(iii)(01101100)excess-3
(iv) (47)8
(v) (27)16
(vi) (110100)Gray

13
Digital Circuits
▪ Digital circuit can be represented by a black-box with inputs on one side, and
outputs on the other.

inputs Digital outputs


: circuit :

The input/output signals are discrete/digital in nature, typically with two distinct
voltages (a high voltage and a low voltage).

High

Low

In contrast, analog circuits use continuous signals.


Digital Circuits

▪ Advantages of Digital Circuits over Analog Circuits:


❖ more reliable (simpler circuits, less noise-prone)
❖ specified accuracy (determinable)
❖ but slower response time (sampling rate)
▪ Important advantages for two-valued Digital Circuit:
❖ Mathematical Model – Boolean Algebra
❖ Can help design, analyze, simplify Digital Circuits.
Boolean Algebra[1,2,3]
What is an Algebra? (e.g. algebra of integers)
set of elements (e.g. 0,1,2,..)
set of operations (e.g. +, -, *,..)
postulates/axioms (e.g. 0+x=x,..)

▪ Boolean Algebra named after George Boole who used it to study human
logical reasoning – calculus of proposition.
▪ Events : true or false
▪ Connectives : a OR b; a AND b, NOT a
▪ Example: Either “it has rained” OR “someone splashed water”, “must be tall”
AND “good vision”.
Boolean Algebra[1,2,3]

Later, Shannon introduced switching algebra (two-valued Boolean algebra) to


represent bi-stable switching circuit.
Two-valued Boolean Algebra[1]
▪ Set of Elements: {0,1}
▪ Set of Operations: { ., + }

x x
x.y x+y x x'
y y

Signals: High = 5V = 1; Low = 0V = 0


Boolean Algebra Postulates[1,2]
A Boolean algebra consists of a set of elements B, with two binary operations
{+} and {.} and a unary operation {'}, such that the following axioms hold:

▪ The set B contains at least two distinct elements x and y.


▪ Closure: For every x, y in B,
❖ x + y is in B
❖ x . y is in B
▪ Commutative laws: For every x, y in B,
❖ x+y=y+x
❖ x.y=y.x
Boolean Algebra Postulates[1,2]
▪ Associative laws: For every x, y, z in B,
❖ (x + y) + z = x + (y + z) = x + y + z
❖ (x . y) . z = x .( y . z) = x . y . z
▪ Identities (0 and 1):
❖ 0+x=x+0=x for every x in B
❖ 1.x=x.1=x for every x in B
▪ Distributive laws: For every x, y, z in B,
❖ x . (y + z) = (x . y) + (x . z)
❖ x + (y . z) = (x + y) . (x + z)
Boolean Algebra Postulates[1,2]
▪ Complement: For every x in B, there exists an element x' in B such that
❖x + x' = 1
❖x . x' = 0

The set B = {0, 1} and the logical operations OR, AND and NOT satisfy all the
axioms of a Boolean algebra.
A Boolean function maps some inputs over {0,1} into {0,1}
A Boolean expression is an algebraic statement containing Boolean variables
and operators.
References

[1] M. Morris Mano and Michael D. Ciletti, “Digital Design with an Introduction to the
Verilog HDL,” 5th Edition, Pearson Education,2013.

[2] Reshu Gupta, Amit Gupta ,Atul Kumar Sharma “ Switching Theory(Digital
Electronics)”, Tech India Publication Series, Satya Prakashan, New Delhi.

[3] R. P. Jain, “Modern Digital Electronics,” 4th Edition, Tata McGraw-Hill Education,
2009.

22

You might also like