In this chapter, we introduce some of the capabilities in MATLAB related to the analysis, design, modeling, simulation, implementation, and verification of communications systems. We attempt to answer the following question: How can MATLAB, a high-level programming language and a design and simulation environment with an extensive library of software toolboxes, help academics and practitioners in the development of mobile and wireless systems?
To answer this question, we review multiple stages of development: from early research and algorithm design to integration of individual algorithms into a prototype system model, to verification using simulations that the system works as intended, to checking whether the system is realizable, to assessing its resource consumption, memory, complexity, and so on, to coding the design as a software or hardware implementation. The step before implementation – that is, system-level resource assessment – requires some form of software coding for system-level simulation. It also involves integrating real constraints such as data types and memory with complexity trade-offs. This system-level code can be used as the basis for hardware implementation, with the aim being to integrate sufficient detail that the task of the implementer becomes the creation of a bit-accurate model of the software simulation as either assembly code for implementation on Digital Signal Processors (DSPs) or as Hardware Description Language (HDL) code for implementation on a Field-Programmable Gate Array (FPGA) or an Application-Specific Integrated Circuit (ASIC). Throughout this process we must continuously monitor new details as they are added to the model in order to ensure that the elaborated design still meets the requirements set out at the research and development level.
We face a number of challenges when we start from a typical standards specification until we implement the design. These challenges include:
MATLAB and its toolboxes can help address some of these challenges.
We can divide these capabilities into four categories: algorithm development, modeling and simulation, simulation acceleration, and path to implementation. In this chapter, following a quick introduction to MATLAB and Simulink as core products, we will introduce three categories of capability:
The modeling and simulation capabilities, including various toolboxes, enable users to create simulation models of communications standards, including wireless and mobile standards. Running these simulation models enables the designer to gauge the performance of the entire system and of individual algorithms and to determine the effects of channel degradations and other real-time conditions.
The focus of this book is on LTE PHY (Physical Layer) modeling as MATLAB programs. For example, we discuss modeling and simulation of the LTE standard only in the FDD (Frequency Division Duplex) mode. Without any loss of generality and with some modification of MATLAB code, the reader can then adopt our MATLAB program for TDD (Time Division Duplex) mode. We will not cover topics related to control-plane processing, roaming or random access, or multimedia broadcast frames, nor will we cover detailed MATLAB programs related to multicast mode or multi-user MIMO. We will focus instead on a general scenario in which a mobile unit is assigned to a cell and we fully detail user-plane data processing.
Starting from the simplest component of the LTE (i.e., the modulators), we will create a series of MATLAB programs that progressively add other components such as scrambling and channel coding to the signal processing chains. At each stage, we will compute performance measures such as Bit Error Rate (BER) to ensure that the combinations of components are properly modeled in MATLAB. We will continue this process and develop MATLAB programs to model OFDM and MIMO operations specified in the standard. In so doing, we will also generate multiple subfunctions that help match the model to the LTE standard. At the end of this process, we will have MATLAB programs and Simulink models that represent important signal processing operations of various downlink modes of the LTE standard.
In this book we will iteratively and systematically build up the necessary components of the LTE PHY in MATLAB for downlink transmission. However, in order to make the discussion fit a book of this size, we have to be selective in the details we highlight. The pedagogic value of iterative and gradual design can be more beneficial than adherence to all parameters and details specified in the standard. As the title of the book attests, we are aiming for a creating understanding of LTE by augmentation of technical discussions with software programs that can be executed in MATLAB. The ability to run and execute the software and simulate the system adds another dimension to the level of understanding.
Next, we will highlight various products that helps users model, simulate, prototype, and implement wireless systems in MATLAB.
MATLAB is a widely-used programming language for algorithm development, data analysis, visualization, and numerical computation. If the volume of technical papers and publications mentioning it is any indication, MATLAB has a long history in communications system design and is used by both academics and practitioners. It lets designers focus on algorithms rather than low-level programming. Many of its features and capabilities are perfect for modeling wireless systems: (i) it has an interactive program and environment that matches the exploratory nature of science; (ii) it provides seamless access to data and algorithms; and (iii) it has tools for visualization, algorithm development, and data analysis.
MATLAB's add-on software tools are called toolboxes. These provide specialized mathematical functionalities in areas including signal processing and communications. They complement the core MATLAB library and provide application-specific functions and objects that accelerate the process of modeling and building algorithms and systems. These algorithmic building blocks enable the user to focus on their area of expertise instead of having to reinvent and implement the basics.
Four system toolboxes – DSP System Toolbox 2, Communications System Toolbox 3, Phased Array System Toolbox 4, and Computer Vision System Toolbox 5 – are particularly suitable for system modeling in different application areas. Not only do they provide algorithms for the design, simulation, and verification of various application areas, but they provide components that facilitate the creation of simulation test benches for the modeling of dynamic systems. In later sections we will review some of these system toolboxes in further detail.
Simulink requires MATLAB and provides an environment for multidomain simulation and model-based design for dynamic and embedded systems 6. It provides an interactive graphical environment and a customizable set of block libraries. With an easy-to-use graphical design environment, Simulink allows us to design, simulate, implement, and test a variety of time-varying systems, including communications, control, signal processing, and video processing.
With Simulink, we can create, model, and maintain a detailed block diagram of our system using a comprehensive set of predefined blocks. Simulink provides tools for hierarchical modeling, data management, and subsystem customization. Additional blocksets or system toolboxes extend Simulink with specific functionality for aerospace, communications, radio frequency, signal processing, video, image processing, and other applications; these features are particularly useful for the modeling and simulation of communications systems.
Most algorithm development for various systems and components starts in MATLAB. With a library of digital signal-processing, linear algebra, and mathematical operators, designs can be expressed easily in MATLAB as algorithms composed of a pertinent sequence of operations. As individual algorithms are developed and connected to each other, this forms the basis of a system model. System modeling can best be done in either MATLAB or Simulink. As we saw earlier, Simulink allows MATLAB algorithms and functions to be integrated seamlessly as system components. By using various add-on toolboxes, we can expand the scope of the system and simulate it to verify that it behaves according to specifications. In this section we will introduce some of the MATLAB and Simulink add-on toolboxes that help with this process.
The DSP System Toolbox provides algorithms and tools for foundational signal processing operations. It comes with a slew of specialized filter design capabilities, FFTs (Fast Fourier Transforms), and multirate processing abilities and features algorithms captured as System objects that make the task of processing streaming data and creating real-time prototypes easier. The DSP System Toolbox has specialized tools for connecting to audio files and devices, performing spectral analysis, and using other interactive visualization techniques that enable the analysis of system behavior and performance. All of these components support automatic C/C++ code generation, most support fixed-point data, and a few generate HDL code.
The Communications System Toolbox provides algorithms and tools for the design, simulation, and analysis of communications systems. This toolbox is specially designed to model the PHY of communications systems. It contains a library of components including ones for source coding, channel coding, interleaving, modulation, equalization, synchronization, MIMO, and channel modeling. These components are provided as MATLAB functions, MATLAB System objects, and Simulink blocks, so they can be used as part of MATLAB or Simulink system models. All support C/C++ code generation, most support fixed-point data arithmetic, and a few generate HDL code for FPGA or ASIC hardware implementation.
The Parallel Computing Toolbox 7 can help accelerate computationally and data-intensive problems using multicore processors, GPUs (Graphics Progressing Units), and computer clusters. Features such as parallelized for loops, special array types, and parallelized numerical algorithms allow the parallelization of MATLAB applications. The toolbox can be used with Simulink to run multiple simulations of a model in parallel. Two main approaches to simulation acceleration can be identified:
Fixed-Point Designer 8, previously Fixed-Point Toolbox, provides fixed-point data types, operations, and algorithms in MATLAB. Using Fixed-Point Designer, the effects of finite word lengths can be modeled for variables in various algorithms. The toolbox allows fixed-point algorithms to be designed using MATLAB syntax and the results to be compared with the floating-point implementation of the same algorithm. These algorithms can be reused in Simulink and can pass fixed-point data to and from Simulink models. The toolbox provides a suite of tools that make it easier to convert an algorithm from a floating-point to a fixed-point implementation.
Various MathWorks products can help elaborate a design from concept to embeddable code while staying within the MATLAB environment. The MATLAB algorithm must first be refined based on design constraints such as finite word lengths, limitations on memory and complexity, and so on. It can then be integrated and simulated as part of a larger system model, and bit-true test sequences can be generated to verify that software and hardware implementations match the golden reference results in MATLAB. Finally, C and HDL code can be generated for hardware implementation. With this step, the errors introduced by manual coding can be avoided by maintaining a single design source in MATLAB. Some of these products are presented in this section.
MATLAB Coder 9 generates standalone C and C++ code from MATLAB code. The generated source code is portable and readable. MATLAB Coder supports code generation for a large subset of MATLAB language, including program control constructs, functions, and matrix operations. It also supports code generation for the functions and System objects of various toolboxes and System toolboxes. With MATLAB Coder we can generate:
A design for a communication system can be realized as either embedded software or embedded hardware. An embedded software implementation targets DSP and general-purpose processors. The path from a MATLAB model to an embedded software implementation involves two steps: (i) C/C++ code generation from MATLAB and (ii) compiling or hand-coding of the C code as assembly code on the target. MATLAB Coder can be used for the first step and the compilers of various software simulators for hardware targets can be used for the second.
An embedded hardware implementation targets the design on FPGAs and ASICs. The process of realizing a design from a MATLAB model to the final FPGA or ASIC prototype involves two steps: (i) VHDL or Verilog code generation of MATLAB functions or Simulink models with the HDL Coder and (ii) post-processing by the integrated simulation environments to convert the RTL (Register Transfer Level) Verilog and VHDL code into a fully synthesized FPGA or ASIC design. HDL Coder 10 generates portable, synthesizable VHDL and Verilog code from MATLAB functions and Simulink models. It can be used to perform the first step of the implementation. Another MathWorks HDL tool, HDL Verifier, automates Verilog and VHDL design verification using HDL simulators and FPGA hardware-in-the-loop. HDL Verifier 11 can be used to bring an RTL design into MATLAB and to verify it by comparing the outputs of the VHDL and Verilog code with detailed implementations of the same algorithm in MATLAB and Simulink. Since in this book we focus on modeling, simulation, and software prototyping of the LTE standard, discussions regarding hardware implementations and realization of a design as HDL code are outside our scope.
In this book we highlight many features of the Communications System Toolbox, particularly we will introduce the new System objects used in the product. With a very intuitive user interface, System objects make the task of expressing communications systems easier and make the resulting MATLAB code more readable and sharable. System objects can be used as part of both MATLAB programs and Simulink models. They are MATLAB objects that represent time-based and executable algorithms and they are organized as objects to make them easy to use and virtually self-documenting. Since in the rest of this book we rely on System objects to express LTE-system models in MATLAB, a short tutorial on how to use these algorithmic components is presented in this section.
System objects of the Communications System Toolbox belong to the communications (comm) package and their names start with the common prefix “comm.” In order to access all of the System objects of the Communications System Toolbox, type “comm.” followed by a Tab key at the MATLAB command prompt:
>> comm.<Tab>
This will produce an alphabetical list of all the System objects available in the toolbox. As of the latest release of MATLAB, the Communications System Toolbox contains a total of 123 algorithms provided as System objects.
Let us choose one of these System objects, for example comm.QPSKModulator, and create one instance of this type of modulator. Let us call this instance “Modulator”:
>> Modulator=comm.QPSKModulator
A QPSK (Quadratue Phase Shift Keying) modulator will be created and a description of this object will appear in the MATLAB workspace (Figure 3.1).
Every System object contains properties and methods. Its default properties appear when they are created; this self-documentation is a useful feature of System objects. From looking at the property list of a given System object, we know what parameters it can take and what values are typically assigned to them. For example, the phase-offset property of the QPSK modulator is by default set to π/4. Let us change this parameter to π/2. There are two ways to modify properties:
>> Modulator = comm.QPSKModulator; >> Modulator.PhaseOffset = pi/2
>>Modulator = comm.QPSKModulator ('PhaseOffset',pi/2);
If properties are expressed as a string of characters, a convenient list of possible values appears when we want to set a particular property. For example, when we type “Modulator.SymbolMapping=” followed by a Tab, a list of mapping choices appears to facilitate setting of the property to any of the several options, in this case “Binary” and “Gray.”
The step method is the main method of execution of a System object. After an object is created and configured, it can be passed an input (or multiple inputs) and its step method can be called to produce its output (or multiple outputs). There are two syntaxes available by which to execute the step method of a System object. We can:
In Figure 3.2, a 10 × 1 column vector of bits (variable u) is created using the MATLAB randi function and then passed as input to the Modulator System object. By calling its step method, a 5 × 1 output vector (y) of modulated symbols representing the modulated bits using the QPSK algorithms based on specified properties is created.
Now that we have seen how to access, create, set the properties of, configure, and call a System object to perform computations, let us create a simple script that uses a few System objects to express a simple communications system.
Following is a MATLAB script, otherwise known as a testbench, that uses System objects to perform BER analysis of a simple transceiver system. The transceiver is composed of a QPSK modulator, an Additive White Gaussian Noise (AWGN) channel, and a QPSK demodulator. Note that this code employs four System objects from the Communications System Toolbox: comm.QPSKModulator, comm.AWGNChannel, comm.QPSKDemodulator, and comm.ErrorRate.
%% Constants FRM=2048; MaxNumErrs=200;MaxNumBits=1e7; EbNo_vector=0:10;BER_vector=zeros(size(EbNo_vector)); %% Initializations Modulator = comm.QPSKModulator('BitInput',true); AWGN = comm.AWGNChannel; DeModulator = comm.QPSKDemodulator('BitOutput',true); BitError = comm.ErrorRate; %% Outer Loop computing Bit-error rate as a function of EbNo for EbNo = EbNo_vector snr = EbNo + 10*log10(2); AWGN.EbNo=snr; numErrs = 0; numBits = 0;results=zeros(3,1); %% Inner loop modeling transmitter, channel model and receiver for each EbNo while ((numErrs < MaxNumErrs) && (numBits < MaxNumBits)) % Transmitter u = randi([0 1], FRM,1); % Generate random bits mod_sig = step(Modulator, u); % QPSK Modulator % Channel rx_sig = step(AWGN, mod_sig); % AWGN channel % Receiver y = step(DeModulator, rx_sig); % QPSK Demodulator results = step(BitError, u, y); % Update BER numErrs = results(2); numBits = results(3); end % Compute BER ber = results(1); bits= results(3); %% Clean up & collect results reset(BitError); BER_vector(EbNo+1)=ber; end %% Visualize results EbNoLin = 10.^(EbNo_vector/10); theoretical_results = 0.5*erfc(sqrt(EbNoLin)); semilogy(EbNo_vector, BER_vector) grid;title('BER vs. EbNo - QPSK modulation'); xlabel('Eb/No (dB)');ylabel('BER');hold; semilogy(EbNo_vector,theoretical_results,'dr');hold; legend('Simulation','Theoretical');
The script is organized in four sections. In the initialization section, the System objects are created and some parameters are set. The second section contains the processing testbench that iterates through Eb/N0 values and computes the corresponding BER measures. The third section is the transceiver processing loop, where the step methods of the System objects are called in order to modulate the input signal, add channel noise to the modulated signal, and demodulate to produce the received signal and compute BER. Finally, in the fourth section, the simulation is cleaned up and terminated and the BER performance results are visualized.
Figure 3.3 verifies that the simulated results match the analytical results.
By running this script we obtain the BER curves of a QPSK modulation system using an AWGN channel. Theoretical results for a QPSK modulation scheme processed by an AWGN channel are expressed in the following equation:
3.1
The use of System objects results in a modular and easy-to-understand MATLAB code and fosters a structure that can be expanded for more complex systems. We will follow this four-step process of initialization, processing loop, termination, and visualization throughout this book. One way of improving MATLAB programs and making them more readable is to separate testbench and visualization operations from the algorithms and system description. Next we will show how to achieve this by capturing our transceiver as a MATLAB function and separating our algorithmic component from the testbench script.
The MATLAB function chap3_ex02_qpsk performs the algorithmic portion of our simple QPSK transceiver system. This function has three input variables:
For each Eb/N0 value, the code runs in a while loop until either the specified maximum number of errors is observed or the maximum number of bits is processed. The code executes each System object by calling the step method. It computes two outputs:
function [ber, bits]=chap3_ex02_qpsk(EbNo, maxNumErrs, maxNumBits) %% Initializations persistent Modulator AWGN DeModulator BitError if isempty(Modulator) Modulator = comm.QPSKModulator('BitInput',true); AWGN = comm.AWGNChannel; DeModulator = comm.QPSKDemodulator('BitOutput',true); BitError = comm.ErrorRate; end %% Constants FRM=2048; M=4; k=log2(M); snr = EbNo + 10*log10(k); AWGN.EbNo=snr; %% Processsing loop modeling transmitter, channel model and receiver numErrs = 0; numBits = 0;results=zeros(3,1); while ((numErrs < maxNumErrs) && (numBits < maxNumBits)) % Transmitter u = randi([0 1], FRM,1); % Random bits generator mod_sig = Modulator.step(u); % QPSK Modulator % Channel rx_sig = AWGN.step(mod_sig); % AWGN channel % Receiver demod = DeModulator.step(rx_sig); % QPSK Demodulator y = demod(1:FRM); % Compute output bits results = BitError.step(u, y); % Update BER numErrs = results(2); numBits = results(3); end %% Clean up & collect results ber = results(1); bits= results(3); reset(BitError);
To avoid the overhead involved in creating and releasing System objects every time we call a function, the System objects in a function are denoted by persistent variables. Using a persistent variable allows us to perform such operations as creating System objects only the first time a function is called. This adds to the efficiency of function calls and improves the simulation speed as we call the function in a loop.
The Communication System Toolbox provides BERTool as an integrated testbench for the performance of BER simulations. BERTool is a graphical application that computes a series of simulated bit error rates and compares the results with known analytical results.
For example, to visualize the simulated BERs for the function chap3_ex02_qpsk.m, as depicted in Figure 3.4, go to the Monte Carlo tab, specify the file as the simulation MATLAB file, and specify the Eb/N0 values and stopping criteria. BERTool will compute the BER for the range of Eb/N0 values provided and will automatically display the results. These simulated results can be compared with theoretical results by going to the Theoretical tab and specifying the modulation and coding schemes used. Figure 3.5 shows an example of the comparison plots generated by the BERTool testbench.
In this section, using a pedagogic approach and a series of MATLAB programs, we will examine what the Toolbox offers in terms of channel coding. First we will model a system that uses convolutional encoding and Viterbi decoding based on hard-decision decoding. Then we will update the algorithm to use soft-decision decoding. Finally, we will replace convolutional coding with a turbo-coding algorithm and compare the performance at each stage. With these simple exercises, not only will we learn how easy it is to use MATLAB and the Communications System Toolbox to add more complexity to our mobile communication model but we will clearly see that the substantial improvement in BER performance explains the predominant role turbo coding plays in the channel coding of the LTE standard.
Channel coding comprises error detection and error correction. With error detection using the CRC (Cyclic Redundancy Check) detector, the receiver can request the repeat of a transmission, in what is known as an automatic repeat request. Forward-error-correction coding allows errors to be corrected based on the redundancy bits that are included with the transmitted signal. A hybrid of error detection and forward error correction known as HARQ (Hybrid Automatic Repeat Request) forms an integral part of most 3G standards and is also used in the LTE standards. Error-correcting codes are usually classified into block codes and convolutional codes. Convolutional codes are widely used in 2G and 3G mobile communications standards, primarily because of their low complexity.
In this section, we will elaborate our growing MATLAB model, which already includes modulation, to include channel coding. As a perfect vehicle for explaining the value and motivation of the use of turbo coding in the LTE standard, we will compare the performances of convolutional and turbo coding. Furthermore, to explain the tradeoff involved in the use of receiver designs, we will compare the performance of modulation-coding combinations with and without soft-decision decoding.
Convolutional codes are generated by the convolution of the input sequence with the impulse response of the encoder. The encoder accepts blocks of k-bit input samples and, by operating on the current block of data and the m previous input blocks, produces an n-bit block of output samples. The coding rate of the encoder is given by the ratio Rc = k/n and the convolutional encoder is specified by these three parameters (n,k,m). Figure 3.6 illustrates a convolutional encoder.
In the first iteration of this exercise, we modify the MATLAB function in the last section to add a channel-coding scheme to the modulation. When a channel-coding scheme is used, the transmitter sends redundancy bits along with message bits through the wireless channel. The receiver accepts the transmitted signal and uses the redundancy bits to detect and correct some of the errors introduced by the channel. Let us start by adding a convolutional encoder and a Viterbi decoder to the communications system. This communications system uses hard-decision Viterbi decoding, where the demodulator maps the received signal to bits and then passes the bits to the Viterbi decoder for error correction. The following MATLAB function (chap3_ex03_qpsk_viterbi) uses QPSK modulation and hard-decision Viterbi decoding with an AWGN channel.
function [ber, bits]=chap3_ex03_qpsk_viterbi(EbNo, maxNumErrs, maxNumBits) %% Initializations persistent Modulator AWGN DeModulator BitError ConvEncoder Viterbi if isempty(Modulator) Modulator = comm.QPSKModulator('BitInput',true); AWGN = comm.AWGNChannel; DeModulator = comm.QPSKDemodulator('BitOutput',true); BitError = comm.ErrorRate; ConvEncoder=comm.ConvolutionalEncoder(… 'TerminationMethod','Terminated'); Viterbi=comm.ViterbiDecoder('InputFormat','Hard',… 'TerminationMethod','Terminated'); end %% Constants FRM=2048; M=4; k=log2(M); codeRate=1/2; snr = EbNo + 10*log10(k) + 10*log10(codeRate); AWGN.EbNo=snr; %% Processsing loop modeling transmitter, channel model and receiver numErrs = 0; numBits = 0;results=zeros(3,1); while ((numErrs < maxNumErrs) && (numBits < maxNumBits)) % Transmitter u = randi([0 1], FRM,1); % Random bits generator encoded = ConvEncoder.step(u); % Convolutional encoder mod_sig = Modulator.step(encoded); % QPSK Modulator % Channel rx_sig = AWGN.step(mod_sig); % AWGN channel % Receiver demod = DeModulator.step(rx_sig); % QPSK Demodulator decoded = Viterbi.step(demod); % Viterbi decoder y = decoded(1:FRM); % Compute output bits results = BitError.step(u, y); % Update BER numErrs = results(2); numBits = results(3); end %% Clean up & collect results ber = results(1); bits= results(3); reset(BitError);
By running this function within BERTool, we can gauge the performance of hard-decision Viterbi decoding and compare it with the upper-bound theoretical results. Examining the results in Figure 3.7, we can see that the simulated BER curve falls below the theoretical upper-bound values, which is consistent with our expectations. These results indicate that in order to arrive at a better performance we need to improve our decoding algorithm.
In this iteration, we improve BER performance results by using a soft-decision decoding algorithm. In soft-decision decoding, the demodulator maps the received signal to log-likelihood ratios. These probability measures are based on the logarithm of the likelihood that the correct data are received instead of corrupted data. When log-likelihood ratios are provided as the input to the Viterbi decoder, the BER performance of the decoder is improved. An algorithm can be made to perform soft-decision Viterbi decoding by changing a few demodulator and Viterbi-decoder System-object parameters. The following MATLAB function (chap3_ex04_qpsk_viterbi_soft) has been updated to use soft-decision Viterbi decoding.
function [ber, bits]=chap3_ex04_qpsk_viterbi_soft(EbNo, maxNumErrs, maxNumBits) %% Initializations persistent Modulator AWGN DeModulator BitError ConvEncoder Viterbi Quantizer if isempty(Modulator) Modulator = comm.QPSKModulator('BitInput',true); AWGN = comm.AWGNChannel; DeModulator = comm.QPSKDemodulator('BitOutput',true,… 'DecisionMethod','Log-likelihood ratio',… 'VarianceSource', 'Input port'); BitError = comm.ErrorRate; ConvEncoder=comm.ConvolutionalEncoder(… 'TerminationMethod','Terminated'); Viterbi=comm.ViterbiDecoder(… 'InputFormat','Soft',… 'SoftInputWordLength', 4,… 'OutputDataType', 'double',… 'TerminationMethod','Terminated'); Quantizer=dsp.ScalarQuantizerEncoder(… 'Partitioning', 'Unbounded',… 'BoundaryPoints', -7:7,… 'OutputIndexDataType','uint8'); end %% Constants FRM=2048; M=4; k=log2(M); codeRate=1/2; snr = EbNo + 10*log10(k) + 10*log10(codeRate); noise_var = 10.^(-snr/10); AWGN.EbNo=snr; %% Processsing loop modeling transmitter, channel model and receiver numErrs = 0; numBits = 0;results=zeros(3,1); while ((numErrs < maxNumErrs) && (numBits < maxNumBits)) % Transmitter u = randi([0 1], FRM,1); % Random bits generator encoded = ConvEncoder.step(u); % Convolutional encoder mod_sig = Modulator.step(encoded); % QPSK Modulator % Channel rx_sig = AWGN.step(mod_sig); % AWGN channel % Receiver demod = DeModulator.step(rx_sig, noise_var); % Soft-decision QPSK Demodulator llr = Quantizer.step(-demod); % Quantize Log-Likelihood Ratios decoded = Viterbi.step(llr); % Viterbi decoder with LLRs y = decoded(1:FRM); % Compute output bits results = BitError.step(u, y); % Update BER numErrs = results(2); numBits = results(3); end %% Clean up & collect results ber = results(1); bits= results(3); reset(BitError);
Theoretically, we expect a 2 dB improvement in the results, and that is exactly what is shown by the simulated curves in Figure 3.8. Next we examine turbo coding to see whether it can offer any improvements to BER results.
Turbo codes substantially improve BER performance over soft-decision Viterbi decoding. Turbo coding uses two convolutional encoders in parallel at the transmitter and two A Posteriori Probability (APP) decoders in series at the receiver. This example uses a rate 1/3 turbo coder. For each input bit, the output has one systematic bit and two parity bits, for a total of three bits.
The following MATLAB function has been updated to use turbo encoders and decoders. Note that turbo decoding is an iterative iteration, where performance improves as more iterations are gone through. In this example, we have chosen six as the number of iterations the decoder performs.
function [ber, bits]=chap5_ex05_qpsk_turbo(EbNo, maxNumErrs, maxNumBits) %% Constants FRM=2048; Trellis=poly2trellis(4, [13 15], 13); Indices=randperm(FRM); M=4;k=log2(M); R= FRM/(3* FRM + 4*3); snr = EbNo + 10*log10(k) + 10*log10(R); noise_var = 10.^(-snr/10); %% Initializations persistent Modulator AWGN DeModulator BitError TurboEncoder TurboDecoder if isempty(Modulator) Modulator = comm.QPSKModulator('BitInput',true); AWGN = comm.AWGNChannel; DeModulator = comm.QPSKDemodulator('BitOutput',true,… 'DecisionMethod','Log-likelihood ratio',… 'VarianceSource', 'Input port'); BitError = comm.ErrorRate; TurboEncoder=comm.TurboEncoder(… 'TrellisStructure',Trellis,… 'InterleaverIndices',Indices); TurboDecoder=comm.TurboDecoder(… 'TrellisStructure',Trellis,… 'InterleaverIndices',Indices,… 'NumIterations',6); end %% Processsing loop modeling transmitter, channel model and receiver AWGN.EbNo=snr; numErrs = 0; numBits = 0;results=zeros(3,1); while ((numErrs < maxNumErrs) && (numBits < maxNumBits)) % Transmitter u = randi([0 1], FRM,1); % Random bits generator encoded = TurboEncoder.step(u); % Turbo Encoder mod_sig = Modulator.step(encoded); % QPSK Modulator % Channel rx_sig = AWGN.step(mod_sig); % AWGN channel % Receiver demod = DeModulator.step(rx_sig, noise_var); % Soft-decision QPSK Demodulator decoded = TurboDecoder.step(-demod); % Turbo Decoder y = decoded(1:FRM); % Compute output bits results = BitError.step(u, y); % Update BER numErrs = results(2); numBits = results(3); end %% Clean up & collect results ber = results(1); bits= results(3); reset(BitError);
Figure 3.9 illustrates the results for turbo coding in QPSK modulation under an AWGN channel. Note that at 1 dB we have a BER value that occurs at 5 dB for hard-decision and at 3 dB for soft-decision decoding. This clearly indicates the superiority of the turbo-coding algorithm. Bear in mind that this performance gain comes at the cost of an increase in computational complexity. Our turbo decoder went through iterative decoding six times to arrive at this performance. We will study this compromise between performance and complexity for turbo decoders in later chapters.
MATLAB, Simulink, and their toolboxes provide capabilities that can be used to model, simulate, assess the performance of, and eventually generate and implement code for communication systems. For modeling and simulation, we can use algorithmic building blocks from the Communications System Toolbox, either as System objects or as Simulink blocks. Many aspects of PHY processing of mobile standards can be modeled and simulated more efficiently in MATLAB because instead of focusing on creating building blocks, such as modulators and coders, we can focus on introducing more advanced functionality to a system model. Of special interest are the System objects of the Communications System Toolbox. System objects are modeling and simulation components that are designed to be self-documented, easy-to-use, and custom-designed for the modeling of block-based streaming systems.
When simulating complex systems, we need to access various acceleration techniques. These techniques help us process larger sets of test data and obtain statistically correct assessments in reasonable simulation times. MATLAB toolboxes such as the Parallel Processing Toolbox and MATLAB Coder can speed up simulations. Finally, in order to implement a design in software or hardware we can use code-generation products to gain access to the exact implementation detail via automatic C or HDL code generation.
[1] MathWorks Documentation Center, http://www.mathworks.com/help/MATLAB/random-number-generation.html (accessed 16 August 2013).
[2] MathWorks DSP System Toolbox, http://www.mathworks.com/products/dsp-system (accessed 16 August 2013).
[3] MathWorks Communications System Toolbox, http://www.mathworks.com/products/communications (accessed 16 August 2013).
[4] MathWorks Phased Array System Toolbox, http://www.mathworks.com/products/phased-array (accessed 16 August 2013).
[5] MathWorks Computer Vision System Toolbox, http://www.mathworks.com/products/computer-vision (accessed 16 August 2013).
[6] MathWorks Simulink, http://www.mathworks.com/products/simulink (accessed 16 August 2013).
[7] MathWorks Parallel Computing Toolbox, http://www.mathworks.com/products/parallel-computing (accessed 16 August 2013).
[8] MathWorks Fixed-Point Designer, http://www.mathworks.com/products/fixed-point-designer (accessed 16 August 2013).
[9] MathWorks MATLAB Coder, http://www.mathworks.com/help/coder/index.html (accessed 16 August 2013).
[10] MathWorks HDL Coder, http://www.mathworks.com/products/hdl-coder (accessed 16 August 2013).
[11] MathWorks HDL Verifier, http://www.mathworks.com/products/hdl-verifier (accessed 16 August 2013).