0% found this document useful (0 votes)
13 views8 pages

BCD and Gray Code Overview

Uploaded by

alityyyteshome
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

BCD and Gray Code Overview

Uploaded by

alityyyteshome
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

COMPUTER SCIENCE DEPARTMENT

DIGITAL LOGIC DESIGN

TITLE: BCD, XS-3, Gray Code and ROM circuit


NAME ALEMTSEHAY TESHOME
ID NO 0063/22

BCD, XS-3, Gray Code and ROM circuit


1|Page
BINARY CODED DECIMAL (BCD)
• In this code each digit is represented by a 4 -bit binary number.

– Such as 0001 1001 = 1910

• The 8421 code is a type of BCD to do that.

• BCD code provides an excellent interface to binary systems:

– Keypad inputs

– Digital readouts

– Used to represent the decimal digits 0 - 9.

– 4 bits are used.

– Each bit position has a weight associated with it (weighted code).

– Weights are: 8, 4, 2, and 1 from MSB to LSB (called 8-4-2-1 code).

– BCD Codes:

0: 0000 4: 0100 8: 1000

1: 0001 5: 0101 9: 1001

2: 0010 6: 0110

3: 0011 7: 0111

– Used to encode numbers for output to numerical displays

– Used in processors that perform decimal arithmetic.

– Example: (9750)

= (1001 0111 0101 0000)BCD

9 7 5 0

Decimal Digit 0 1 2 3 4 5 6 7 8 9

BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!

2|Page
Conversion from decimal to BCD

• The decimal digits 0 to 9 are converted into BCD, exactly in the same way as binary.

Invalid BCD codes:

• With 4 bits we can represent total sixteen numbers (0000 to 1111) but in BCD

only first ten codes are used (0000 to 1001)

• Therefore remaining six codes (1010 to 1111) are invalid in BCD

Conversion of bigger decimal numbers to BCD:

• Express each decimal digit with its equivalent 4-bit BCD code

• Eg.: Convert (964)10 to its equivalent BCD code.

(964)10= (1001 0110 0100)BCD

• Hence smallest number in BCD is 0000 i.e., 0 and largest is 1001 i.e., 9 after

which 10 will be expressed by combinations i.e., 0001 0000 and is known as

packed BCD

Comparison with Binary:

• Less efficient than binary, since conversion of a decimal number into BCD

needs more bits than in binary.

Eg., (22)10= (10110)2= (0010 0010)BCD

So BCD uses more bits than binary for the same decimal number.

• BCD arithmetic is more complicated than binary arithmetic.

• BCD – decimal conversion is simpler than Binary – decimal conversion.

ADVANTAGES OF BCD CODES:


• Its similar to decimal number system.

• We need to remember binary equivalents of decimal numbers 0 to 9 only.

• Conversions from decimal to BCD or BCD to decimal is very simple and no

3|Page
Calculation is needed.

Disadvantages of BCD codes:

• Less efficient than binary, since conversion of a decimal number into BCD

needs more bits than in binary

• BCD arithmetic is more complicated than binary arithmetic.

THE GRAY CODE


• The Gray code is unweighted and is not an arithmetic code.

– There are no specific weights assigned to the bit positions.

• Important: the Gray code exhibits only a single bit change from one code word to the next in
sequence.

– This property is important in many applications, such as shaft position encoders.

 To convert binary to gray or gray to binary it follow or use Ex-OR rule.

• Binary-to-Gray code conversion

– The MSB in the Gray code is the same as corresponding MSB in the binary number.

– Going from left to right, add each adjacent pair of binary code bits to get the next Gray code
bit. Discard carries.

ex: convert 101102 to Gray code

1 + 0 + 1 + 1 + 0 binary

1 1 1 0 1 Gray

• Gray-to-Binary Conversion

– The MSB in the binary code is the same as the corresponding bit in the Gray code.

– Add each binary code bit generated to the Gray code bit in the next adjacent position. Discard
carries.

ex: convert the Gray code word 11011 to binary Gray Binary

4|Page
1 1 0 1 1

+ + + +

1 0 0 1 0

Decimal Binary Gray Code

0 0000 0000

1 0001 0001

2 0010 0011

3 0011 0010

4 0100 0110

5 0101 0111

6 0110 0101

7 0111 0100

8 1000 1100

9 1001 1101

10 1010 1111

11 1011 1110

12 1100 1010

13 1101 1011

14 1110 1001

15 1111 1000

5|Page
Excess 3 Code

• Non-weighted code.

• A BCD Code formed by adding 3 (0011) to its true four bit binary value.

• Excess 3 is a self-complementing code. If the bits of the Excess-3 digit are inverted, they yield
the 9’s complement of the decimal equivalent.

• Excess-3 code is useful for performing decimal arithmetic digitally.

Examples

• 3 = 0011 + 0011 = 0110 = 6 in E-3.

• 1 = 0001 + 0011 = 0100 = 4 in E-3

• If we complement 1’s = 1011 in E-3 this is the code for an 8.

• 9s Complement of 1(0100) = (9 - 1) = 8 (Self Complement )

Conversion of decimal numbers XS-3 code:

• Eg.: Convert (964)10 to its equivalent XS-3 code.

(964)10= (1100 1001 0111) XS-3

Conversion of XS-3 code to equivalent decimal numbers :

• Eg.: Convert (0011 1010 1100)XS-3 to its equivalent decimal number.

(1010 0011 1100)XS-3= (709)10

ROM

ROM consists of an array of semiconductor devices interconnected to store an array of

memory data. Data can be only read, it cannot be changed under normal operating

conditions.

6|Page
BASIC ROM STRUCTURE

Fig.1 ROM Block diagram

A block diagram of the ROM is shown in the figure 1. There are n inputs and m outputs. The
inputs provide the address for the memory, and the outputs give the data bits of the stored
word that is selected from the address. The number of words in the ROM device is determined
from the fact that n address input lines can specify 2nwords. For example a 4 x 8 ROM has 2
(ie., n=2) Input Address lines. & Can store 4 words each of 8 (ie., m=8) bits.

Internally a ROM consists of a decoder and a memory array. When a pattern of n 0s and 1s is
applied to the decoder inputs, exactly one of the 2n-decoder outputs is ‘1’. This decoder output
line selects one of the words in the memory array, and the bit pattern stored in this
word is transferred to the memory output lines. 2n x m ROM can realize m functions of n
variables , since it can store a truth table with 2n rows and m columns.

Note: ROM doesn’t have data inputs, because it doesn’t have write operation.

TYPES OF ROM

Four technologies are used for ROM programming.

Mask programmable ROM

If mask programming is used, then the data array is permanently stored at the time

of manufacture. Preparation of the mask is expensive, so mask programmable ROMs are

economically feasible if large quantity are required within the same data array.

7|Page
Erasable programmable ROM (EPROM)

If a small quantity of ROMs are required within a given data array, then

EPROMs may be used. EPROMs allow the modification of the data stored as they use a

special charge storage mechanism to enable or disable the switching elements in the

memory array. The data stored in the EPROM is generally permanent until erased using

ultraviolet light.

EEPROM

The electrically erasable PROM (EEPROM)is similar to EPROM except that the

erasure of data is accomplished using electrical pulses instead of ultraviolet light. An

EEPROM can be erased and reprogrammed only a limited number of times.

Flash

Flash memoriesare similar to EEPROMs except that they use a different charge

storage mechanism. They also have built in programming and erase capability so that the

data can be written to the flash memory while it is in place in a circuit without the need

for a separate programmer.

8|Page

You might also like