This project implements a CDMA decoder (Code Division Multiple Access) in the programming languages C++ and C. It was developed as part of the Embedded Software Lab at Karlsruhe University of Applied Sciences during the winter semester 2020/21.
CDMA is a code division multiplexing method that allows multiple transmissions to use the same frequency simultaneously by separating them with different code sequences. This method is used in particular in satellite communications, such as GPS. The main task of the project was to develop software that decodes a chip sequence and provides information about the data transmitted by a satellite.
The chip sequences are generated by a combination of master sequences (gold sequences), which are necessary for decoding the signal. The aim of the project was to implement an efficient solution that reads in the sequences, decodes them and outputs the relevant information in a clear form.
The implementation was carried out in two phases: first in C++, followed by an implementation in C, whereby the C version was also created in two variants, unoptimized and optimized. No external libraries were used and only the Standard Template Library (STL) was used in order to guarantee a portable and lightweight solution.
The implementation in C++ uses object-oriented principles and offers a clean separation of tasks in different classes and functions. An essential part of the implementation includes the decoding of the chip sequence by generating the necessary gold sequences. These sequences are needed to perform the cross-correlation of the received chip sequence and to identify the transmitted bits.
Main components:
- SequenceGenerator: Generates the gold sequences based on the master sequences.
- Decoder: Performs the actual decoding by comparing the chip sequence with the gold sequences.
The program reads a chip sequence from a file, starts the decoding and then outputs the results including the time required.
The implementation in C is based on the C++ implementation, but does not use object-oriented concepts. All C++ constructs had to be rewritten in C-compatible code. The main difference is the use of arrays instead of vectors and manual memory management.
Optimizations in the C version:
- Memory optimizations: Reduction of memory accesses and use of pointer arithmetic instead of index accesses.
- Early exit: Decoding is aborted as soon as all relevant satellite bits have been found, which significantly shortens the runtime with lower satellite utilization.
- Avoidance of the modulo operator: By duplicating the gold sequences, the modulo operator could be removed entirely, which further improves the execution speed.
The runtime analysis was carried out in both C++ and C. The optimized versions showed significant speed advantages.
- C++ release build: Reduced the runtime from 8 seconds (debug build) to 72 milliseconds through compiler optimizations.
- C unoptimized: The unoptimized C version achieved a smaller speed increase, with the release build only halving the runtime.
- C optimized: The optimized C version resulted in an additional reduction in runtime due to specific improvements such as the removal of the modulo operator.
- C++11 for the C++ implementation.
- CMake to manage the build.
- Tested under Windows (MSVC) and Linux (GCC).
- Clone the repository:
git clone https://github.com/THaenlein/CDMA-Decoder.git
- Build instructions:
- Under Windows:
cmake -S . -B build cmake --build build --config Release
- Under Linux:
make release
- Under Windows:
- Run the program: The program expects a text file with the chip sequence to be decoded as input.
./cdma_decoder <path-to-chip-sequence-file>
- Development environment: Visual Studio with MSVC under Windows.
- Profiling: Visual Studio diagnostic tool was used to analyze CPU performance.
This project is licensed under the MIT License. See the LICENSE file for details.