Top Banner
Simulation environment for Software Defined Radio with application to Wideband CDMA Master of Science Thesis in Electronic System Design by Weisheng Zhong Stockholm, January 2007 Supervisor: Svante Signell Jinliang Huang Examiner: Svante Signell
58

Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Mar 19, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Simulation environment for Software Defined Radio

with application to Wideband CDMA

Master of Science Thesis

in Electronic System Design

by

Weisheng Zhong

Stockholm, January 2007

Supervisor: Svante Signell

Jinliang Huang

Examiner: Svante Signell

Page 2: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

ABSTRACT

Software Defined Radio (SDR) switches across various wireless air interfaces by using a

programmable and dynamically reconfigurable method and Wideband Code Division Multiple

Access (WCDMA) is a promising candidate to be adopted into SDR.

We implement WCDMA system in a SDR workbench in Matlab/Octave environment. Two

scenarios are considered in this thesis. In non-adaptive scheme, the Channel State Information

(CSI) is not known at the transmitter side. The signals are transmitted in a fixed rate and

modulation method. In adaptive scheme, the transmitter has complete and accurate knowledge of

the CSI so that adaptive modulation is applied to achieve high data rate transmission under a target

BER. The performance of WCDMA is examined in both flat Rayleigh fading and frequency

selective Rayleigh fading channel.

In an attempt to accelerate simulation speed in Matlab/Octave, mixed C++/Matlab and

C++/Octave programming is employed. It turns out that programming using C++/Matlab is more

efficient than the Matlab code only when the size of matrix is not larger than 25; the simulation

speed is slowed down by programming C++/Octave compared to Octave.

ii

Page 3: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Acknowledgments This thesis work was carried out at the School of Information and Communication

Technology (ICT), KTH.

I would like to thank my advisor Prof. Svante Signell for giving me this opportunity and the

valuable guidance and comments. I would also thank my advisor Jinliang Huang for always

offering suggestions and discussions throughout the thesis work.

I also would like to thank my parents for their consistent encouragement and support.

Specially, I want to take the opportunity and express my deepest regards to all my friends for

many great helps with my thesis research and graduate study.

iii

Page 4: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Contents Abstract ............................................................................................................................................ ii Acknowledgments........................................................................................................................... iii Contents ...........................................................................................................................................iv List of Figures ................................................................................................................................ vii List of Tables.................................................................................................................................. vii Abbreviations................................................................................................................................ viii Chapter 1 Introduction ......................................................................................................................1

1.1 WCDMA.......................................................................................................................1 1.2 Programming using Matlab/Octave ..............................................................................1 and C++.....................................................................................................................................1 1.3 Thesis Outline ...............................................................................................................3

Chapter 2 Overview of Previous Work .............................................................................................4

2.1 Introduction to Software Defined Radio .......................................................................4 2.2 3G air interface Fundamentals ......................................................................................4 2.3 Workbench Architecture................................................................................................8

Chapter 3 WCDMA Simulation......................................................................................................10

3.1 Characteristics.............................................................................................................10 3.1.1 Background .....................................................................................................10 3.1.2 Characteristics .................................................................................................10

3.2 Spreading and Despreading.........................................................................................11 3.2.1 Direct Sequence Spread spectrum...................................................................13 3.2.2 Pseudorandom Sequences (Spreading Codes) ................................................15

3.3 Multipath Radio Channel ............................................................................................16 3.4 Rake receiver...............................................................................................................17 3.5 WCDMA Simulation results in SDR-WB...................................................................21

3.5.1 Flat Fading Channel ........................................................................................21 3.5.1.1 Non-Adaptive Scheme .............................................................................21 3.5.1.2 Adaptive Scheme .....................................................................................22

3.5.2 Frequency Selective Fading Channel ..............................................................24 3.5.2.1 Frequency Selective Fading Channel with Non-adaptive Scheme...........25 3.5.2.2 Frequency Selective Fading Channel with Adaptive Scheme ..................26

Chapter 4 Programming using Matlab/Octave and C++.................................................................28

4.1 Introduction.................................................................................................................28 4.1.1 Matlab and Interface Function MEX file ........................................................28 4.1.2 Octave and Interface Function OCT file .........................................................29

iv

Page 5: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

4.2 Methodlogy .................................................................................................................30 4.2.1 Performance Analysis......................................................................................30 4.2.2 MEX File Programming..................................................................................32 4.2.3 OCT File Programming...................................................................................32

4.3 Numerical Results .......................................................................................................33 4.3.1 Programming using Matlab and C++..............................................................33 4.3.2 Programming using Octave and C++..............................................................34

4.4 Conclusion ..................................................................................................................36 Chapter 5 Conclusions and Future Work ........................................................................................37

5.1 Conclusions.................................................................................................................37 5.2 Future Work ................................................................................................................37

Appendix A MEX FILE ...............................................................................................................38 Appendix B DLL FILE ................................................................................................................45 Bibliography ...................................................................................................................................49

v

Page 6: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

List of Figures 2.1 System block diagram ..........................................................................................................8 2.2 Block diagrams of TX and RX ..............................................................................................9 3.1 Direct Sequence Spread Spectrum .....................................................................................13 3.2 Transmitted signals in DS-CDMA system ..........................................................................13 3.3 Power spectral density of baseband signal and SS signal .................................................14 3.4 Power spectral density of baseband SS signal and Noise ..................................................14 3.5 Power spectral density of baseband SS signal and Interference........................................15 3.6 Block diagram of a generalized feedback shift register with m stages...............................15 3.7 Fast Rayleigh fading as caused by multipath propagation ................................................163.8 A Spread Spectrum System with RAKE receiver ................................................................17 3.9 Rake Receiver Architecture with L branches......................................................................19 3.10 Performance comparation of the three combining methods ..............................................20 3.11 Average BER for BPSK and QPSK over a Rayleigh fading channel .................................22 3.12 Throughput of an adaptive system in a Flat Rayleigh fading channel ...............................23 3.13 Throughput of the adaptive system for different target BER ..............................................24 3.14 BER versus SNR over a frequency selective Rayleigh fading channel ...............................25 3.15 Comparison of BER versus SNR in Flat FC and FS fading channel .................................26 3.16 Throughput of adaptive system in a Frequency Selective fading channel..........................27 3.17 Throughput of the adaptive system for different target BER ..............................................27 4.1 Time spent on the functions ................................................................................................30 4.2 Time spent on the sub-lines ................................................................................................31 4.3 Time spent on the lines .......................................................................................................31 4.4 Time costs in the MATLAB multiplication with large matrix-size ......................................33 4.5 Time costs in the MATLAB multiplication with small matrix-size......................................34 4.6 Time costs in the OCTAVE multiplication with small matrix-size ......................................35 4.7 Time costs in the OCTAVE multiplication with large matrix-size ......................................35

vi

Page 7: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

List of Tables 2.1 Main differences between WCDMA and GSM air interfaces...............................................5 2.2 Main differences between WCDMA and IS-95 air interfaces ..............................................6 2.3 A comparison of major physical layer operational parameters of WCDMA, CDMA2000

and TD-SCDMA standards ..................................................................................................7 3.1 Direct Sequence Spread Spectrum Diagram ......................................................................11

vii

Page 8: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Abbreviations 3G 3rd Generation 3GPP 3rd Generation partnership project AWGN Additive white Gaussian noise BER Bit error rate BPSK Binary phase shift keying CDMA Code division multiple access CLPCF Closed loop power control frequency CSI Channel State Information DS-CDMA Direct spread code division multiple access FDD Frequency Division Duplex FDMA Frequency division multiple access GSM Global System for Mobile Communications IID independent and identical distributed. IMT-2000 International mobile telephony, 3rd generation networks are referred

as IMT-2000 within ITU ISI Intersymbol Interference MIMO Multiple-input multiple-output OFDM Orthogonal Frequency Division Multiplexing OVSF Orthogonal variable spreading factor PCBC Pilot channel based coherent PSBC Pilot symbol based coherent QAM Quadrature amplitude modulation QoS Quality of service QPSK Quadrature phase shift keying SNR Signal to noise ratio TDD Time Division Duplex UMTS Universal mobile telecommunication services VSF Variable spreading factor TD-SCDMA Time division synchronous CDMA WCDMA Wideband CDMA, Code division multiple access

viii

Page 9: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Chapter 1

Introduction 1.1 WCDMA

The goal for the next generation of mobile communications system is to seamlessly provide a

wide variety of communication services to anybody, anywhere, anytime. The intended service for

next generation mobile phone users includes services like transmitting high speed data, video and

multimedia traffic as well as voice signals. The technology needed to tackle the challenges to

make these services available is popularly known as the Third Generation (3G) Cellular Systems.

The first generation systems are represented by the analog mobile systems designed to carry the

voice application traffic. The subsequent digital counterparts are known as second generation

cellular systems. Third generation systems mark a significant leap, both in applications and

capacity, from the current second generation standards. Whereas the current digital mobile phone

systems are optimized for voice communications, 3G communicators are oriented towards

multimedia message capability.

Third generation systems are designed for multimedia communication: person to person

communication can be enhanced with high quality images and video, and access to information

and services on public and private networks will be enhanced by the higher data rates and new

flexible communication capabilities of third generation systems. Nowadays, WCDMA technology

has emerged as the most widely adopted third generation air interface [3]. The principles of the

WCDMA will be introduced in detail in Chapter 3.

1.2 PROGRAMMING USING MATLAB/OCTAVE

AND C++

Today software is used to solve complex numerical problems in a wide variety of

1

Page 10: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

environments. Therefore the software and the mathematical algorithms need to run on various

inhomogeneous hardware components, employing small specialized mobile devices as well as

high performance mainframes.

Interactive array languages such as Matlab and Octave have proven to be effective

development tools for numerical algorithms. Comparing with conventional languages, such as

C++, many programmers consider that using array languages is easier to prototype algorithms.

The main reason is the interactive nature of the language, which facilitates debugging and

analysis [4]. Another, in these languages it is not necessary to specify the dimension or type of

arrays. Though static typing decreases the probability of programming errors, the practice of

omitting types is a convenient feature to programmers. The third, these languages also offer a rich

set of functions and higher-level operators for matrix manipulation.

At the same time, however, the drawback is that interactive array languages are executed

with interpreters, which often makes programs inefficient. The interpreter is parsing the program,

allocating storage for variables dynamically, and determining at runtime which version of the

operations to invoke. This way type declared, which are omitted in Octave, are set dynamically at

runtime. In fact, most of the execution time is wasted doing work that could be done once before

deploying the software, at compile time.

Because of these downsides, interactive array languages are used only for the prototyping of

algorithms. Later the algorithm is re-implemented in a conventional language, such as C++.

An alternative would be to analyze and translate interactive array languages using the

interface functions to improve the efficient of the simulation environment.

MEX-Files are a way to call our custom C++ routines directly from MATLAB as if they were

MATLAB built-in functions. On Octave, it can also dynamically load and execute functions

written in C++. Octave can only directly call functions written in C++, but we can also load

functions written in other languages by calling them from a simple wrapper function written in

C++ [16]. We discussed the estimation on both of the two systems and a detailed result analysis

will be given in Chapter 4.

2

Page 11: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

1.3 THESIS OUTLINE

The introduction of this workbench architecture, which is the basic simulation environment

for SDR is presented in Chapter 2. This architecture is based on the existed simulation

environment, but refined to fit the needs of this thesis.

The brief description of key characteristics of WCDMA system is provided in Chapter 3. In

this Chapter, the physical layer of the WCDMA system is described in detail. The WCDMA

simulation results in SDR-WB are also described in this chapter.

The improvement of the efficiency of the simulation workbench is discussed in Chapter 4.

Both Matlab and Octave have their own interface function of C++ program. We tried to call C

functions from Matlab and Octave in the simulation codes of MIMO-OFDM. The results are

shown and the analysis follows.

Finally Chapter 5 gives a conclusion and directions for further research.

3

Page 12: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Chapter 2

Overview of Previous Work 2.1 INTRODUCTION TO SOFTWARE DEFINED RADIO

Traditional communications systems have typically been implemented using custom

hardware solutions [1]. Even with a single communication system the hardware development

cycle is onerous. While multiple communications systems requirements are considered, both

silicon area and design validation are major inhibitors to commercial success.

Most radios are hardware defined with little or no software control, and they are fixed in

function for mostly consumer items for broadcast reception. They have a short life and are

designed to be discarded and replaced.

Software defined radio (SDR) is an exciting new field for the wireless industry; it is gaining

momentum and beginning to be included in commercial and defense products. The technology

offers the potential to revolutionize the way radios are designed, manufactured, deployed, and

used. SDR promises to increase flexibility, extend hardware lifetime, lower costs, and reduce time

to market [2].

The basic definition of SDR can be summarized like that: SDR is a kind of open system

structure which connects modular and standardized hardware units by way of bus to form a basic

platform and accomplish different wireless communication functions through the software control.

2.2 3G AIR INTERFACE FUNDAMENTALS

Analog cellular systems are commonly referred to as first generation systems. The digital

systems currently in use, such as GSM, PDC, CDMA-One (IS-95) and US-TDMA (IS-136), are

second generation systems. These systems have enabled voice communications to go wireless in

many of the leading markets, and customers are increasingly finding value also in other services,

4

Page 13: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

such as text messaging and access to data networks, which are starting to grow rapidly. Now, the

third generation systems have been played an important role in the modern communication. As we

mentioned before, WCDMA technology has emerged as the most widely adopted third generation

air interface.

The main differences between the third and second generation air interfaces are described.

GSM and IS-95 (the standard for CDMA-One systems) are considered as the main second

generation air interfaces here [3].

Table 2.1 lists the main differences between WCDMA and GSM, and Table 2.2 lists the main

differences between WCDMA and IS-95. In this comparison only the air interface is considered.

Table 2.1 Main differences between WCDMA and GSM air interfaces

WCDMA GSM Carrier spacing 5MHz 200kHz Frequency reuse factor 1 1-18 Power control frequency 1500Hz 2Hz or lower Quality control Radio resource management

algorithms Network planning (frequency planning)

Frequency diversity 5MHz bandwidth gives multipath diversity with Rake receiver

Frequency hopping

Packet data Load-based packet scheduling Time slot based scheduling with GPRS

Downlink transmit diversity Supported for improving downlink capacity

Not supported by the standard, but can be applied

The differences in the air interface reflect the new requirements of the third generation

systems. For example, the larger bandwidth of 5 MHz is needed to support higher bit rates.

Transmit diversity is included in WCDMA to improve the downlink capacity to support the

asymmetric capacity requirements between downlink and uplink. Transmit diversity is not

supported by the second generation standards. The mixture of different bit rates, services and

quality requirements in third generation systems requires advanced radio resource management

algorithms to guarantee quality of service and to maximize system throughput. Also, efficient

support of non-real time packet data is important for the new services.

5

Page 14: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Table 2.2 Main differences between WCDMA and IS-95 air interfaces

WCDMA IS-95 Carrier spacing 5 MHz 1.25 MHz Chip rate 3.84 Mcps 1.2288 Mcps Power control frequency 1500 Hz, both uplink and

downlink Uplink: 800 Hz, downlink: slow power control

Base station synchronization Not needed Yes, typically obtained via GPS

Inter-frequency handovers Yes, measurements with slotted mode

Possible, but measurement method not specified

Efficient radio resource Yes, provides required quality of service

Not needed for speech only networks

Packet data Load-based packet scheduling Packet data transmitted as short circuit switched calls

Downlink transmit diversity Supported for improving downlink capacity

Not supported by the standard

The main differences between WCDMA and IS-95 are discussed below. Both WCDMA and

IS-95 utilize direct sequence CDMA. The higher chip rate of 3.84 Mcps in WCDMA enables

higher bit rates. The higher chip rate also provides more multipath diversity than the chip rate of

1.2288 Mcps, especially in small urban cells. Most importantly, increased multipath diversity

improves the coverage. The higher chip rate also gives a higher trunking gain, especially for high

bit rates, than do narrowband second generation systems.

Experiences from second generation air interfaces have been important in the development of

the third generation interface, but there are many differences, as listed above. In order to make the

fullest use of the capabilities of WCDMA, a deep understanding of the WCDMA air interface is

needed, from the physical layer to network planning and performance optimization.

However, an important problem with 3G is that it has added to the number of air interface

standards that needs to be supported by the infrastructure and terminal industry. Of the 3G

standards, the 3GPP Universal Mobile Telecommunications System (UMTS) is unlikely to be

universal and will be strongest in Europe. The 3GPP2 CDMA2000 standard and the TDMA based

GSM-EDGE systems will be successful in North and South America, while Japan has its own

WCDMA system similar to UMTS. The TD-SCDMA standard makes use of TDD synchronous

CDMA technology and offers several operational advantages. This standard has received the full

6

Page 15: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

blessing of the Chinese government and will surely play a critical role in mobile communications

development in China as well as in the world.

A comparison of fundamental system parameters of WCDMA, CDMA2000 and

TD-SCDMA standards is given in Table 2.3 [4].

Table 2.3 A comparison of major physical layer operational parameters of W-CDMA, CDMA2000 and TD-SCDMA standards

WCDMA CDMA2000 TD-SCDMA Multiple Access DS-CDMA DS-CDMA/MC-CDMA TDMA/DS-CDMA CLPCF 1600Hz 800 Hz 200Hz Channel coding

Convolutional, RS, or turbo coding

Convolutional or turbo coding

Convolutional or turbo coding

Spreading code OVSF DL:Walsh, UL:M-ary Walsh mapping

OVSF

VSF 4…256 4…256 1…16 Carrier 2 GHz 2 GHz 2 GHz Modulation DL: QPSK, UL: BPSK DL: QPSK, UL: BPSK QPSK,

8-PSK (at 2 Mb/s) Bandwidth 5*2 MHz 1.25*2/3.75*2 MHz 1.6 MHz UL-DL spectrum Paired Paired Unpaired Chip rate 3.84 Mchips/s 1.2288/3.6864 Mchips/s 1.28 Mchip/s

Frame length 10 ms 20 ms, 5 ms 10 ms Interleaving periods

10/20/40/80 ms

5/20/40/80 ms

10/20/40/80 ms

Maximum data rate

2 Mb/s

2.4 Mb/s

2 Mb/s

Detection PCBC PSBC PSBC Inter-BS timing Asynchronous/synchronous Synchronous Synchronous

All of the 3G systems are potential SDR applications. Software radio offers the potential to

solve many of the problems caused by the proliferation of new air interfaces. Base stations and

terminals using SDR architectures can support multiple air interfaces during periods of transition

and be easily software upgraded. Intelligent SDR can detect the local air interface and adapt to suit

the need.

7

Page 16: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

2.3 WORKBENCH ARCHITECTURE

In the previous work, we have an existed simulation environment. The workbench consists of

five parts: SOURCE, TX, CH, RX and SINK. These modules realize the most basic functions.

Signals to be transmitted generate inside SOURCE. TX defines the transmitters and RX defines

the receivers. Different channel models were defined in CH module. The Channel State

Information (CSI) can be transmitted from RX to TX through a feedback channel “CH_R”. Finally,

the received signals were demodulated and decoded in SINK module [5]. The system block

diagram is shown in Figure 2.1.

SOURCE TX CH RX SINK

CH_R

Figure 2.1. System block diagram

Inside each module, there are sub-modules that define sub-blocks. The block diagram of TX

and RX are shown in Figure 2.2: where BBU_T/BBU_R are the BaseBand Unit, SPU_T/SPU_R

are the Space Processing Unit, DRU_T/DRU_R are the Digital Radio Unit and ARU_T/ARU_R

are the Analog Radio Unit. The EAU_R is the Estimation and Adaptation Unit. Data bits are

encoded in the BBU_T block, and then fed into SPU_T, where baseband modulation is

accomplished. The outputs of SPU_T are OFDM modulated in DRU_T part if wideband

communication is chosen. More details about the workbench are introduced in [6].

TX

BBU_T SPU_T DRU_T ARU_T

8

Page 17: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

RX

ARU_R DRU_R SPU_R BBU_R

EAU_R

Figure 2.2. Block diagrams of TX and RX

In this thesis, we did the physical layer simulation of WCDMA systems based on a SDR

environment. Here we set two m file dsencoder.m and dsdecoder.m in the SPU_T and SPU_R

modules. The function of the two files will be explained in Section 3.3.

9

Page 18: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Chapter 3

WCDMA Simulation This chapter introduces the principles of the WCDMA and analyzes the performance of the

WCDMA system. The main characteristics of the WCDMA are introduced in Section 3.1. The

concept of spreading and despreading is described in Section 3.2, followed by a presentation of

the multipath radio channel in Section 3.3 and Rake receiver in Section 3.4. The WCDMA

simulation results in wideband will be shown in Section 3.5.

3.1 CHARACTERISTICS

3.1.1 Background

One of the most promising approaches to 3G is to combine a Wideband CDMA (WCDMA)

air interface with the fixed network of GSM. Several proposal supporting WCDMA were

submitted to the International Telecommunication Union (ITU) and its International Mobile

Telecommunications for the year 2000 (IMT2000) initiative for 3G.

3.1.2 Characteristics

We present the main system design parameters of WCDMA in this section. Here we highlight

some of the items that characterize WCDMA [3].

WCDMA is a wideband Direct-Sequence Code Division Multiple Access (DS-CDMA)

system, i.e. user information bits are spread over a wide bandwidth by multiplying the user data

with pseudorandom (PN) sequence derived from CDMA spreading codes. In order to support very

high bit rates (up to 2 Mbps), the use of a variable spreading factor and multi-code connections is

supported.

The chip rate of 3.84 Mcps leads to a carrier bandwidth of approximately 5 MHz. DS-CDMA

10

Page 19: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

systems with a bandwidth of about 1 MHz, such as IS-95, are commonly referred to as

narrowband CDMA systems. The inherently wide carrier bandwidth of WCDMA supports high

user data rates and also has certain performance benefits, such as increased multipath diversity.

Subject to its operating license, the network operator can deploy multiple 5 MHz carriers to

increase capacity, possibly in the form of hierarchical cell layers.

WCDMA supports highly variable user data rates, in other words the concept of obtaining

bandwidth on demand is well supported. The user data rate is kept constant during each 10 ms

frame. However, the data capacity among the users can change from frame to frame.

WCDMA supports two basic modes of operation: Frequency Division Duplex (FDD) and

Time Division Duplex (TDD). In the FDD mode, separate 5 MHz carrier frequencies are used for

the uplink and downlink respectively, whereas in TDD only one 5 MHz is timeshared between the

uplink and downlink. Uplink is the connection from the mobile to the base station, and downlink

is that from the base station to the mobile.

Table 3.1 summarizes the main parameters related to the WCDMA air interface.

Table 3.1. Main WCDMA parameters

Multiple Access Scheme DS-CDMA Duplex Scheme FDD/TDD Base station synchronisation Asynchronous operation Chip Rate 3.84 Mcps Carrier Spacing 4.4-5.2 MHz (200 kHz carrier raster) Frame Length 10ms Multirate concept Variable spreading factor and multicode Detection Coherent using pilot symbols or common pilotChannel Coding Scheme

Convolutional Code (rate 1/2 and 1/3 ) Turbo code

3.2 SPREADING AND DESPREADING

In 1985, the FCC (Federal Communications Commission) allocated three frequency bands

for a radio transmission technique known as spread spectrum communications, originally

developed by the military. This transmission technique has much greater immunity to interference

11

Page 20: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

and noise compared to conventional radio transmission techniques. In addition, an increasing

number of users can use the same frequency. These rules are designed to drive usage towards local

data communications.

Spread spectrum is a modulation technique which increases the transmit signal bandwidth.

There are several benefits obtained in exchange for this increased bandwidth. First, spread

spectrum modulation mitigates the effect of inter-symbol interference (ISI) and narrowband

interference. The narrowband interference rejection also applies to hostile jamming signals, and

for that reason spread spectrum is often used in military systems. In addition, spread spectrum also

“hides” the signal beneath the noise floor. This property means that the transmitted signal is

another desirable property for military communication systems. Finally, spread spectrum

modulation can be used as a multiple access technique, which is the basis of the digital cellular

standard IS-95.

There are two common forms of spread spectrum: direct sequence (DS) and frequency

hopping (FH). Since direct sequence is more commonly used, we will focus on this technique. In

this section, the operation of direct sequence spread spectrum radio technology will be presented.

Conventional DS-CDMA systems offer several advantages in cellular environments

including easy frequency planning, high immunity against interference if a high processing gain is

used, and flexible data rate adaptation.

Besides these advantages, DS-CDMA suffers from several problems in multi-user wireless

communications systems with limited available bandwidth:

Multiple access interference (MAI)

As the number of simultaneously active users increases, the performance of the DS-CDMA

system decreases rapidly, since the capacity of a DS-CDMA system with moderate processing

gain (limited spread bandwidth) is limited by MAI.

Complexity

In order to exploit all multipath diversity it is necessary to apply a matched filter receiver

approximated by a rake receiver with sufficient number of arms. In addition, the receiver has to be

matched to the time-variant channel impulse response. Thus, proper channel estimation is

necessary. This leads to additional receiver complexity with adaptive receiver filters and a

considerable signaling overhead.

12

Page 21: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Single-/Multitone interference

In the case of single-tone or multi-tone interference the conventional DS-CDMA receiver

spreads the interference signal over the whole transmission bandwidth whereas the desired signal

part is despread. If this interference suppression is not sufficient, additional operations have to be

done at the receiver. Hence, this extra processing leads to additional receiver complexity.

3.2.1 Direct Sequence Spread spectrum

Figure 3.1 shows the process of a direct sequence spread spectrum system. A common

communication system that employs a wide bandwidth is a direct sequence spread spectrum (SS)

system. Its basic components are shown in the following figure. Information is encoded and

modulated by a PN sequence and transmitted over a bandwidth W.

ChannelEncoder Modulator Channel

DecoderDemodulatorChannel

PseudorandomPattern

Generator

PseudorandomPattern

Generator

Information

Sequence

Output

Data

Figure 3.1. Direct sequence Spread spectrum

The following Figure depicts the basic operations of spreading and despreading for a

DS-CDMA System.

Figure 3.2. Transmitted signals in DS-CDMA system

13

Page 22: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

User data is here assumed to be a BPSK-modulated bit sequence. The spreading operation, in

this example, is the multiplication of each user data bit with a sequence of 8 code bits, called chips.

We assume this also for the BPSK spreading modulation and we can see that the resulting spread

signal has the same random appearance as the spreading code. In this case we would say that we

used a spreading factor of 8. This wideband signal would then be transmitted across a wireless

channel to the receiving end.

During despreading we multiply the spread user signal sequence, bit duration by bit duration,

with the very same 8 code chips as we used during the spreading of these bits. As shown, the

original user bit sequence has been recovered perfectly, provided we have (as shown in Figure 3.2)

also perfect synchronization between the spread user signal and the spreading code.

Figure 3.3. Power spectral density of baseband signal and SS signal

Figure 3.3 shows the power spectral density of baseband SS signal. A narrowband signal is

spread to a wideband signal over a broader portion of the radio frequency band, in order to utilize

the entire available bandwidth. Figure 3.4 shows the power spectral density of Basepass SS signal

after the interference of noise.

Figure 3.4. Power spectral density of baseband SS signal and Noise

14

Page 23: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Figure 3.5. Power spectral density of baseband SS signal and Interference

Figure 3.5 shows the power spectral density of baseband SS signal and Interference after

despreading. We can find that the part of noise which will interfere with the detector signal is the

detector noise that falls within the frequency region of the desired signal. Thus, this technique

makes the SS signal immune to interference

3.2.2 Pseudorandom Sequences (Spreading Codes)

The pseudorandom (PN) sequence is a binary sequence with an autocorrelation that

resembles, over a period, the autocorrelation of a random binary sequence. Its autocorrelation also

roughly resembles the autocorrelation of band-limited white noise. Although it is deterministic, a

PN sequence has many characteristics that are similar to those of random binary sequences, such

as having a nearly equal number of -1s and +1s, very low correlation between shifted versions of

the sequence, very low correlation between any two sequences, etc. The PN sequence is usually

generated using sequential logic circuits. A feedback shift register, which is diagrammed in Figure

3.6, consists of consecutive stages of two state memory devices and feedback logic.

FEEDBACK LOGIC

Stage1

Stage2

Stage3

Stagem

PN seqoutput

Clock

Figure 3.6. Block diagram of a generalized feedback shift register with m stages

15

Page 24: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Binary sequences are shifted through the shift registers in response to clock pulses, and the

output of the various stages are logically combined and fed back as the input to the first stage.

This shift register is called a linear PN sequence generator.

The initial contents of the memory stages and the feedback logic circuit determine the

successive contents of the memory. If a linear shift register reaches zero state at some time, it

would always remain in the zero state, and the output would subsequently be all 0s. Since there

are exactly nonzero states for an m-stage shift register, a sequence of period

generated by a linear feedback register is called a maximal length (ML) sequence.

12 −m 12 −m

3.3 MULTIPATH RADIO CHANNEL

Multipath radio propagation in the land mobile channel is characterized by multiple

reflections, diffractions and attenuation of the signal energy. These are caused by natural obstacles

such as buildings, hills, and so on.

0 1 2 3 4 5 6 7 8 9 1010-4

10-3

10-2

10-1

100Received field

Rec

eive

d fie

ld in

tens

ity

time

Figure 3.7. Fast Rayleigh fading as caused by multipath propagation

16

Page 25: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Figure 3.7 shows an exemplary fast fading pattern as would be discerned for the arriving

signal energy at a particular delay position as the receiver moves. We see that the received signal

power can drop considerably when phase cancellation of multipath reflections occurs.

3.4 RAKE RECEIVER

A DS spread-spectrum signal waveform is well matched to the multipath channel. In a

multipath channel, the original transmitted signal reflects from obstacles such as buildings and

mountains, and the receiver receives several copies of the signal with different delays. If the

signals arrive more than one chip apart from each other, the receiver can resolve them. Actually,

from each multipath signal’s point of view, other multipath signals can be regarded as interference

and are suppressed by the processing gain [7].

A further benefit is obtained, if the resolved multipath signals are combined using a RAKE

receiver. Thus, the signal waveform of CDMA signals facilitates use of multipath diversity.

Expressing the same phenomenon in the frequency domain means that the bandwidth of the

transmitted signal is larger than the coherence bandwidth of the channel and the channel is

frequency selective.

A RAKE receiver consists of correlators, each receiving a multipath signal. After despreading

by correlators, the signals are combined using, for example, maximal ratio combining. Because

the received multipath signals are fading independently, diversity order and thus performance are

improved.

The following Figure 3.8 illustrates a spread spectrum system with RAKE receiver.

Modulationg(t) X X

PN Generator tfcπ2cos

x(t)Data bits Channelh(t) + Demod Decision

Device

n(t)+I(t)

X

PN Generator

)(tsc )( τ−tsc

r(t)

Figure 3.8. A Spread Spectrum System with RAKE receiver

17

Page 26: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

After spreading and modulation, the signal is transmitted and it passes through a multipath

channel, which can be modeled by a tapped delay line. The multipath components have different

delays and attenuation factors, and each of them correspondes to a different propagation path. It is

assumed that the receiver has perfect channel estimation.

The RAKE receiver has a receiver finger for each multipath component. In each finger, the

received signal is correlated by the spreading code, which is time-aligned with the delay of the

multipath signal.

After despreading, the signals are combined by MRC, where each signal is weighted by the

path gain. Because of transmitter or receiver movements, the scattering environment will change,

and thus, the delays and attenuation factors change as well.

Consider the case that the wideband signals are transmitted in a multipath environment. It is

regarded as a frequency selective channel which will be introduced in detail in section 3.5.2. As

we mentioned in section 3.2, the spreading codes are designed to have very low autocorrelation,

multipath components delayed by more than one chip duration are uncorrelated and appear as

resolvable paths in the model. Typically, WCDMA systems are designed to have several

resolvable paths within the multipath delay spread. At the same time, the delay spread must be

lower than the bit duration T. If the delay spread is larger than the bit duration T, then the data rate

is higher than the coherence bandwidth and ISI is introduced to the system. To avoid ISI, the data

rate should be maintained below the coherence bandwidth.

When the delay spread is lower than T and there are several delayed versions of the

transmitted code sequence with delay differences larger than Tc, they will have a low correlation

with the original code sequence. Thus, each of these delayed signals will appear at the receiver as

another uncorrelated user and will be ignored by the matched filter receiver of the desired signal.

However, spread spectrum signals are inherently resistant to multipath fading since multipath

components carry the information about the transmitted signal and they are independent. Thus, if

one of the multipath components is attenuated by fading, the other may not be and the receiver

could use unfaded components to make the decision. The WCDMA receiver that takes advantage

of the multiple paths to provide diversity is called a rake receiver.

The Rake receiver structure, shown in Figure 3.9, consists of a bank of correlators. Each of

them is used to detect separately one of the L strongest multipath components. This receiver is

18

Page 27: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

basically a diversity receiver based on the fact that the multipath components in a WCDMA

system are uncorrelated if the relative delays are larger than the chip period. It uses the

autocorrelation properties of the code to coherently combine all multipath components.

X

X

)(tsc

)( 1−τtsc

)( 2τ−tsc

)( 1−− Lc ts τ

X

X

CoherentCombiner

DemodulatorData OutputReceived

Signal r(t)

Figure 3.9. Rake Receiver Architecture with L branches

Maximum Ratio Combining (MRC), Equal Gain Combining (EGC) and Selective Combining

(SC) are the three main combing methods. Although EGC is the most common, since it doesn’t

require knowledge of the multipath amplitudes.

As in other diversity receivers, the outputs from the correlators are weighted and added to

compute the estimate for the transmitted signal. Considering the three combining methods, the

mean value of the combining gain is shown in Figure 3.10. Observing that, EGC is just slightly

poorer than maximal ratio combining. For large values of L, we can see that there is about 1 dB

difference when compared to MRC. From the figure, we can see that MRC has the best combing

gain. If the MRC technique, which gives the highest reduction of fading, is used, the weighting

coefficient is the complex conjugate of the corresponding channel tap coefficient .*kk αα =

19

Page 28: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

0 2 4 6 8 10 12 14 16 18 200

0.5

1

1.5

2

2.5

3

3.5

4

4.5

Com

bini

ng G

ain

Number of Path N

MRCEGCSC

Figure 3.10. Performance comparation of the three combining methods

Each multipath demodulator in the RAKE receiver is called a finger. In the original Rake

receiver [8] the delay between consecutive taps and the number of taps was fixed. These receivers

require a large number of taps in order to capture major multipath components. Modern receivers

have only a few Rake fingers and are capable of adjusting the tap positions. In this thesis, it is

assumed that there are 5 RAKE fingers and each of them is capable of adjusting the tap position.

A more detailed description of the RAKE receiver for the discrete-time multipath channel

model with unknown delays and amplitudes can be found in [9]. If we ignore the effects of

interference and synchronization errors, and we also assume a steep autocorrelation function

which equals zero for codes delayed by more than a chip time and one for codes within a chip

time, then performance of the RAKE receiver with L branches is identical to any other L-branch

diversity technique. Since these assumptions usually don’t hold in practice and spread spectrum is

more difficult to implement than other diversity techniques, spread spectrum is not usually used

for diversity alone. However, if spread spectrum signaling is chosen for its other benefits, such as

its multi-user or interference rejection capabilities, then L branch diversity comes almost for free.

[10]

20

Page 29: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

3.5 WCDMA SIMULATION RESULTS IN SDR-WB

3.5.1 Flat Fading Channel

We know that a multipath fading channel having a delay spread much smaller than the

symbol duration is referred to a flat fading channel.

When the channel is flat fading, both the amplitude and the phase of the channel

multiplicative factor can be estimated at the receiver. The average symbol error probability is

obtained by averaging the conditional symbol error probability over all possible values of as Γ

, (3.1) γγγ dpPP ss )()(0 Γ

+∞

∫=

where is the instantaneous received SNR and Γ )(γΓp is the probability density function (pdf)

of the instantaneous SNR.

The amplitude of a fading channel is Rayleigh distributed. The average bit error probability

of BPSK is given by [11]

⎟⎟⎠

⎞⎜⎜⎝

+−=

0

0

11

21

γγ

bP (3.2)

where 0γ is the average received SNR/bit.

3.5.1.1 Non-Adaptive Scheme

Firstly, let’s consider a non-adaptive scheme, where the Channel State Information (CSI) is

not known at the transmitter side. The signals are transmitted in a fixed rate and modulation

method. As shown in Equation 3.2, the average BER is a function of the mean SNR 0γ only. Here

the length of the spreading code is 127.

The average BER for BPSK is plotted in Figure 3.11. It is observed that the BER is

decreasing with the increasing SNR. The BER decreases slowly as compared to the performance

of the theoretical BER for BPSK in a Rayleigh fading channel given by Equation 3.2.

21

Page 30: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

-10 -5 0 5 10 15 20 25 30 3510-5

10-4

10-3

10-2

10-1

100

SNR

BE

R

TheoreticalEmpirical.BPSK

Figure 3.11. Average BER for BPSK and QPSK over a Rayleigh fading channel

3.5.1.2 Adaptive scheme

Adapting transmission parameters according to the CSI can increase average throughput,

reduce required transmit power, or reduce error probability. We consider adaptation to enhance the

spectral efficiency.

The basic idea of adaptive system is to estimate the channel at the receiver and feed it back to

the transmitter, so that the transmission parameters can be adapted relatively to the CSI. Adaptive

modulation enables robust and spectrally efficient transmission over flat fading channels. In this

case, the transmitter has complete and accurate knowledge of the CSI so that adaptive modulation

can be applied to achieve high data rate transmission under a target BER.

To approach channel capacity, Gaussian signal has to be used. In reality, however, Gaussian

coding with continuous rate is unavailable and MQAM modulation with discrete modulation

orders is used instead.

When the full CSI is known at the transmitter side, a channel with high SNR can be assigned

with a high modulation order, whereas a channel with low SNR is assigned with a low modulation

order. No bits are loaded when the SNR is too low to carry.

22

Page 31: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

0 5 10 15 20 25 30 35 401

2

3

4

5

6

7

8

9

10

11

SNR [dB]

Rat

e &

Thr

ough

put [

bps/

Hz]

CapacityCapacity CQAMThroughput

Figure 3.12. Throughput of an adaptive system in a Flat Rayleigh fading channel

Assuming a target BER, the optimum switching thresholds in order to maximize the spectral

efficiency are found for the transmission. The relationship between the modulation scheme and

various SNR can be found in details in [18].

In Figure 3.12, the performance of a DS-CDMA adaptive modulation system with the target

BER = 0.001 is plotted. The upper curve is the theoretic value of the channel capacity given by

Shannon theory and the middle curve is the spectral efficiency by using continuous MQAM

modulation [12]. The lower curve is the empirical spectral efficiency.

Limited to the modulation scheme of 64QAM, there is a leveling out of the practical

throughput while SNR larger than 25dB. It is also observed that there exists a large gap between

the channel capacity and the spectral efficiency, which is due to that Gaussian coding and infinite

coding length is assumed to achieve the capacity whereas uncoded discrete rate, MQAM

modulation, is applied in practice. CQAM, is a closer upper bound to the practical spectral

efficiency. The difference between them only comes from the rate continuity, which is not

achievable in practice.

23

Page 32: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

-5 0 5 10 15 20 25 30 351

1.5

2

2.5

3

3.5

4

4.5

5

5.5

6

SNR [dB]

Rat

e &

Thr

ough

put [

bps/

Hz]

Throughput.TargetBER=0.01

Throughput.TargetBER=0.001

Figure 3.13. Throughput of the adaptive system for different target BER

Figure 3.13 shows the throughput versus SNR for different target BER. The higher the target

BER becomes, the higher the throughput will be.

3.5.2 Frequency Selective Fading Channel

If the transmitted signal has a bandwidth larger than the coherence bandwidth of the

channel , the channel can no longer be considered as a flat fading channel. In this case the

radio channel is regarded as a frequency selective channel. Given the symbol duration T and delay

spread , we can assume that T >> so that the ISI is negligible.

RB

mB

mT mT

The signal is transmitted through a multipath channel with different path gains. However,

each transmission of these signals can be considered as a transmission through a flat fading

channel.

Using the channel model for the frequency selective channel shown in Figure 3.10, we may

express the received signal as

(3.3) )()/()()(1

tnWitstctrL

ii +−= ∑

=

24

Page 33: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

where W is the bandwidth of the signal and n(t) represents the AWGN. Therefore, the frequency

selective channel provides the receiver with up to L replicas of the transmitted signal, where each

signal component is multiplied by a corresponding channel tap weight , i=1, 2, …, L. )(tci

As introduced in section 3.3, in order to perform maximal ratio combining, it is necessary to

estimate the channel tap coefficients from the received signal. Here a RAKE demodulator

is used to collect all the signal components on all channel taps.

)(tci

3.5.2.1 Frequency Selective Fading channel with Non-adaptive scheme

Similarly to the flat fading channel, we assume that the transmitter and the receiver have

complete and accurate knowledge of the CSI.

The average BER is plotted for BPSK and QPSK in a frequency selective Rayleigh fading

channel is shown in Figure 3.14. As seen from the figure, the BER decreases with the increasing

SNR.

-10 -5 0 5 10 15 20 25 3010

-3

10-2

10-1

100

SNR [dB]

BE

R

Empirical.QPSKEmpirical.BPSK

Figure 3.14. BER versus SNR over a frequency selective Rayleigh fading channel

We also compared the BPSK and QPSK modulation in Flat Fading channel and Frequency

Selective fading channel, respectively. The number of paths L = 5 and the length of PN sequence

25

Page 34: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Lc = 127. The results are shown in Figure 3.15.

-10 -5 0 5 10 15 20 25 30 3510-3

10-2

10-1

100

SNR [dB]

BE

RBPSK.Flat FCQPSK.Flat FCBPSK.FS FCQPSK.FS.FC

Figure 3.15. Comparison of BER versus SNR in Flat FC and FS fading channel

We can see that with the same modulation, the BER in the frequency selective fading channel

is a little lower than that in flat fading channel. Since direct sequence (DS) waveforms have a wide

bandwidth, anytime that bandwidth exceeds the coherence bandwidth of the channel, the fading

tends to be frequency selective. Thus, a RAKE receiver can be used to enhance system

performance and decrease the BER with the same SNR.

3.5.2.2 Frequency Selective Fading channel with Adaptive scheme

In this section, the signal that transmitted through a Frequency Selective fading channel is

considered. In this channel model, a RAKE receiver with perfect CSI was assumed.

The result is shown in Figure 3.16. Similar with that in Flat Fading channel, the throughput

of an adaptive system with the target BER =0.001 is plotted. In the following figure, the upper

curve is the theoretic value of the system throughput and the middle curve is the theoretic value of

system capacity with CQAM. The lower curve is the empirical throughput. Compared with the

upper bound of system throughput, the empirical result is much less because of the QAM

modulation, without coding and a SNR loss.

26

Page 35: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

-5 0 5 10 15 20 25 30 351

2

3

4

5

6

7

8

9

10

11

SNR [dB]

Rat

e &

Thr

ough

put [

bps/

Hz]

CapacityCapacity CQAMThroughput

Figure 3.16. Throughput of adaptive system in a Frequency Selective fading channel

Figure 3.17 shows the performance of the same system for different target BER. The

throughput increases with the increasing SNR. Comparing the two curves, we can see that the

higher the target BER, the lower the throughput.

-5 0 5 10 15 20 25 30 351

1.5

2

2.5

3

3.5

4

4.5

5

5.5

6

SNR [dB]

Rat

e &

Thr

ough

put [

bps/

Hz]

Throughput.TargetBER=0.01Throughput.TargetBER=0.001

Figure 3.17. Throughput of the adaptive system for different target BER

27

Page 36: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Chapter 4

Programming using

Matlab/Octave and C++ 4.1 INTRODUCTION

4.1.1 Matlab and Interface Function MEX file

MATLAB is a powerful tool in engineering field. However, it takes a long time to execute

because its nature is very slow in executing functions. In order to solve this problem, Mathworks

provides a toolbox to compile M-Files converting them to executable ones. Then we can write and

compile a script be executable whose extension is exe.

Functions could also be compiled to other executables called MEX-Files. MEX-Files in

Microsoft Windows have the dll extension. Now MATLAB can execute these functions very

quickly. MEX-Files in other operating systems have different extensions.

As we know, DLL is the abbreviation of Dynamic Link Library, and contains variables,

functions and classes which can be dynamically loaded by the operating system or in this case by

MATLAB. They can be executed very fast because they have been compiled.

The MATLAB M-Files are very good for putting functions or scripts together that run many

of MATLAB's fast Built-In functions. One of the advantages of these files is that they are never

compiled and can run in any system that is already running in MATLAB [13]. MATLAB achieves

so by interpreting each line of the M-File every time when running. This method of running the

code can make processing time very slow for complicated functions, especially those with many

loops, because every line within the loop will be interpreted as a new line. Good MATLAB code

avoids these things by using as many Built-In features and array operations as possible. However,

sometimes this is not enough.

28

Page 37: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

MATLAB is capable of running C++ functions. The files that hold sources for these functions

are called MEX-Files. The mexFunctions are not intended to be a substitute for MATLAB's

Built-In operations. However, if you need to code many loops and other things, at which

MATLAB is not very good, mexFunction is a good choice. This feature also allows

system-specific Application Programming Interface (API) to be called to extend MATLAB's

abilities.

4.1.2 Octave and Interface Function OCT file

GNU Octave is a high-level language, primarily for numerical computations [14]. It provides

a convenient command line interface for solving linear or nonlinear problems numerically, and for

performing other numerical experiments by using a language that is compatible with Matlab. It

may also be used as a batch-oriented language.

The strength of Octave (as well as Matlab) is its short syntax for matrix operations. In fact it

is almost as readable and writable as the mathematical notation.

In some systems, such as Linux, Octave can dynamically load and execute C++ functions

[15]. Octave can only directly call functions written in C++, but we can also load functions written

in other languages by calling them from a simple wrapper function written in C++.

An OCT-File is a dynamical extension of the Octave interpreter, a shared library or shared

object in other words. The source files, that make up an OCT-File, are written in C++, and

therefore, conventionally, carry the extension cc. It is a means of writing an Octave function in a

compliable language like C++, rather than as a script file. This result is a significant acceleration

in the code.

Sometimes the performance of native Octave-code is not enough to tackle a problem.

Octave-code is interpreted, thus it is inherently slow when executing. In such a case moving from

M-code to compiled C++-code speeds up the execution by a factor of ten or more. The second

group of problems, where reverting to low-level code is necessary, is when interfacing with

foreign libraries or routines written in languages other than C++, most notably Fortran.

29

Page 38: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

4.2 METHODOLOGY

4.2.1 Performance Analysis

Nowadays, software is used to solve complex numerical problems in a wide variety of

environments. Therefore the software and its mathematical algorithms need to be run in various

inhomogeneous hardware components.

Before we try and make any program to run faster, we first need to find out which bits of it

are executed slowly. Profiling the execution time of MATLAB code is easily achieved by adding

the commands [17]. The command is profile on before the start of the program, and profile viewer

after the codes end.

The profiling was run based on simulation of a MIMO-OFDM system. The three following

figures show the time spent on the functions and lines.

The function of line 190 and line 192 are the same base on the same simulation situation.

Line 192 is the existed code written by Matlab, and line 190 is rewritten by Matlab and c++.

Figure 4.1 shows the line 192 was the most time consuming part through the whole system. Thus,

we should first try to rewrite the Matlab code of the line 190.

Figure 4.1. Time spent on the functions

However, from the following figure, we can see that the line 190 consumes more time than

line 192. In our simulation environment, the programming using Matlab and C++ seems to be less

30

Page 39: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

effective than Matlab programming.

In order to rewrite the Matlab code with C++, we need to rewrite three computation

algorithm codes. These computed codes are used to compute the multiplication between complex

matrices, complex number and complex matrices, and the addition between complex matrices.

Figure 4.2 shows the time spent on the three computation algorithm. It illustrates that the

computation between complex matrices took up the most time. Thus, first we should rewrite the

computation between complex matrices to increase the efficiency of the system.

Figure 4.2. Time spent on the lines

Figure 4.3. Time spent on the sub-lines

Analyzing the time spent in line 190, from the two figures above, we can see that commulz is

the most time consuming command in the written codes. This function is used for computing the

multiplication between two complex matrices. We will study the performance of this function in

the later sections.

31

Page 40: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

4.2.2 MEX File Programming

The source code for a MEX-File consists of two distinct parts:

A computational routine that contains the code for performing the computations in the

MEX-File. Computations can be numerical computations, as well as inputting and outputting

data.

A gateway routine that interfaces the computational routine with MATLAB by the entry

point mexFunction and its parameters prhs, nrhs, plhs, nlhs, where prhs is an array of

right-hand input arguments, nrhs is the number of right-hand input arguments, plhs is an

array of left-hand output arguments, and nlhs is the number of left-hand output arguments.

The gateway calls the computational routine as a subroutine.

In the gateway routine, you can access the data in the mxArray structure and then manipulate

this data in the C computational subroutine. For example, the expression mxGetPr(prhs[0])

returns a pointer of type double * to the real data in the mxArray pointed to by prhs[0]. You can

then use this pointer like any other pointer of type double * in C. After calling your C

computational routine from the gateway, you can set a pointer of type mxArray to the data it

returns. MATLAB is then able to recognize the output from your computational routine as the

output from the MEX-File.

A detailed explanation of an example of MEX-Files is presented in the Appendix A. The file

commulz.c is used for computing the multiplication between two complex matrices. The file

comaddz.c is used for computing the addition between two complex matrices. The file

nummulcomz.c is used for computing the multiplication between a complex number and a

complex matrix.

4.2.3 OCT File Programming

Octave's dynamic linking features currently have the following limitations.

Dynamic linking only works on systems that support the GNU dynamic linker, dld.

Clearing dynamically linked functions doesn't work.

32

Page 41: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Octave uses a lot of memory if the dynamically linked functions are compiled to include

debugging symbols. This appears to be a limitation with dld, and can be avoided by not using

–g to compile functions that will be linked dynamically.

A detailed explanation of an example of OCT-Files is presented in the Appendix B. The file

mulocatcmat.cc is used for computing the multiplication between two complex matrices. The file

addoctcmat.cc is used for computing the addition between two complex matrices. The file

nmuloctcmat.cc is used for computing the multiplication between a complex number and a

complex matrix.

4.3 NUMERICAL RESULTS

4.3.1 Programming using Matlab and C++

The results of time in the MATLAB multiplication with different sizes of matrices are

presented in this section. Every point is averaged over 5000 realizations. The overloads of the

simulation in the two following figures are the same, and the difference is only the different sizes

of matrices.

50 100 150 200 250 300 350 400 450 50010-2

10-1

100

101

102

103

104

Size of Matrix

Tim

e

MatlabMatlab.C++

Figure 4.4. Time costs in the MATLAB multiplication with large matrix-size

33

Page 42: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

The two figures show the performance of time costs in the matrix multiplication. Considering

the case when the matrix-size is very large, from Figure 4.4, we can see that the time spent by

using Matlab is less than that of using Matlab and C++.

5 10 15 20 25 30 35 40 45 5010-3

10-2

10-1

100

101

Size of Matrix

Tim

e

MatlabMatlab.C++

Figure 4.5. Time costs in the MATLAB multiplication with small matrix-size

Considering the case when the matrix-size is small, from the Figure 4.5, we can see that there

is a cross point of the two curves. It illustrates that the written code is efficient when the

matrix-size is small. However, as the matrix-size becomes larger, approximately 25, the existing

code in pure Matlab is more efficient.

4.3.2 Programming using Octave and C++

The two following figures show the average time spent on the matrix multiplication in

OCTAVE. The first figure considers the scenario with small matrix-size while the second one

considers large matrix-size.

The overloads of the simulation in the two following figures are the same, and the difference

is only the size of matrices. Figure 4.6 and Figure 4.7 show that programming using OCTAVE and

C++ will spend more time than programming only using OCTAVE. The larger the size of matrix

becomes, the larger the difference is.

34

Page 43: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

0 5 10 15 20 25 30 35 40 45 5010-1.4

10-1.3

10-1.2

Size of Matrix

Tim

eOctaveOctave.C++

Figure 4.6. Time costs in the OCTAVE multiplication with small matrix-size

0 50 100 150 200 250 300 350 400 450 50010-2

10-1

100

101

Size of Matrix

Tim

e

OctaveOctave.C++

Figure 4.7. Time costs in the OCTAVE multiplication with large matrix-size

35

Page 44: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

4.4 CONCLUSION

Through the figures above, we can see that the shown results are not the same as we thought

before. This is because that both Octave and Matlab link to external libraries to perform the matrix

and vector computations, and these libraries are directly highly optimized and probably faster than

anything we could use a simple Mex file. Maybe we could consider some other ways to increase

the efficiency, for example, by using the ATLAS project that is a library with OCTAVE focusing

on this area of the ongoing research.

36

Page 45: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Chapter 5

Conclusions and Future Work 5.1 CONCLUSIONS

In this thesis work, performance of the DS-CDMA communication system is presented by

using Matlab simulation environment. The performances of the system is expressed through

comparisons of the bit error rates (BER) that one obtained from different parameters of the signal,

channel model and implementation of the receiver. Both blind and adaptive scenarios are

considered. We also investigated the BER for the flat fading channel and frequency selective

fading channel. RAKE receiver is presented to solve ISI problem caused by multipath. So far, we

get some results as follow.

We tried to increase the efficiency of the Matlab code by combining Matlab/Octave with C++.

Although this goal was not reached, this project gives an insight to the simulation speed.

5.2 FUTURE WORK

The analysis of these different scenarios is discussed in the physical layer. In WCDMA

simulation, an interesting characteristic which could be taken into account is the Uplink and

Downlink scenarios. In addition, different spreading code and Multi-Carrier techniques should

also be considered. Furthermore, the simulations of CDMA2000 and TD-SCDMA based on this

workbench are also worth doing.

About the optimization of the codes, first we should find a profiler to analyze the efficiency

of the codes. A substantial amount of work still has to be done to implement this proposal. We

should find an efficient way to implement the improvement of the codes.

37

Page 46: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Appendix A MEX FILE

commulz.c /* In order to make a mex-function, you must include the "mex.h" library. This library contains all of the APIs that MATLAB provides.*/ #include "mex.h" void commulz(double *xr, double *xi, int m, double *yr, double *yi, int k, int n, double *zr, double *zi) { int i,j,l; zr[0]=0.0; zi[0]=0.0; for(i=0;i<m;i++) { for(j=0;j<n;j++) { for(l=0;l<k;l++) { *(zr+j*m+i)=*(zr+j*m+i)+*(xr+l*m+i)**(yr+j*k+l)-*(xi+l*m+i)**(yi+j*k+l); *(zi+j*m+i)=*(zi+j*m+i)+*(xr+l*m+i)**(yi+j*k+l)+*(xi+l*m+i)**(yr+j*k+l); } } } } /* Every MEX-File has the mexFunction entry point. There are four input parameters to the mexFunction which correspond to the way a function is called in MATLAB.*/ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *xr, *xi, *yr, *yi, *zr, *zi; int rows, cols, m, k, n;

38

Page 47: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

/* Check the numbers of the input and output arguments. */ if (nrhs!=3) mexErrMsgTxt("Three inputs required."); if (nlhs>1) mexErrMsgTxt("Too many output arguments."); if (mxGetN(prhs[0])!=mxGetM(prhs[1])) mexErrMsgTxt("The vectors of Matrix 1 must be equal to the rows of Matrix 2."); /* Check if the first argument is Numeric. */ if (mxIsNumeric(prhs[0])==1) { xi = mxGetPr(prhs[2]); } if (mxIsComplex(prhs[0])==1) { xi = mxGetPi(prhs[0]); } /* Check if the second argument is Numeric. */ if (mxIsNumeric(prhs[1])==1) { yi = mxGetPr(prhs[2]); } if (mxIsComplex(prhs[1])==1) { yi = mxGetPi(prhs[1]); } /* Get the size of the input matrices. */ m = mxGetM(prhs[0]); k = mxGetN(prhs[0]); n = mxGetN(prhs[1]); /* Get real data elements of the input arguments. */ xr = mxGetPr(prhs[0]); yr = mxGetPr(prhs[1]);

39

Page 48: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

rows = m; cols = n; /* Create output matrix. */ plhs[0] = mxCreateDoubleMatrix(rows,cols,mxCOMPLEX); /* Get real data elements and imaginary data elements of output arguments. */ zr = mxGetPr(plhs[0]); zi = mxGetPi(plhs[0]); commulz(xr,xi,m,yr,yi,k,n,zr,zi); return; }

40

Page 49: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

comaddz.c #include "mex.h" void comaddz(double *xr, double *xi, int m, double *yr, double *yi, int n, double *zr, double *zi) { int i,j; zr[0]=0.0; zi[0]=0.0; for(i=0;i<m;i++) { for(j=0;j<n;j++) { *(zr+j*m+i)=*(xr+j*m+i)+*(yr+j*m+i); *(zi+j*m+i)=*(xi+j*m+i)+*(yi+j*m+i); } } } void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *xr, *xi, *yr, *yi, *zr, *zi; int rows, cols, m, n; if (nrhs!=3) mexErrMsgTxt("Three inputs required."); if (nlhs>1) mexErrMsgTxt("Too many output arguments."); if (mxGetM(prhs[0])!=mxGetM(prhs[1])) mexErrMsgTxt("Both inputs must be in the same row."); if (mxGetN(prhs[0])!=mxGetN(prhs[1])) mexErrMsgTxt("Both inputs must be in the same vector.");

41

Page 50: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

if (mxIsNumeric(prhs[0])==1) { xi = mxGetPr(prhs[2]); } if (mxIsComplex(prhs[0])==1) { xi = mxGetPi(prhs[0]); } if (mxIsNumeric(prhs[1])==1) { yi = mxGetPr(prhs[2]); } if (mxIsComplex(prhs[1])==1) { yi = mxGetPi(prhs[1]); } m = mxGetM(prhs[0]); n = mxGetN(prhs[0]); xr = mxGetPr(prhs[0]); yr = mxGetPr(prhs[1]); rows = m; cols = n; plhs[0] = mxCreateDoubleMatrix(rows,cols,mxCOMPLEX); zr = mxGetPr(plhs[0]); zi = mxGetPi(plhs[0]); comaddz(xr,xi,m,yr,yi,n,zr,zi); return; }

42

Page 51: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

nummulcomz.c #include "mex.h" void nummulcom(double *xr, double *xi, int m, double *yr, double *yi, int n, double *zr, double *zi) { int i,j; zr[0]=0.0; zi[0]=0.0; for(j=0;j<n;j++) { for(i=0;i<m;i++) { *(zr+j*m+i)=*(xr)**(yr+j*m+i)-*(xi)**(yi+j*m+i); *(zi+j*m+i)=*(xr)**(yi+j*m+i)+*(xi)**(yr+j*m+i); } } } void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *xr, *xi, *yr, *yi, *zr, *zi; int rows, cols, m, n; if (nrhs!=3) mexErrMsgTxt("Three inputs required."); if (nlhs>1) mexErrMsgTxt("Too many output arguments."); if (mxIsNumeric(prhs[0])==1) { xi = mxGetPr(prhs[2]); } if (mxIsComplex(prhs[0])==1) { xi = mxGetPi(prhs[0]); }

43

Page 52: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

if (mxIsNumeric(prhs[1])==1) { yi = mxGetPr(prhs[2]); } if (mxIsComplex(prhs[1])==1) { yi = mxGetPi(prhs[1]); } m = mxGetM(prhs[1]); n = mxGetN(prhs[1]); xr = mxGetPr(prhs[0]); yr = mxGetPr(prhs[1]); rows = m; cols = n; plhs[0] = mxCreateDoubleMatrix(rows,cols,mxCOMPLEX); zr = mxGetPr(plhs[0]); zi = mxGetPi(plhs[0]); nummulcom(xr,xi,m,yr,yi,n,zr,zi); return; }

44

Page 53: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Appendix B DLL FILE

muloctcmat.cc /*The firrst line of the file includes declarations for all of Octave's internal functions that we will need. */ #include <octave/oct.h> /* The next line declares the function. */ DEFUN_DLD (muloctcmat, args, , "The multiplication of two complex matrices.") { octave_value_list retval; /* Get the value of the input matrices elements. */ const ComplexMatrix Am = args(0).complex_matrix_value(); const ComplexMatrix Bm = args(1).complex_matrix_value(); /* Get the size of the input matrices. */

int m = Am.rows(); int k = Am.cols(); int n = Bm.cols(); /* Create the output matrix. */ ComplexMatrix resAddm (m, n); /* Describe the computation algorithm of the function. */ for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { resAddm(i,j).real() = 0.0; resAddm(i,j).imag() = 0.0; for(int l = 0; l < k; l++) {

45

Page 54: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

resAddm(i,j).real() = resAddm(i,j).real() + Am(i,l).real() * Bm(l,j).real() - Am(i,l).imag() * Bm(l,j).imag(); resAddm(i,j).imag() = resAddm(i,j).imag() + Am(i,l).real() * Bm(l,j).imag() + Am(i,l).imag() * Bm(l,j).real(); } }

}

retval.append(resAddm); return retval; }

46

Page 55: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

addoctcmat.cc #include <octave/oct.h> DEFUN_DLD (addoctcmat, args, , "The addition of two complex matrices.") { octave_value_list retval; const ComplexMatrix Am = args(0).complex_matrix_value(); const ComplexMatrix Bm = args(1).complex_matrix_value(); int m = Am.rows(); int n = Am.cols(); ComplexMatrix resAddm (m, n); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { resAddm(i,j).real() = Am(i,j).real() + Bm(i,j).real(); resAddm(i,j).imag() = Am(i,j).imag() + Bm(i,j).imag(); } } retval.append(resAddm); return retval; }

47

Page 56: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

nmuloctcmat.cc #include <octave/oct.h> DEFUN_DLD (nmuloctcmat, args, , "The multiplication between complex number and complex matrix.") { octave_value_list retval; const Complex An = args(0).complex_value(); const ComplexMatrix Bm = args(1).complex_matrix_value(); int m = Bm.rows(); int n = Bm.cols(); ComplexMatrix resMulnm (m, n); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { resMulnm(i,j).real() = An.real() * Bm(i,j).real() - An.imag() * Bm(i,j).imag(); resMulnm(i,j).imag() = An.real() * Bm(i,j).imag() + An.imag() * Bm(i,j).real(); } } retval.append(resMulnm); return retval; }

48

Page 57: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

Bibliography [1] John Glossner, Daniel Iancu, Jin Lu, Erdem Hokenek, and Mayan Moudgill, Sandbridge Technologies, Inc. “A Software-Defined Communications Baseband Design”, IEEE Communications Magazine, January 2003. [2] Paul Burns, “Software Defined Radio for 3G”, Artech.House, 2003. [3] Harri Holma and Antti Toskala, “WCDMA for UMTS, Radio Access For Third Generation Mobile Communications”, Third Edition, John Wiley & Sons, Ltd. [4] Hsiao-Hwa Chen, Changxin Fan and Willie W. Lu, “China’s Perspectives on 3G Mobile Communications and Beyond: TD-SCDMA Technology”, IEEE Wireless Communications, April 2002. [5] T.Eng and L.B.Milstein, “Coherent DS-CDMA performance in Nakagami multipath fading,” IEEE Trans. Commun., vol.43 pp.1134-1143, Mar. 1995. [6] Jinliang Huang, “A Matlab/Octave Simulation Environment for SDR with application to OFDM and MIMO”, Master thesis, Electronic System Design, Royal Institute of Technology, April, 2005. [7] Richard van Nee and Ramjee Prasad, “OFDM for wireless communication system”, Artech House, Boston London, 2002. [8] Price, R., and P.E.Green “A communication Technique for Multipath Channels,” Proc. IRE, vol.46, 1958, pp. 555-570. [9] G.L. Turin. “Introduction to spread spectrum antimultipath techniques and their application to urban digital radio,” IEEE Proceedings, Vol. 68, No. 3, pp. 328–353, March 1980. [10] Andrea Goldsmith, “Wireless Communication”, Stanford University, 2004. [11] John G. Proakis, “Digital communications”, Fourth Edition, McGraw-Hill, 2000. [12] S.T.Chung and A.J.Goldsmith, ”Degrees of freedom in adaptive modulation: A unified view”, IEEE Transactions on Communications, vol.49, no.9, pp. 1561-1571, Sept.2001. [13] Jason Laska, “Writing C Functions in MATLAB (MEX-Files)”, http://cnx.org/content/m12348/latest/ [14] About Octave, http://www.gnu.org/software/octave/about.html

49

Page 58: Simulation environment for Software Defined Radio with ... · The brief description of key characteristics of WCDMA system is provided in Chapter 3. In this Chapter, the physical

[15] Octave_manual. [16] Jens Rücknagel, “An Octave Type Estimator – Essential Part of an Octave to C++ Compiler”, Master Thesis, Department of System and Control Theory Faculty of Computer Science and Automation Technical University Ilmenau, March, 2005 [17] “Improving performance in MATLAB”, http://www.enm.bris.ac.uk/staff/pjn/Programming/matlab.html [18] José F. Paris, M. del Carmen Aguayo-Torres, and José T. Entrambasaguas, “Optimum Discrete-Power Adaptive QAM Scheme for Rayleigh Fading Channels”, IEEE communications letters, VOL. 5, NO. 7, July 2001.

50