code converters experiment

Upload: kannan-alagumuthiah

Post on 07-Jul-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 Code Converters Experiment

    1/12

    CODE CONVERTERS

    AIM :To design and implement a digital combinational circuit that converts the given code

    in• Binary to Gray code and vice versa• Excess 3 code to BC code and vice versa

    Components !e"uired :

    #$ igital IC Trainer %it #&$ IC '()( * #3$ IC '()+ * #($ IC '(3& * #,$ IC '(+- * #-$ Connecting .ires * !e"uired "uantity

    Theory :.hile the binary system o/ representation is the most extensively used one in digital

    systems0 including computers0 octal and hexadecimal number systems are commonly used /or representing groups o/ binary digits$ The binary coding system0 called the straight binarycode becomes very cumbersome to handle 1hen used to represent larger decimal numbers$ Toovercome this shortcoming0 and also to per/orm many other special /unctions0 several binarycodes have evolved over the years$ 2ome o/ the better*%no1n binary codes0 including thoseused e//iciently to represent numeric and alphanumeric data0 and the codes used to per/ormspecial /unctions0 such as detection and correction o/ errors$ Coding 1as de/ined as the use o/ groups o/ bits to represent items o/ in/ormation that are multivalued$ Assigning each item o/ in/ormation a uni"ue combination o/ bits ma%es a trans/ormation o/ the original in/ormation$This 1e recogni e as in/ormation being processed into another /orm$ Moreover0 1e have seenthat there are many coding schemes exist$ i//erent digital systems may use di//erent codingschemes$ It is sometimes necessary to use the output o/ one system as the input to other$There/or a sort o/ code conversion is necessary bet1een the t1o systems to ma%e themcompatible /or the same in/ormation$ A code converter is a combinational logic circuit thatchanges data presented in one type o/ binary code to another type o/ binary code$ A general

    bloc% diagram o/ a code converter is sho1n in 4ig$

    Fig. Code converter

    Gray CodeThe Gray code 1as designed by 4ran% Gray at Bell 5abs and patented in #6,3$ It is an

    un1eighted binary code in 1hich t1o successive values di//er only by # bit$ 71ing to this/eature0 the maximum error that can creep into a system using the binary Gray code to encode

    data is much less than the 1orst*case error encountered in the case o/ straight binaryencoding$ An examination o/ the /our*bit Gray code numbers sho1s that the last entry rollsover to the /irst entry$ That is0 the last and the /irst entry also di//er by only # bit$ This is%no1n as the cyclic property o/ the Gray code$

  • 8/19/2019 Code Converters Experiment

    2/12

    Binary–Gray Code ConversionA given binary number can be converted into its Gray code e"uivalent by going through the/ollo1ing steps:#$ Begin 1ith the most signi/icant bit 8M2B9 o/ the binary number$ The M2B o/ the Graycode e"uivalent is the same as the M2B o/ the given binary number$&$ The second most signi/icant bit0 ad acent to the M2B0 in the Gray code number is obtained

    by adding the M2B and the second M2B o/ the binary number and ignoring the carry0 i/ any$That is0 i/ the M2B and the bit ad acent to it are both ;#

  • 8/19/2019 Code Converters Experiment

    3/12

    determined by adding ;3< to each decimal digit in the given number and then replacing eachdigit o/ the ne1ly /ound decimal number by its /our*bit binary e"uivalent$ It may bementioned here that0 i/ the addition o/ ;3< to a digit produces a carry0 as is the case 1ith thedigits '0 + and 60 that carry should not be ta%en /or1ard$ The result o/ addition should beta%en as a single entity and subse"uently replaced 1ith its excess*3 code e"uivalent$ Another signi/icant /eature that ma%es this code attractive /or per/orming arithmetic operations is thatthe complement o/ the excess*3 code o/ a given decimal number yields the excess*3 code /or

    6

  • 8/19/2019 Code Converters Experiment

    4/12

    G2 = ∑ (4, 5, , !, 8, 9, 10, 11)G1 = ∑ (2, 3, 4, 5, 10, 11, 12, 13)G0 = ∑ (1, 2, 5, , 9, 10, 13, 14)"

    The above expressions can be simpli/ied using >*mapMap for G3:

    #ro$ t%e octet, &e 'etG 3 = B 3

    Map for G 2 :

    #ro$ t%e t&o *d+, &e 'etG 2 = B 3 ' B2 + B 3 B 2 '

    = B 3 ⊕ B 2 .Map for G 1 :

    #ro$ t%e t&o *d+, &e 'etG 1 = B 2 B 1 ' + B 2 ' B1

    = B 2 ⊕ B1Map for G 0 :

    #ro$ t%e t&o *d+, &e 'etG 0 = B 1 ' B0 + B 1 B 0 '

    = B 1 ⊕ B 0 .G 3 = B 3G 2 = B 3 ⊕ B 2G 1 = B 2 ⊕ B 1

    G 0 = B 1 ⊕ B 0 .

  • 8/19/2019 Code Converters Experiment

    5/12

    o1 the above expressions can be implemented using *7! gates to yield the desired codeconverter circuit sho1n in 4ig$

    4-bit Gray code to Binary code conver ion

    The bloc% diagram o/ a (*bit Gray code to binary code converter is sho1n in 4ig$ belo1

    I/ has /our inputs 8G 3G&G#G ) 9 representing (*bit Gray code and /our outputs 8B 3B& B#B) 9representing (*bit Binary number$

    !"#!$ !%B&':G"%( )* #! B)*%"( ,#! #!

    G3 G2 G1 G0 B3 B2 B1 B00 0 0 0 0 0 0 00 0 0 1 0 0 0 10 0 1 0 0 0 1 10 0 1 1 0 0 1 00 1 0 0 0 1 1 10 1 0 1 0 1 1 00 1 1 0 0 1 0 00 1 1 1 0 1 0 1

    1 0 0 0 1 1 1 11 0 0 1 1 1 1 01 0 1 0 1 1 0 01 0 1 1 1 1 0 11 1 0 0 1 0 0 01 1 0 1 1 0 0 11 1 1 0 1 0 1 11 1 1 1 1 0 1 0

    o1 1e solve all the Binary outputs$ 4rom the truth table0 the logic expressions /or theBinary coded outputs can be 1ritten as :

    3 = ∑ ( $ 8 , $ 9 , $ 10, $ 11 , $ 12 , $ 13 , $ 14 , $ 15 )2 = ∑ ( $ 4, $ 5 , $ $ ! , $ 8 , $ 9 , $ 10 , $ 11 )1 = ∑ ($ 2 , $ 3 , $ 4 , $ 5, $ 8 , $ 9 , $ 14 , $ 15 )0 = ∑ ($ 1 , $ 2 , $ 4 , $ ! , $ 8 , $ 11 , $ 13 , $ 14 )"

    These expressions can be simpli/ied using %*map

  • 8/19/2019 Code Converters Experiment

    6/12

    Map for B3

    B3 = G3

    Map for B2

    Map for B1

    Map for B0

  • 8/19/2019 Code Converters Experiment

    7/12

    B 3 = G 3B 2 = G 3 ⊕ G 2B 1 = G 3 ⊕ G 2⊕ G 1B 0 = G 3 ⊕ G 2 ⊕ G 1 ⊕ G 0 .

    o1 the above expressions can be implemented using *7! gates to yield the desired codeconverter circuit sho1n in 4ig$

    !-3 to BC" code converterThe bloc% diagram o/ an 2*3 to BC code converter is sho1n in 4ig$ It has /our

    inputs 8E 30E&0E#0E) 9 representing ( bit 2*3 number and /our outputs 8B 3B&B#B) 9 representing(*bit BC code$

    2*3 codes are obtained /rom BC code by adding 3 to each coded number$ Moreover ( binary variables may have #- combinations0 but only #) are listed$ The six not listed are don

  • 8/19/2019 Code Converters Experiment

    8/12

    variable either a # or a )0 1hichever gives a simpler circuit$ In this particular example0 theunused iDo combinations are listed belo1 the truth table$

    Truth Table for !-3 to BC" code converter

    o1 1e solve all the BC outputs$ 4rom the truth table0 the logic expressions /or the BC

    coded outputs can be 1ritten as :3 = ∑ ($ 11 , $ 12 ), d ($ 0 , $ 1 , $ 2 , $ 13 , $ 14 , $ 15 )2 = ∑ ($ ! , $ 8 , $ 9 , $ 10 ), d ($ 0 , $ 1 , $ 2 , $ 13 , $ 14 , $ 15 )1 = ∑ ($ 5 , $ , $ 9 , $ 10 ), d ($ 0 , $ 1 , $ 2 , $ 13 , $ 14 , $ 15 )0 = ∑ ($ 4 , $ , $ 8 , $ 10 , $ 12 ), d ($ 0 , $ 1 , $ 2 , $ 13 , $ 14 , $ 15 )"

    These expressions can be simpli/ied using %*mapMap for B3

    B 3 = ' 3 ' 2 + ' 3 ' 1 ' 0Map for B #

    B2 = ' 2 ' ' 0 ' + ' 2 ' 1 ' 0 + ' 2 $' 1 $

  • 8/19/2019 Code Converters Experiment

    9/12

    Map for B 1

    B1 = ' 1 ' ' 0 + ' 1 ' 0 '

    = ' 1 ⊕ ' 0Map for B 0

    B 0 = ' 0 '

    B 3 = ' 3 ' 2 + ' 3 ' 1 ' 0B 2 = ' 2 ' ' 0 ' + ' 2 ' 1 ' 0 + ' 2 ' ' 1 '

    B 1 = ' 1 ⊕ ' 0B 0 = ' 0 '

    The expressions /or BC outputs 8B3 B& B# B)9 can be implemented /or terms o/ inputs8E3 E& E# E)9 to /orm a 2*3 to BC code converter circuit as belo1

    1E3

    5

    3

    3

    2

    1

    2

    1

    43

    32

    1

    215

    432

    B 2 = ' 2 ' ' 0 ' + ' 2 ' 1 ' 0 +

    B 3 = ' 3 ' 2 + ' 3

    B 0 = ' 0 '

    B 1 = ' 1

    E2

    E0E1

  • 8/19/2019 Code Converters Experiment

    10/12

    B to '/ce -3 ode converter:The input is a BC code 1ord$ 2ince this is a (*bit code that represents a decimal

    digit 8)*to*690 there 1ill be ( input bits 1hich 1ill be represented by /our input variablesB30B&0B#0 and B) $ 7utput is a (*bit excess*3 code 8E 30 E&0 E# 0E) 9 ?aving de/ined the inputsand outputs0 1e proceed to build the truth table /or this code converter$ The bloc% diagramdepicts the inputs and output details$

    The truth table0 lists the values o/ the output 8that is the excess*3 code9 /or all possiblecombinations o/ the binary code$ ote that0 these codes are codes /or decimal digits )*6$ Inother 1ords0 even though the ( bits o/ the input can represent up to #- di//erent combinations07 5 #) combinations are used to represent the #) decimal digits$ Thus0 a total o/ - inputcombinations are not li%ely to occur$ 2ince these inputs 1ill never occur0 1e use don*maps$ Thus 1e 1ill be having /our >*maps0 one /or each output/unction$ Each o/ these >*maps are given belo1

    -Map for ' 3

  • 8/19/2019 Code Converters Experiment

    11/12

    ' 3 =B 3 +B2;B0+B 1 <-Map for ' 2

    ' 2 =B 2 B1 +B 2 B0 +B 2 B 1 B0 = B 2 ;B1 +B 0

  • 8/19/2019 Code Converters Experiment

    12/12

    The expressions /or Excess*3 outputs 8E 3E&E#E) 9 can be implemented /or terms o/ inputs8B3B&B#B) 9 to /orm a BC to 2*3 code converter circuit as belo1