



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Massachusetts Institute of Technology Handout 18.413: Error-Correcting Codes Laboratory March 4, 2004 Professor Daniel A. Spielman
In this project, you are going to implement the simplest low-density parity-check codes, and see how well they work. Due: Thursday, April 1, 2004
This project has three phases
I’ll explain what you should do for each in turn.
Your implementations will have six parts:
A. sparse graph generator
B. encoder
C. Channel simulators,
D. decoder,
E. evaluator that compares the output of the decoder to the input to the encoder (or output of the encoder).
F. code to drive all these
These parts should all be separable so that you can test each individually. This will also allow you change components. Many of you will be using parts of these components in your final projects. Let’s examine each in more detail.
A. sparse graph generator A low-density parity-check code is specified by a sparse graph. You should create code that generates this graph. In this project, it will be a graph between n bit nodes of degree 3 and n/2 check nodes of degree 6. n should be 10,000 if possible, and 3,000 if that is too slow. Note that very different results may be seen for different n. Your code should save this graph so that other components may pick it up. You should also save the graphs you use so that your experiments can be reproduced. If you use matlab, you will find the save command useful for storing data. (type help save to learn more) The functional form of save is especially useful (like save(’graph.dat’,’G’))
If you code in C, don’t use the routine rand() to generate your random graph. The resulting graph turns out not to be very random. (and probably won’t work for our purposes) Try instead the pseudo-random number generator I posted on the course web page. If you use Matlab, you might find the commands repmat or randperm useful.
B. encoder To encode a LDPC code, it is easiest to make a generator matrix that is dual to your low- density check matrix. You can then generate a random codeword by multiplying a random vector by the matrix. It would be best if the matrix were systematic (contain the identity matrix as a sub-matrix) so that the message bits appear in the codeword. The most natural way to compute the generator matrix is to observe that it is a dual of the check matrix, and then compute it using my code FormDualMod2.c. This code is described in a separate document. You can either use FormDualMod2.c as a C program that can be called from matlab, or you can rip routines from it to incorporate into you own C code. It will take a lot of time to encode your LDPC codes. So, you might want to initially test your code on the all-0 or all-1 codewords (note that both of these will be codewords). But, to generate reasonable results, you should really do tests on random codewords. That said, generating codewords is so expensive that it would not make sense to generate a fresh codeword for each test. My suggestion would be to generate a small set of codewords, say 10 to 50, save them, and use them for your experiments. In this case you should be sure to cycle through each codeword the same number of times in each experiment. That is, if you are doing 1000 runs at 1.4 dB, then you should use each codeword the same number of times in these experiments. Some of you will note that if you use an ideal implementation of the decoder, then your simulations will give the same performance if you start with random codewords or the all-0 codeword. However, numerical errors could skew the results of your simulation in unpredictable ways. C. channel simulators, We’ll test these codes on 3 different channels: the Binary Erasure Channel with erasure probability p, the Binary Symmetric Channel with crossover probability p, and the Gaussian channel with ±1 signaling. You should design a separate module for each that takes as input a codeword and ouputs the result of passing the codeword through the channel. At some point (here or in the decoder), you will need to estimate the probability that each codeword bit was 1 (or 0) given the output of the channel. If you like, you may make this output the result of the channel simulator. For example, if you are transmitting over the BSCp, and the channel outputs 0, 0 , 1, then you could report this as p, p, 1 − p.
D. decoder
This is where most of the work will be. The decoder should take as input the graph defining the check matrix of the low-density parity-check code, as well as the output from the channel. The decoder should then output a guess for the value of each bit of the codeword (or, just a guess for each message bit). Let me re-state how the decoder should work. The decoder proceedes in stages, and at each stage it passes a message along the edges of the graph. It begins with an initial stage, alternates between check node and bit node stages, and finishes with a terminal stage.
While I have described the messages being passes along the edges as probabilities, you should feel free to encode them however you like (e.g., as likelihoods, log likelihoods, log probabilities, etc.) One thing to be careful of when implementing the decoder is that many of the probabilities will approach 0 or 1. However, this may cause division-by-zero errors, or trouble if you ever take a logarithm of 0. There are many ways to circumvent these problems. One is to force all probabilities to lie between and 1 − for some > 0 that you pick. I’m sure you can think of other ways as well. There will often be a tradeoff between speed and precision in how you handle this.
E. evaluator: this will compare the output of the decoder to the input to the encoder (or output of the encoder), and compute the word error rate and bit error rate. If you used a systematic generator matrix, then you should just score bit errors on the message (systematic) bits. If you did not use a systematic generator matrix, then count the fraction of bit errors among all the bits. There is some theory that indicates that this value shouldn’t be all that different.
F. driver code: I’m sure that you will want to generate some scripts to tie all these together. Of course, when you first test your code you will want to do this part manually. Make sure that your driver code occasionally reports what it is doing. This way you will still save some information even if your job dies.
A random thought: if you’d like to test your system on a small code, you could always use the (9, 4) product code from Small Project 2. It has 9 bit nodes of degree 2 and 6 check nodes of degree
Arvind makes the following suggestions regarding longjobs:
If your code is fast enough, then you should work with codes of block-length n = 10, 000. If that is too slow, try n = 3, 000. Note that your results will be different with different block-lengths. You will generate various types of reports. The first type is the standard channel vs. BER plots. For these, you should simulate your system over
Run at least 100 iterations for each. Try to run 1000 iterations for those on which the system performs better (we need to work harder to observe failures when they are rare). The next type of output we would like to generate is some that will help us understand how our algorithm is behaving. One thing we would like to understand is how much progress the algorithm is making at each iteration. We can measure this by simulating a terminal stage after each check- node stage, and counting how many bits it gets right. We can then plot the number of iterations on the X-axis and the BER if we were to stop at that point on the Y-axis. Do this twice: once at a noise level for which the algorithm tends to work, and once at a noise level for which it tends to fail. You could combine many runs to do this. Be sure to explain how you derived the data for your plot. Finally, we would like to understand how the messages sent by the algorithm are distributed at each iteration (or maybe every 5 iterations). So, we will extract this data for a few simulations. Of course, there is a question about how one should report this data. A histogram would be natural. However, it might not be meaningful if most of the data is near 0 or 1. A more useful approach might be to output some order statistics for the data. One way of obtaining these is to sort the data, and, if there are n items, report the 1st, n/10th, n/ 5 th, 3n/10th, etc. data point in the sorted order. This gives one some feel for distribution. Generate data like this for each iteration (or every 2nd or 5th) of the algorithm on some run on which it succedes, and on some run on which it fails. It would be most interesting to see it for a run on which it barely fails. Don’t forget to explain how you got the data.
Submit all code, plots, and the data used to generate plots (unless it is absurdly big). Start with an overview explaining what is to follow, and how your code is organized. To the extent that you generated data by interaction, rather than merely running the code you’ve submitted, explain what you did. Note that I’m going to actually try to read your code, so please document it well!
For this project you are free to discuss how you do this with others in the class (and especially to get technical help). But, you should write your own code. You must acknowledge your collaborators.