Coding No. 1 Seattle Pacific University Digital Coding Kevin Bolding Electrical Engineering...

22
Coding No. 1 Seattle Pacific University Digital Coding Kevin Bolding Electrical Engineering Seattle Pacific University

description

Coding No. 3  Seattle Pacific University Coding Sampling Quantizing Coding Modulation Transmission Coding is the transformation of the digital signal into a different form Usually to a more rugged form that can tolerate errors, reducing the BER Usually involves expansion of the signal Higher bit rate – may require more bandwidth

Transcript of Coding No. 1 Seattle Pacific University Digital Coding Kevin Bolding Electrical Engineering...

Coding No. 1Seattle Pacific University

Digital Coding

Kevin BoldingElectrical Engineering

Seattle Pacific University

Coding No. 2Seattle Pacific University

Digital Transmission of Analog Data

Sampling

Quantizing

Coding

Modulation

Transmission

Convert to discrete samples (time domain)

Convert to discrete levels (amplitude)

Re-map to a different logical code (may expand)

Map to a physical code at desired frequency band

Amplify and transmit

Analog signal

Digitaldata

Coding No. 3Seattle Pacific University

Coding

Sampling

Quantizing

Coding

Modulation

Transmission

• Coding is the transformation of the digital signal into a different form • Usually to a more rugged form that can tolerate

errors, reducing the BER• Usually involves expansion of the signal

• Higher bit rate – may require more bandwidth

Coding No. 4Seattle Pacific University

Code Space• PCM produces an efficient code

• All possible codes used• Examples: 256 codes use 8 bits;

4096 codes use 12 bits

Sampling

Quantizing

Coding

Modulation

Transmission

• Efficient codes don’t tolerate errors• If an error causes one bit to

change, it produces a new codeword

• New codeword is valid because all possible codewords are valid

V V V V V VV V V V V VV V V V V VV V V V V VV V V V V V

Coding No. 5Seattle Pacific University

Code Space – Even/Odd Parity

Sampling

Quantizing

Coding

Modulation

Transmission

• Expanding the code space introduces redundancy• Some codewords are invalid

(inefficient)• Errors may change valid codewords

to invalid codewords

V V VV V V

V V VV V V

V V V• Add up all the bits in a codeword – is the total even or odd?

• Generate an extra bit that forces the total to be even• Doubles the size of the code space • All codewords with odd parity are invalid

010100110101 111101010110• If a single bit is flipped, parity is changed from even to odd

111101010110 110101010110• The receiver can re-check parity and find invalid codewords

Coding No. 6Seattle Pacific University

Block Coding

• Bits are grouped into fixed-size blocks• Could be 8, 16, 24, etc. bits• A computation is performed on the bits on the

block to create the codeword

Sampling

Quantizing

Coding

Modulation

Transmission

• Most block codes produce extra bits that are appended to the original block to form the codeword• Parity is an example – one block + one parity bit• More complex block codes can detect more than

one error and/or correct errors

Coding No. 7Seattle Pacific University

Block Error Correction

Sampling

Quantizing

Coding

Modulation

Transmission

• Further expand the code space so that each valid bit is further from its neighbors• Each codeword now has a group of

unique “one bit-flip” neighbors• Codewords in this group can be

mapped back to the original codeword

VV

VV

• Hamming codes are a class of codes that provide multi-bit error detection/correction• Formulaic way of adding redundant bits to provide any level

of detection/correction desired• Upside/Downside – Each block is independent

• Lots of errors in one block may exceed the correction ability• Even if neighboring blocks have no errors

Coding No. 8Seattle Pacific University

Performance of Hamming codes

a. Baseline: Binary PSKb. (7,4) Hamming coding, hard decisionsc. (7,4) Hamming coding, soft decisionsd. Mariner '69 deep space probe, (32,6) bi-orthogonal codinge. Voyager probes, NASA deep space standard (ref 6)f. Theoretical Shannon limit on coding performance.

Coding No. 9Seattle Pacific University

Convolutional Coding• Treat an entire (near-infinite) stream of bits as a continuous

coding input• Create an output bitstream that includes the original

information, but transforms it into a form that has redundant information built into structure

• Recovery of the message can use a large portion of the received bitstream to correct errors

• Rather than appending “parity” bits, convolutional codes increase the number of bits that are output• Requires an increase in bit rate to keep up• For example, an encoder might substitute two encoded bits for

each input bit• Output data stream is at twice the bit rate

Coding No. 10Seattle Pacific University

A Simple Convolutional Encoder

D Q D QInput stream ABC

X

Y

1

0Output stream

Input clock (1x)

Output clock (2x)

• A,B,C are the three most recent bits (A oldest, C newest)• X and Y are the outputs

• For each new input bit, both X and Y are produced• Output rate double the input rate

C B A X Y

0 0 0 0 0

0 0 1 1 1

0 1 0 1 0

0 1 1 0 1

1 0 0 1 1

1 0 1 0 0

1 1 0 0 1

1 1 1 1 0

Coding No. 11Seattle Pacific University

StatesD Q D Q ABC

• The two bit shift register holds two bits…• Four states (BA)• Input to the FSM is C

• The state transition table can be drawn in a linear form• For each set, left side is starting

state, right side is ending state• Arcs for inputs 0 or 1

BAC

Coding No. 12Seattle Pacific University

Outputs• The outputs depend on the state

(AB) and the input (C)• Add them to the arcs in the

diagram

D Q D Q ABC

X

Y

1

0

C B A X Y

0 0 0 0 0

0 0 1 1 1

0 1 0 1 0

0 1 1 0 1

1 0 0 1 1

1 0 1 0 0

1 1 0 0 1

1 1 1 1 0

BAC

XYUpper arc: input C=0, Lower arc: Input C=1

For startstate BA=00

For startstate BA=01

For startstate BA=10

For startstate BA=11

BA BAXY

00

01

10

11

00

01

10

11

00

11

BA BAXY

00

01

10

11

00

01

10

11

11

00

BA BAXY

00

01

10

11

00

01

10

11

10

01

BA BAXY

00

01

10

11

00

01

10

11

01

10

Coding No. 13Seattle Pacific University

Encoding

• Concatenate “trellis” state diagrams for the transitions and outputs for each input bit

Upper arc: input C=0, Lower arc: Input C=1

For startstate BA=00

For startstate BA=01

For startstate BA=10

For startstate BA=11Input: 100111011

1In:

Out: 11

0

10

0

11

1

11

1

01

1

10

0

01

1

00

1

01

0

01

0

11See http://www.ee.unb.ca/cgi-bin/tervo/viterbi.pl?binary=100111011 for more examples

ENCODING DIAGRAM

Coding No. 14Seattle Pacific University

Encoding/Decoding DiagramsUpper arc: input C=0, Lower arc: Input C=1

For startstate BA=00

For startstate BA=01

For startstate BA=10

For startstate BA=11

ENCODING DIAGRAM

Upward arc: input C=0, Downward arc: Input C=1

For receivedXY=00

For receivedXY=01

For receivedXY=10

For receivedXY=11

BA BAXY

00

01

10

11

00

01

10

11

00

11

BA BAXY

00

01

10

11

00

01

10

11

11

00

BA BAXY

00

01

10

11

00

01

10

11

10

01

BA BAXY

00

01

10

11

00

01

10

11

01

10

0

0 0

01

11

1

DECODING DIAGRAM

Coding No. 15Seattle Pacific University

Decoding

• Generate diagram corresponding to possible transitions that create XY codes

Code (XY): 11 10 11 11 01 10 01 00 01 01

1In: 0 0 1 1 1 0 1 1 0 0 11

BA BA

00

01

10

11

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

• Find “best” path

0

1

Upward arc: input C=0, Downward arc: Input C=1

For receivedXY=00

For receivedXY=01

For receivedXY=10

For receivedXY=11

BA BAXY

00

01

10

11

00

01

10

11

00

11

BA BAXY

00

01

10

11

00

01

10

11

11

00

BA BAXY

00

01

10

11

00

01

10

11

10

01

BA BAXY

00

01

10

11

00

01

10

11

01

10

0

0 0

01

11

1

DECODING DIAGRAM

Coding No. 16Seattle Pacific University

Decoding with Errors

• What if an error occurs to the coded message? (Third symbol has a bit flip)

1Input (from code 1): 0 0 1 1 1 0 1 1 0 0

• Find “best” path

Rcvd Code (XY): 11 10 10 11 01 10 01 00 01 01 11

BA BA

00

01

10

11

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

0

1

Candidate Code 1: 11 10 11 11 01 10 01 00 01 01 11Candidate Code 2: 11 01 01 00 01 10 01 00 01 01 11

1 bit difference

6 bit difference

All PossiblePaths

BA BA

00

01

10

11

00

01

10

11

Upward arc: input C=0, Downward arc: Input C=1

For receivedXY=00

For receivedXY=01

For receivedXY=10

For receivedXY=11

BA BAXY

00

01

10

11

00

01

10

11

00

11

BA BAXY

00

01

10

11

00

01

10

11

11

00

BA BAXY

00

01

10

11

00

01

10

11

10

01

BA BAXY

00

01

10

11

00

01

10

11

01

10

0

0 0

01

11

1

DECODING DIAGRAM

Coding No. 17Seattle Pacific University

Decoding with Errors

• What about multiple errors?

1Input (from code 2): 0 0 1 1 1 0 1 1 0 0

Candidate Code 2: 11 10 11 11 01 10 01 00 01 01 11

Candidate Code 1: 11 01 01 11 00 00 00 11 01 01 11

2 bit difference

6 bit difference

Rcvd Code (XY): 11 10 11 11 00 00 01 00 01 01 11

BA BA

00

01

10

11

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

0

1All PossiblePaths

BA BA

00

01

10

11

00

01

10

11

Candidate Code 3: 11 10 11 11 10 00 10 00 01 01 11 3 bit difference

Upward arc: input C=0, Downward arc: Input C=1

For receivedXY=00

For receivedXY=01

For receivedXY=10

For receivedXY=11

BA BAXY

00

01

10

11

00

01

10

11

00

11

BA BAXY

00

01

10

11

00

01

10

11

11

00

BA BAXY

00

01

10

11

00

01

10

11

10

01

BA BAXY

00

01

10

11

00

01

10

11

01

10

0

0 0

01

11

1

DECODING DIAGRAM

Coding No. 18Seattle Pacific University

Viterbi Decoding Algorithm

• The goal of the decoder is to find a path through the trellis with the best match• Best match = fewest bit flips from received data

• Viterbi algorithm is an efficient method to find the best match

See http://www.ee.unb.ca/tervo/ee4253/convolution3.htm for details

Coding No. 19Seattle Pacific University

Performance

http://home.netcom.com/~chip.f/viterbi/simrslts.html

Coding No. 20Seattle Pacific University

Soft Decoding

2. Using channel quality information from the demodulator • The demodulator sees the unquantitized analog

signal and may have additional helpful info

• Soft decoding refers to two different techniques for improving coding performance1. Using neighboring bits to improve the reliability of

the decoding decision• The trellis-decoding method for convolutional

coding is an example

Coding No. 21Seattle Pacific University

Using Channel Quality Info

BA BA

00

01

10

11

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

BA

00

01

10

11

0

1

Channel Quality

Poor quality input - erase

• If the channel quality is below a threshold when receiving a symbol, erase the symbol• Erasing removes the erroneous symbol from

consideration, so more weight can be given to the correct symbols

Coding No. 22Seattle Pacific University

Obtaining signal quality info• The demodulator receives imperfect data, but quantitizes it

based on the best possibility• The error can be measured and reported

I

Q

• In standard QPSK, the angle of the received waveform determines the binary value• Ideally, each received symbol

overlies a blue dot

• In reality, the received signals are more spread out

• Define a threshold that decides when to throw out far-off data points