Coder Decoder: CODEC - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Coder Decoder: CODEC

Description:

Gibbons | GNG1101-23: 1. Coder - Decoder: CODEC. Problem Definition: ... precision: how to show 10-6? representation: how to show 106? ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 31
Provided by: davidg84
Category:
Tags: codec | codec | coder | decoder

less

Transcript and Presenter's Notes

Title: Coder Decoder: CODEC


1
Coder - Decoder CODEC
  • Problem Definition
  • To transmit data without errors.
  • Gather Information
  • Why not analog?
  • precision how to show 10-6?
  • representation how to show 106?
  • loss in noise during transmission
  • Digital Arithmetic
  • binary system 0 or 1
  • representation/precision duplication of basic
    cell

2
Analog Representation of i
  • Notice the effect of noise.
  • Noise unwanted signal.

3
Digital Noise Performance
1
Threshold
0
4
Number Representation
  • Decimal Position value HTU
  • 123
  • 456
  • 579
  • Binary Position value 8421
  • 0101 5
  • 1001 9
  • 1110 14

5
Number Range
  • 4bits 0000 - 1111 0 - 15 16
  • 8bits 00000000 - 11111111 0 - 255 256
  • 10bits 0 - 1023 1k
  • 16bits 0 - 65535 64k
  • 24bits 16M
  • 32bits 4G

6
Negative Numbers
  • Same as decimal sign offset
  • 5 0101 -5 1101
  • Most Significant Bit
  • MSB used for sign (0, 1-)
  • Range -(2n-1) 1111 to (2n-1) 0111, includes
    0 0000 and -0 1000

7
Twos Complement
  • Definition
  • At fixed length, a negative number is represented
    as that number which when added to the positive
    number produces the answer zero in the same fixed
    length.
  • 0101 5
  • 1011 -5
  • 1 ? 0000 0
  • i.e.. (-n) 2n - n
  • Range -(2n) 1000 to (2n-1) 0111,
  • single zero, 0 0000

8
Floating Point
  • In floating point numbers we use
  • mantissa and exponent 1.23 107 (1.23E07)
  • In our system we have 4 bytes for a floating
    point 32 bits
  • we use 24 bits for the mantissa and
  • 8 bits for the exponent.

9
Mantissa
  • MSB is the sign (0, 1-) then we have 23 bits
    for precision.
  • We assume 0.1010101.
  • Hence the bits have values 1/2, 1/4 1/2N
  • Maximum N23 1/223 0.00000012
  • Because this last bit forces changes to the 7th
    significant digit, we say that we can only accept
    the first 6 significant digits.

10
Exponent
  • MSB is the sign (0, 1-) then we have 7 bits
    for precision.
  • 7 bit 0 ? 127 (27-1)
  • Of course the exponent in our binary system
    operates on the number 2
  • 2127 ? 1038
  • Hence the range of our numbers
  • 3.40282 1038

11
Communications
Noise
  • Use a single line, bits are sent serially.
  • 4 bits representing 13 (1101) are sent as 1-1-0-1

1 1 0 1
time
12
Transmission Errors
  • Bits may arrive corrupted by the noise of
    transmission, ones can become zeroes and zeroes
    can become ones.
  • Our transmission of 1101 may be received as any
    number 0000 to 1111 because noise can affect any
    one of the bits.

13
Error Detection
  • Parity Bit
  • add an extra bit to the transmission to help
    detect errors 1001P
  • P is chosen so that the number of ones in the 5
    bit message is even - EVEN PARITY.
  • For 1101 we send 11011 - 4 ones
  • For 1001 we send 10010 - 2 ones

14
Bit Manipulation OR
  • Assume int a, b, x
  • OR xab
  • a b x
  • 0 0 0
  • 0 1 1
  • 1 0 1
  • 1 1 1
  • if a1101 and b0110 then x1111

15
Bit Manipulation AND
  • Assume int a, b, x
  • AND xab
  • a b x
  • 0 0 0
  • 0 1 0
  • 1 0 0
  • 1 1 1
  • if a1101 and b0110 then x0100

16
Bit Manipulation XOR
  • Assume int a, b, x
  • Exclusive OR (XOR) xab
  • a b x
  • 0 0 0
  • 0 1 1
  • 1 0 1
  • 1 1 0
  • if a1101 and b0110 then x1011

17
Bit Manipulation NOT
  • Assume int a, x
  • NOT xa
  • a x
  • 0 1
  • 1 0
  • if a1101 then x0010

18
Bit Manipulation SHIFT
  • Assume int a, x
  • SHIFT RIGHT xagtgt2
  • if a1101 then x??11
  • System dependent on what is shifted in from the
    left.
  • SHIFT LEFT xaltlt3
  • if a1101 then x1000
  • Zeroes are always shifted in from the right.

19
Calculating the Parity
  • Shift right and mask
  • int i, a, p0, x
  • for(i0 ilt4 i)
  • if(a80) x0 else x1
  • //x is transmission bit
  • ppx aaltlt1 i a x p
  • 0 1101 1 1
  • 1 1010 1 0
  • 2 0100 0 0
  • 3 1000 1 1

20
Receiving the Data
  • int i, a0, p0, x
  • for(i0 ilt4 i)
  • Read x from line a(altlt1)x ppx
  • Read x from line
  • if(p!x) printf("Error\n")
  • i x a p
  • 0 1 0001 1
  • 1 0 0011 0
  • 2 0 0110 0
  • 3 1 1101 1

21
Checking the Parity
  • Parity only tells us if one bit has changed and
    it does not say which bit. It could be that the
    error is in the parity bit itself.
  • Only way to fix this error is to ask for a
    retransmission.

22
Adding Redundant Bits
  • A technique due to Hamming (Hamming Codes) allows
    single bit errors to be corrected at the
    receiver.
  • Consider the 4-7 code.
  • 3 extra bits are added to the 4 data bits to make
    a seven bit code.

23
Using a Structure
  • struct bits
  • unsigned int b61
  • unsigned int b51
  • unsigned int b41
  • unsigned int b31
  • unsigned int b21
  • unsigned int b11
  • unsigned int b01
  • m

24
Coding
  • Data bits are m.b6, m.b5, m.b4, and m.b3
  • Extra bits are m.b2, m.b1, and m.b0
  • m b6 b5 b4 b3 b2 b1 b0
  • the extra bits are coded as
  • m.b2(m.b5m.b4m.b3)
  • m.b1(m.b6m.b5m.b3)
  • m.b0(m.b6m.b4m.b3)

25
Decoding
  • Three bits are decoded as
  • s.b2(m.b5m.b4m.b3m.b2)
  • s.b1(m.b6m.b5m.b3m.b1)
  • s.b0(m.b6m.b4m.b3m.b0)
  • error is the number s.b2 s.b1 s.b0
  • error(s.b2ltlt2)(s.b1ltlt1)s.b0

26
Error detection
  • if(error0) //No error
  • if(error1) //Error in m.b0
  • if(error2) //Error in m.b1
  • if(error3) //Error in m.b6
  • if(error4) //Error in m.b2
  • if(error5) //Error in m.b4
  • if(error6) //Error in m.b5
  • if(error7) //Error in m.b3

27
Functions in Simulation
  • void code(int)
  • Takes the integer and codes the seven bits (b6-b3
    from integer).
  • int decode(void)
  • Takes the seven bits checks and corrects errors,
    returns the number.
  • void transmit(void)
  • Takes the seven bits and applies transmission
    noise to them.

28
Random Numbers
  • Two random number routines allow for the
    simulation to proceed.
  • int randcode(void)
  • Generates a random code word in the range
  • 0-15 (4 bits)
  • int randcode()
  • return rand()16

29
int randerror(void)
  • Generates errors on each bit ( 1 bit in error
    every BER bits - bit error rate)
  • define BER 140
  • int randerror()
  • return rand()BER
  • void transmit()
  • if(randerror()0) m.b0(m.b0)
  • .
  • if(randerror()0) m.b6(m.b6)

30
Program
  • The program runs a large number of times
  • define BER 140
  • errors are applied to the bits at the bit error
    rate (1 bit in BER)
  • the program counts the number of overall errors
    where the coder could not repair multiple errors
    in the transmission.
  • the program prints out the word error rate which
    is significantly less than would be expected
    (7/BER - each word has 7 bits).
Write a Comment
User Comments (0)
About PowerShow.com