Space Time Trellis Code

Using MATLAB and C MEX

The software is capable to simulate space time code [1] for QPSK modulation using different number of state. Examples of generator matrix up to 256 stetes are provided. Variable signal to noise ratio (SNR) might be applied to produce bit error rate (BER) or frame error rate (FER) curves.

The software

The MEX codes are applied to the decoder section: stViterbi.dll and bitErrFast.dll (stViterbi.mexglx and bitErrFast.mexglx in their Linux counterpart). stViterbi.dll decodes the space time code using viterbi algorithm, while bitErrFast.dll compares the resulting bits to the original one.

The source codes are heavily commented, explaining how the codes works step by step. I included the MATLAB’s .m file version of the encoder-decoder (sttc4Psk.m) should you find easier to read and understand. It should be fun to see how fast the MEX function compared to the m function.

The program (Microsoft Windows version) consists of:

 qpskSpaceTimeMain.m   stTrellis.m   sttc4PskUseMex.m   stViterbi.dll   bitErrFast.dll Here all the functions are executed.   Build the trellis structure.   Space time code encoder and decoder.    Space time code viterbi decoder.   Compares the resulting bits to the original one and find the error rate.

Table 1. Function (Microsoft Windows version)

For Linux/Unix version:

 qpskSpaceTimeMain.m   stTrellis.m   sttc4PskUseMex.m   stViterbi.mexglx   bitErrFast.mexglx Here all the functions are executed.   Build the trellis structure.   Space time code encoder and decoder.    Space time code viterbi decoder.   Compares the resulting bits to the original one and find the error rate.

Table 2. Function (Linux/Unix version)

MATLAB’s .m file version of the encoder-decoder:

 qpskSpaceTimeMainNormal.m   stTrellis.m   sttc4Psk.m   bitErrFast.dll Here all the functions are executed.   Build the trellis structure.   Space time code encoder and decoder.   Compares the resulting bits to the original one and find the error rate.

Table 3. MATLAB m file function

The C source code:

stViterbi.c

bitErrFast.c

Running simulation

I did not include some fancy user interfaces in order to keep the souce codes as clean as possible, hence the main idea can be conveyed with clarity. Nevertheless, the codes are written with flexibility, so only minimal alteration is needed to run the simulation under various conditions. Firstly, you need to decide the number of states by changing qpskSpaceTimeMain.m for MEX, or qpskSpaceTimeMainNormal.m for normal MATLAB script:

[line 5]: nrState = 4;

The readily available option for nrState are 4, 8, 16, 32, 64, 128, and 256. If you be able to generate your own generator matrix, you might want to try nrState beyond 256 states. Secondly, you might want to change other parameters, such as:

[line 8]: SNRindB = [8 10 12 14 16];, Signal to Noise Ratio (SNR) range,

[line 11]: N = 10000;, number of frame,

[line 14]: D = 130;, number of data per frame.

Finally, call qpskSpaceTimeMain.m or qpskSpaceTimeMainNormal.m from MATLAB's shell. If you want to make multiple plots under one figure, do not forget to hold the plot and change the curve properties (color, line, and point) as well.

Example of the output

Figure 1. Frame error rate vs. SNR

Figure 1 shows that codes with 64, 128 and 256 states almost overlap each other. It seems that improvement is negligible when you increase the state number over 64, but you must take into account the code design, which is how you define the generator matrix. In this simulation I do not use the optimum code criterion as described in [1] for 64, 128 and 256 states.

References

[1] V. Tarokh, N. Seshari, and A. R. Calderbank, "Space-Time Code for High Data Rate Wireless Communication: Performance Criterion and Code Construction", IEEE Trans. On Information Theory, vol. 44, no. 2, pp 744-765, March 1998.