Вы находитесь на странице: 1из 199

Communication System Design

Using DSP Algorithms


With Laboratory Experiments
for the TMS320C30
Applications of Communications Theory
Series Editor: R. W. Lucky, Bel/core
Editorial Board:
Anthony S. Acampora, Columbia University
Larry Greenstein, AT&T Bell Laboratories
Tingye Li, AT&T Bell Laboratories
William H. Tranter, University of Missouri. Rolla

Recent volumes in the series:


BASIC CONCEPTS IN INFORMATION THEORY AND CODING:
The Adventures of Secret Agent 00 III
Solomon W. Golomb, Robert E. Peile, and Robert A. Scholtz

COMMUNICATION SYSTEM DESIGN USING DSP ALGORITHMS: With


Laboratory Experiments for the TMS320C30
Steven A. Tretter

COMPUTER COMMUNICATIONS AND NETWORKS


John R. Freer

COMPUTER NETWORK ARCHITECTURES AND PROTOCOLS


Second Edition. Edited by Carl A. Sunshine

DATA COMMUNICATIONS PRINCIPLES


Richard D. Gitlin, Jeremiah F. Hayes, and Stephen B. Weinstein

DATA TRANSPORTATION AND PROTECTION


John E. Hershey and R. K. Rao Yarlagadda

DIGITAL PICTURES: Representation and Compression


Arun N. Netravali and Barry G. Haskell

FUNDAMENTALS OF DIGITAL SWITCHING


Second Edition. Edited by John C. McDonald
AN INTRODUCTION TO BROADBAND NETWORKS: LANs, MANs, ATM,
B-ISDN, and Optical Networks for Integrated Multimedia Telecommunications
Anthony S. Acampora

AN INTRODUCTION TO PHOTONIC SWITCHING FABRICS


H. Scott Hinton

OPTICAL CHANNELS: Fibers, Clouds, Water, and the Atmosphere


Sherman Karp, Robert M. Gagliardi, Steven E. Moran, and Larry B. Stotts

PRACTICAL COMPUTER DATA COMMUNICATIONS


William J. Barksdale

SIMULATION OF COMMUNICATIONS SYSTEMS


Michel C. Jeruchim, Philip Balaban, and K. Sam Shanmugan

A Continuation Order Plan is available for this series. A continuation order will bring delivery of each
new volume immediately upon publication. Volumes are billed only upon actual shipment. For further
information please contact the publisher.
Communication System Design
Using DSP Algorithms
With Laboratory Experiments
for the TMS320C30

Steven A. Tretter
University of Maryland
College Park, Maryland

SPRINGER SCIENCE+BUSINESS MEDIA, LLC


Library of Congress Cataloging-in-Publication Data

Tretter, Steven A.
Communication system design using DSP algorithms.: with laboratory
experiments for the TMS320C30 I Steven A. Tretter.
p. em. -- (Applications of communications theory)
Includes bibliographical references and index.
ISBN 978-0-306-45032-7 ISBN 978-1-4757-9763-3 (eBook)
DOI 10.1007/978-1-4757-9763-3
1. Signal processing--Digital techniques. Digital 2.
communications--Equipment and supplies--Design--Data processing.
3. Texas Instruments TMS320 series microprocessors. 4. Real-time
data processing. I. Title. II. Series.
TK5102.9.T74 1995
621.382·2·078--dc20 95-36860
CIP

If your diskette is defective in manufacture or has been damaged in transit, it will be replaced
at no charge if returned within 30 days of receipt to Managing Editor, Springer Science+Business
Media, LLC.
The publisher makes no warranty of any kind, expressed or implied, with regard to the
software reproduced on the diskette or the accompanying documentation. The publisher shall
not be liable in any event for incidental or consequential damages or loss in connection with,
or arising out of. the furnishing, performance, or use of the software.

Additional material to this book can be downloaded from http://extras.springer.com


ISBN 978-0-306-45032-7

© 1995 Springer Science+Business Media New York


Originally published by Plenum Press, New York in 1995

1098765432

All rights reserved

No part of this book may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means, electronic, mechanical, photocopying, microfilming, recording, or
otherwise. without written permission from the Publisher
To Terry, Anne, and in memory of David
Preface

This book began in January 1993 when I was "elected" by Dr. William Destler, who was then Chainnan of the
Electrical Engineering Department and is now Dean of the College of Engineering, to set up and write experiments
for a new Senior elective laboratory course, ENEE418c Communications Laboratory, scheduled to be given for the
first time in the Fall 1993 semester. Books with standard digital signal processing and filter design experiments
existed, but no book focusing on analog and digital communications techniques was available. My enthusiasm for
the project gradually grew until I became almost totally immersed in it.
Labs in the Electrical Engineering Department at the University of Maryland are separate courses. Occurring
on a weekly basis, these labs include a I-hour lecture by a regular faculty member, who introduces the theory and
explains the experiments, and a 3-hour laboratory period run by a graduate teaching assistant. Students can get keys
for the Communications Lab room and work whenever they please. One section of the lab was frrst offered in the
Fall 1993 semester and two in the Spring 1994 semester. The students were highly enthusiastic and often spent extra
hours working on the experiments because they found them to be very interesting and challenging. They also had the
feeling that this was something that would directly help them with their future jobs. In fact, several graduate students
and one faculty member sat in on the lab to learn some real-world practical skills.
The goal of this book is to explore the digital signal processing and communication systems theoretical concepts
presented in typical Senior elective courses on these subjects by implementing them on actual hardware in real time.
In the process, students will gain experience using equipment commonly used in industry, including oscilloscopes,
spectrum analyzers, signal generators, error rate test sets, digital signal processors, and analog-to-digital and digital-
to-analog converters.
This book differs from any others on the market in that its primary focus is on communication systems. Fun-
damental digital signal processing concepts like digital filters and FFTs are included because they are required in
communication systems. Approaches that are particularly useful for DSP implementations are presented. While the
experiments, particularly the earlier ones, are described for the TMS320C30 Evaluation Module, they can be easily
modified for any PC DSP board with an AID and D/A converter.
There are several books on digital signal processing experiments for stable software packages like MATHCAD
and MATLAB. In my view, one of the purposes of a laboratory course is to help prepare students for industrial jobs.
Oflline software simulation is no substitute for making actual hardware work in real-time. It does not present students
with the strange, unexpected, and often frustrating things that occur when using actual hardware in real-time-things
that cannot be explained by nice equations - nor does it teach them how to use standard lab equipment.
The prerequisites for this course are an understanding of linear systems and transfonn methods at a level that
is often presented in a Junior required course on Signals and Systems, and a working know ledge of PCs and C
programming. Students who have programmed in other languages, such as BASIC or FORTRAN, can quickly
learn enough C to do the experiments if they are willing to make the effort. Corequisite are a Senior-level elective
course in Digital Signal Processing and/or Communication Systems. Ideally, both courses should be taken before

vii
viii Preface

the Communications Laboratory. However, this is not usually possible for our Seniors. We wanted our students to
have the opportunity to take this lab, so we made just one of them a corequisite. With the engineering background
of a Senior, the presentation of the necessary theory in the text, and the I-hour lab lecture to explain the theory,
students have quickly learned the signal processing and communication system concepts required for the experiments.
In addition, it can be argued that a lab course should help prepare students for the work world where they will have
to figure out new things for themselves so the experiments should have some uncertainty and require students to fIll
in some of the details.
There is a large inital hurdle for the students to get over while learning the details required to use the lab's
hardware and software tools. The experiments in Chapters 1 and 2 gradually introduce them to these tools and the
architecture of the TMS320C30 floating-point DSP. The tools include the TMS320C30 Evaluation Module (EVM),
C compilers for the PC and TMS320C30, and an assembler and linker for the TMS320C30. An attempt has been
made to reduce this hurdle by including some basic programs on the program disk for initializing the EVM that can
be used as a starting point for the experiments.
FIR and I1R filter design and implementation are explored in Chapter 3. Experiments comparing the relative
merits of C and assembly language implementations are performed. Filters are required in most of the following
experiments.
Chapter 4 investigates the FFT and power spectrum estimation. A simple spectrum analyzer is made.
Chapters 5-8 explore the classical analog communication methods of amplitude modulation, double-sideband
suppressed-carrier amplitude modulation, single-sideband modulation, and frequency modulation. Transmitters and
receivers are built using DSP techniques. Noncoherent receivers using envelope detectors and coherent receivers using
phase-locked loops are implemented. The use of Hilbert transforms and complex signal representations in modulation
systems are explored.
Chapters 9-15 introduce some modem digital communication techniques. These experiments focus on methods
used in high-speed wire-line data modems where DSPs have been used extensively. Topics covered include linear shift
register scramblers, the RS232C interface, pulse amplitude modulation (PAM), and quadrature amplitude modulation
(QAM). The experiments lead up to building almost a complete V.22bis transmitter and receiver. Symbol clock
recovery, carrier tracking, and adaptive equalizer receiver functions are implemented. The echo cancelling technique
used in V.32 modems is studied in Chapter IS. Enough details are included so that this set of experiments could
form a good practical guide to engineers in industry interested in modem design. I learned many of these techniques
while consulting since 1970 for companies that build high-speed wire-line modems, and have seen them employed in
hundreds of thousands of modems.
Chapter 16 briefly presents some ideas for additional projects related to current high-speed wire-line modem
design. These ideas can be expanded to satisy the capstone design project requirements of the ABET accrediting
committee.
Appendix A discusses how to transfer data back and forth between the TMS320C30 Evaluation Module and Pc.
The transfers are used in some of the experiments to display signals processed by the DSP. We wanted the students
to concentrate on learning communication system concepts rather than getting bogged down with involved hardware
details. Therefore, complete working programs for transferring data from the EVM to the PC are included on the
program disk.
Appendix D contains a complete list of the equipment used for this laboratory at the University of Maryland.
It has been included as a guide to others setting up a similar lab and is not intended to be an endorsement of any
specific manufacturer. Clearly, any equipment with equivalent capabilities can be substituted for items in the list.
A detailed listing of the directory structure on the PC hard disk is shown in Appendix E as a guide to others
setting up a communications lab.
There are many more experiments in this book than can be performed in one semester. Based on two semesters
of experience, an ambitious goal is to have all students complete Chapters 1-3 followed by a choice of any three
additional chapters. It would be nice if students could continue in the lab for a second semester for additional credit
and build on their earlier experiments.
Preface ix

Acknowledgments
I would like to thank Mark Kohler and Sonjai Gupta for helping to unpack equipment and install and debug
hardware and software in the PCs during the Spring 1993 semester when the lab was initially being set up. The
students in the original Communications Laboratory section offered in the Fall 1993 semester as well as their Teaching
Assistant Yifeng Cui deserve a great deal of thanks for being extremely patient and enthusiastic guinea pigs. They
helped correct and significantly improve the first few experiments. In particular, I want to thank Mike Barr who,
with his partner Brian Silverman, forged well ahead of the rest of the students and was so enthusiastic by the end
of the semester that he asked about helping with the lab in the Spring 1994 semester. The Electrical Engineering
Department was able to make an exception and assign Mike as a Senior to be the TA for one section and he did an
outstanding job. Mrs. Tahereh Fazel was also an excellent Graduate TA for a second lab section in the Spring 1994
semester.
I would also like to thank my friends from RIXON - which was in Silver Spring, Maryland, but has long since
dissipated in a chain of corporate take-overs - and at Penril Datability Networks in Gaithersburg, Maryland, for helping
me stay at the state-of-the-art in DSP applications to wire-line modems by using me as a consultant.
I also want to thank Texas Instruments for granting us permission to include on our program disk the C callable
utility functions developed by Gerry Shoults and included with TI's TMS320C3x DSP Design Workshop. These
functions provide a convenient interface to the various registers and peripherals in the TMS320C30. Any questions
about these functions should be addressed to me, and not to TI.
And last but not least, I want to thank Dr. William Destler for "electing" me to this task.

College Park, Maryland Steven A. Tretter


Contents

1. Brief Overview of the Hardware and Software Tools .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.1. Some DSP Chip History and Typical Applications ........................................... 1


1.2. Introduction to the TMS320C30 Floating-Point DSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1. The Central Processing Unit (CPU) ................................................. 5
1.2.2. Memory Organization ............................................................. 5
1.2.3. The Internal Bus ................................................................ 6
1.2.4. The External Buses and Interrupts .................................................. 6
1.2.5. Peripherals ..................................................................... 6
1.2.6. The Direct Memory Access (DMA) Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.7. Brief Description of the Instruction Set .............................................. 6
1.3. The TMS320C30 Evaluation Module ..................................................... 7
1.4. Software Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.1. Software Supplied by Texas Instruments ...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4.2. Digital Filter Design Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.3. Other Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.5. Introductory Experiments ............................................................... 11

2. Learning to Use the Hardware and Software Tools by Generating a Sine Wave .................... 13

2.1. Some Basic Utility Files, Programs, and Environment Variables Required by the TMS320C30
Assembler, C S:ompiler, and Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2. Method 1 for Generating a Sine Wave ............ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3. Method 2 for Generating a Sine Wave--Using Interrupts ..................................... 24
2.4. Method 3-DMA from a Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 26

xi
xii Contents

3. Digital Filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.1. Discrete-Time Convolution and Frequency Responses ....................................... 29


3.2. Finite Duration Impulse Response (FIR) Filters ............................................. 30
3.2.1. Block Diagram for Most Common Realization. .. ... ... ... .. . . .. . ... . ... . . . . . . . . .. . . .. 30
3.2.2. Two Methods for Finding the Filter Coefficients to Achieve a Desired Frequency Response. .. 30
3.2.3. Using Circular Buffers to Implement FIR Filters ...................................... 32
3.2.4. How to Make an Assembly Language Convolution Function that Is Called from and Returns
to C ........................................................................... 36
3.3. Infinite Duration Impulse Response (IIR) Filters ............................................ 40
3.3.1. Realizations for IIR Filters... .. .. . .. .. . .. ..... .. . .. ... . .. . ... . .. . . . . . . . . . . . . . . . . .. 40
3.3.2. A Program for Designing IIR Filters ................................................ 41
3.3.3. Two Methods for Measuring a Phase Response ....................................... 42
3.4. Hardware Details and Laboratory Experiments for FIR and IIR Digital Filters. . . . . . . . . . . . . . . . . . .. 44
3.4.1. Some Hardware and Software Details for the EVM .................................... 44
3.4.2. Measuring the Time to Execute a Program Segment by Using the Benchmarking Capability
ofEVM30...................................................................... 46
3.4.3. Laboratory Experiments for FIR Filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 47
3.4.4. Laboratory Experiments for IIR Filters .............................................. 49
3.5. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 49

4. The FFT and Power Spectrum Estimation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4.1. The Discrete-Time Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 51


4.2. Data Window Functions ................................................................ 51
4.3. The Discrete Fourier Transform and Its Inverse ............................................. 52
4.4. The Fast Fourier Transform ............................................................. 53
4.5. Using the FFT to Estimate a Power Spectrum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 54
4.6. Laboratory Experiments ................................................................ 60
4.6.1. FFT Experiments ................................................................ 60
4.6.2. Experiments for Power Spectrum Estimation ......................................... 60
4.7. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 63

5. Amplitude Modulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

5.1. Theoretical Description of Amplitude Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 65


5.1.1. Mathematical Formula for an AM Signal ............................................ 65
5.1.2. Example for Single Tone Modulation ............................................... 65
5.1.3. The Spectrum of an AM Signal .................................................... 66
5.2. Demodulating an AM Signal by Envelope Detection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 66
5.2.1. Square-Law Demodulation of AM Signals ........................................... 66
5.2.2. Hilbert Transforms and the Complex Envelope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 67
5.3. Laboratory Experiments for AM Modulation and Demodulation ............................... 69
5.3.1. Making an AM Modulator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 69
5.3.2. Making a Square-Law Envelope Detector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 69
5.3.3. Making an Envelope Detector Using the Hilbert Transform ............................. 70
5.4. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 71
Contents xiii

6. Double-Sideband Suppressed-Carrier Amplitude Modulation and Coherent Detection 73

6.1. Mathematical Description of the DSBSC-AM Signal ........................................ 73


6.2. The Ideal Coherent Receiver ............................................................ 73
6.3. The Costas Loop as a Practical Approach to Coherent Demodulation ........................... 74
6.4. Laboratory Exercises and Experiments for the Costas Loop ................................... 76
6.4.1. Theoretical Design Exercises ...................................................... 77
6.4.2. Hardware Experiments ........................................................... 78
6.5. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 78

7. Single-Sideband Modulation and Frequency Translation ...•.••.•..•.....••....•.....•.•....••• 79

7.1. Single-Sideband Modulators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 79


7.2. Coherent Demodulation of SSB Signals ................................................... 80
7.3. Frequency Translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 81
7.4. Laboratory Experiments ................................................................ 82
7.4.1. Making an SSB Modulator ........................................................ 82
7.4.2. Coherent Demodulation of an SSB Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 82
7.5. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 83

8. Frequency Modulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

8.1. The FM Signal and Some ofIts Properties ................................................. 85


8.1.1. Definition ofInstantaneous Frequency and the FM Signal .............................. 85
8.1.2. Single Tone FM Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
8.1.3. Narrow Band FM Modulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
8.1.4. The Bandwidth of an FM Signal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
8.2. FM Demodulation by a Frequency Discriminator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
8.3. Using a Phase-Locked Loop for FM Demodulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
8.4. Laboratory Experiments for Frequency Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 89
8.4.1. Experimentally Measuring the Spectrum of an FM Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 89
8.4.2. FM Demodulation Using a Frequency Discriminator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 90
8.4.3. Using a Phase-Locked Loop for FM Demodulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 90
8.5. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 90

9. Pseudo-Random Binary Sequences and Data Scramblers. . • . . • . • . . • . . . . . . • . . . . • • . . . . . • • • • • . . . • . 91

9.1. Using Linear Feedback Shift Registers to Generate Pseudo-Random Binary Sequences ............ 91
9.1.1. The Linear Feedback Shift Register Sequence Generator ............................... 92
9.1.2. The Connection Polynomial and Sequence Period ..................................... 92
9.1.3. Properties of Maximal Length Sequences ............................................ 93
9.2. Self Synchronizing Data Scramblers ...................................................... 93
9.2.1. The Scrambler .................................................................. 93
9.2.2. The Descrambler ................................................................ 94
9.3. Theoretical and Simulation Exercises for Shift Register Sequence Generators and Scramblers. . . . . .. 94
9.3.1. Exercises for a Shift Register Sequence Generator with a Primitive Connection Polynomial . .. 95
9.3.2. Exercises for a Shift Register Sequence Generator with an Irreducible but not Primitive
Connection Polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 95
9.3.3. Exercises for a Shift Register Sequence Generator with a Reducible Connection Polynomial .. 95
9.4. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
xiv Contents

10. Introduction to the RS-232C Protocol and a Bit-Error Rate Tester. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

10.1. The EIA RS-232C Serial Interface Protocol ............................................... 97


10.2. Bit-Error Probability for Binary Signaling on the Additive, White, Gaussian Noise Channel ....... 99
10.3. The Navtel Datatest 3 Bit-Error Rate Tester ............................................... 99
10.4. Bit-Error Rate Test Experiment ......................................................... 100
10.5. Additional References ................................................................. 102

11. Digital Data Transmission by Baseband Pulse Amplitude Modulation (PAM) • . . .. . . . . . . . . . . . . . . . .. 103

11.1. General Description of a Baseband Pulse Amplitude Modulation System ....................... 103
11.2. Baseband Shaping and Intersymbol Interference ........................................... 105
11.2.1. The Nyquist Criterion for No lSI ...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 105
11.2.2. Raised Cosine Baseband Shaping Filters .......................................... 106
11.2.3. Splitting the Shaping between the Transmit and Receive Filters . . . . . . . . . . . . . . . . . . . . . . .. 106
11.2.4. Eye Diagrams ................................................................ 107
11.3. Implementing the Transmit Filter by an Interpolation Filter Bank ............................. 107
11.4. Symbol Error Probability for a Channel with a Perfect Frequency Response and Additive Gaussian
Noise .............................................................................. 108
11.5. Symbol Clock Recovery ............................................................... 109
11.6. Simulation and Theoretical Exercises for PAM ............................................ 110
11.6.1. Generating Four-Level Pseudo-Random PAM Symbols .............................. 110
11.6.2. Eye Diagram for a PAM Signal Using a Raised Cosine Shaping Filter .................. III
11.6.3. Eye Diagram for a PAM Signal Using a Square-Root of Raised Cosine Shaping Filter ..... III
11.6.4. Theoretical Error Probability for a PAM System .................................... III
11. 7. Hardware Exercises for PAM ........................................................... 111
11.7.1. Generating a PAM Signal and Eye Diagram .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 111
11.7.2. Testing the Square-Law Symbol Clock Frequency Generator. . . . . . . . . . . . . . . . . . . . . . . . .. 112
11.7.3. Optional Team Exercise ........................................................ 113
11.8. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 113

12. Fundamentals of Quadrature Amplitude Modulation .......................................... 115

12.1. A Basic QAM Transmitter ............................................................. lIS


12.2. Two Constellation Examples ........................................................... 116
12.2.1. The 4 x 4 16-Point Constellation ................................................. II 6
12.2.2. A4-Point Four-Phase Constellation ............................................... 1I9
12.3. A Modulator Structure Using Passband Shaping Filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1I9
12.4. Ideal QAM Demodulation ............................................................. 120
12.5. QAM Modulator Experiments .......................................................... 120
12.5.1. Steps to Follow in Making a Transmitter .......................................... 121
12.5.2. Testing Your Transmitter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 123
12.5.3. Optional Exercise--Testing Your Transmitter by Sending to a Commercial Modem ....... 123
12.6. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 125

13. QAM Receiver I. General Description of Complete Receiver Block Diagram and Details of the
Symbol Clock Recovery and Other Front-End Subsytems ...................................... 127

13.1. Overview ofa QAM Receiver .......................................................... 127


13.2. Details about the Receiver Front-End Subsystems .......................................... 129
Contents xv

13.2.1. Automatic Gain Control ...................................... , ................. 129


13.2.2. The Carrier Detect Subsystem ................................................... 129
13.2.3. Symbol Clock Recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 129
13.3. Experiments for the QAM Receiver Front-End. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 134
13.4. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 135

14. QAM Receiver II. The Passband Adaptive Equalizer and Carrier Recovery System... . . . . .• . . . .• .• 137

14.1. The Complex Cross-Coupled Passband Adaptive Equalizer .................................. 137


14.1.1. The LMS Method for Adjusting the Equalizer Tap Values . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 138
14.1.2. Theoretical Behavior of the LMS Algorithm ....................................... 140
14.1.3. Adding Tap Leakage to the LMS Algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 142
14.2. The Phase-Splitting Fractionally Spaced Equalizer ......................................... 142
14.3. Decision Directed Carrier Tracking ...................................................... 144
14.4. Blind Equalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 146
14.4.1. Blind Equalization with the Complex Cross-Coupled Equalizer . . . . . . . . . . . . . . . . . . . . . . .. 146
14.4.2. Blind Equalization with the Phase-Splitting Equalizer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 147
14.5. Complex Cross-Coupled Equalizer and Carrier Tracking Loop Experiments .................... 147
14.5.1. Implementing the Slicer ........................................................ 148
14.5.2. Making a Demodulator and Carrier Tracking Loop .................................. 148
14.5.3. Making a Complex Cross-Coupled Adaptive Equalizer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 149
14.5.4. Bit-Error Rate Test ............................................................ 149
14.5.5. Optional Experiment-Receiving the 16-Point V.22bis Constellation ................... ISO
14.5.6. Optional Experiment-Ideal Reference Training. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 150
14.6. Optional Experiment-Phase-Splitting Fractionally Spaced Equalizer ......................... 150
14.7. Optional Experiment-Blind Equalization ................................................ 151
14.8. Additional References ............ " ................................................... 151

15. Echo Cancellation for Full-Duplex Modems .........•........................................ 153

15.1. The Echo Sources in a Dialed Telephone Line Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 153


15.2. The Data-Driven, Nyquist, In-Band Echo Canceller ........................................ 154
15.2.1. General Description ........................................................... 154
15.2.2. The Near-End Echo Canceller ................................................... 155
15.2.3. The Far-End Echo Canceller .................................................... 157
15.2.4. Far-End Frequency Offset Compensation .......................................... 158
15.3. Echo Canceller Experiments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 158
15.3.1. Making a Near-End Echo Canceller .............................................. 158
15.3.2. Making a Far-End Echo Canceller with Frequency Offset Correction ................... 159
15.4. Additional References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 159

16. Suggestions for Additional Experiments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 161

16.1. Elementary Modem Handshake Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 161


16.2. Fast Equalizer Training Using Periodic Sequences ........................................ " 161
16.3. Trellis Coded Modulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 161
16.4. V.34 Constellation Shaping by Shell Mapping ............................................. 162
16.5. Nonlinear Precoding for V.34 ........................................................... 162
xvi Contents

Appendix A. Communicating between the PC and EVM 163

AI. Overview of the PC/EVM Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 163


AI.I. The Data Transfer Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 163
A.I.2. EVM Interrupts to the TMS320C30 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 165
A.1.3. Flags that Indicate to the PC when the TMS320C30 has Read or Written the Transfer
Register ..................................................................... 165
Al.4. Resetting the EVM ............................................................ 166
A2. A Command Passing Protocol .......................................................... 166
A.3. Using DMA for Data Transfers .......................................................... 167
A.3.1. TMS320C30 to PC Data Transfers ................................................ 167
A.3.2. PC to TMS320C30 Data Transfers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 168
A3.3. Turning off the DMA .......................................................... 168
A4. Laboratory Experiments on Transferring Data between the TMS320C30 and PC ................. 168
A.4.l. Functions the TMS320C30 Program Must Perform ............................... . .. 168
A4.2. Functions the PC Program Must Perform .......................................... 171
A.4.3. Testing Your PC and TMS320C30 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 173

Appendix B. Generating Gaussian Random Numbers ............................................. 175

Appendix C. A TTL/RS-232C Interface for Serial Port 1 ........................................... 177

Appendix D. Equipment List for Each Station .................................................... 179

Appendix E. Software and Directory Structure ................................................... 181

References ................................................................................... 183

I. List of Manuals ....................................................................... 183


A Manuals for the TMS320C30 Tools ................................................. 183
B. Manuals for Borland C++ ......................................................... 183
C. Assorted Manuals for Lab Test Equipment ........................................... 184
II. Selected Reference Books and Papers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 184
A DSP Laboratory Books Using DSP Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. ] 84
B. DSP Laboratory Books Using Software Simulation .................................... 184
C. Books on Digital Signal Processing ................................................. 184
D. Books and Papers on Communications .............................................. 184
E. Books and Papers on Error-Correcting Codes .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 186

Index ....................................................................................... 187


Communication System Design
Using DSP Algorithms
With Laboratory Experiments
for the TMS320C30
1

Brief Overview of the Hardware


and Software Tools

The purpose of this initial experiment is to introduce you ity of your classmates feel the same way. Very shortly you
to the main features of the hardware and software tools will get over this initial hurdle and fmd the experiments
that will be used in this course. A variety of signal pro- interesting and challenging. As the semester progresses,
cessing and communication system components will be you will build up a bag-of-tricks that can be used in fol-
implemented by writing C and/or assembly language pro- lowing experiments so they will almost seem to get easier.
grams for the TMS320C30 DSP. The DSP communicates
with the analog world through AID and DIA converters
and with a host PC through the 8-bit PC data bus. The 1.1. Some DSP Chip History
DSP and converters reside on a card called the Evaluation and Typical Applications
Module (EVM) that plugs into a PC slot. It is important
to have a general picture of the hardware platform so you Digital signal processing chips (DSP's) were intro-
will understand how to write programs to accomplish the duced in the early 1980's and have caused a revolution
desired tasks. First, a very brief history of DSP chips in product design. Current major DSP manufacturers
is presented and some typical applications are discussed. include Texas Instruments (TI), Motorola, AT&T, Ana-
Then, the important features of the TMS320C30 DSP are log Devices, NEC, SGS-Thomson, and Rockwell Interna-
described. Next, a block diagram of the EVM is discussed tional. DSP's differ from ordinary microprocessors in that
followed by an introduction to some of the software tools. they are specifically designed to perform the sum of prod-
Finally, you will be guided through some very simple ex- ucts operation required in many discrete-time signal pro-
periments to learn the basics of how to use the system. cessing algorithms rapidly. They contain hardware paral-
If you fmish these experiments before the end of the lab lel multipliers, and functions implemented by microcode
period, go on to Chapter 2. in ordinary microprocessors are implemented by high-
speed hardware in DSP's. Low-cost DSP's have made
Details of the TMS320C30 architecture and instruc-
it more economical to implement functions by digital sig-
tion set and of the EVM board will be introduced grad-
nal processing techniques rather than by hard-wired ana-
ually in the first few experiments as they are required.
log circuits, particularly for audio band applications like
Complete details for the TMS320C30, EVM, and TI soft-
speech compression and telephone line modems. Some of
ware can be found in the Texas Instruments manuals when
the advantage results from the fact that integrated digital
required. (The ability to read manuals is an important skill
circuits are very reliable and can be automatically inserted
to acquire.)
in boards easily. In addition, programmable DSP's can
There are many things to be learned initially and you implement complicated linear and nonlinear algorithms
may feel overwhelmed. Please be assured that the major- and easily switch functions by jumping to different sec-

1
2 Chapter 1

tions of program code. The complexity of the algorithms nary microprocessor acting as a controller as little as five
is only limited by the imagination of the programmer and years ago, can now be implemented using a single DSP
the processing speed of the DSP. Once the program is and at lower cost!
perfected, the chip function does not change with age un- Another milestone in DSP history occurred around
less a very rare failure occurs. On the other hand, analog 1986 when AT&T introduced the first commercial float-
components require more board space, sometimes must be ing-point DSP, the DSP32. In 1988, TI shipped initial
trimmed to the correct values after insertion, and change samples of the TMS320C30 at a price of $1,300 to be-
with temperature and age. Analog circuits are designed gin its first-generation TMS320C3x floating-point DSP
to perform specific functions and lack the flexibility of family. Both processors have a 32-bit word length. The
the programmable DSP approach. Another advantage is TMS320C30 is currently offered with clock speeds of 27,
that small changes in the DSP function or bug fixes can 33, and 40 MHz. The suggested resale price for a 33 MHz
be made by changing a few lines of code in a ROM or TMS320C30 is now $158 in quantity. A stripped down
EPROM, while similar changes may be very difficult with version, the TMS320C31, followed and has a suggested
a hard-wired analog circuit. resale price of $53 for the 33 MHz version. Recently, TI
DSP techniques were used earlier but required build- started its second-generation floating-point DSP family
ing your own processor with many TTL MSI chips, in- with the TMS320C40, which contains extensive support
cluding cascadable ALU sections and stand-alone multi- for parallel processing.
plier chips. A typical system contained over 100 MSI Some new generations of DSP's are now being de-
chips. These systems were big and expensive to man- signed with video applications in mind. In the Fall of
ufacture because of the large chip count; they consumed 1994, TI began shipping samples of its next generation
many watts of power and required cooling fans. The most TMS320C8x DSP series. The initial member of this
popular first-generation DSP chips, the NEC J.LPD7720 series, the TMS320C80, contains four advanced-integer
and Texas Instruments TMS32010, became commercially DSP's using 32-bit data and 64-bit instruction words, one
available in late 1982. These chips performed 16-bit in- RISC processor that includes a floating-point unit, 50K
teger arithmetic at the rate of 5 million instructions per words of SRAM, a crossbar switch, a video controller,
second (MIPS) and had limited internal RAM, ROM, and and extensive 110 capabilites. It has special instructions
110 capabilities. They initially cost about $600 and now designed for pixel processing. TI claims the chip can
can be bought for about $2. They reduced the chip count perform two billion operations per second. It is projected
by a very large percentage, resulting in smaller circuit that the chip will soon sell for around $400 in quantity.
boards using significantly less power; more reliable sys- Floating-point DSP's are now being used in many
tems, and reduced manufacturing complexity and cost. applications because of their ease in programming and
DSP's have continually evolved since they were first reasonable price. However, integer DSP's are still be-
introduced as VLSI technology improved, as users re- ing chosen very often because they are cheaper, some-
quested additional functionality, and as competition arose. what faster, and use less power. Cost is a major con-
More internal RAM and ROM has been added and the cern in the competitive commercial market, particularly
total address space has been increased. Additional func- for mass-produced products like modems and hard disk
tions have been added, including hardware bit-reversed drives. Care must be taken with integer DSP's to scale
addressing for FFT's, hardware circular buffer address- signals to avoid overflow and underflow. However, this
ing, serial ports, timers, DMA controllers, and sophisti- is not much of a problem in many digital communication
cated interrupt systems including shadow registers for low system applications where signal power levels remain rel-
overhead context switching. Analog Devices has included atively constant. Floating-point DSP's automatically per-
switched capacitor fIlters and sigma-delta AID and DIA form the scaling.
converters on some DSP chips. Instruction rates have in- DSP's are used in a wide variety of oflline and real-
creased significantly. State-of-the-art integer DSP's like time applications. Some typical areas and specific appli-
the TMS320C5x series have recently arrived on the mar- cations are:
ket that can operate at 57 MIPS and cost as little as $31
in quantity. The speed increase is largely a result of re- • Telecommunciations: telephone line modems, fax,
duced geometries and improved CMOS technology. The cellular telephones, speaker phones, ADPCM trans-
introduction of CMOS technology after the first couple coders, digital speech interpolation, and answering
of generations of DSP's significantly reduced power con- machines
sumption. Also, DSP's using lower supply voltages are
now being built. Applications like telephone line modems • Voice/Speech: speech digitization and compression,
that required at least two DSP's and an additional ordi- voice mail, speaker verification, and speech synthesis
Brief Overview Of the Hardware and Software Tools 3

• Automotive: engine control, antilock brakes, active modem, usually referred to as the answer modem, trans-
suspension, airbag control, and system diagnosis mits a signal called the answer tone to the calling modem.
In the V.34 case, a small sinusoidal amplitude modulation
• Control Systems: head positioning servo systems is impressed on the answer tone to identify it as a V.34
in disk drives, laser printer control, robot control, modem, so the receiver in the calling modem needs to
engine and motor control, and numerical control of perform the function of an envelope detector. In another
automatic machine tools phase of the handshake, a channel probing sequence con-
sisting of a sum of sine waves is transmitted first by one
• Military: radar and sonar signal processing, naviga-
tion systems, missile guidance, HF radio frequency modem and then by the other. The calling and answer
modem transmitters must synthesize this signal and the re-
modems, secure spread-spectrum radios, and secure
ceivers must process it to estimate channel characteristics
voice
such as frequency response, noise level, and nonlinear-
• Medical: hearing aids, MRI imaging, ultrasound ities. Another special sequence is transmitted to rapidly
imaging, and patient monitoring adjust adaptive equalizers in the receivers. During still an-
other portion of the handshake, binary differential phase
• Instrumentation: spectrum analysis, transient anal- shift keying (DBPSK) is used to exchange configuration
ysis, signal generators information between the modems. Quadrature amplitude
modulation (QAM) is used during normal data transmis-
• Image Processing: HDTV, pattern recognition, im-
sion. Transmit and receive signal separation is achieved
age enhancement, image compression and transmis-
by using adaptive echo cancellers. Additional tasks that
sion, 3-D rotation, and animation
must be performed during normal data transmission are
Clearly, real-time DSP applications are limited to scrambling and descrambling the input bit stream, map-
cases where the required signal sampling rate is suffi- ping the scrambled data bits to transmitted signal points
ciently less than the DSP instruction rate so a reasonable by a technique called shell mapping, trellis encoding, non-
number of instructions can be performed between sam- linear precoding, and soft decision Viterbi decoding. All
ples. For example, a wide-band radio frequency (RF) these tasks, and more, can now be performed by a sin-
signal with a high carrier frequency can not be directly gle state-of-the-art 50 MIPS integer DSP. In addition,
sampled and demodulated with a DSP. However, when as a result of intense competition, all the V.34 modems
the bandwidth of the RF signal is sufficiently less than thejust now beginning to reach the market can also act as at
instruction rate, analog front-end circuits can be used to least six older modem types and include FAX modes. All
demodulate it to baseband inphase and quadrature com- that is required to include new functions is to "add a few
ponents, which can then be sampled at a rate equal to the more lines of code and, possibly, some more memory."
bandwidth and processed by a DSP. Alternatively, an ana- These modems will cost the consumer $400 or less. Pro-
log filter can be used to form the Hilbert transform of the grammable DSP's have made it possible to manufacture
products with tremendous complexity and sophistication
RF signal and then the original signal and its Hilbert trans-
form can be sampled at a rate equal to the bandwidth and at prices that the ordinary consumer can easily afford.
processed with a DSP. DSP's have been used extensively Finally, to maintain a balanced viewpoint, it should
in audio frequency applications, where many instructions be pointed out that the DSP approach is not always the
can be performed between samples. However, they are best solution to a problem even if a DSP can accomplish
being used to process increasingly wide-band signals as the task. For example, a commercial AM radio signal,
the instruction rates of new generations increase. which has a carrier frequency on the order of I MHz, can
A very important attribute of the DSP approach is trivially be demodulated by a simple envelope detector
the flexibility of a programmable device. A timely ex- consisting of little more than a diode, resistor, and capac-
ample illustrating an ideal application for this flexibilityitor. As engineers, you should always look for the most
will now be presented. In June 1994, the ITU approved reasonable and economical method of solving a design
the final draft of the V.34 telephone line modem recom- problem.
mendation. This modem can transmit data at rates varying
from 2400 to 28,800 bits/sec in multiples of2400 bits/sec.
1.2. Introduction to the TMS320C30
A variety of modulation schemes are used during hand-
shaking and normal data transmission. During the initial
Floating-Point DSP
handshaking phase, binary, continuous phase, frequency The experiments in this book are explained for the
shift keying is used to exchange information about mo- Texas Instruments TMS320C30 floating-point DSP. A
dem capabilities using the V.8 protocol. Later, the called floating-point DSP was chosen for these experiments to
4 Chapter 1

Program
RAM Block 0 RAM Block 1 ROM Block 0
Cache EXPANSION BUS
(lK x 32) (lK x 32) (4K x 32)
(64 x 32)
XIDW
IOSTRB
XR/W
Data Buses XD(31-0)
XA(12-0)
MSTRB
CPU DMA

Integer/ Integer/ Address


Floating-Point Floating-Point Generators
Multiplier ALU
Control Registers

Eight Extended-Precision
Registers Serial Port O~--+I

Address Address
Generator 0 Generator 1 Serial Port 11+---.1

8 Auxiliary Registers
Timer 0
12 Control Registers
Timer 1

Peripheral
RDY Bus
RESET
HOLD C
INT(3-0)
0
HOLDA lACK
n
STRB XF(1-0)
t
R/W r MC/MP
D(31-0) 0 Xl
A(23-0) X2/CLKIN
PRIMARY BUS VDD
e VSS
r
SHZ

Figure 1.1. Functional block diagram of TMS32OC30 DSP.


Brief Overview Of the Hardware and Software Tools 5

simplify the programming tasks. A functional block di- The Auxiliary Register Arithmetic
agram of the TMS320C30 is shown in Fig. 1.1 and its Units (ARAU's)
components are described in the following subsections.
For complete details, see the TMS320C3x User's Guide. The Address Generator 0 and Address Generator 1
blocks shown in Fig. 1.1 are called auxiliary register
arithmetic units ARAUO and ARAUI in the TI manu-
1.2.1. The Central Processing Unit (CPU) als. They can generate two addresses in a single cycle
The CPU has a register-based architecture and con- and operate in parallel with the ALU and multiplier. The
sists of the following components: ARAU's can compute addresses using index registers and
displacements. They also support circular buffers and bit-
• A floating-point/integer multiplier reversed addressing.
• An arithmetic logic unit (ALU) for performing
floating-point and integer arithmetic and logical op-
erations The CPU Register File

• A 32-bit barrel shifter The TMS320C30 CPU Register File contains 28 reg-
isters. All these registers can be operated on by the ALU
• Internal buses (CPUlICPU2 and REG l1REG2) and multiplier, and can be used as general purpose regis-
• Auxiliary register arithmetic units (ARAU's) ters. These include:

• CPU register file • Eight 40-bit extended preclSlon registers, RO-R7,


which are typically used for extended-precision float-
These components are described briefly below.
ing-point results

The Multiplier • Eight 32-bit auxiliary registers, ARO-AR7, which


The multiplier performs integer and floating-point are typically used as pointers in indirect addressing
multiplications in a single cycle. The integer multipli- modes but can be used as general-purpose integer
cation forms the product of two 24-bit integers and gives and logical registers.
a 32-bit result. Floating-point numbers are represented by
32-bit words consisting of an 8-bit exponent and a 24-bit • Control registers that include a stack pointer, CPU/
mantissa. The multiplication of two 32-bit floating-point DMA interrupt enable mask and flags, block repeat
words results in an extended-precision 40-bit word, which registers for zero overhead loops, a status register,
consists of an 8-bit exponent and a 32-bit mantissa with an and two index registers.
implied most-significant non-sign bit. The floating-point
normalization is performed by the hardware automatically.
Some ALU operations can be performed in parallel 1.2.2. Memory Organization
with multiplications to achieve increased speed in opera-
tions like sums of products. The TMS320C30 has a 16-megaword (24-bit ad-
dresses) logical memory space for program, data, and 110.
All the CPU and peripheral control and data registers are
The Arithmetic Logic Unit (ALU)
memory mapped. See the TMS320C3x User's Guide for
The ALU performs operations on 32-bit integer, 32- a detailed memory map. The memory space contains:
bit logical, and 40-bit floating-point words in a single
cycle. The operations include additions and integer and • Two lK x 32-bit on-chip RAM blocks
floating-point conversions. The ALU results are always
maintained in 32-bit integer or 40-bit floating-point for- • One 4K x 32-bit on-chip ROM block that is only
mats. A barrel shifter can be used to shift up to 32 bits enabled in the microcomputer mode
left or right in a single cycle.
The internal buses, CPUlICPU2 and REGl/REG2, • A 64 x 32-bit on-chip instruction cache that can be
carry two operands from the register file and two operands enabled or disabled
from memory, which allows parallel multiplications and
additions/subtractions on four integer or floating~point Each internal RAM and ROM block can be accessed twice
operands in a single cycle. in one cycle.
6 Chapter 1

1.2.3. The Internal Bus The serial ports operate independently and have iden-
tical structures. They can be set to transfer 8, 16, 24, or
The TMS320C30 has separate program, data, and 32 bit words. The bit clocks can be internal or external.
DMA buses that allow parallel program fetches, data ac- The ports can also be configured as timers.
cesses, and DMA transfers. These buses connect to the The timers are general purpose 32-bit timer/event
memory, registers, and peripherals. counters with internal or external clocking. Each timer
The program counter (PC) is attached to the 24-bit has an I/O pin that can be used as an input clock to the
program address bus (PADDR) and the instruction register timer or as an output clock signal driven by the timer.
is attached to the 32-bit program data bus (PDATA). A
single instruction word can be fetched each cycle by these
buses. 1.2.6. The Direct Memory Access
There are two 24-bit data address buses (DADDRI (DMA) Controller
and DADDR2) and a 32-bit data data bus (DDATA).
These buses accomplish two data memory accesses every The DMA controller can perform data transfers in the
machine cycle. Data is transferred from the DDATA bus background while the CPU is executing instructions at full
to the CPU over the CPUI and CPU2 buses. These buses speed. The DMA controller contains source and destina-
can carry two data words to the multiplier. The CPU tion registers, source and destination address generators,
also has two register buses, REG 1 and REG2, which can and a word transfer counter. Source and destination ad-
carry two data words from the CPU register file to the dresses can be automatically incremented or decremented
multiplier and ALU every cycle. after each word transfer by the DMA address generators.
A 24-bit address bus (DMAADDR) and a 32-bit data The DMA can interrupt the CPU when the transfer count
bus (DMADATA) are connected to the DMA controller. reaches 0 to inform the CPU it has finished transferring
Using these buses, the DMA controller can perform mem- the desired data block. Transfers can be synchronized to
ory accesses at the same time memory accesses are taking various interrupt sources.
place from the data and program buses.
1.2.7. Brief Description of the Instruction Set
1.2.4. The External Buses and Interrupts The TMS320C30 instruction set is specifically de-
The TMS320C30 has two external buses: the pri- signed for the arithmetically intensive operations required
mary bus and the expansion bus. Both have a 32-bit data by digital signal processing algorithms. The 114 instruc-
bus and a set of control signals. The primary bus has a tion op-codes are listed in Table 1.1. Detailed descriptions
24-bit address bus. However, the expansion bus has only of the instructions can be found in the TMS320C3x User's
a 13-bit address bus. Both buses can access program/data Guide [1.A.2] and the TMS320 Floating-Point DSP As-
memory or I/O space. Hardware wait states can be gener- sembly Language Tools User's Guide [I.A.6]. The in-
ated for each bus by external RDY signals. The number structions can be divided into the following functional
of wait states for each bus can also be set by software in- groups:
structions. Beware that the number of software wait states
• Load and store
is automatically set to the maximum value of 7 when the
TMS320C30 is reset. • Two-operand arithmetic/logical
The TMS320C30 has four external interrupts, several
internal interrupts, and a nonmaskable external reset sig- • Three-operand arithmetic/logical
nal. They can interrupt the CPU or be used by the DMA
• Program control
controller to sychronize data transfers. The interrupts can
be individually enabled or disabled under software control • Parallel operations
by setting bits in CPU control registers or all disabled by
a global interrupt enable bit. • Interlocked operations

The parallel instructions are particularly useful for


1.2.5. Peripherals computing a sum of products, such as would be required
to implement an FIR filter. For example, the parallel
The TMS320C30 contains two bidirectional serial instruction
ports and two timers. They are controlled through
memory-mapped registers on an internal peripheral bus MPYF3 *ARO++,*AR1++%,RO
consisting of a 32-bit data bus and a 24-bit address bus. II ADDF3 RO,R2,R2
Brief Overview Of the Hardware and Software Tools 7

Table 1.1. The TMS320C30 Instruction Set

Load and Store Two-Operand Three-Operand


LDE ABSF LSH ROR ADDC3 MPYF3
LDF ABSI MPYF RORC ADDF3 MPYI3
LDFcond ADDC MPYI SUBB ADDI3 OR3
LDI ADDF NEGB SUBC AND3 SUBB3
LDIcond ADDI NEGF SUBF ANDN3 SUBF3
LDM AND NEGI SUBI ASH3 SUBI3
POP ANDN NORM SUBRB CMPF3 TSTB3
POPF ASH NOT SUBRF CMPI3 XOR3
PUSH CMPF OR SUBRI LSH3
PUSHF CMPI RND TSTB
STF FIX ROL XOR
STI FLOAT ROLC

Program Control Parallel Arithmetic with Store Parallel Multiply


Bcond IDLE ABSFIISTF MPY311STF and Add/Subtract
BcondD NOP ABSIIISTI MPY311STI MPYF311ADDF3
BR RETIcond ADDF3IISTF NEGFIISTF MPYF311SUBF3
BRD RETScond ADDI3IISTI NEGIIISTI MPYI311ADDI3
CALL RPTB AND311STI NOTIISTI MPYI3 II SUB 13
CALLcond RPTS ASH311 STI OR311 STI
BDcond SWI FIXIISTI STFIISTF
DBcondD TRAPcond FLOATII STF STIli STI
lACK LDFIISTF SUBF311STF
LDIIISTI SUBI3IISTI
LSH311STI XOR311STI

Parallel Load Interlocked


LDFIILDF LDFI
LDIIILDI LDII
SIGI
STFI
STII

multiplies the floating-point words pointed to by the aux- EVM is shown in Fig. 1.2. The EVM contains the fol-
iliary registers ARO and AR1, stores the new product in lowing components and features:
the extended precision register RO, increments the con-
tents of ARO, increments the contents of ARI circularly, • A TMS320C30 clocked at 30 MHz
adds the old extended precision product previously stored
in RO to R2 and stores the result in R2. These operations • 16K 32-bit words of zero wait state SRAM on the
take place within a single machine cycle. You will learn primary bus
about these instructions in detail in Chapter 3.
• Voice-band AID and DIA converters and continuous-
time filters in the TLC32044A Analog Interface Chip
1.3. The TMS320C30 Evaluation Module (AIC)

The TMS320C30 Evaluation Module (EVM) is the • RCA jacks on the back for analog input and output
hardware DSP board you will be using for the experi-
ments. The EVM is an IBM PCIAT half-card that plugs • A 16-bit register and logic for communicating with
into an 8-bit PC slot. A functional block diagram of the the PC host
8 Chapter 1

16 IJ
C30 TMS320C30 /
16K
host port LSB) RAM
PC ----. Expansion bus Primary bus /
/
D D /
Bus 32
,.--- INTO - INT2
Serial port 0 AIC

Serial port I I+--


Emulation control r
Analog
1
Control Buffers
Logic

1 I
-
-I- TBC
Out In
8
TBC SN74ACT8990
host port 16 10 pin header
/
"--0 D D D
/

Figure 1.2. TMS32OC30 evaluation module (EVM) block diagram.

• An external 10-pin connector for the TMS320C30 The TMS320C30 communicates with the host PC
Serial Port I, external flag (XFI), and Timer Clock through a 16-bit bidirectional, memory-mapped transfer
I lead (TCLKI) register in the expansion bus address space. The host PC
exchanges commands and data with the EVM by inputting
• Embedded emulation support via the 74ACT8990 or outputting bytes to addresses in the PC's 110 space. A
Test Bus Controller (TBC) word is transmitted by the PC to the EVM by outputting
a pair of bytes to successive 110 locations. Logic on
Complete details for the EVM including circuit dia- the EVM loads the bytes into the 16-bit transfer register.
grams can be found in the TMS320C30 Evaluation Mod- Similarly, words are read from the EVM by inputting a
ule Technical Reference [1.A.4] and Digital Signal Pro- pair of bytes at successive 110 addresses. See Appendix
cessing Applications with the TMS320C30 Evaluation A for details.
Module, Selected Application Notes [1.A.5]. Also, Ap- The EVM comes with a program for the host PC
pendix A explains in detail how to transfer data from the named EVM30.EXE called a C Source Debugger by TI.
TMS320C30 to the host PC and vice-versa. This program is used to load programs created for the
The Analog Interface Chip contains anti-aliasing and TMS320C30 on the host PC into the TMS320C30 mem-
highpass input filters and a lowpass output reconstruc- ory and monitor execution at the C or assembly language
tion filter. The cutoff frequencies of these filters can be statement level.
changed by writing values to the control registers. It also
has 14-bit AID and D/A converters that can perform con-
versions up to 19,200 samples per second. The AIC sends
1.4. Software Tools
and receives samples from the TMS320C30 through Se-
rial Port 0 of the DSP. The clocks for the AIC are derived The major software tools you will use to create pro-
from the output of Timer 0 of the TMS320C30. The first grams for the TMS320C30 are the TI assembler, C com-
few experiments explain how to initialize the TMS320C30 piler, and linker. You will use the TI C source debugger
and AIC to perform the desired serial data sample trans- to load programs into the TMS320C30 memory and start
fers and set the sampling rate and filter cutoff frequencies. and monitor execution. Several digital filter design pro-
Brief Overview Of the Hardware and Software Tools 9

grams will be used for many of the experiments. A com- For complete details about the C compiler and shell
plete list of the programs available at each PC and the program, see the TMS320 Floating-Point DSP Optimizing
directory structure can be found in Appendix E. These C Compiler User's Guide [I.A.8].
programs are described briefly in the following subsec-
tions. For complete details for the TI programs, see the The Linker, LNK30.EXE
appropriate TI manuals.
The linker, LNK30.EXE, combines relocatable ob-
ject modules to form an executable output program. The
1.4.1. Software Supplied by Texas Instruments default extension for executable programs is .OUT. In ad-
The TMS320C30 Assembler, ASM30.EXE dition, the linker can generate a .MAP file showing the ab-
solute memory addresses of all variables. You will nearly
The assembler for the TMS320C30 is named ASM- always invoke the linker automatically through the CL30
30.EXE. It converts the symbolic assembly language shell program in these experiments.
source code consisting of symbolic machine instructions, The input object modules and options can be in-
labels, macros, assembler directives, etc., into relocatable cluded on the linker command line. Another very im-
object modules which have the default extension, .OBI. portant input to the linker is a linker command file which
The assembler generates the binary 32-bit machine in- has the extension .CMD. The command file can contain
struction for each symbolic source code instruction when names of additional object modules to link, paths to li-
possible and creates a table of addresses that must be braries, names for the .MAP and .OUT files, a memory
resolved when the relocatable object modules are linked map for the target hardware system, and commands de-
together. See the TMS320 Floating-Point DSP Assem- scribing where to put specific program sections in mem-
bly Language Tools User's Guide [I.A.6] for complete ory. An example of a linker command file is presented
details. You will begin to use the assembler in Chapter 2. early in Chapter 2.
See the TMS320 Floating-Point DSP Assembly Lan-
guage Tools User's Guide [I.A.6] for complete details on
The TI Optimizing C Compiler
how to use the linker.
The TMS320C30 C compiler translates standard
ANSI C source programs into assembly language source The C Source Debugger
code. It can perform selected levels of optimization. The
assembly language output files must be passed through the The C source debugger is the primary tool you
assembler and linked with other user created and library will use to load an executable program file into the
relocatable object modules to form an executable output TMS320C30 memory on the EVM from the host PC, start
file. A few extensions, such as including assembly lan- the program running, and monitor execution. EVM30.
guage statements mixed in with the C source program EXE is the DOS version and EVM30W.EXE is the Mi-
and the volatile variable type, have been added. All crosoft Windows version of the C source debugger. The
variable and constant types use single 32-bit TMS320C30 two versions have almost identical screen displays but the
words. An output file interlisting the original C source Windows version has slightly more capabilities. The de-
statements and the assembly code generated for each state- bugger can be controlled through commands typed on the
ment can be created. keyboard, by function keys, by pull-down menus, or by
The compiler consists of three separate programs: (1) the mouse. Commands can also be read from batch files.
the parser, AC30.EXE, (2) the optimizer, OPT30.EXE, The display contains a number of windows showing the
which is optionally used, and (3) the code generator, contents of the CPU registers, C and assembly language
CG30.EXE. These three programs, the assembler, and the source code, contents of memory blocks, and values of
linker can be called individually for greatest flexibility. selected variables, among other things. The debugger can
However, TI provides a shell program, CL30.EXE, that run an entire program, run to a selected label, run to se-
greatly simplifies the process by automatically carrying lected break points, or single-step through programs at the
out all these steps. The shell compiles and assembles the C or assembly language statement level. Statistics about
C source files on its command line, assembles assembly program execution, like the number of instructions be-
language source files on its command line, and links the tween two break points, can be collected. The values of
results and library files to create an executable output file. variables, arrays, structures, and pointers can be displayed
You will begin to use CL30 in Chapter 2 and will con- and edited in their natural formats (float, int, char, etc.).
tinue to use it for most of your experiments. The details CPU registers and memory words can be set to desired
bf the command line format are introduced as needed. values and memory blocks can be saved in or loaded from
10 Chapter 1

PC files. The C source debugger is a powerful tool and C code must be compiled with the -g option to include the
has many more capabilities than you will probably use in information needed by the debugger. The debugger auto-
the experiments. See the TMS320C3x C Source Debugger matically displays the COMMAND, CALLS, and l<'ILE
User's Guide [I.A.7] for complete details. windows when running C code. WATCH and DISP win-
The C source debugger displays data in nine kinds dows can also be opened.
of windows, which can be grouped into four categories. Assembly mode is for viewing assembly language
The windows can be moved and resized, and some can programs only, and you will always see the assembly dis-
be turned on and off. The categories and windows are: play whether C or assembly code is running. The MEM-
ORY, DISASSEMBLY, CPU, and COMMAND windows
1. The COMMAND window has a line for typing in are automatically displayed. A WATCH window can be
commands. It displays information like error mes- opened.
sages, progress messages, and command output. Mixed mode displays assembly language and C code
2. The Code-display windows show C or assembly lan- simultaneously. The debugger displays all the windows
guage code. that can be displayed in the auto and assembly modes.
In the profiling environment, only the COMMAND,
• The DISASSEMBLY window displays the as- PROFILE, DISASSEMBLY, and FILE windows are dis-
sembly language source statements correspond- played.
ing to memory words. The debugger actually When you simply want to load and run a program and
disassembles the memory contents into sym- do not need all the fancy capabilities of the C source de-
bolic source statements. bugger, you can use the utility program EVMLOAD.EXE.
• The FILE window displays any file you select. To load and run a program called prog. out, just type
However, its primary purpose is to display the
C source code being executed.
EVMLOAD prog.out
• The CALLS window shows the current func-
tion traceback when C code is executing.
1.4.2. Digital Filter Design Programs
3. The PROFILE window displays statistics about
code execution that can be useful in optimizing pro- Filtering is a fundamental operation in communica-
gram organization. tion systems. Several programs have been collected, mod-
ified, and written for designing digital filters for the ex-
4. The Data-display windows are used for viewing and periments. These digital filter design programs are:
modifying various types of data.
• WINDOW.EXE-a program for designing lowpass,
• The MEMORY window displays the contents highpass, bandpass, bandstop, and Hilbert transform
of a memory block. FIR filters using the Fourier series and window func-
• The CPU window displays the contents of the tion method. The basic program was taken from the
TMS320C30 registers. classic IEEE Press book, Programs for Digital Sig-
nal Processing [II.C.5] and modified by the author.
• A WATCH window is an optional window that
can be created to display user selected data, • REMEZ87.EXE-a program for designing multi-
such as C variables, registers, memory loca- ple passband/stopband, differentiation, and Hilbert
tions, or special debugger variables. transform FIR filters using the McClellan-Parks ap-
• A DISP window is similar to a WATCH win- proach. The basic program was taken from [II.C.5]
dow but displays the contents of an aggregate and modified by the author.
type such as an array or structure.
• IIR.EXE - a program for designing lowpass, high-
The C source debugger can be run in a basic or pass, bandpass, and band-reject IIR digital filters us-
profiling environment. In the basic environment, the three ing the bilinear transformation to convert classical
debugging modes are auto mode, assembly mode, and analog prototype filters into digital filters. Classical
mixed mode. analog Butterworth, Chebyshev, inverse Chebyshev,
In auto mode, the debugger automatically displays and elliptic filters can also be designed. The basic
assembly language source code in the DISASSEMBLY program was downloaded from the TI bulletin board
window when it is running assembly code, or C source and modified by the author. The original program
code in the FILE window when it is running C code. The was written by S. Burrus at Rice University.
Brief Overview Of the Hardware and Software Tools 11

• RASCOS.EXE - a program written by the author for the sampling rate, filter bandwidths, display magnifica-
designing FIR filters that approximate the raised co- tion, etc. When you adjust the magnification properly by
sine frequency response. The impulse response is pressing the HOME key, you should see samples of the
separated into subfilters for an interpolation filter sinewave input to the EVM. Attach the free oscilloscope
bank. channel to the EVM RCA output jack. The program loops
the input samples back out to the DIA converter and out-
• SQRTRACO.EXE-a program written by the author put lowpass filter. You should see a sinewave similar to
for designing FIR filters that approximate the square- the input sinewave on the oscilloscope.
root of raised cosine frequency response. The im- Play with the different function keys and sinew ave
pulse response is separated into subfilters for an in- frequency and see what happens. When you are done,
terpolation filter bank. exit from the program.
4. Now move to the directory C: \ UTIL.DSP\
1.4.3. Other Software SCOPE. Start the C source debugger by entering the com-
mand
Other software available for the laboratory includes:
EVM30
• The standard MS-DOS and Windows programs
When the debugger display appears, enter the debugger
• Borland C++ for the PC commands
• Programs for plotting x-y data on the PC screen and
reset
printer
load evm.out
• Spread sheets, editors, Norton Utilities, and many
This resets the EVM and loads the program EVM.OUT,
other programs available on the Engineering College
which is an executable program for performing the steps
CLAM network server.
required by the exercise at the end of Appendix A. Ex-
amine the different windows in the display.
To get a taste for how to use the C source debugger,
1.5. Introductory Experiments
do the following:
The purpose of these experiments is to give you a (a) At this point, the program counter should be at the
very elementary introduction to using the hardware and start of the standard C initialization code and you should
C source debugger at your setup. You will learn simple see assembly code in the DISASSEMBLY window. Enter
things like where to find cables and T-connectors, and the debugger command
where the EVM AID input and DIA output RCA jacks are
located on the back of the PC. No lab report is required go main
for this experiment. If you finish these exercises before
the end of the lab period, go on to Chapter 2. Every C source program must contain a function called
Perform the following tasks: mainO where the high-level C code logically starts. You
1. Tum on the PC, signal generator, and oscillosope. should now observe C code in the FILE window and the
2. Attach a T-connector to the signal generator out- program should be halted at the label, main.
put and connect one end to the oscilloscope. Set the signal (b) Single step through several C statements by press-
generator to generate a 2-kHz sinewave with a peak am- ing the F8 function key. This single steps into called
plitude of I volt. Attach the other end ofthe T-connector functions. To avoid stepping into functions, try pressing
to the RCA input jack on the back of the EVM board in the NEXT=FlO function key.
the PC. )c) Enter the following commands
3. Move to the directory C:\APPS.DSP and enter
the command restart
go main
osc
to restart the program at the beginning and get back to
on the PC keyboard. (You must follow the command by the label main. Look in the FILE window for the line
pressing the return key.) This will start an elementary
oscilloscope demonstration program supplied by TI. Look init_c30bus(); /*Disable wait states
at the displayed menu to see how the different keys affect & enable cache */
12 Chapter 1

Move the mouse cursor to this line and press the left
button. The line should become intensified with a > at
the left edge. This means you have set a break point at
this instruction. Set another break point at the line

buf_init(&input, &output)j /*Allocate


space for buffers */

Press the RUN=F5 function key to execute C statements


to the first breakpoint. Now type in the commands

runb
? clk
The value displayed is the number of TMS320C30 clock
cycles executed between the run and runb commands.
This is called benchmarking.
(d) The C souoce program contains a variable named
index, which is an index into a sample storage array and
one named sample, which is an AID input sample. Set
up a WATCH window to see the values of these variables
by entering the commands

va index
va sample

Press F5 to let the program run and press ESC to halt


it. You should end up inside an infmite for (j j) loop.
Single step the program and observe the values in the
WATCH window. Explain why index takes on the values
it does. Now press RUN=F5 and ESC alternately and
observe the variable values.
Congratulations! You have now "learned to crawl."
You will gradually learn more about the hardware and
software as needed to perform the experiments and will
be an expert acrobat by the end of the semester. One
additional suggestion is that you should browse through
the Table of Contents to see what the other experiments
involve.
2

Learning to Use the Hardware and Software


Tools by Generating a Sine Wave

The goal of this experiment is to learn how to use the include the labels as symbols in the .obj file which is
hardware and software tools available at each setup. useful for debugging.
The software tools include C compilers for the PC and Next copy the linker command file, c30. cmd, listed
TMS320C30, the C30 assembler and linker, and the TI C below to your working directory from the directory
source debugger for interfacing with the DSP board. The C:\UTIL.DSP. Linker command files are used to defme
hardware includes the TMS320C30 floating point DSP how relocatable program sections are mapped into the
and the Analog Interface Chip (AIC) on the Evaluation physical system memory. They can also contain assem-
Module (EVM). These tools will be explored by generat- bler options and lists of object programs to be included in
ing a sine wave using three different methods. the output modules. Additional object modules can also
be included on the linker command line. The modules
are loaded in the order in which they appear in the com-
2.1. Some Basic Utility Files, Programs, mand line list of .cmd and .obj files. Command files are
and Environment Variables Required convenient for saving definitions and operations that will
by the TMS320C30 Assembler, be ordinarily used when linking programs for a particular
C Compiler, and Linker project.
Before writing programs to generate the sine wave, The second program you should create is one for han-
you should create an assembly language program, two C dling the interrupts. Copy the dummy interrupt handler
C program ints. c listed below to your working direc-
programs, a C header file, and a linker command file that
tory from the directory C: \ UTIL.DSP. When an interrupt
will be used throughout this class. These can all be copied
from the directory C:\UTIL.DSP to your working direc- is enabled and an interrupt function is required, you will
have to replace the corresponding empty function with
tory. The first program, vectors. asm, is listed below. It
one that performs the required operations. The TI C-
defines the interrupt vectors required by the TMS320C30.
compiler recognizes that functions with names of the form
After copying the .asm file to your working directory, as-
semble it by using the command c_intnn 0, where nn represents a two digit decimal num-
ber, are interrupt service routines and includes the required
asm30 -sl vectors.asm entry code for saving internal registers that are modified
by the function and the exit code for restoring the regis-
(The second symbol in "sl" is a lower case L.) The ters and returning from an interrupt. You are responsible
assembler will create a relocatable object file named for setting and clearing specific interrupt masks in your
vectors. obj. The -sl option causes the assembler to program. The compiler prefixes each function name with

13
14 Chapter 2

Program 2.1 vectors.asm

.length 54
.title "C30 Interrupt Vector Table"

File: vectors.asm
Assemble with: asm30 -sl vectors.asm

.global RESET,INTO,INT1,INT2,INT3
.global XINTO,RINTO,XINT1,RINT1,TINTO,TINT1,DINT
.global _c_intOO,_c_int01,_c_int02,_c_int03,_c_int04
.global _c_int05,_c_int06,_c_int07,_c_int08
.global _c_int09,_c_int10,_c_int11

.sect "vectors" Linker will locate at address 0


RESET .word c intOO RESET vector
INTO .word c int01 INTO vector
INT1 .word c int02 INTi vector
INT2 .word c int03 INT2 vector
INT3 .word _c_int04 INT3 vector
XINTO .word c int05 Serial port o XMT
RINTO .word c int06 Serial port o RCV
XINTi .word c int07 Serial port 1 XMT
RINTi .word c int08 Serial port 1 RCV
TINTO .word _c_int09 Timer 0 interrupt
TINTi .word c int10 Timer 1 interrupt
DINT .word c int11 DMA counter interrupt
. space 20 Reserved space (don't use)
. space 32 Trap vector locations
. end

an underscore so that the assembler entry point labels for command SET. The options should be
the interrupt routines have the form _c_intnn.
The next step is to compile the program ints. c. COPTION= -gs -mm -asl -iC:\C.DSP -iC:\UTIL.DSP
The compiler shell program is called c130. The general There should be no space between the Nand =. This vari-
format for invoking c130 is able should have already been automatically set by the
c130 [-compiler options] [filenames] AUTOEXEC.BAT file when you turned on your com-
[-z [link options]] puter. The options specified by COPTION are treated
by c130 as if they appear as compiler options on the
See Section 2.1 of the TMS320 Floating-Point DSP Op- c130 command line. These options will normally be used
timizing C Compiler User's Guide for details. This shell throughout the course and have the following meanings:
can compile, assemble, and link programs. The entry
[filenames] is a list of source filenames. Filenames -g Enable symbolic debugging which is used by the
that have no extension are automatically considered to EVM30 C-Source Debugger
have the .c extension and to be C source code. Filenames -s Interlist C and asm source statements
with the .asm extension are considered to be assembly
language source code and are assembled. Everything to -mm Use MPYI for integer multiplication. This causes
the right of the -z option applies only to the linker. a 24 x 24 bit hardware integer multiplication on
Before compiling ints . c, check that the C_OPTION the C30 rather than a 32 x 32 bit multiplication
environment variable is set properly by entering the DOS involving software.
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 15

Program 2.2 Linker Command File c30.cmd

/************************************************************************/
/* c30.cmd COMMAND FILE FOR LINKING C30 C PROGRAMS */
/* */
/* Usage: lnk30 c30.cmd <obj files ... > -0 <out file> -m <map file> */
/************************************************************************/

-c /* Use the ROM autoinitialization */


/* model for C programs */
-stack Ox80 /* 128 word STACK (can be changed) */
-heap Ox400 /* 1K HEAP (can be changed) */
-i c:\c.dsp /* Directory for libraries */
-1 rts30.lib /* Run-time C library */

vectors.obj /* Load interrupt vectors */


ints.obj /* Load interrupt handlers */

/* SPECIFY THE SYSTEM MEMORY MAP */

MEMORY
{
VECS: org 0 len Ox40 /* Interrupt vectors */
SRAM: org Ox40 len Ox3fcO /* rest of 16K C30 EVM RAM */
IRAM: org Ox809800 len Ox800 /* Internal RAM (2K) */
}

/* SPECIFY THE SECTION ALLOCATION INTO MEMORY

SECTIONS
{
vectors: > VECS /* INTERRUPT VECTOR TABLE */
.text: > SRAM /* PROGRAM CODE */
.cinit: > SRAM /* INITIALIZATION TABLES */
.const: > IRAM /* CONSTANTS */
.data: > I RAM /* INITIALIZED DATA (FROM .ASM ONLY) */
.stack: > IRAM /* SYSTEM STACK */
.bss: > IRAM /* VARIABLES */
.sysmem: > SRAM /* MEMORY DYNAMICALLY ALLOCATED BY C */
/* FUNCTIONS (HEAP). DELETE IF NOT USED*/
}
16 Chapter 2

Program 2.3 Program ints.c

/**********************************************************************
* Dummy Interrupt Handlers *
* File name: ints.c *
* Compile with normal optimization: *
* cl30 -mn ints.c *
***********************************************************************/
void c_intOl0 /* INTO */
{
}
void c_int020 /* INTl */
{
}
void c_int030 /* INT2 */
{
}
void c_int040 /* INT3 */
{
}
void c_int050 /* Serial port 0 XMT */
{
}
void c_int060 /* Serial port 0 RCV */
{
}
void c_int070 /* Serial port 1 XMT */
{
}
void c_intOBO /* Serial port 1 RCV */
{
}
void c_int090 /* Timer 0 */
{
}
void c_intl00 /* Timer 1 */
{
}
void c_intll0 /* DMA */
{
}
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 17

-asl Make the assembler keep labels as symbols and cre- Useful C callable functions such as pO_xmi to for
ate an assembly listing file. setting and interfacing with the serial ports, DMA con-
troller, timers, and CPU and DMA interrupt facilities
-\ Add these directories to the path c130 searches for are located in the directory C:\UTIL.DSP. These are de-
#include files scribed in Appendix B of the TMS320Cx DSP Design
Workshop Student Guide and in somewhat more detail in
Now compile ints. c by using the command C:\UTIL.DSP\README.DOC.
The function pO_ini to should already be set up
c130 -ron ints.c
to configure serial port 0 with the parameters required by
(The second character in "cl30" is a lower case L.) The this experiment. If your program does not work properly,
-mn option tells the compiler to use normal optimization. or if you wish to change the configuration, or if you want
This step will create the object file ints. obj. to see the source code, you can extract pO_ini t. c from
You will have to write C and assembly language the archive file serial. src with the TI archiver utility
programs to accomplish the tasks required by the ex- program ar30. exe. The command required to extract
periments. As a preliminary step in each of these pro- pO_ini t. c to your current directory is
grams, you wi\l have to initialize the TMS320C30 and
Analog Interface Chip (AIC). The header file aic.h and ar30 -x C:\UTIL.DSP\serial.src pO_init.c
C program c30start. c listed below show how to do this
and can be used as the starting point for your programs. This command copies the desired program from the ar-
Copy them to your working directory from C: \ UTIL.DSP. chive file to your current directory but leaves the orig-
This program sets the TMS320C30 primary and expan- inal program in the archive. You can then modify the
sion bus wait states to 0, turns on the instruction cache, function, recompile it, and link the resulting object file
initializes Timer 0 to provide a 7.5 MHz clock to the with your program. Please do not change the files in the
AIC, initializes Serial Port 0, and configures the AIC. It UTIL.DSP directory. Of course, you can extract and view
uses functions from the libraries in C: \ UTIL.DSP. These the source code for any of the utility programs by using
are explained briefly below and are fully documented in ar30. exe. A detailed description of the archiver can be
README.DOC in C:\UTIL.DSP. found in Chapter 7 of TMS320 Floating-Point DSP As-
Having generated these utility programs, you wi\l sembly Language Tools.
now go on to learn more about the lab hardware and C:\UTIL.DSP contains C callable functions in TIM-
software by generating a sine wave several ways. ERS.LIB for interfacing with the two timers in the TMS-
320C30. The function to_ini to sets the Timer 0 Glo-
bal Control Register and is configured to set Timer 0 as
required for this experiment. It sets the output pin TCL-
2.2. Method 1 for Generating a Sine Wave
KO to be the timer output, puts the timer in pulse mode,
As a first approach, write a C program that uses the and sets the GO bit to 1. This clears the timer Counter
C library function sinO to generate the samples of a 2- Register, which then starts counting from O. The function
kHz sine wave at an 8-kHz sampling rate. Give your to_period(n) sets the Timer 0 Period Register to the
program the .c extension. You can use the program on value n. The function to_reset 0 just sets the GO bit
page 16-35 of the TMS320C3x DSP Design Workshop in the Timer 0 Global Control Register to 1, so you can use
manual as a guide. In this approach, the AIC acts as this function to clear the Counter Register and restart the
the master and provides the 8-kHz sampling frequency to counting from 0 when desired. The following sequence
the TMS320C30 serial port. The sine wave samples are can be followed to make Timer 0 generate a 7.5 MHz
loaded into the TMS320C30 Serial Port 0 Transmit Data clock for the AIC:
Register by the function pO_xmi t (j), which waits for
the XRDY flag in the Serial-Port Global-Control Register
to_init() /* Set Timer ° Global Control
Register; pulse mode */
to indicate that the Transmit Data Register is empty. This
to_period(1) /* Frequency =
approach is called "polling" the flag.
f(H1)/(2*n) = 15 MHz/2
In a more complicated application, you could have
the C30 perform additional tasks that were guaranteed to
= 7.5 MHz */
be completed before the next sample has to be loaded into Include the appropriate header files from the set {bus.
the serial port transmit register and then use pO_xmi t (j) h, serial.h, dma.h, timers.h} at the beginning of your C
to wait the remaining time and transmit the next sample program when you use the functions in UTIL.DSP. The
when XRDY gets set. compiler shell needs to know where to find the #include
18 Chapter 2

Program 2.4 aic.h

1**************************************************************************1
1* AIC.H *1
1**************************************************************************1
1*------------------------------------------------------------------------*1
1* AIC VOLTAGE INPUT CONTROL MACROS *1
1*------------------------------------------------------------------------*1
#define THREE_V 1
#define ONEp5_V 2
1*----------------------------------------------------------------------*1
#define OFF 0
#define ON 1
1*======================================================================*1
1* STRUCTURES *1
1*======================================================================*1
1* AIC COMMAND WORD BITFIELD ENCODING STRUCTURES *1
1*======================================================================*1
typedef struct
{
unsigned int command :2; 1* COMMAND BITS --- SHOULD BE SET TO 00*1
unsigned int ra :5; 1* RECEIVE COUNTER A LOAD VALUE *1
unsigned int d_78 :2; 1* UNUSED - DON'T CARE *1
unsigned int ta : 5; 1* TRANSMIT COUNTER A LOAD VALUE *1
unsigned int d_ef : 2; 1* UNUSED - DON'T CARE *1
} AIC_COMMAND_O;

typedef struct
{
unsigned int command :2; 1* COMMAND BITS --- SHOULD BE SET TO 01*1
signed int ra_prime :6; 1* RECEIVE COUNTER DELTA A' LOAD VALUE *1
unsigned int d_8 : 1; 1* UNUSED - DON'T CARE *1
signed int ta_prime :6; 1* RECEIVE COUNTER DELTA A' LOAD VALUE *1
unsigned int d_f : 1; 1* UNUSED - DON'T CARE *1
} AIC_COMMAND_1;

typedef struct
{
unsigned int command : 2; 1* COMMAND BITS --- SHOULD BE SET TO 10*1
unsigned int rb :6; 1* RECEIVE COUNTER B LOAD VALUE *1
unsigned int d_8 : 1; 1* UNUSED - DON'T CARE *1
unsigned int tb :6; 1* TRANSMIT COUNTER B LOAD VALUE *1
unsigned int d_f : 1; 1* UNUSED - DON'T CARE *1
} AIC_COMMAND_2;
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 19

Program 2.4 (continued)

typedef struct
{
unsigned int command :2; /* COMMAND BITS --- SHOULD BE SET TO 11*/
unsigned int highpass : 1; /* HIGHPASS FILTER ENABLE */
unsigned int loopback : 1; /* LOOPBACK TEST ENABLE */
unsigned int aux : 1; /* AUX INPUT ENABLE */
unsigned int sync : 1; /* SYNCHRONOUS TRANSMIT/RECEIVE ENABLE */
unsigned int gain :2; /* GAIN SELECTION BITS */
unsigned int d_8 : 1; /* UNUSED - DON'T CARE */
unsigned int sinx : 1; /* SINX/X CORRECTION FILTER ENABLE */
unsigned int d_abcdef : 1; /* UNUSED - DON'T CARE */
} AIC_COMMAND_3;

/*----------------------------------------------------------------------*/
/* AIC CONTROL VARIABLES */
°
/*----------------------------------------------------------------------*/
AIC_COMMAND_O aic_command_O; /* AIC COMMAND WORD */
AIC_COMMAND_l aic_command_l; /* AIC COMMAND WORD 1 */
AIC_COMMAND_2 aic_command_2; /* AIC COMMAND WORD 2 */
AIC_COMMAND_3 aic_command_3; /* AIC COMMAND WORD 3 */
/*----------------------------------------------------------------------*/

files. If they are not in the current directory, c130 first The search sequence for this form is:
looks for these files in the directories specified by the -i
compiler options. It next searches the path specified by 1. Directories specified by the -i compiler options
the environment variable C-DIR. The required path for 2. Directories specified by the C-DIR environment vari-
the periperal control headers should have already been able
set by the AUTOEXEC.BAT file when you turned on
the computer. The command line that does this sets the The current directory is not searched with the angle
COPTION environment variable as described on page bracket form.
14. Also add the following line, after the -i line you
The #inc1 ude directive has two forms and the previously created, to c30. cmd to inform the linker where
search path is slightly different for each. Let FILENAME to find the library files:
be the name of an #inc1ude file. One form is the double -i C: \UTIL. DSP
quote form:
For each set of functions you use, add a -I line to c30. cmd
#inc1ude "FILENAME" to make the linker search that library for unresolved ref-
erences. For example, if functions from bus.lib and se-
The search sequence for this form is:
rial.lib are used, add the lines:
1. The current directory
-1 bus.lib
2. Directories specified by the -i compiler options -1 serial.lib

Your program should do the following:


3. Directories specified by the CDIR environment vari-
1. Set the TMS320C30 primary and expansion bus
able
wait states to 0 and tum on the cache.
The other is the angle bracket form: The EVM has 16K 32-bit words of SRAM, which
can run with 0 wait states, attached to the primary bus
#inc1ude <FILENAME> of the TMS320C30. The number of wait states generated
20 Chapter 2

Program 2.5 c30start.c

/* PROGRAM C30START.C

/* This program provides a framework for writing TMS320C30 C Programs. */

/*========================================================================*/
/* These header files can be found in C:\UTIL.DSP */
/*========================================================================*/
#include "bus.h"
#include "serial.h"
#include "timers.h"
#include "aic.h" /* MACROS and STRUCTURES for AIC */
/*========================================================================*/
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
void init_c30bus(void);
void init_aic(void);

/*========================================================================*/
/* INIT_C30BUS(): INITIALIZE TMS320C30 BUS WAIT STATES AND TURN ON CACHE */
/* Uses functions from C:\UTIL.DSP\BUS.LIB */
/*========================================================================*/
void init_c30bus(void)
{
pri_wait(O); 1* 0 wait states on primary bus
exp_wait(O); /* 0 wait states on expansion bus
cache_onO; /* enable instruction cache
}
/*========================================================================*/
/* INIT_AIC(): INITIALIZE TMS320C30 TIMER 0 AND SERIAL PORT 0 FOR */
/* COMMUNICATION WITH AIC. INITIALIZE AIC PARAMETERS. */
/* NOTE: i IS A VOLATILE TO FORCE TIME DELAYS AND TO FORCE */
/* READS OF SERIAL PORT DATA RECEIVE REGISTER TO CLEAR */
/* THE RECEIVE INTERRUPT FLAG */
/*========================================================================*/
void init_aic(void)
{
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 21

Program 2.5 (continued)

volatile int i;
/*--------------------------------------------------------------------*/
/* SET AIC CONFIGURATION CHIP */
/* 1. ALLOW 8 KHZ SAMPLING RATE AND 3.6 KHZ ANTIALIASING FILTER */
/* GIVEN A 7.5 MHZ MCLK TO THE AIC FROM A 30 MHZ TMS320C30 */
/* 2. ENABLE A/D HIGHPASS FILTER */
/* 3. SET SYNCHRONOUS TRANSMIT AND RECEIVE */
/* 4. ENABLE SINX/X D/A CORRECTION FILTER */
/* 5. SET AIC FOR +/- 1.5 V INPUT */
/*--------------------------------------------------------------------*/
aic_command_O.command 0; /* SETUP AIC COMMAND WORD ZERO */
aic command_O.ra 13; /* ADJUST SAMPLING RATE TO 8 kHz */
aic command_O.ta 13; /* AND 3.6 kHz ANTIALIAS FILTER */
aic_command_1.command 1; /* SETUP DEFAULT AIC COMMAND WORD 1 */
aic_command_1.ra_prime 1;
aic_command_1.ta_prime 1;
aic_command_1.d_f 0;
aic_command_2.command 2; /* SETUP DEFAULT AIC COMMAND WORD 2 */
aic command_2.rb 36;
aic command_2.tb 36;
aic command_3.command 3; /* SETUP DEFAULT AIC COMMAND WORD 3 */
aic_command_3.highpass ON; /* TURN ON INPUT HIGHPASS FILTER */
aic_command_3.loopback OFF; /* DISABLE AIC LOOPBACK */
aic_command_3.aux OFF; /* DISABLE AUX INPUT
aic_command_3.sync ON; /* ENABLE SYNCHRONOUS A/D AND D/A */
ONEp5_V; /* SET FOR 1.5 v p-p INPUT */
/* USE THREE_V for 3 v p-p INPUT */
aic command 3.sinx ON; /* ENABLE SIN x/x CORRECTION FILTER */
/*--------------------------------------------------------------------*/
/* CONFIGURE TIMER °
TO ACT AS AIC MCLK
/* THE TIMER IS CONFIGURED IN THE FOLLOWING WAY
*/

°
*/
/* 1. THE TIMER'S VALUE DRIVES AN ACTIVE-HIGH TCLK PIN */
/* 2. THE TIMER IS RESET AND ENABLED */
/* 3. THE TIMER IS IN PULSE MODE */
/* 4. THE TIMER HAS A PERIOD OF TWO INSTRUCTION CYCLES */
/*--------------------------------------------------------------------*/
to_period(1) ; /* In C:\UTIL.DSP\TIMERS.LIB
to_initO; /* In C:\UTIL.DSP\TIMERS.LIB
22 Chapter 2

Program 2.5 (continued)

/*--------------------------------------------------------------------*/
/* CONFIGURE SERIAL PORT 0 */
/* 1. EXTERNAL FSX, FSR, CLKX, CLKR */
/* 2. VARIABLE DATA RATE TRANSMIT AND RECEIVE */
/* 3. HANDSHAKE DISABLED */
4. ACTIVE HIGH DATA AND CLK
5. ACTIVE LOW FSX,FSR
6. 16 BIT TRANSMIT AND RECEIVE WORD
7. TRANSMIT INTERRUPT
8. RECEIVE INTERRUPT ENABLED/RECEIVE
9. FSX, FSR, CLKX, CLKR, OX, DR CONFIGURED AS SERIAL
PORT PINS
/*--------------------------------------------------------------------*/

/* In C:\UTIL.DSP\SERIAL.LIB. Initializes */
/* Serial Port °
to the above state */

asm(" LDI 2,IOF"); /* RESET AIC BY PULLING XFO ACTIVE-LOW

for(i = 0; i < 50; i++); /* KEEP RESET LOW FOR SOME PERIOD OF TIME */

/* In C:\UTIL.DSP\SERIAL.LIB. Reset and */


/* start Serial Port 0. */
pO_transmit(O); /* In C:\UTIL.DSP\SERIAL.LIB. Load Serial*/
/* Port ° transmitter with °
using non- */
/* polling function to make sure first */
/* word sent to AIC is not a command. */

asm(" LDI 6,IOF"); /* PULL AIC OUT OF RESET

/*--------------------------------------------------------------------*/
/* MODIFY AIC CONFIGURATION */
/*--------------------------------------------------------------------*/

/* In C:\UTIL.DSP\SERIAL.LIB. Notify AIC */


/* that next word will be a command. */
pO_xmit(*((int *) &aic_command_O)); /* Init TA and RA registers. */

/* Note: aic_command_1 and 2 are set to the correct values when the */
/* AIC is reset since they are the default AIC reset values. */

pO_xmit(3); /* Notify AIC next word is a command. */


pO_xmit(*((int *) &aic_command_3)); /* Init AIC control register */
}
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 23

Program 2.5 (continued)

/*========================================================================*/

void main(void)
{

/*------------------------------------------------------------------------*/
/* Declare variables here. In the TI C compiler, all variables must be */
/* declared at the beginning of a function before they are used and */
/* before any executable statements. Variables may be initialized in the */
/* declaration statements. */
/*------------------------------------------------------------------------*/

gie_clearO; /* In C:\UTIL.DSP\BUS.LIB. Disable */


/* interrupts by clearing GIE bit. */
clear_intsO; /* In C:\UTIL.DSP\BUS.LIB. Clear all flags*/
in interrupt flag (IF) register.
°
/* */
init_c30busO; /* Set bus wait states and enable cache. */

/*------------------------------------------------------------------------*/
/* Initialize arrays and variables before starting the AIC so there is */
/* no delay after the AIC is turned on. They can be initialized here */
/* or in the declaration section. */
/*------------------------------------------------------------------------*/
init_aic(); /* Set up Timer 0, initialize Serial Port */
/* 0, start AIC and set its parameters */

/*------------------------------------------------------------------------*/
/* Now all the mundane and tedious initialization tasks have been */
/* completed. At this point put in your C program for accomplishing */
/* the tasks required by the experiments. Good luck and have fun! */
/*------------------------------------------------------------------------*/
}

by the TMS320C30 can be software selected from 0 to external memory with wait states is used. Enable the
7 by the value loaded into the 3-bit WTCNT field in the cache by the function call cache _on 0 .
Primary-Bus Control Register. The default value at reset 2. Configure the C30 Timer 0 to be the AIC MCLK
is 7, which is the maximum. The number of wait states by setting it in the following way:
can be set to 0 by the C statement
(a) The timer's value drives an active-high TCLK 0 pin
pri_wait(O)
(b) Reset and enable the timer
where pri_wait(int n) is a function in C:\UTIL.
DSP\bus.lib. (c) Put the timer in pulse mode
The expension bus is connected to a single data trans- (d) Set the timer period to two instruction cycles
fer register connected to the PC bus and can also run with
o wait states. Use the function exp_wait(O) to set the 3. Configure the C30 Serial Port 0 as follows:
expansion bus wait states to O.
(a) External FSX, FSR, CLKX, CLKR
The TMS320C30 has a 64-word instruction cache
which can speed up program execution, particularly when (b) Variable transmit and receive data rate
24 Chapter 2

(c) Handshake disabled Whenever you want to halt the program press
(d) Active high data and CLK ESCAPE
(e) Active low FSX and FSR If you want to continue the program from where it halted
enter
(t) 16 bit transmit and receive word
run or FS
(g) Enable transmit interrupt XINT and receive interrupt
RINT To restart the program from the begining, first halt it and
then enter the commands
(h) Configure FSX, FSR, CLKX, CLKR, DX, DR as
serial port pins restart and run

4. Initialize the AIC for the following conditions: Sometimes this may not work, due to peculiarities of the
EVM. If this happens, halt the program and then enter the
(a) 8 kHz sampling rate and 3.6 kHz antialiasing filter command sequence
cutoff given a 7.5 MHz MCLK to the AIC from the
C30 reset, restart, run

(b) Enable the AID highpass filter If this fails, reload the program and begin again. See
the TMS320C3x C Source Debugger User's Guide for a
(c) Set synchronous transmit and receive mode complete description of all the commands and capabilities
of EVM30.EXE.
(d) Enable the sin xix D/A correction filter
To check that your program is running properly, at-
(e) Set AIC for +1- 1.S V input tach the DIA output to an oscilloscope and observe the
waveform. Estimate the frequency of the sine wave by
S. Generate and transmit the 2 kHz sine wave sam- measuring its period.
ples to the DIA converter using an endless loop. The sinO Next, use the signal generator to measure the fre-
function generates floating point numbers so you have to quency of the sine wave. Set the EXT-INT switch to
scale them and convert them to 16 bit integers. The two EXT. Attach the EVM DIA converter output to the EXT
Isb's must be 0 so the AIC recognizes these words as data COUNTER input jack. Set the resolution to 2.0000 kHz
samples and not command words. Generate the angle for by selecting the Gate Setting of lOS using the GATE push-
the sinO function recursively. Each sample, increment the button switch.
angle by Once you have completed the above tasks, go back
and experiment with changing the frequency of the sine
woT = 211" fo/ fs = 211"2000/8000 = 11"/2 wave while keeping the sampling frequency fixed at 8
kHz. In particular, generate the samples of a 6-kHz sine
Reduce the incremented angle modulo 211" so it does not
wave and measure the frequency of the sine wave at the
grow without bound.
D/A converter output. Explain any discrepancies mathe-
Suppose your program is named sine. c. Compile
matically. (Hint: Look up "aliasing" in any of the refer-
and link it using the command
ences on digital signal processing.)
c130 sine -z c30.cmd -0 sine.out -m sine.map Note: The EVM output amplifier is connected to
the output jack through a series 220 J-Lf capacitor. If for
The options after -z are for the linker. some reason the capacitor becomes charged and the output
After successfully compiling and linking your pro- is open circuited or connected to a very high impedance
gram, download it to the EVM with the debugger by the like the oscilloscope input, you will observe a dc offset
command in the output signal. You can discharge the capacitor by
connecting a load - such as a speaker or several hundred
evm30 sine
ohm resistor-to the output. Do not short the output.
Reset the EVM using the debugger command
reset 2.3. Method 2 for Generating a Sine
Wave- Using Interrupts
and then run your program by pressing FS or entering
The serial port transmit register must be loaded after
run it becomes empty but before the word in the transmit shift
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 25

register is completely shifted out. A task like this, that interrupts can be serviced. If several enabled interrupts
requires immediate real-time attention, is called a fore- are pending, they are serviced in order of priority.
ground task. An application program often performs other You will find useful C callable interrupt utility pro-
tasks that can take an arbitrary amount of time and do not grams in C:\UTIL.DSP\BUS.LIB. These include func-
have to be synchronized with the foreground tasks. These tions to set and clear the GIE bit and individual bits in
are called background tasks. An effective way of integrat- the IE and IF registers. Actually, many of these functions
ing the foreground and background tasks is to have the are just a #def ine statement in bus. h that generates a
foreground tasks interrupt the background tasks for the single inline assembly instruction to set or clear the de-
short periods of time they require servicing. sired bit.
In this exercise, you will learn how to use the in- Modify your program for Method 1 to include a C
terrupt facility of the TMS320C30. Section 6.6 of the interrupt service routine for the Serial Port 0 Transmit
TMS320C3x User's Guide describes the interrupt sys- Interrupt that:
tem. Interrupts are also explained in Chapter 13 of the
TMS320C3x DSP Design Workshop Student Guide. The 1. Increments the angle by the amount 27rfo/fs where fo
interrupts are prioritized by the CPU according to Table is the frequency and Is is the sampling frequency of
6-4 in the TMS320C3x User's Guide. The TMS320C30 8 kHz
has both CPU and DMA interrupts. Only the CPU inter- 2. Reduces the new angle modulo 27r so it does not
rupts will be used in Method 2. grow without bound
In order for the Serial Port 0 transmitter to generate
a CPU interrupt, the following four conditions must be 3. Computes the sine of the angle using the C library
true: function sinO

I. The Global Interrupt Enable (GIE) bit must be set to 4. Converts the sample to an integer with the correct
1 in the C30 Status Register (ST). You must set this scaling for the AIC D/A converter
bit initially.
5. Loads the result into the Serial Port 0 Transmit Data
2. The Transmit Interrupt Enable (XINT) bit must be Register
set to 1 in the Serial Port 0 Global Control Regis-
The name of the interrupt service routine should be
ter. (You should already have done this when you
c_int05, so that the TI C compiler will automatically
initialized the C30 for Method 1.)
insert the appropriate context saving and restoring instruc-
3. The Enable Serial Port 0 Transmit Interrupt (EX- tions. You should modify the program ints. c which you
INTO) bit must be set to 1 in the CPU Interrupt En- already created to include this service routine and recom-
able Register (IE). This is bit 4 in the register. pile it. You might want to look at the assembly code the
compiler generates for the interrupt routine in the listing
4. When the Transmitter Shift Register (XSR) shifts out file.
its last bit, the Transmit Data Register (DXR) is au- You can use several approaches to compiling and
tomatically transferred into the XSR. The transmitter linking your program. Suppose the main program file is
interrupt occurs immediately following this transfer. called sine2. c. Three approaches are:
1. Merge ints . c into your main program file to cre-
Suppose no interrupts are pending. When an in- ate a single file called sine2. c. Remove the ints. obj
terrupt occurs, the corresponding bit is set in the Inter- line from c30. cmd. Then compile and link with the com-
rupt Flag Register (IF). See Table 3-4 in the TMS320C3x mand
Users's Guide. Bit 4 (XINTO) is the Serial Port 0 Trans-
mit Interrupt Flag. If the interrupt is enabled, the CPU c130 sine2 -z c30.cmd -0 sine2.out
services it by taking the following action. The GIE bit -m sine2.map
is automatically cleared so that no other interrupts can
be serviced and the CPU jumps to the routine pointed to 2. Leave sine2. c and ints. c as separate files. Be
by the corresponding interrupt vector. The interrupt flag sure to #include the required . h header files in each
bit is automatically cleared when the jump to the service
separate program file. Remove the ints. obj line from
routine occurs. The instructions in the service routine are c30 . cmd. Then compile and link with the command
performed and control is returned to the point where the
program was interrupted by an RETI instruction. The c130 sine2.c ints.c -z c30.cmd -0 sine2.out
RETI instruction automatically sets the GIE bit so more -m sine2.map
26 Chapter 2

3. Leave sine2. c and ints. c as separate files. Be • DMA Global-Control Register


sure to #include the required .h header files in each
program file. First compile ints. c with the command • DMA Source Address Register
• DMA Destination Address Register
cl30 -mn ints. c
• DMA Transfer Counter Register
as before. Leave the ints. obj line in c30. cmd. Then
compile sine2. c and link with the command After a DMA read, the source address is modified accord-
ing to the INCSRC and DECSRC bits, 4 and 5, respec-
c130 sine2.c -z -x c30.cmd -0 sine2.out tively, of the DMA Global-Control Register. The source
-m sine2.map address is incremented if INCSRC = 1 and DECSRC =
0, decremented if INCSRC = 0 and DECSRC = 1, and
unchanged if INCSRC = DECSRC.
The -x linker option forces the linker to search the li-
After the DMA write, the destination address is mod-
braries again for any unresolved references. Otherwise an
ified according to the INCDST and DECDST bits, 6 and
error message stating that _sin was not found will occur.
7, respectively, in the DMA Global-Control Register. The
Do not enable the interrupts before completing the
destination address is incremented if INCDST = 1 and
initialization of the TMS302C30 and the AIC. Otherwise,
DECDST = 0, decremented ifINCDST = 0 and DECDST
a signal sample might get written to the AIC during the
= 1, and unchanged if INCDST = DECDST. The DMA
interrupt routine instead of the desired command word.
Transfer Counter is decremented after every DMA write.
Enable the interrupts after completing the initialization
The DMA controller can be set to generate a CPU in-
and just before starting an infmite loop that the serial
terrupt when the DMA Transfer counter reaches O. When
port transmit register interrupts when it is empty.
bit 11, TCINT, of the DMA Global-Control Register is set
Check that the program works properly as you did
to 1, the DMA interrupt flag in the CPU Interrupt Flag
for Method 1.
Register is set when the DMA Transfer counter makes a
transition to O. In order to allow a CPU interrupt by the
DMA, bit 10, EDINT, in the CPUIDMA Interrupt Enable
2.4. Method 3 - DMA from a Table
Register must also be set to 1.
In Methods 1 and 2, the sine wave sample value is Bit 10, TC, of the DMA Global-Control Register
numerically computed using the sinO function. This can also affects transfer operations. When TC = 0, transfers
be time consuming. In many real-time applications, a set are not terminated when the transfer counter becomes o.
of tasks is repeated periodically, so the DSP has a limited When TC = 1, transfers are terminated when the counter
amount of time to perform each task and computational becomes zero.
efficiency is critical. An efficient method for generating Usually, when TCINT is set to 0, TC should also be
a sine-wave carrier signal in communication systems is to set to o. Otherwise, the DMA transfer will terminate when
read the sample values out of a precomputed table. In this the count becomes 0 and the CPU will not be notified.
exercise, you will learn how to read the samples from a When TCINT is 1, TC should usually also be 1 so the
table and load them into the Serial Port 0 Transmit Data CPU will be notified when the transfer is finished and the
Register by using the direct memory access (DMA) and DMA will be halted and ready to start a new transfer.
interrupt capabilities of the TMS320C30. Bits 8 and 9, SYNC, of the DMA Global-Control
The DMA system is described in Section 8.3 of the Register control when the DMA reads and writes occur.
TMS320C3x User's Guide and in Section 15.3 of the If SYNC = 00, DMA transfers occur as fast as possi-
TMS320C3x DSP Design Workshop Student Guide. Ex- ble. In the other three cases, transfers are synchronized to
amples showing how to use DMA can be found on pages selected interrupt sources. Table 8-11 in the TMS320C3x
90 and 93 of the manual Digital Signal Processing Ap- User's Guide lists the bits in the CPUIDMA Interrupt En-
plications with the TMS320C30 Evaluation Module, Se- able Register that enable the different interrupt sources.
lected Application Notes. The DMA controller performs If SYNC = 01, a DMA read is performed when an en-
input/output operations without interfering with CPU op- abled interrupt occurs, then the data just read is written
erations. A DMA transfer consists of two operations: (1) to the destination address, and the DMA controller goes
a read from a memory location, and (2) a write to a mem- back and waits for another interrupt before performing
ory location. Data can be read from and written to any another read. If SYNC = 10, a write is performed when
location in the TMS320C30 memory space, including all an enabled interrupt occurs, a read is performed, and the
of the memory mapped peripherals. The following four controller then waits for an enabled interrupt before an-
registers control the DMA operation: other write. If SYNC = 11, a read is performed when an
Learning to Use the Hardware and Software Tools by Generating a Sine Wave 27

enabled interrupt occurs and a write is performed when (a) Tum off and reset the DMA.
the next enabled interrupt occurs, etc.
C callable utility functions for the DMA are included (b) Set the source address to the start of the sinew ave
in C:\UTIL.DSP\DMA.LIB. They are described in the array.
README.DOC file in this directory and also Appendix B (c) Set the destination address to the serial port 0 Data
of the TMS320C3x DSP Design Workshop Student Guide. Transmit Register (DXR).
These functions are:
(d) Set the transfer count to 512.
• ini tdma(int *source, int *dest, int count, int incsrc,
int decsrc, int incdst, int decdst, syncdma sync, int (e) Increment the source address after a read.
tcint)
(t) Do not change the destination address after a write.
Initializes the source address, destination address,
transfer count, incrementing or decrementing of (g) Set SYNC so that a source read occurs on an enabled
source and destination addresses, synchronization interrupt.
mode, and enabling or disabling of the generation
of an interrupt when the count reaches O. It also sets (h) Set TCINT to 1 so the DMA sets the DMA interrupt
the START bits to 00 so the DMA is stopped and flag in the IF register when the transfer count reaches
reset. It sets TC to 0 for continuous operation if the O.
transfer count is greater than 0, and sets TC to I if
(i) Clear TC to 0 for continuous mode.
the count is less than or equal to 0 so the DMA stops
when the count reaches O. 5. Initialize Timer 0, serial port 0, and the AIC as
• dmastart 0 Starts or restarts DMA operation before.
6. Set bit 20 (EXINTO) of the IE register to en-
• dmaha1 to Halts DMA operation able the serial port 0 transmitter to interrupt the DMA
controller when the serial port transfers a word from its
• dmastatus 0 Returns the DMA status
DXR register to its serial shift register (XSR) and sets the
To use these functions, include dma. h at the begin- transmitter ready flag (XRDY).
ning of your program and add the line 7. Set bit 10 (EDINT) in the IE register to enable
the DMA controller to set the DMA interrupt flag to the
-1 dma.lib
CPU in the IF register when the transfer count reaches o.
to c30. cmd to tell the linker to search this library for 8. Discard any pending interrupts by clearing the IF
unresolved references. register.
To learn how to use the DMA controller, you will 9. Enable interrupts by setting GIE.
generate a I-kHz sine wave from samples taken at an 8- 10. Start the DMA controller.
kHz rate using a C program for the TMS320C30. Write 11. Go into an infinte loop which will be interrupted
a program to do the following in the order listed: by the DMA interrupts.
1. Set the bus wait states to 0 and tum on the in- C program segment 2.6 shows how you can perform
struction cache. these steps using the functions in the C: \ UTIL.DSP di-
2. Disable all CPU interrupts by clearing the GIE rectory.
bit. Also clear the Interrupt Enable (IE) and Interrupt Write an interrupt service routine c_int 11 0 to han-
Flags (IF) registers. These registers should automatically dle the CPU interrupts that occur when the DMA Transfer
be cleared when the TMS320C30 is hardware reset. Counter Register reaches o. This routine should reset the
3. Generate an array containing samples of 64 cy- Transfer Counter value to 512, reset the source address
cles of a I-kHz sine wave taken at the 8-kHz sampling to the start of the sine wave array, and restart the DMA
rate. This array will contain 512 = 8 x 64 samples. The controller by setting the START bits in the DMA Global-
samples should be scaled and converted to integers ap- Control Register to 11 after first setting them to 00.
propriate for the AIC DfA converter. The ideal samples Check that your program is operating properly by
to convert to integers for the array should be observing the DfA output on the oscilloscope.
x(n) = sin(2rrnlOOO/8000) for n = 0, ... ,511
4. Initialize the DMA controller according to the
following list. You can use the ini tdma function to do
this.
28 Chapter 2

Program 2.6 Generating a Sine Wave by DMA From a Table

int y[512];

int tableO
{
extern int y [] ;
int n;
for(n=0;n<=511;n++) {
yEn] = 200.0*sin(2.*PI*n*1000/8000);
yEn] «= 2;
}
}
mainO
{
extern int y[];
pri_wait(O); °
1* wait states on primary bus *1
exp_wait(O); °
1* wait states on expension bus *1
cache_onO; 1* Enable instruction cache *1
gie_clearO; 1* Clear GIE *1
clear_intsO; 1* Clear IF *1
table 0 ; 1* Generate sine wave table *1
initdma(&y[O],(int *)Ox808048,512,1,0,0,0,SOURCE,1);
init_aicO;
xintO_dma_enable(); 1* Enable DMA to be interrupted *1

dint_enable 0 ;
°
1* by serial port XRDY flag *1
1* Enable CPU to be interrupted *1
1* when DMA word count reaches 0*1
clear_intsO; 1* Clear IF *1
gie_setO; 1* Set GIE *1
dmastartO; 1* Start DMA transfers
fore;;);
}
3

Digital Filters

The major goal of this experiment is to learn how to imple- According to (3.1), the output is
ment using real-time hardware the discrete-time filtering
L
00

techniques usually presented in a typical required Elec- y[n] h[k]GejwCn-k)T


trical Engineering undergraduate course on signals and k=-oo
sytems and a Senior elective course on digital signal pro-
L
00

cessing. Discrete-time filtering is often called digital fil- Ge jwnT h[k]e- jwkT
tering. In the process, you will learn more about the k=-oo
TMS320C30 and the EVM. x[n]H(z)!z=e jWT (3.3)
Thus, the output is a sinusoid at the same frequency as
3.1. Discrete-Time Convolution the input but with its amplitude scaled by the complex
and Frequency Responses number
H*(w) = H(z)!z=ejWT (3.4)
The output y[n] of a linear, time-invariant, discrete-
time system (LTI) can be computed by convolving its in- The function H*(w) is called the frequency response of
put x[n] with its unit pulse response h[n]. The equation the system. The function A(w) = !H*(w)! is called the
for this discrete-time convolution is amplitude response of the system and (J(w) = arg H*(w)
is called its phase response. Notice that all of these re-

L L sponses are periodic as functions of w with period w s =


00 00

y[n] = .'r[k]h[n - k] = h[k]x[n - k] (3.1) 27rIT. In polar form


k=-oo k=-oo
H*(w) = A(w)e jIiCw ) (3.5)
The z-transform of a discrete-time convolution is the prod-
uct of the transforms, that is, so, according to (3.3), the output can be expressed as
y[n] = GA(w)ej[wnT+liCw)] (3.6)
L
00

Y(z) = y[n]z-n = X(z)H(z) (3.2) When the input is the real sinusoid
n=-(X)

x[n] G cos(wnT + 1»
The response of an LTI system to a sinusoid after the
Re{ Ge j </> e·iwnT }
transients have become negligible is called its sinusoidal
steady-state response. To determine this response, let the the ouput is
input be the sampled complex sinusoid
y[n] Re{ H* (w )Ge j </> ejwnT }
x[n] = Ge jwnT GA(w) cos[wnT + (J(w) + 1>]
29
30 Chapter 3

In other words, the system scales the magnitude of the x[n] h[Q] y[n]
sinusoidal input by the amplitude response and shifts its ----....--------*+l-----
phase by the phase response. This is the basis for digital
filtering.

3.2. Finite Duration Impulse


h[l]
Response (FIR) Filters
3.2.1. Block Diagram for
Most Common Realization

If the unit pulse response is identically zero outside h[2]


the set of integers {O, 1, ... , N - I}, the convolution (3.1)
becomes
N-l
y[n] L h[k]x[n - k] h[N-2]

n
L x[k]h[n - k] (3.7)
k=n-N+l

A filter of this type is called an N-tap finite duration im-


h[N-l]
pulse response (FIR) filter, nonrecursive filter, transver-
sal filter, or moving average filter. A block diagram for
the most common method of implementing FIR filters is Figure 3.1. Type 1 direct fonn realization.
shown in Fig. 3.1. It consists of a delay line represented
by the chain of blocks labelled z-l and a set of taps into
the delay line with weights equal to the unit pulse response from the IEEE Press book, Programs for Digital Signal
samples. Processing [II.C.5] and modified to make it more user
The block diagram of an FIR shown in Fig. 3.1 could friendly. The program presents a selection of seven differ-
represent the physical layout of a hardware implementa- ent window types. The Hamming window (3) and Kaiser
tion or just the structure of a software algorithm. In a window (6) are the ones you will most likely find best.
software implementation, the delay line would just be an Five different filter types are available: (1) lowpass, (2)
array in memory. Entering a new sample into an array highpass, (3) bandpass, (4) bandstop, and (5) bandpass
by shifting the entire array is inefficient. In the exer- Hilbert transform. To use this program, first copy it to
cises described below, you will learn how to implement your working directory and then type WINDOW. As an ex-
the "shift register" by forming a circular array using the ample of how to use the program, suppose the sampling
C mod operator (%) and the hardware circular addressing rate is 8 kHz, and a 21-tap bandpass filter with a lower
capabilities of the TMS320C30. cutoff frequency of 1 kHz and an upper cutoff frequency
of 3 kHz is desired using the Hamming window. The
program screen output and typical responses are shown
3.2.2. Two Methods for Finding the Filter below. The text written by the program is in capital let-
Coefficients to Achieve a Desired ters and the user responses are shown in lower case letters
Frequency Response but they can be entered as either capital or lower case let-
ters. The lower case functions after window types 3, 4,
Two programs for designing digital filters are in- and 5 are displayed by the program.
cluded in the directory C:\DIGFIL. Both methods design
filters with exactly linear phase, which is a reason FIR ENTER NAME OF LISTING FILE: junk. 1st
filters are sometimes preferred over IIR filters. ENTER FILENAME FOR COEFFICIENTS: junk. cot
Historically, the first method for designing digital fil- ENTER SAMPLING FREQUENCY IN HZ: 8000
ters was the Fourier series and window function method. WINDOW TYPES
(See [II.C.14, Chapter 8] for the theory.) The program 1 RECTANGULAR WINDOW
WINDOW.EXE implements this method. It was taken 2 TRIANGULAR WINDOW
Digital Filters 31

3 HAMMING WINDOW Use of REMEZ87 will be demonstrated by an ex-


0.54 + 0.46 cos (theta) ample. Suppose the sampling rate is 8 kHz and a 21-tap
4 GENERALIZED HAMMING bandpass filter with a passband extending from 1000 to
WINDOW alpha + (i-alpha) 3000 Hz is desired. Using the conventions of this pro-
cos (theta) gram, three bands must be specified. They are: (1) a
5 HANNING WINDOW 0.5 lower stopband, (2) the passband, and (3) an upper stop-
+ 0.5 cos (theta) band. Let the lower stopband edges extend from 0 to 500
6 KAISER (IO-SINH) WINDOW Hz, the passband edges extend from 1000 to 3000 Hz,
7 CHEBYSHEV WINDOW and the upper stopband edges extend from 3500 to 4000
Hz. Values must be specified for the amplitude in each of
FILTER TYPES the bands. Let the values in the two stopbands be 0 and
1 LOWPASS FILTER the value in the passband be 1. Also, weights for each
2 HIGHPASS FILTER band must be specified. The weight values scale the er-
3 BANDPASS FILTER ror in each band. Since the algorithm generates an equal
4 BANDSTOP FILTER ripple weighted error, larger weights result in bands with
5 BANDPASS HILBERT smaller unweighted ripple. For this example let the bands
TRANSFORM be equally weighted with the value 1.
REMEZ87 uses a variable GRID DENSITY to deter-
ENTER FILTER LENGTH, WINDOW TYPE, mine the frequency increment for computing the frequency
FILTER TYPE: 21,3,3 response error, with larger numbers corresponding to more
SPECIFY LOWER, UPPER CUTOFF closely spaced frequencies. Values in the range of 16 to
IN HZ: 1000,3000 32 seem to work well with little difference observed in
the results. The smaller number requires less computation
CREATE (FREQUENCY, RESPONSE) and uses smaller arrays. The program computes the fre-
FILE (Y OR N)? Y quency response of the resulting filter and asks the user to
ENTER FILENAME: junk.dat enter the lower and upper frequency limits to use for the
LINEAR (L) OR DB (D) SCALE ?: d response. Program screen prompts are in capital letters.
User responses can be in either upper or lower case. The
The LISTING FILE is where the number of taps, fil- prompts and responses for this example are shown below.
ter type, window type, sampling frequency, and filter coef-
ficients are written. The FILENAME FOR COEFFICIENTS ENTER LISTING FILENAME: junk. 1st
has one entry per line. The first line is the number of coef- ENTER COEFFICIENT STORAGE FILENAME: junk.cof
ficients. The remaining lines are the coefficients in order LINEAR OR DB AMPLITUDE SCALE
of increasing index and in floating point format. This file FOR PLOTS? (L OR D): d
is useful for using the coefficients in another program. ENTER SAMPLING FREQUENCY (HZ): 8000
The (FREQ, RESPONSE) file is a listing of the amplitude ENTER START AND STOP FREQUENCIES
response of the filter on a linear or dB scale. Each line IN HZ FOR RESPONSE CALCULATION
contains a pair of numbers consisting of the frequency and (FSTART , FSTOP): 0,4000
corresponding amplitude response. The frequency incre-
ment is automatically selected to show the ripples in the FILTER TYPES AVAILABLE:
amplitude response. If the program GRAPHER is going 1 MULTIPLE PASSBAND/STOPBAND FILTER
to be used to plot the response, this file should be given 2 DIFFERENTIATOR
the extension DAT. 3 HILBERT TRANSFORM
The second program for designing digital filters is
REMEZ87.EXE. It is a modified version of the program ENTER: FILTER LENGTH, TYPE, NO.
in the IEEE book, Programs for Digital Signal Process- OF BANDS, GRID DENSITY: 21,1,3,32
ing. The program was developed by J. McClellan and T. ENTER THE BAND EDGES (FREQUENCIES IN HERTZ)
Parks, who were at Rice University at the time. It uses 0,500,1000,3000,3500,4000
the Remez algorithm to design filters that are optimum SPECIAL USER DEFINED AMPLITUDE
in the Chebyshev sense, i.e., the maximum absolute er- RESPONSE(Y/N)? n
ror is minimized and causes the error to be equal ripple. SPECIAL USER DEFINED WEIGHTING
The program can design (1) multiple passband/stopband FUNCTION(Y/N)? n
filters, (2) differentiators, and (3) Hilbert transform filters.
32 Chapter 3

ENTER (SEPARATED BY COMMAS): array index filter coefficient circular buffer


1. VALUE FOR EACH BAND FOR MULTIPLE array hr array xcirc
PASS/STOP BAND FILTERS
2. SLOPES FOR DIFFERENTIATOR
(GAIN = Ki*f -> SLOPE = Ki
°
1
h[N - 1]
h[N - 2]
x[n - oldest + 1]
x[n - oldest + 2]

WHERE Ki = SLOPE OF i-TH BAND,


f IN HERTZ) x[n - 1]
3. MAGNITUDE OF DESIRED VALUE newest x[n]
FOR HILBERT TRANSFORM oldest x[n - N + 1]
0,1,0 x[n - N + 2]
ENTER WEIGHT FOR EACH BAND. (FOR
A DIFFERENTIATOR THE WEIGHT
FUNCTION GENERATED BY THE N-2 h[l] x[n - oldest - 1]
PROGRAM FOR THE i th N-l h[O] x[ n - oldest]
BAND IS WT(i)/f WHERE WT(i) IS
THE ENTERED BAND WEIGHT AND Figure 3.2. Contents of coefficient array and circular buffer.
f IS IN HERTZ.)
1,1,1 (3.1) becomes
STARTING REMEZ ITERATIONS n

DEVIATION . 159436E-03 y[n] :r[k]h[n - k]


k=n-(N-l)
x[n - (N - l)]h[N - 1] + ...
+ x[n - l]h[l] + x [n] h[O] (3.8)
CALCULATING IMPULSE RESPONSE
Note that the oldest input sample x[n - (N - 1)] is mul-
CALCULATING FREQUENCY RESPONSE tiplied by the impulse response sample h[N - 1] with the
largest index and the newest sample x[ n] is multiplied by
CREATE (FREQ,RESPONSE) FILE the impulse response sample h[O] with the smallest in-
(Y OR N)? Y dex. This equation is shown schematically in Fig. 3.1,
ENTER FILENAME: junk.dat where the N required signal samples are shown stored in
a delay line. In a software implementation, the delay line
The files requested by REMEZ87 are essentially the represents an array in memory. Entering the newest sam-
same as for WINDOW. However, the LISTING file con- ple into the "delay line" by shifting the elements in the
tains more information, such as the frequencies where the entire array is inefficient for a software implementation
peak errors occur, a frequency response listing in linear and a better approach is to use circular buffers. Circu-
and dB form, and a crude plot of the response used in the lar buffers can be implemented in C by using the mod
days when only line printers without graphics capabilities operator %. The TMS320C30 has hardware support that
were available. can be accessed by assembler instructions to implement
REMEZ87 asks if you want a SPECIAL USER DE- circular buffers even more efficiently.
FINED AMPLITUDE RESPONSE or a SPECIAL USER The concept of a circular buffer is illustrated in
DEFINED WEIGHTING FUNCTION. You can write Fig. 3.2. The filter coefficients are stored in the N el-
your own special subroutines for a special desired am- ement array hr in reverse order, i.e., hr[k] = h[N - 1 -
plitude response and/or weighting function and link them k] for k = 0, ... , N - l.
into the main program. No special functions are included A variable, oldest, points to the location in the cir-
in this version of the program. cular buffer array that contains the oldest shift register
sample. When a new sample is received at time n, it is
written over the sample at location oldest. In a physical
3.2.3. Using Circular Buffers to implementation using a shift register, this sample would
Implement FIR Filters be shifted out of the end of the shift register when the
new one is shifted in. Next, the variable oldest must be
For an N-tap FIR filter with coefficients nonzero only incremented modulo N to point to the new oldest sam-
for indices in the set {O, ... , N - I}, the convolution sum ple. Notice that when oldest initially has the value N -
Digital Filters 33

1, it becomes 0 when incremented modulo N. Thus, data Because of the way the hardware implements the
circular addressing, the beginning address of the circular
samples are written into the array in a circular fashion.
Finally, the filter output can be calculated as buffer array must start at an address that is a multiple
of the smallest power of 2 strictly greater than the filter
N-l
y[n] = L length N. In other words, suppose the binary representa-
hr[k]xcirc[(oldest + k) mod N] (3.9) tion of N with no leading O's requires B bits. Then the B
k=O lsb's of the buffer start address must be O. This can be
accomplished by using the name of the circular array as
Circular Buffers Using C the label for a section and then the linker can be used to
align the section on the correct boundary. For example,
A segment of a C program for implementing the FIR
suppose the circular buffer is named xcirc as above and
filter with a circular buffer is shown below.
that N = 32. The smallest power of 2 greater than N is Nb
= 64 so the start of xcirc must be aligned on a multiple
Program 3.1 C Program Segment for an
of 64. The assembly language program should contain a
FIR Filter with Circular Buffer
statement like
mainO .usect circbuf 32
xcirc II II ,
{
To align the start of the section on an address that is a
multiple of 64, the linker command file should contain a
line in the SECTIONS portion similar to
xcirc[oldest] = newsample;
/* Put new sample in circbuf: >IRAM, align 64
delay line. */
oldest = (oldest + 1) % N; Data samples in the circular buffer are indirectly ad-
/* Circularly increment dressed through one of the auxiliary registers using post-
input pointer. */ displacement add or subtract with circular modification.
y = 0; The selected auxiliarly register should be initialized with
for (k = 0; k < N; k++) the address of the start of the circular buffer. The post-
/* Compute convolution sum. */ displacement add source address has the form
y += hr[k]*xcirc[(oldest + k) % N];
*ARn++%

and the post-displacement subtract source address has the


form
}
*ARn--%
The variable, oldest, must be incremented rather than
decremented modulo N because the C mod operator % The forms shown above increment or decrement by I cir-
does not do what is desired for negative integers. It does cularly. More general forms with and arbitrary displace-
not add multiples of N to a negative integer to make it ment or an index register also exist. (See pages 5-6 and
fall in the set {O, ... , N - I}, but leaves it as a congruent 5-7 of the TMS320C3x User's Guide.)
negative number which will not be an index into the array. An outline of the assembly code for an N = 32 tap
FIR filter is shown below. It can be called from a C pro-
Circular Buffers Using the gram that simply initializes the EVM and it never returns
TMS320C30 Hardware to C. (A slightly more complicated assembly language
function that is called from and returns to C is presented
The TMS320C30 includes special hardware for do- in Section 3.2.4.) The coefficient array, hr, and data sam-
ing circular addressing. Unlike the C mod operator, the ple circular buffer, xcirc, are assumed to be organized
addresses can be either incremented or decremented cir- as shown in Fig. 3.2.
cularly modulo the buffer block size. See Section 5.3 of Notice how the addresses ofthe coefficient and circu-
the TMS320C3x Users's Guide. Let N be the number of lar buffer arrays are loaded into ARO and ARI. They are
filter taps, which is also the circular buffer block size. first put into memory locations xcirc_addr and hr _addr
The TMS320C30 contains a block size register named by . word statements. Then they are loaded into the ap-
BK and N must be loaded into this register. propriate auxiliary registers by the direct addressing mode
34 Chapter 3

Program 3.2 FIR Filter Using Circular Buffers with Assembly Language

PROGRAM FIR.ASM for N = 32

REGISTER USE
ARO Address of filter coefficient
ARi Address of data sample at filter coefficient
BK Circular buffer block size = N = 32
RO Result of product of single tap and data values
R2 Accumulator for convolution sum (filter output)
R3 New data sample x[n] from serial port 0 receiver put in R3

CONSTANTS
N .set 32 Number of filter taps
RCi .set N-2 Repeat count for convolution loop

PUT THE CIRCULAR BUFFER IN A NAMED SECTION AND USE THE LINKER TO ALIGN
IT ON AN ADDRESS THAT IS A MULTIPLE OF THE SMALLEST POWER OF 2 GREATER
THAN N BY A STATEMENT IN THE LINKER COMMAND FILE OF THE FORM
circbuf: > I RAM , align 64

xcirc .usect " circbuf " , N

PUT THE FILTER COEFFICIENTS IN THE .data SECTION AND INCLUDE THE
FOLLOWING STATEMENT IN THE LINKER COMMAND FILE
.data: > IRAM

PUTTING THE DATA SAMPLES AND COEFFICIENTS IN INTERNAL RAM MAKES THE
PROGRAM RUN FASTER .

. data
hr . float Put value of hr [0] = h [N-i] here.
. float Put value of hr[1] = h [N-2] here.

. float Put value of hr [N-i] = h [0] here.

SET UP WORDS THAT CONTAIN THE 24-BIT ADDRESSES OF THE FIRST WORDS IN
THE ARRAYS hr AND xcirc .

. word hr
xcirc addr .word xcirc
Digital Filters 35

Program 3.2 (continued)

.text
.global _fir ; Make the function entry point accessible to C
fir LDI N, BK ;Load the circular buffer block size
LDP @809800h ;Data page for internal ram block
LDI @xcirc_addr, AR1 ;Initialize the pointer to "oldest"
XOR R2, R2 ;O->R2 so 1st word sent to AIC is
;all zero and not an AIC command
PUSH AR1 ;Save "oldest" on the stack

;************* START OF THE MAIN CONVOLUTION LOOP **********

convol LDI ;Point to start of coefficient array

,----------------------------------------------------------------------
The timing for this digital filter will be synchronized to the
serial port 0 data transmit ready flag (XRDY). First poll the XRDY
flag and when it is set to 1, load the previously computed filter
output stored in R2 into the serial port data transmit register
(DXR).
Next, take the sample from the serial port data receive register
(DRR) and put it in R3. Since the AIC has been configured for the
synchronous mode, a received sample will always be available after
a transmit sample has been taken and it can be read without polling
the RRDY flag. Shift the received sample up 16 bits to get rid of
junk and put the sign bit in the msb. Then shift it right 18 bits
to extend the sign bit and get rid of the two 0 lsb's from the AIC.
Convert the resulting integer to floating point and leave it in R3.
Use the FLOAT instruction to convert the integer to floating point.
The following information will help you with the above tasks.
1. Address of Serial Port 0 Global Control Register = 808040h
Bit 1 of the Global Control Register is the XRDY flag.
2. Address of Serial Port 0 Data Transmit Register (DXR) = 808048h
3. Address of Serial Port 0 Data Receive Register (DRR) = 80804ch
4. You can test the XRDY flag by first loading the Global Control
Register into a CPU register, for example, R7 with an LDI
instruction and then testing with the instruction: TSTB 2,R7 .
;---------------------------------------------------------------------

POP AR1 ;Get "oldest"


STF R3, *AR1++% ;Put x[n] in circular buffer and inc "oldest"
PUSH AR1 ;Save new value of "oldest" on stack

INITIALIZE RO WITH FIRST PRODUCT

MPYF3 *ARO++,*AR1++%,RO h[N-1]*x[n-(N-1)] -> RO


36 Chapter 3

Program 3.2 (continued)

INITIALIZE R2 (CONVOLUTION SUM)

LDF 0.0, R2 0.0 -> R2

PERFORM REMAINING N-i PRODUCTS

RPTS RCi ;Set up the repeat count


Note: The next instruction is repeated RC+i = N-i times. The
instruction consists of the two lines and is called a
parallel instruction by TI.

MPYF3 *ARO++,*ARi++%,RO h[N-i-k]*x[n-(N-i)+k] -> RO


II ADDF3 RO,R2,R2 Add product for previous iteration
to previous sum and store in R2

ADD THE LAST PRODUCT TO THE CONVOLUTION SUM

ADDF RO,R2

NOW R2 CONTAINS THE FILTER OUTPUT SAMPLE

Convert the output sample (R2) to an integer, make its two lsb's °
so it is not an AIC command. Use the FIX instruction to convert from
floating point to integer format. Then branch back to "convol" to
process another received sample.

which is signified by the @ prefix. This is necessary be- times faster than the C version. However, a large assem-
cause addresses are 24 bits and there are no immediate bly language program is considered by most people to be
addressing instructions with 24-bit constant fields except more difficult to write and maintain than one written in a
for branching instructions. higher level language.
A good compromise, when execution time is not ab-
solutely critical, is to use C to control the overall pro-
3.2.4. How to Make an Assembly Language gram flow and do simple, quick functions, but to call
Convolution Function that Is Called hand coded assembly language functions to perform the
from and Returns to C numerically intensive computations like the convolution
sum for an FIR digital filter. Details about how to call
It is usually necessary to carefully hand code an en- assembly language functions from C can be found in the
tire program in assembly language to gain the fastest ex- TMS320C3x DSP Design Workshop Student Guide and
ecution speed. This is because a higher level language the TMS320 Floating-Point DSP Optimizing C Compiler,
like C requires some overhead to satisfy standard con- Users's Guide. A simple method for implementing a con-
ventions of the particular compiler for calling functions, volution sum by an assembly language function without
passing variables, stack management, etc. More impor- passing any arguments is explained in this subsection.
tantly, in number-crunching applications like FIR digital An N = 31 tap FIR filter is implemented by the ex-
filters, the TI C compiler does not make use of the spe- ample in this section. Again, assume that the filter co-
cial TMS320C30 hardware functions like circular auxil- efficients and circular buffer for the data samples are or-
iary register incrementing and the parallel multiply and ganized as in Program 3.2. The function that performs
accumulate capability. You will fmd in the experiments the convolution sum is called convolO in C so the entry
you will be asked to perform that the assembly language point label must be _convol in the assembly language
version of an FIR filter using a circular buffer is about 40 function. Also, the C program should contain the decla-
Digital Filters 37

ration ; .cinit section


.word M ;Declare the
extern float convol(); ;number of constants
Let the circular buffer be called xcirc [ ] in the C ;that follow
program so that it must be called _xcirc in the assembly .word CONST ;The memory location
language function. It is declared in the C program as ;where the M word
;block starts
extern float xcirc[N]; . word Co ;The first constant
.word c) ;The second constant
The hardware circular buffer must be aligned on an
address that is a multiple of 32, which is the smallest
power of 2 greater than N = 31. Just as before, this
can be accomplished by putting the circular buffer into a .word CM-) ;The M-th constant
named section by a statement in the assembly language
function of the form
When C calls the assembly language function, the DP
xcirc .usect "circbuf", 31
register contains the page of the . bss section. Therefore,
This section is aligned on an address that is a multiple of the constant Cj can be accessed in the assembly program
32 by including the following statement in the SECTIONS by using direct addressing to read the location at offset j
portion of the linker command file from CONST. For example,

circbuf: >IRAM, align 32 LDI @CONST+j, RO


immediately after the statement
loads the constant Cj into RO. In particular, the . cini t
.bss >IRAM record for the coefficient and circular buffer base ad-
dresses is built in the following assembly language pro-
The supervisory functions are included in the C pro- gram CONVOL.ASM by the statements:
gram. Therefore, the filter coefficient array hr [N] is de-
clared and initialized in the C program. The variable, .bss ADDRESSES, 2
oldest, is also declared and circularly incremented in the ;Reserve 2 words
C program since the incrementing operation takes place
just once per sample. Words containing the base addresses .sect ".cinit"
of the coefficient array and circular buffer must be acces- .word 2
sible to the assembly language function. One method for ;2 words must be initialized
accomplishing this was described on page 38 for the com- . word ADDRESSES
pletely assembly language FIR filter implementation. An- ;Start of place to copy
other method is to make C load these values into known ; constants
memory locations in the . bss section with its autoini- .word _hr
tialization routine. This requires building an initialization ;base address of coefficient
record in the . cini t section. More generally, suppose ; array
M words are to be autoinitialized. The first step is to .word xcirc
reserve space for the constants in the. bss section by an ;base address of circular
assembly statement of the form ; buffer
.bss CONST, M
The assembly language convolution function must
where CONST is a label of your choosing, whose value return its result to C. The TI C compiler convention is
becomes the address of the start of the memory block of that a called function places an integer, pointer, or float
M words. Next, an initialization record of the following return value in register RO.
form must be created: The incomplete C program FIRCASM.C and com-
plete assembly language function CONVOL.ASM that
follow are examples of how to use the techniques just
.sect ".cinit" ;Put the following presented. The source code for CONVOL.ASM can be
;lines in the found in the directory C:\UTIL.DSP.
38 Chapter 3

Program 3.3 Segment of a C Program for a 31-Tap FIR Filter

/**************************************************************************/
/* Program FIRCASM.C */
/* This is a partial listing of the C portion of a 31-tap FIR filter */
/* program. It calls the assembly language function CONVOL.ASM to */
/* perform the convolution sum using a circular buffer.
/**************************************************************************/

/**************************************************************************/
/* Include required header files and C functions here. */
/**************************************************************************/

#define N 31 /* Number of filter taps */


float hr [N] = /* Declaration and
{h[N - 1], ... , h[N - 2], ... , h[O]}; */
/* initialization of reversed coefficient array */
extern float xcirc[N]; /* Circular buffer for samples */
extern float convol(); /* Declare asm function
int oldest = 0; /* Declare and initialize oldest
float y; /* Output from convolution sum
int iy = 0; /* Integer output for AIC

mainO
{
/*************************************************************************/
/* First initialize the TMS320C30 as before. Then clear the xcirc[] */
/* array and initialize any other variables. Next initialize the AIC as */
/* before using a 4 kHz sampling rate. */
1***************************************************** ********************/
while (1)
{
pO_xmit(iy); /* Transmit previous filter output using polling. */
xcirc[oldest] = pO_receive() « 16 »18; /* Get new input */
/* sample without polling. Eliminate garbage and extend */
/* sign bit. Convert to float and put in circular buffer. */
oldest = (oldest+1) % N; /* Increment pointer to oldest sample.*/
y = convol(); /* Compute new filter output. */
iy = y; /* Convert output to integer. */
iy «= 2; /* Make 2 lsb's 0 for AIC. */
}
/*************************************************************************/
}
Digital Filters 39

Program 3.4 Assembly Language Function for 31-Tap Convolution

PROGRAM CONVOL.ASM

Assembly language function to perform 31-term convolution sum


using a circular buffer.

This function is called from C and returns its result to C. No


local frame is needed and no arguments are passed, so no runtime
stack management is required by this assembly function.

REGISTER USE
ARO Pointer to filter coefficients
AR1 Pointer to circular buffer sample at coefficient
BK Circular buffer block size = N = 31
RO Result of single tap x data value; return total sum to C
R2 Accumulator for products

CONSTANTS
N .set 31 Number of filter taps
RC1 .set N-2 Repeat count for sum of products loop

Put the circular buffer in a named section and use the linker to align
it on an address that is a multiple of the the smallest power of 2
greater than N by a statement in the linker command file of the form:

circbuf: >IRAM, align 32

immediately after the linker command file statement

.bss > IRAM

xcirc .usect "circbuf", N

.global _oldest,_hr,_xcirc ; Global access to addresses

Set up record for C initialization routine

.bss ADDRESSES, 2 Reserve two words for addresses

.sect ".cinit" Put following in .cinit section


.word 2 Number of words to initialize
.word ADDRESSES Place to copy following 2 words
.word _hr Base address of filter coefficients
.word xcirc Base address of circular buffer
40 Chapter 3

Program 3.4 (continued)

Now begin convolution function instructions

.text
. global _convol Make entry point available to C.

convol LDI N,BK Set circular buffer block size.


LDF O.O,R2 Clear convolution sum.
LDI @ADDRESSES+O,ARO Make ARO point to hr[O].
LDI @ADDRESSES+i,ARi Make ARi point to xcirc[O].
ADDI @_oldest,ARi Make ARi point to xcirc[oldest].
MPYF3 *ARO++,*ARi++%,RO ; Put hr[O]*xcirc[oldest] in RO.

RPTS RCi ; Repeat next instruction RCi+i times.


MPYF3 *ARO++,*ARi++%,RO ; put hr[i]*xcirc[(oldest+i)%N] in RO.
II ADDF3 RO,R2,R2 Accumulate previous product in R2.

ADDF3 RO,R2,RO Add final product to R2 and return


result to C in RO.
RETS Return to C
. END

3.3. Infinite Duration Impulse


Response (IIR) Filters
A filter with an impulse response, h(n), that has in- N
fmite duration is known as an IIR filter. When h(n) is the = X(z) L bkz- k (3.12)
sum of damped exponentials, its z-transform, H(z), which k=O
is also called its transfer function, is a rational function of
z. That is, it is the ratio of two finite degree polynomials. Taking all except the Y(z) term to the right-hand side
We will use a rational function of the form yields
bo + b1z- + b2z- + ... + bNz-
1 2 N
H(z) = 1 + alz- 1 + a2z-2 + ... + aMz- M Y(z)
N
= L bkX(z)z-k -
M
L akY(z)z-k (3.13)
B(z) k=O k=l
(3.10)
A(z)
The time domain equivalent is the difference equation

3.3.1. Realizations for IIR Filters N M

Rational transfer functions can be realized in many


y[n] = L bkx[n - k] - L aky[n - k] (3.14)
k=O k=l
ways. Three common realizations will be described be-
low. The first realization will be called a type 0 direct This equation shows how to compute the current fil-
form. The ratio of the z-transforms of the filter output ter output from the current and N past inputs and M past
and input is outputs. A filter implemented in this way is also called
a recursive filter since past outputs are used to calculate
Y(z) = H(z) = B(z) (3.11 ) the current output. It is called a direct form because the
X(z) A(z) coefficients in the transfer function appear directly in the
Cross multiplying gives difference equation.
Another realization which we will call a type 1 di-
Y(z)A(z) = X(z)B(z) or rect form is based on observing that (3.11) can be rear-
Digital Filters 41

x[n] y[n]

~L-_A_~Z_) ----lHL-_B_(Z_) ----l~

Figure 3.3. First step in finding type I


direct form realization.

ranged into the cascade fonn

y(z) = ~i:? B(z) = V(z)B(z) (3.15)

where
1
V(z) = X(z) A(z) (3.16)

This is illustrated in Fig. 3.3.


The intennediate signal v[ n] can be computed using
the direct fonn 0 realization
M Figure 3.4. Type 1 direct form realization.
v[n] = x[n] - L akv[n - k] (3.17)
k=l the resulting filter is a cascade (product) of sections, each
Then, the output can be computed as with a second-order numerator and denominator with the
leading constant tenns nonnalized to 1, possibly a first-
N
order section nonnalized in the same way, and an overall
y[n] = L bkv[n - k] (3.18) scale factor. These second-order sections are also know
k=O as biquads. The sections can be realized by any of the
A block diagram for these equations is shown in Fig. 3.4, three direct fonns described above, or by other structures
where it is assumed that M = N. This fonn requires less that can be found in DSP books. Care must be taken to
storage than the type 0 direct fonn. prevent overflows and underflows when digital filters are
Another realization called the type 2 direct form implemented with fixed point DSP's. This problem is re-
can be found by rearranging (3.12). For simplicity, let M duced significantly with floating point DSP's. Sometimes
= N. Then the overall scale factor generated by IIR is quite small and
to maintain numerical accuracy it should be split among
N
the different sections.
Y(z) boX(z) + L[bkX(z) An example of how to use IIR is shown below. The
k=l
program prompts are shown in upper case letters and the
akY(z)]z-k (3.19) user responses in lower case letters or numbers. In this
example, a bandpass filter is designed based on an elliptic
A block diagram for this realization is shown in Fig. 3.5.
analog prototype filter. The nominal lower stopband ex-
It requires essentially the same storage and arithmetic as
tends from 0 to 600 Hz, the passband extends from 1000
direct fonn 1.
to 2000 Hz, and the upper stopband extends from 3000 to
4000 Hz. The questions and answers are explained more
3.3.2. A Program for Designing IIR Filters fully after the dialog.

The program, C:\DIGFIL\IIR.EXE, designs IIR SAVE RESULTS IN A FILE (Y OR N): y


filters by using the bilinear transfonnation [II.C.l4, pp. ENTER LISTING FILENAME: junk. 1st
212-219] with a Butterworth, Chebyshev, inverse Cheby- ENTER 1 FOR ANALOG, 2 FOR DIGITAL: 2
shev, or elliptic analog prototype filter. It can design low- ENTER SAMPLING RATE IN HZ: 8000
pass, highpass, bandpass, or bandstop filters. The fonn of ENTER NUMBER OF FREQS TO DISPLAY: 100
42 Chapter 3

n
which are equally spaced over the range of frequencies
selected. You are then prompted for the type of analog
prototype filter desired and the frequency selectivity type
of the digital filter. In the case of a bandpass (BP) filter,
four critical frequencies, FI < F2 < F3 < F4, must be
entered. The frequency FI is the upper edge of the lower
stopband, F2 is the lower edge of the passband, F3 is
the upper edge of the passband, and F4 is the lower edge
of the upper stopband. In the case of an elliptic filter,
you are then prompted for the desired maximum pass-
band ripple and the minimum stopband attenuation. The
program then computes the order of the required analog
lowpass prototype filter, which in this example is 4. The
actual order of the digital filter is double this number for
bandpass and band reject filters. The user is given the
option of choosing the filter order or letting IIR choose
the order for some of the other prototype filters. Finally
you are prompted for the types of frequency response files
you wish to generate, which can then be plotted with your
favorite graphing program.
The RESULTS file for this example is shown below.
Figure 3.5. Type 2 direct fonn realization.
First, the z-plane zeros and poles are displayed in rect-
angular form. Then they are shown in polar form. The
radius is the magnitude of the pole or zero and the fre-
ENTER STARTING FREQUENCY IN HZ: 0 quency isls()/(27f) where () is the angle andls is the sam-
ENTER STOPPING FREQUENCY IN HZ: 4000 pling frequency. Note that, for this bandpass filter, the
ENTER 1 FOR BW, 2 FOR CHEBY, 3 FOR ICHEBY, zeros are all exactly on the unit circle with frequencies in
4 FOR ELLIPTIC: 4 the stop bands. The pole frequencies are in the passband.
ENTER 1 FOR LOWPASS, 2 FOR HP, The coefficients of the numerators and denominators
3 FOR BP, OR 4 FOR BR: 3 of the second-order sections are given and they can be
ENTER F1,F2,F3,F4 FOR BP OR realized by the direct forms. It is shown in many DSP
BR FREQS: 600,1000,2000,3000 books that it is computationally better to realize an IIR
ENTER PASSBAND RIPPLE AND STOPBAND filter by splitting it into low-order sections rather than by
ATTENUATION IN +DB: 0.2,40 one high-order section.
ELLIPTIC FILTER ORDER = 4 Finally, the amplitude response on a linear scale, the
amplitude response on a dB scale, the phase response, and
CREATE FREQ, LINEAR GAIN the envelope delay are listed for the chosen range. This
FILE (Y,N)? n data also appears in separate files if selected in the dialog.
CREATE FREQ, DB GAIN FILE
(Y,N)? Y
3.3.3. Two Methods for Measuring
ENTER FILENAME: junkdb.dat
CREATE FREQ, PHASE FILE a Phase Response
(Y,N)? n You will be asked to measure the phase response of
CREATE FREQ, DELAY FILE an IIR filter in the laboratory experiments below. Two
(Y,N)? Y methods for measuring phase differences, (1) Lissajous
ENTER FILENAME: JUNKDEL.DAT figures and (2) relative time delays, are explained in this
section. Suppose the input to a system is
The first line of the dialog asks if you want to save
the results in in a disk file. If the answer is Y or y, you x(t) = A sin wot (3.20)
are prompted for the name of a file. If the answer is N
or n, the results appear on the screen (usually too fast to and the output is
be read). The program computes the frequency response
of the designed filter at the number of points specified y{t) = Bsin{wot + ()) (3.21)
Digital Filters 43

DIGITAL BANDPASS ELLIPTIC FILTER

FILTER ORDER = 8
Z PLANE

ZEROS POLES

.977149 +- j .212554 .173365 +- j .761580


.902015 +- j .431705 -.028463 +- j .919833
-.538154 +- j .842847 .683010 +- j .651915
-.873779 +- j .486323 .482595 +- j .656484

RADIUS FREQUENCY RADIUS FREQUENCY

.100000E+01 . 272712E+03 . 781063E+00 . 171502E+04


.100000E+01 . 568352E+03 . 920273E+00 .203939E+04
.100000E+01 . 272351E+04 . 944190E+00 . 970348E+03
.100000E+01 . 335335E+04 . 814782E+00 .119288E+04

4 CASCADE STAGES, EACH OF THE FORM:

F(z) (1 + B1*z**(-1) + B2*z**(-2) ) / ( 1 + A1*z**(-1) + A2*z**(-2) )

B1 B2 A1 A2
-1.954298 1.000000 -.346731 .610059
-1.804029 1.000000 .056927 .846903
1.076307 1.000000 -1. 366019 .891495
1.747559 1.000000 -.965191 .663870

SCALE FACTOR FOR UNITY GAIN IN PASSBAND: 1.8000479016654E-002

FREQUENCY RESPONSE

FREQUENCY GAIN GAIN (dB) PHASE DELAY (SEC)

.0000 2.1048E-03 -5. 3536E+01 .00000 . 13458E-03


40.0000 2.0557E-03 -5. 3741E+01 -.03385 . 13493E-03
80.0000 1.9093E-03 -5.4382E+01 -.06789 . 13600E-03
120.0000 1.6681E-03 -5.5556E+01 -.10228 . 13780E-03
44 Chapter 3

Measuring Phase Differences frequency responses. Execution time of a program is cru-


by Lissajous Figures cial in real-time signal processing and you willieam how
to use the EVM30 benchmarking facility to measure the
If x(t) is applied to the horizontal input of an oscillo-
time required by your programs to process an input sam-
scope and yet) is applied to the vertical input, the ellipse
ple. Before getting to the experiments, some details about
the EVM analog 110 characteristics and how to set the
2 (~) (~) cos() Ale sampling rate and filter parameters are presented.

+ . 2()
( -X)2 = SIn (3.22)
A
3.4.1. Some Hardware and Software
will be observed. If () = 0 the ellipse degenerates into a
Details for the EVM
straight line with positive slope, if () = n it becomes a line
with negative slope, and if () = n/2 or 3n/2 its principal The EVM hardware and software details described
axes become aligned with the x and y axes. in this section should help you design and explain your
From (3.20), it can be seen that the maximum value digital filter experiments.
for x is X max = A. The ellipse crosses the x-axis when y
= 0 or wot + () = n. The corresponding value for x is
The AIC AID and DIA Word Formats
Xo = Asin(n - ()) = Asin() (3.23)
The Ale AID and DIA converters are 14 bit convert-
Thus
ers. However, 16 bit words are sent to and received from
~ = sin() (3.24)
Xmax the Ale. The two least significant bits of the 16 bit data
and so samples received from the Ale are always o. The two
() . -1 Xo least significant bits of the words sent to the Ale contain
=Sln -- (3.25)
Xmax control information. During normal operation, these bits
A similar equation can be derived for y measurements. should be 00. To reconfigure the Ale these bits are set to
11, which causes the Ale to request the transmission of a
Measuring Phase Differences second control word. The meaning of the secondary word
by Relative Time Delay is specified by its two least significant bits as described
in Table 3.2.
You may find it difficult to accurately measure X max When a sample is read from the serial port data-
and Xo using the oscilloscope and also to determine what receive register, the lower 16 bits contain the Ale sample
value to use for the arcsine. An alternative method for and the upper 16 bits are garbage. The new sample should
fmding the phase difference is to measure the time delay be corrected by first shifting it left 16 bits to put the Ale
between the positive zero crossings of x(t) and yet). The sample's sign bit in the sign bit of the TMS320C30 32
output can also be expressed as bit integer word. Then the result can be arithmetically
shifted right 18 bits to extend the sign bit and eliminate
y(t) B sin[wo(t - d)]
the two O's in the least significant bits of the Ale sample.
B sin(wot + 0) (3.26) Suppose the data-receive register has been read into the
C integer variable sample. Then the required correction
where
d can be accomplished by the following C statement:
() = wod = 2n - radians (3.27)
To
sample = sample « 16 » 18
Therefore, the phase difference can be easily found by
multipling the relative time delay by the frequency. When
using this method, make sure the oscilloscope traces for Gain Characteristics of
x(t) and yet) are synchronized to the same time reference. the EVM and AIC

The EVM and Ale amplifiers introduce the gains


3.4. Hardware Details and Laboratory
shown in the following list.
Experiments for FIR and
IIR Digital Filters
1. There is an analog buffer amplifier between the EVM
In these experiments you will design and implement ReA audio input connector and the Ale input. This
FIR and IIR bandpass digital filters and measure their amplifier has a gain of 2
Digital Filters 45

2. There is an analog buffer amplifier between the AIC are considered to be unsigned binary integers. The values
0/A output and the RCA audio output connector on of these registers must satisy the following constraints:
the EVM. This amplifier has a gain of 4 with output
loads of more than 16 ohms 1. 1 < TA :::; 31, I < RA :::; 31

3. The AIC has an internal gain of 2 when it is con- 2. 1 < TB :::; 63, 1 < RB :::; 63
figured so that its AID converter is fully loaded with 3. -32 :::; TA' :::; 31, -32 :::; RA' :::; 31
± 1.5 V inputs. The AIC internal gain is 1 when it
is configured for ±3 V peak inputs 4. TA ± TA' > 1, RA ± RA' > 1

Note: The gain through the analog path of the Each sampling period, the two least significant bits
EVM may differ significantly from the values stated above of the sample received from the TMS320C30 direct the
which were taken from the EVM manual. Take the actual AIC to form receive and transmit A's according to Tables
gain of your EVM into account in your experiments. 3.1 and 3.2, and these are loaded into the transmit and
receive A counters. TB and RB are also loaded into the
DC Offset in the EVM transmit and receive B counters each sample. In each of
the four cases, the 14 most significant bits of the received
Audio Output Signal
sample are sent to the OfA converter in the AIC.
The EVM output amplifier is connected to the au- In Chapter 2 you used the case (b 1 bO) = (1 1) while
dio output jack through a 220-J.Lf blocking capacitor. In initializing the AIC parameters and then the (0 0) case
some circumstances, it is possible for this capacitor to for all subsequent sample transfers. The (0 1) and (1 0)
become charged. If the output is left open circuited or cases are useful for adjusting the sampling clock phases
connected to a very high impedance, like the oscilloscope or frequencies when implementing systems like modem
input, the capacitor will not discharge and a dc offset will receivers.
be observed in the output signal. The capacitor can be The sampling rates for the transmit (0/A) and receive
discharged by attaching a load like a speaker or several (AID) conversions can be computed from the correspond-
hundred ohm resistor to the output. Do not short the ing A's and B's by the formula
output!
f - f(MCLK) _ 3750 kHz
(3.28)
s - 2AB - AB
Setting the AlC Sampling Rate
and Filter Cutoff Frequencies The input antialiasing lowpass filter is an eighth-
order Chebyshev/elliptic transitional filter implemented
The AIC is supplied by the timer 0 output of the by switched-capacitor technology, and is preceded by a
TMS320C30 with a 7.5-MHz clock called MCLK. Let continuous-time filter to eliminate any possibility of alias-
this frequency be denoted by f(MCLK) = 7.5 MHz. It ing caused by sampled-data filtering. It can be cascaded
is divided down to provide the switched capacitor filter with a fourth-order Chebyshev/elliptic transitional high-
clocks and the sampling clocks. The AIC contains six reg- pass filter also implemented by switched-capacitor tech-
isters that can be loaded through its serial port receiver, nology. The output reconstruction filter is an eight-order
with data words sent by the TMS320C30's serial port 0 Chebyshev/elliptic transitional lowpass filter followed by
transmitter. These words control the divide ratios. (Ac- a second-order (sin x)/x correction filter and is imple-
tually, TI calls the AIC's serial port receiving pin the OX mented by switched-capacitor technology. It is followed
or transmit pin since this is the data that normally goes to by a continuous-time filter to eliminate images of the 0/A
the 0/A converter and is transmitted to the analog channel output signal. The input and output lowpass filter cutoff
when the AIC is used for modem applications. Similarly, frequencies (edge of equal ripple passband) are
the AIC's serial port transmitting pin is called the RX or
receive pin since this is the digitized data from the A/O 3.606 x f(MCLK) kHz
converter that would be received from a remote modem.) fclp
288
These registers are called TA, TA', TB, RA, RA', and
x 2A -
2.- _
46.953125 k
(3.29)
RB with the T prefix indicating a transmit parameter and A Hz
the R prefix indicating a receive parameter. TA and RA
are 5 bit registers and their values are considered to be The starting frequency for the highpass filter equal ripple
unsigned binary integers. TA' and TB' are 6 bit registers passband is
and their values are considered to be 2's complement inte-
gers. TB and RB are also 6 bit registers, but their values fchp = 150 Hz x fs kHz
8
46 Chapter 3

Table 3.1. How the two LSB's of the Received Sample Affect the Ale

b 1 bO AIC Action
o0 Transmit A - TA, Receive A = RA
o1 Transmit A = TA + TA', Receive A = RA + RA'
10 Transmit A = TA - TA', Receive A = RA - RA'
11 Transmit A = TA, Receive A = RA
A secondary transmitted word is requested.
See Table 3.2 or the TI TLC32044 data sheets
for details of the secondary word.

150 Hz x f(MCLK) kHz 3.4.2. Measuring the Time to Execute


16AB a Program Segment by
70312.5
(3.30) Using the Benchmarking Capability
AB Hz
of EVM30
For example, with A = 13 and B = 36, Is = 8.013 In real time applications, each program segment must
kHz,/clp = 3.612 kHz, and/chp = 150.24 Hz. complete its task in the time allowed. For example, to
implement a digital filter with a sampling rate of Is = 8
kHz, each filter iteration must execute in no more than T
The Synchronous Transmit = 1/fs = 125 JlS. The speed at which a program executes
and Receive Ale Mode depends on the processor clock frequency, the efficiency
ofthe basic instruction set for the required operations, and
In Chapter 2 you initialized the AIC to run in the
the efficiency of the compiler when writing in a higher
synchronous mode. This was done by setting bit 5 of
level language like C. In this experiment, you will write
AIC control word 3. In this mode, the AID conversion
programs in C and assembly language and compare their
timing is derived from and is equal to the DIA timing,
speed by using the benchmarking capability of EVM30.
i.e., the timing of the AIC's transmit section. For each
The TMS320C30 is driven by a crystal oscillator
sample, the frame synchs FSX and FSR are brought high,
clock called CLKIN in the TI literature. The frequency
one 16 bit data word is transmitted and one 16 bit data
of this clock on the EVM is I(CLKIN) = 30 MHz. The
word received, and then FSX and FSR are brought low
frequency of this signal is divided by 2 in the TMS320C30
again. The synchronous mode will be convenient for most
to get a signal called HI which, in the EVM, has the
of your experiments.
frequency
The AIC can also be set up to run in an asynchronous
mode. This is used when the transmit and receive sections f(CLKIN)
f( H1) = 2 = 15 MHz (3.31)
must run independently with different sampling rates.

Table 3.2. Format for Secondary Transmission

Bit Number Purpose of


15 141 13 1 12 1 11 1 10 1 9 8 7 1 6 1 5 1 4 1 3 1 2 1 0 Word
x x I TA x x 1 RA 0 0 Set A registers
x TA x RA 0 1 Set A registers
x TB x RB 1 0 Set B registers
x x l x l x l x l x l d 9 x d7 1 d6 1 d5 1 d4 I d3 1 d2 1 1 Control Word
d2 Oil Delete/msert AID hlghpass filter
d3 Oil Disablelenable loopback function
d4 Oil Disablelenable AUX IN+ and AUX IN- pins
d5 Oil Asynch/synch transmit and receive sections
d7 d6 10 ± 1.5 V peak-to-peak full scale
d7 d6 o 1 ±3 V peak-to-peak full scale
d9 Oil Deletelinsert sin xix correction
Digital Filters 47

The period of HI is the basic instruction cycle period of enter the command runb to count cycles to the second
the TMS320C30. Thus, on the EVM the DSP's instruc- breakpoint. When the program halts, you can examine
tion clock cycle period is CLK as described previously.
Try benchmarking sections of a C program you have
1 already written.
Tcycle = f(Hl) = 66.667 ns (3.32)

When implementing a digital filter with a sampling


rate ofis, the number of instruction clock cycles that can 3.4.3. Laboratory Experiments
be used to process a sample is for FIR Filters

T f(Hl) Perform the following sequence of tasks:


Ncycle = -- = -- (3.33)
T cll cle fs 1. Measure the EVM Frequency Response
For example, with the EVM and a sampling rate of 8 kHz, In order to measure the response of your digital filter,
1875 HI cycles occur in T= 125 J.Ls. you must know the response of the analog input/output
The number of instruction clock cycles required path of the AIC. Write a program to set the bus wait states
to execute a program segment can be measured by the to zero, tum on the cache, and initialize the timer, serial
EVM30 benchmarking capability. EVM30 has an internal port, and AIC using the same parameters as in Chapter 2
variable named CLK that equals the number of instruc- except change the sampling rate to 4 kHz by setting the
tion clock cycles used to execute a benchmarked program AIC counter parameters TA and RA both to 26. Leave TB
segment. To benchmark a program segment, load the pro- and RB at 36. Calculate the lowpass and highpass filter
gram and put a breakpoint at the first instruction of the cutoff frequencies using (3.29) and (3.30). You may want
segment. Also put a breakpoint immediately after the last change the AIC configuration so that its AID converter is
instruction in the segment. Then enter the EVM30 run fully loaded by ±3 rather than ± 1.5 V inputs. In this
command or press F5 to get to the first breakpoint. Then program, take the received AID samples and loop them
enter the command runb to count instruction cycles to back out to the DIA converter. You may want to scale
the second breakpoint. The number of cycles executed the samples down by 8 or 16 to account for the gains of
between the two breakpoints can be displayed by entering the analog input and output EVM buffer amplifiers and
the command the AIC internal gain depending on whether it is set for
± 1.5 or ±3 V peak input voltages. Remember to clear the
? CLK
two least significant bits of the transmitted samples. You
and the time in microseconds required to execute the seg- should control the program timing by synchronizing it to
ment can be displayed by the command the serial port transmit ready flag (XRDY). You can use
the function pO_xmi t (j ), which includes polling. After
? CLK*O.06667 writing a word, immediately read a word without polling
the receiver ready flag (RROY).
The following command can also be used to display
Measure the amplitude response of the system by
the variable in a watch window:
applying a sine wave to the input with the signal gener-
wa (CLK*O.06667), uSee= ator and measuring the input and output amplitudes with
the oscilloscope. Plot the results on a dB scale using
Benchmarking can be used with C, assembly, and GRAPHER or your favorite plotting routine. Use enough
mixed programs. To benchmark a segment of C state- frequencies to get a reasonable plot of the response. The
ments, first load the program. Then enter the EVM30 response should be quite flat between 75 Hz and 1.8 kHz.
command It should roll off sharply below 75 Hz because of the
highpass filter, so take more measurements in this region.
go main
Also, it should roll off above 1.8 kHz. You should use
The C source statements starting at the label main should the set of frequencies chosen here in the rest of Chapter
appear in the C window. You can see the corresponding 3.
assembly instructions at the same time in another window
2. Implementing a Digital Filter with C
by entering the command mix. Set a breakpoint at the
first C statement of the segment to be benchmarked and (a) Design a 25-tap bandpass FIR filter for a sam-
a breakpoint on the statement just after the last one in the pling rate of 4 kHz using one of the two methods presented
segment. Press F5 to get to the first breakpoint and then above. The filter should have a passband extending from
48 Chapter 3

500 Hz to 1.25 kHz. Plot the theoretical amplitude re- optimized program and see how it has been made more
sponse in dB generated by the design program. efficient than the unoptimized one.
(b) Write a C program for the TMS320C30 to im- (e) Measure the amplitude response of the filter at
plement this digital bandpass filter using a circular data the frequencies used to determine the EVM analog path
buffer. Perform the convolution using floating-point arith- response and plot the results on a dB scale after correct-
metic. Be careful to make your program as computation- ing for the response of the analog path. Compare your
ally efficient as possible, since there are only 114000 = measured results with the theoretical results.
250 J-ls available to process each sample. For example, (t) Increase the number of filter taps from 25 to fmd
convert the input sample to a floating-point format before the largest filter length that can be used without running
storing it in the circular buffer so that the conversion does out of time. Plot the theoretical and measured amplitude
not have to be repeatedly performed for each product in responses of the resulting filter.
the convolution loop. Be sure to remember to set the bus
3. Assembly Language Implementation
wait states to 0 or else the program will run too slowly.
of an FIR Filter
The start of each filter iteration should be controlled
by synchronizing it to the serial port 0 transmitter ready (a) Design a 3 I-tap bandpass digital filter for a sam-
flag (XRDY). The first step in the loop should be to trans- pling rate of 4 kHz with a lower cutoff frequency of 500
mit the output sample computed in the previous iteration Hz and an upper cutoff of 1.25 kHz. Plot the theoretical
by waiting until XRDY becomes I and then loading the amplitude response of your filter.
sample into the data transmit register (DXR). Then, imme- (b) Create a C main program and an assembly lan-
diately read a new input sample from the serial port 0 data guage function like Program 3.2 to implement your fil-
receive register (DRR) without polling the receiver ready ter using the hardware circular buffer capability of the
flag (RRDY). You can do this because you configured the TMS320C30. The C main program should simply initial-
AIC to operate in the synchronous mode. In this mode, ize the bus wait states, cache, timer, serial port, and AIC
the AIC AID clock is derived from and slaved to its DIA as before and then call the function fir (). Be sure to
clock so the AIC transmits a sample to the TMS320C30 declare fir to be external in your C program by using
at the same time it receives one from it. Therefore, after the statement
the AIC has taken a sample from the TMS320C30 serial
extern float fire)
port causing the XRDY flag to be set, a new sample must
be ready in the DRR. Again, synchronize the convolution loop by polling the
Convert the new input sample to a 32-bit integer by serial port transmitter XRDY flag.
shifting it left 16 bits and then right 18 bits. This extends (c) When the program is running properly, measure
the sign bit and eliminates the two zero least significant the time required to process one sample by using the
bits. Then convert the result to a floating-point word and benchmarking capability of EVM30, and record the re-
store it in the circular buffer. Perform the convolution sult. Estimate the largest filter length that could be im-
and convert the filter output to an integer value suitable plemented this way. Write some conclusions about the
for transmission to the AIC. Finally, branch back to the relative efficiencies of hand coding real-time signal pro-
beginning of the loop where you poll XRDY waiting to cessing algorithms in assembly language versus using a
transmit the sample just computed. higher-level language like C.
(c) Compile your program as you did in Chapter 2 (d) Measure and plot the frequency response of the
without using the optimization option. When your pro- filter to check that your program is correct.
gram has been debugged and is running, measure the
4. Mixed C and Assembly Language
time it takes to generate one output sample by using the
Implementation of FIR Filter
benchmarking capability of EVM30, and record the result.
Look at the assembly code generated by the compiler to By this time you have implemented an FIR filter with
get an idea of how each C statement is implemented and the two extremes of an all C program and essentially an
the efficiency of the resulting executable machine code. all hand coded assembly language program. Now im-
You can do this by using the mix command with EVM30 plement the 31-tap bandpass FIR filter used for the as-
or looking at the .asm listing file generated. sembly language exercise with the compromise combined
(d) Recompile your program using the compiler - C and assembly language convolution function approach
o option to invoke the optimizer. Benchmark the filter presented in Section 3.2.4. Remember that the source
loop again and record the time required for the optimized code for CONVOL.ASM is in the C:\UTIL.DSP direc-
program. Compare the times for the unoptimized and tory. This compromise approach will be useful in future
optimized programs. Look at the assembly code for the experiments. Perform the following two tasks:
Digital Filters 49

(a) Roughly check the amplitude response of your control systems and appeared in the late 1950's. They did
filter by slowly sweeping the frequency of an input sine not discuss methods for designing digital filters with the
wave from the signal generator and checking that it is a demanding frequency responses required in many com-
bandpass filter with the correct passband. munications and signal processing applications. The first
(b) Estimate the time required to process one sample complete college textbook that focused on digital signal
by benchmarking the program from the pO _re ce i ve 0 processing, Oppenheim and Schafer [II.C.9], appeared in
C statement to the iy «= 2 C statement. Compare this 1975 and was followed a year later by Tretter [II.C.14].
time with the time required by the all assembly language The theory has advanced very little since these books were
implementation. published, but some of the newer books include sections
on DSP chips.
See Proakis and Manolakis [II.C.12, Chapter 5] for
3.4.4. Laboratory Experiments a more extensive discussion of the frequency responses of
for IIR Filters FIR and IIR digital filters including a variety of examples.
Also see Oppenheim and Schafer [II.C.IO, Chapter 5].
In these experiments you will design a bandpass IIR Detailed discussions of structures for realizing FIR
filter, plot its theoretical amplitude and phase responses, and IIR filters can be found in Oppenheim and Schafer
and compare them with measured responses. Do the fol- [II.C.IO, Chapter 6] and Proakis and Manolakis [II.C.12,
lowing steps for this experiment: Chapter 7]. They discuss the direct forms presented in
1. Design an IIR bandpass filter based on an el- this experiment and additional structures, such as lattice
liptic lowpass analog prototype. Choose 4 kHz as the filters.
sampling rate. The lower stopband should extend from 0 All the books listed in Section II.C of the refer-
to 200 Hz, the passband from 500 to 1250 Hz, and the ences discuss FIR and IIR digital filter design techniques
upper stopband from 1750 to 2000 Hz. The passband to meet frequency domain requirements. For example,
ripple should be no more than 0.3 dB and the stopband see Oppenheim and Schafer [II.C.10, Chapter 7], Proakis
attenuation should be at least 40 dB. Plot the theoretical and Manolakis [II.C.12, Chapter 8], and Tretter [II.C.14,
amplitude response generated by IIR on a dB scale and Chapter 8]. The first two of these references present the
also plot the phase response. Explain the discontinuities theory for the method used in the REMEZ87 FIR filter
in the phase response. design program and filter design examples. An excellent
2. Write a program to implement your filter on the source for FORTRAN digital filter design programs and
TMS320C30. Use type 1 direct forms for the sections. other signal processing programs is the classic IEEE Press
You can use whichever you prefer, C or assembly lan- book [II.C.5].
guage. You might want to look at the TMS320C3x User's Important topics not discussed in this experiment
Guide for an assembly language example IIR filter pro- are the effects of quantization in AID conversion and fi-
gram. Your program should initialize the AIC exactly the nite word length arithmetic. See Oppenheim and Schafer
same as for the FIR filter experiments. [11.C.1O, Sections 6.7 - 6.10], Proakis and Manolakis
3. Use the signal generator and oscilloscope to mea- [II.C.12, Sections 6.2 and 7.6 - 7.8], and Tretter [1I.C.14,
sure the amplitude response and plot it in dB. Also mea- Chapter 9] for discussions of these topics.
sure the phase response using Lissajous figures or time
delays and plot the results. Be sure to adjust the measured
responses for the responses of the analog paths in the Ale.
Compare your theoretical and measured responses.
4. Use the benchmarking facility of the debugger to
measure the number of clock cycles and time required to
process one sample and record the result.

3.5. Additional References

There are many excellent books covering the theo-


retical and practical aspects of digital signal processing.
A few of them are included in Section II.C of the list of
references at the end of this text. The initial books that
dealt with discrete-time systems focused on sampled-data
4

The FFT and Power


Spectrum Estimation

In this experiment, you will review and implement some discrete-time Fourier transform by the inversion integral
important techniques for digital signal processing. In par-
ticular, you will build a spectrum analyzer using the Fast x[n] = -
1 W s/2 j
X(w)e jwnT dw (4.2)
Fourier Transform (FFT). It is assumed that the reader is Ws -w s /2
taking or has had a course on the theory of digital signal Thus, x[ n] can be considered to be the sum of sampled
processing, so the presentation is brief. It sets the no- sine waves at a continuum of frequencies in the Nyquist
tation and summarizes important results. Comprehensive band, -w s /2 < w ~ ws /2, with complex amplitudes given
developments of the theory can be found in the books on by X( w). This suggests calling X( w) the frequency spec-
digital signal processing listed in the references. Refer- trum of the signal.
ences for specific topics are suggested at the end of this
experiment.
4.2. Data Window Functions
The observed data sequence must be limited to a
4.1. The Discrete-Time fmite duration to compute the transform summation in
Fourier Transform practice. The most obvious approach is simply to truncate
the summation to a fmite range, for example, 0 ~ n ~ N
Suppose that a continuous-time signal x(t) is sampled - 1. This is equivalent to forming a new data sequence
with period T or sampling frequency Ws = 27f/T to obtain by multiplying the original signal x[ n] by the rectangular
the discrete-time signal x[n] = x(nT). We will define the N-point data window function
discrete-time Fourier transform ofx[n] to be the following
hI [n] 1 for n = 0,1, ... ,N - 1
sum, if it exists:
hdn] 0 elsewhere (4.3)

L
00
The effect of the trunctation on the spectrum can
X(w) = x[n]e- jwnT (4.1)
be determined by the following product theorem. Let
11,=-00
h[n] and x[n] be discrete-time signals with discrete-time
Fourier transforms H(w) and X(w), respectively. Then, it
The z-transform of the signal is obtained by making the
can be shown that y[n] = h[n]x[n] has the transform
substitution z = ejwT . Note thatX(w) has period Ws since
the sum is a Fourier series.
Y(w) = -
1 j W s/2
X()")H(w -)..) d)" (4.4)
The discrete-time signal can be determined from its Ws -w s /2

51
52 Chapter 4

Thus, the transform of a product in the time-domain be- The maximum sidelobe amplitude is down by 37.5 dB
comes a convolution of the transforms in the frequency for this window. However, the mainlobe has double the
domain. width of that for the rectangular window.
The discrete-time Fourier transform of the rectangu- Another popular data window is the Hamming win-
lar window is dow

L
N-l
e- jwnT h3[n] C3 { 0.54 + 0.46 cos [ ( 1'1, _ N ; 1 ) ~] }
n=O for 1'1, = 0,1, ... , N - 1
e- jw (N-l)T/2 si~(wNT/2)
sm(wT/2)
(4.5) h3[n]
° elsewhere. (4.9)

where C3 = (0.3974)-1/2. The corresponding spectral


The transform of a data window is often called a spectral
window is
window. This function has a peak magnitude of height N
at the origin and is zero at those frequencies kws/N which H3(W) = C3e-jw(N-l)T/2
are not multiples of w3 • Thus, the main lobe centered
about the origin has width 2w s/N. From (4.4) we see that [0.54H1 (w) + 0.23H1 (w - ~)
the transform of the truncated sum is a smoothed version
of the true spectrum, X( w), obtained by convolving X( w) + 0.23H1 (w+ ~)] (4.10)
with HI (w). The value at frequency w is predominantly
This window is almost the same as the Hanning window.
an average of values in the vicinity of w weighted by
Its spectral sidelobes are down by at least 47 dB.
HI (w - >..) over its main lobe, which extends from>.. = w
Other good windows, such as the Kaiser and Black-
- (ws/N) to >.. = w + (ws/N). However, the maximum
man windows, can be found in the DSP reference books.
sidelobe magnitude of HI (w) is down only about 13 dB
In general, reduced sidelobes must be traded against in-
from the main lobe peak, so the value of X( w) estimated
creased main lobe width.
by the truncated summation can be significantly distorted
by large values away from w "leaking through" the spec-
tral window. 4.3. The Discrete Fourier Transform
The spectral leakage problem can be reduced by us- and Its Inverse
ing a data window that has smaller sidelobes in its trans-
form. To obtain unbiased power spectral density estimates Let x[n] be a signal which is zero for n outside the
for a flat spectrum, a data window h[ n] should be nor- set {O, 1, ... , N - I}. We will call this an N-point se-
malized so that quence. Let X(w) be the discrete-time Fourier transform
of x[n] defmed above. Then, the discrete Fourier trans-
form (DFT) of this sequence is defined to be the new
(4.6) N-point sequence
N-l
Note that this normalization is different from that used for X(kws/N) = L x[n]e- j2;nk
windows in digital filter design. n=O
One popular data window is the Hanning window for k=0,1, ... ,N-1 (4.11)

C2 0.5 { 1 + cos [ (1'1, _ N ; 1) ~]} The DFT is simply the set of N samples of X(w) taken at
frequencies spaced by ws/N in the Nyquist band. Notice
for 1'1, = 0,1, ... , N - 1 that if k is allowed to take values outside the set {O, 1, ... ,
° elsewhere (4.7) N - I}, the value computed by (4.11) repeats with period
N.
where C2 = (3/8)-1/2 provides the proper normalization. The original N-point sequence can be determined by
The corresponding spectral window is using the inverse discrete Fourier transform (IDFT) for-
mula
H2(W) = C2e-jw(N-l)T/2
[0.5H1 (w) + 0.25H1 (w - ~) x[n] -1
N
LX .e
N-l
k j'h!.nk
N

k=O
+ 0.25H1 (w + ~)] (4.8) for k = 0,1, ... , N - 1 (4.12)
The FYI and Power Spectrum Estimation 53

4.4. The Fast Fourier Transform

Direct computation of a single DFT point using


(4.11) requires N - 1 additions and N multiplications,
ignoring the fact that, for some k, the exponentials are 1
or -1. Thus, direct computation of all N points requires
N(N - 1) complex additions and JI2 complex multiplica-
tions. The computational complexity can be reduced to
the order of Nlog 2N by algorithms known as fast Fourier
transforms (FFT's) that compute the DFT indirectly. For
example, with N = 1024 the FFT reduces the computa- Figure 4.1. Flowgrapb for an FFT butterfly.

tional requirements by a factor of


LetAk andBk be theNl2-point DFT's of a[n] and b[n] so
N2 = 102.4
Nlog 2 N that these DFT's have period N12. With these defmitions,
(4.17) becomes
The improvement increases with N.
One FFT algorithm is called the decimation-in-time
Xk = Ak+WtBk
algorithm. A brief derivation is presented below for ref-
erence. To simplify the notation, let WN = e-j27r/N so for k = 0,1, ... , N - 1 (4.18)
(4.11) becomes
The next step results in the key equations for the
N-l
decimation-in-time FFT. First observe that ~/2 = -1.
Xk = L x[n]WNk (4.l3) Then, the previous equation can be separated into the two
n=O equations
This algorithm assumes that N is a power of 2. Splitting
the sum into one sum over even n and one sum over odd
n gives N
for k = 0,1, ... , 2 - 1 (4.19)
~-l
L x[2n]W~nk
n=O
~-l
+ L x[2n + l]W~n+l)k for k = 0,1, ... , 2
N
- 1 (4.20)
n=O
for k=0,1, ... ,N-1 (4.14) Equations (4.19) and (4.20) show how to compute an
Let the even numbered points be the NI2 point sequence N-point DFT by combining a pair of Nl2-point DFT's. A
flowgraph for this pair of equations is shown in Fig. 4.1.
a[n] = x [211,] This computation is called an FFT butterfly because of
N the shape of the flowgraph. A complete flowgraph for
for 11,=0,1'''''2-1 (4.15)
this first step with N = 8 is shown in Fig. 4.2.
and the odd numbered points be the NI2 point sequence Assuming that theNl2-point DFT's-Ak and Bk -are
b[n] = x[2n + 1] known, it requires NI2 complex multiplications to com-
N
pute Bkwt, NI2 complex additions to compute Xk = Ak +
for 11,=0,1'''''2-1 (4.16) wtBk, and NI2 complex subtractions to compute Xk+~
= Ak - wtBk for k = 0, 1, ... , 1¥- - 1. Addition and
Also observe that w'2N = WN/2 . Thus, (4.14) can be writ-
subtraction can be considered to be the same in terms of
ten as
computational complexity. Thus, the entire N-point DFT
~-l
can be computed with NI2 complex multiplications and N
Xk = L a[n]WN'2
n=O
complex additions from the pair of Nl2-point DFT's.
The same procedure can be used to compute the N12-
~-l point DFT's from Nl4-point DFT's. Computation of Ak
+ wt L b[n]W~'2
n=O
by this method would require NI4 complex multiplications
and NI2 complex additions. Finding Bk would require the
for k = 0,1, ... , N - 1 (4.17) same amount of computation. Thus the total amount of
54 Chapter 4

a[O] Ao
x [0] Xo

a[l] Al
x[2] Xl
4-point
a[2] DFT A2
x [4] X2

a[3] A3
x [6] X3

b[O] Bo
x[I] X4

b[I] Bl
x [3] X5
Ws
4-point
b[2] DFT B2
x[5] X6
w.s2
b[3] B3
x[7] X7
W/ -1

Figure 4.2. First step in an 8-point decimation-in-time FFT.

computation to compute both Ak and Bk is N/2 multiplica- decimation-in-time FFT is included below. It takes its
tions and N additions, which is the same as for computing complex input array in natural order and then rearranges
Xk from Ak and Bk. it into bit reversed order. The output is in natural or-
The reduction by 2 procedure can be repeated un- der. The computations are performed in-place, with the
til one-point DFT's are reached. A one-point DFT of a output array written over the input array. The complex
point is just the point itself. This requires log2(N) stages. exponentials JVk are computed recursively. The program
Therefore, the entire amount of computation required to could be made more efficient by precomputing and stor-
compute the N-point DFT is ~ log2(N) complex multipli- ing a cosine/sine table at angle increments needed for the
cations and Nlog2(N) complex additions. largest N to be used and addressing the table appropriately
for smaller N. A header file defming a complex structure
A complete flowgraph for an 8-point decimation-in-
type and an example main function that computes the 16-
time FFT is shown in Fig. 4.3. Note that the input points
point FFT of cos(5x 27fnlN) is also shown. The output
are arranged in a scrambled order while the output DFT of this program should be all 0 except for X5 = Xu = 8.
is in its natural order. It can be shown that the successive
separation into even and odd numbered sequences puts
the input sequence in bit-reversed order for any N that
is a power of 2. The bit-reversed order is obtained by 4.5. Using the FFf to Estimate
reversing the bits of the indexes for the original input a Power Spectrum
array elements. The TMS320C30 has built in hardware
for performing bit-reversed addressing. One method for estimating power spectral densities
A C function for computing a complex, radix-2, is based on using a function called the periodogram. The
The FFf and Power Spectrum Estimation 55

x[O] Xo

x[2]

x [4]

x[6]

x[I]

x [3] X5

x[5]

x [7]

Figure 4.3. Complete flowgraph for an 8-point decimation-in-time FFT.

Program 4.1 Header File Defining


Complex Data Structure

1***************************************************************1
1* Header File complex.h *1
1***************************************************************1
struct cmpx
{
double real;
double imag;
};
typedef struct cmpx complex;

periodogram of an N-point sequence y[n] is defined to be is the discrete-time Fourier transfonn of y[n]. It can be
shown that the inverse transfonn of the periodogram is
the sample autocorrelation function
(4.21)
1 N-l

where
R(n) = N L y[n + k]y[k]
k=O
N-l
Y(w) = L y[n]e- jwnT (4.22)
R(n)
for Inl
o elsewhere
~ N-I
(4.23)
n=O
56 Chapter 4

Program 4.2 C Main Program to Test fft.c

/***************************************************************/
/* Program testfft.c */
/* An example of how to use function fft.c */
/* Compile by: gcc testfft.c fft.c -0 fft.out -1m */
/***************************************************************/

#include "complex.h"
#include <math.h>
extern void fft();

mainO
{
complex X[16]; /* Declare input array */
int i; /* loop index */
int M = 4; /* 10g2(16) */
double pi = 3.141592653589;
int N = 16; /* Number of FFT points */
/*-------------------------------------------------------------*/
/* Initialize input array */
/* Generate spectral lines at k = 5 and 11 of height 8. */

for(i=O; i<N; i++)


{
(X [i] ) . real cos(i*5*2.0*pi/N);
(X [i] ) . imag 0.0;
}
/*--------------------------------------------------------------*/
/* Perform FFT */
fft(X,M);

/* Display results on screen

for(i=O; i<N; i++)


printf("%4d%15 .5f\t%15 .5f\n", i, (X[i]) .real, (X[i]). imag);

The variable n in the autocorrelation function is called the At first glance, it is natural to assume that as N in-
lag. For zero lag creases, the periodogram becomes a better estimate of the
power spectral density for a stationary random process.
However, this is not true. Actually, the mean of the pe-
R(O) riodigram converges to the true spectral density but its
variance remains large. As N increases, the periodogram
tends to oscillate more and more rapidly. See references
(4.24)
[II.C.9] or [II.C.14] for details of this property and, more
generally, estimation of power spectral densities.
is the average power in the sequence. This equation pro- A solution to this problem is to average the peri-
vides some justification for interpreting the periodogram odograms of different N-point sections of the observed
as a function that shows how the power is distributed in data sequence. Let x[ n] be an observed data sequence
the frequency domain. with duration M = LN and form the L windowed N-point
The FIT and Power Spectrum Estimation 57

Program 4.3 C Function for Radix-2


Decimation-in-Time FFT

/****************************************************************/
/* Function fft(complex *X, int M) */

/* This is an elementary, complex, radix 2, decimation in */


/* time FFT. The computations are performed "in place" and */
/* the output overwrites the input array. */
/****************************************************************/

#include "complex.h"/* Definition of complex variable structure */


#include <math.h> /* Definitions for math library */

void fft(complex *X, int M)


/* X is an array of N = 2**M complex points. */
{
complex templ; /* temporary storage complex variable */
complex W; /* e**(-j 2 pi/ N) */
complex U; /* Twiddle factor W**k */
int i,j ,k; /* loop indexes */
int id; /* Index of lower point in butterfly */
int N = 1 « M·, /* Number of points for FFT */
int N2 = N/2;
int L; /* FFT stage
int LE; /* Number of points in sub DFT at stage L, */
/* and offset to next DFT in stage */
int LE1; /* Number of butterflies in one DFT at*/
/* stage L. Also is offset to lower */
/* point in butterfly at stage L */
double pi 3.1415926535897;

/*==============================================================*/
/* Rearrange input array in bit-reversed order */
/* */
/* The index j is the bit reversed value of i. Since 0 -> 0 */
/* and N-l -> N-l under bit-reversal, these two reversals are */
/* skipped. */
58 Chapter 4

Program 4.3 (continued)

j = 0;
for(i=1; i«N-1); i++)
{

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* Increment bit-reversed counter for j by adding 1 to msb and */
/* propagating carries from left to right. */

k = N2; /* k is 1 in msb, 0 elsewhere

/*--------------------------------------------------------------*/
/* Propagate carry from left to right */

while (k<=j) /* Propagate carry if bit is 1 */


{
j j - k; /* Bit tested is 1, so clear it. */
k k/2; /* Set up 1 for next bit to right. */
}
j j+k; /* Change 1st 0 from left to 1 */
/*--------------------------------------------------------------*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

/* Swap samples at locations i and j if not previously swapped.*/

if(i<j) /* Test if previously swapped.


{
temp1.real (X [j] ) . real;
temp1.imag (X[jJ) .imag;
(X [j] ) . real (X [i] ) . real;
(X [j] ) . imag (X [i]) . imag;
(X [iJ) . real temp1.real;
(X [i] ) . imag temp1. imag;
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
}

/*==============================================================*/
/* Do M stages of butterflies */

for(L=1; L<= M; L++)


{
LE = 1 « L; /* LE = 2**L = points in sub OFT */
LE1 = LE/2; /* Number of butterflies in sub-OFT */
U.real 1.0;
U. imag 0.0; /* U 1 + j 0
W.real cos (pi/LEi) ;
W. imag - sin(pi/LE1); /* W e**(-j 2 pilLE)
The FFf and Power Spectrum Estimation 59

Program 4.3 (continued)

/*--------------------------------------------------------------*/
/* Do butterflies for L-th stage */
for(j=O; j<LEi; j++) /* Do the LEi butterflies per sub DFT*/
{
/* .............................................................. */
/* Compute butterflies that use same W**k */

for(i=j; i<N; i += LE)


{
id = i + LEi; /* Index of lower point in butterfly*/
tempi.real (X[id]).real*U.real - (X[id]).imag*U.imag;
tempi.imag = (X[id]).imag*U.real + (X[id]).real*U.imag;

(x [id] ) . real (X[i]) .real - tempi.real;


(X [id] ) . imag (X[i]).imag - tempi.imag;

(X [i] ) . real (X[i]).real + tempi.real;


(X [i] ) . imag (X[i]).imag + tempi.imag;
}
/* .............................................................. */
/* Recursively compute W**k as W*W**(k-i) = W*U */

tempi.real = U.real*W.real - U.imag*W.imag;


U.imag = U.real*W.imag + U.imag*W.real;
U.real = tempi.real;
/* .............................................................. */
}
/*--------------------------------------------------------------*/
}
return;
}

data sections The periodograms can be computed at the uniformly


spaced frequencies {kwsIN; k= 0, 1, ... , N - I} by using an
Yk[nJ = N-point FFT. When the observed data sequence is real and
{ ~[n].'r[n + kL] for n = 0,1, ... , N - 1 the FFT program is designed to accept complex inputs, the
elsewhere computation time can be reduced by almost a factor of two
for k = 0,1, ... , L - 1 (4.25) by using the following identity. Let a[n] and b[n] be two
real N-point sequences and form the complex sequence
where h[ n] is a desired data window function. Designate c[n] = a[n] + jb[n]. Then
the periodogram formed from the k-th widowed section
by IN,k(w). Then the desired power spectral density es-
timator is
1
LL
L-1
A
(4.27)
S(w) = IN,k(w) (4.26)
k=O

When the data sections are statistically independent, av-


eraging L sections reduces the variance by a factor of Thus, the sum of the periodograms of the two real se-
L. Additional gains can be achieved by overlapping the quences can be computed from the FFT of the single
sections to some degee. complex sequence.
60 Chapter 4

4.6. Laboratory Experiments (c) Convert the output FFT array to IEEE floating
point format. You should modify the program TOI-
4.6.1. FFT Experiments EEE I.ASM to be a C callable function. R2DIT.ASM
can be used as an example of how to save the C en-
For these experiments, you will need a C callable, vironment, get and return function arguments, and
floating point, fast, 512-point FFT function for the restore the C environment.
TMS320C30 that accepts a complex input array in nat-
ural order and outputs the transformed array in natu- (d) Send the IEEE formatted array to the pc. See Ap-
ral order. A program R2DIT.ASM that meets these re- pendix A for the details of how to do this.
quirements is contained in the self-extracting zipped file
F:\LABNOTES\C30PROG\FFT\FFT.EXE. It also con- 3. Write a C program for the PC to:
tains the program R2DITC.c that gives an example of (a) Read a 512-point FFT from the TMS320C30 into an
how to call R2DIT and a linker command file named array.
R2DIT.cmd. This file was obtained from the TI bulletin
board mirror at Internet address ti.com in the directory (b) Save the array in a disk file. When the program
Imirrors/tms320bbs. The README file claims that this terminates, compare the disk file with the theoretical
FFT will do a 512-point complex transform in 0.886 ms result to check your program.
excluding the bit-reverse ordering process. R2DIT.ASM
differs from the radix-2 decimation-in-time FFT described (c) Plot the magnitude of the FFT array on the PC screen.
above. Its first two stages are radix-4 stages and the You will have to split the plot into two lines, due to
remaining ones are radix-2 stages. The butterflies are the limited resolution of the graphics drivers.
decimation-in-time butterflies but the array ordering has 4. Repeat steps 1, 2, and 3 except multiply the input
been rearranged so that the input is in natural order and sequence by a Hamming window. When checking your
the output is in bit-reversed order. The final step in the results make sure to examine the FFT values in the vicinity
function puts the output array into natural order by us- of 1000 and 7000 Hz.
ing the hardware bit-reverse counting capability of the 5. Change the input sequence to:
TMS320C30. The complex input array must be arranged
so that the real part of the data point x[ n] is in array loca-
tion 2n and the imaginary part is in the next location 2n x[n] °°°)
sin [27r ( 1000 + 0.5 85 12
+ 1, that is, the real and imaginary parts alternate.
In these experiments, you will be asked to transfer x 8;~0] (4.29)
a floating point FFT from the TMS320C30 to the pc.
Unfortunately, the TMS320C30 and Borland C++ floating Repeat steps 1 through 4 for this new signal. Explain
point formats differ. Borland uses the IEEE real format the results.
for 32-bit float C data types. The following program
from page 11-46 of the TMS320C3x User's Guide does
4.6.2. Experiments for Power
the conversion from TMS320C30 to IEEE formats.
To test and extend your understanding ofFFT's, per- Spectrum Estimation
form the following tasks: In these experiments you will make an elementary
1. Let the sampling rate be 8 kHz and the sequence spectrum analyzer. The EVM will be used to collect dig-
length be N = 512 points. Theoretically compute the DFT itized blocks of N = 256 samples taken at an 8-kHz rate
of the sequence and the TMS320C30 will compute and average the peri-
x[n] sin(27r x 1000 x n/8000) odograms. The results will be sent to the PC for display.
for n = 0,1, ... ,511 (4.28)
Program for the TMS320C30
2. Write a C program for the TMS320C30 to do the
following: The power spectral density estimates will be based on
periodograms of 512-point blocks of input samples taken
(a) Fill a 2N-point array with the real and imaginary
at an 8 kHz rate. For efficient use of the 512-point FFT,
parts of the sequence x[n] defined above.
the technique described by (4.27) to compute the sum of
(b) Compute the FFT of x[ n] by calling the function pairs of periodograms should be used. The time required
in R2DIT. Check your answer with the C Source to collect two blocks of 512 samples is 2 x 512/8000
Debugger. = 128 ms. The complex 512-point FFT takes less than
The FFf and Power Spectrum Estimation 61

Program 4.4 TMS320C30 to IEEE


Floating Point Conversion

* FUNCTION: Conversion between TMS320C30 and IEEE floating point numbers.


* The number to be converted is in the upper 32 bits of RO. The
* result will be in the lower 32 bits of RO.
*
* UPON ENTERING THE ROUTINE, AR1 POINTS TO THE FOLLOWING TABLE:
*
(0) OxFF800000 <-- AR1
*
(1) OxFFOOOOOO
* (2) exponent bias (127)
* Ox7FOOOOOO
* (3) Ox80000000 used to add negative sign bit
(4) Ox81000000 representation for 0
*
* (5) Ox7F800000
* (6) Ox00400000 used to set msb of mantissa to 1
* (7) Ox007FFFFF
* (8) Ox7F7FFFFF
*
* ARGUMENT ASSIGNMENTS:
* ARGUMENT I FUNCTION
* --------+-----------------------------
* RO NUMBER TO BE CONVERTED
* AR1 I POINTER TO TABLE WITH CONSTANTS
*
* REGISTERS USED AS INPUT: RO, AR1
* REGISTERS MODIFIED: RO
* REGISTER CONTAINING RESULT: RO
*
* NOTE: Since the STACK POINTER 'SP' is used, make sure to initialize
* it in the calling program.
*
.global TDIEEE1
*
TOIEEE1 LDF RO,RO ;Determine sign of number
LDFZ HAR1 (4) ,RO ;If 0, load appropriate number
BND NEG ;Branch to NEG if negative
ABSF RO ;Take absolute value of number
LSH 1,RO ;Eliminate sign bit in RO
PUSHF RO
POP RO ;Put number in lower 32 bits of RO
ADDI HAR1(2),RO ;Add exponent bias (127)
LSH -l,RO ;Put 0 sign bit in msb
62 Chapter 4

Program 4.4 (continued)

CoNT TSTB HAR1(5),RO


RETSNZ ;1f E>O, return
TSTB HAR1 (7) , RO
RETSZ ;If E=O & F=O, return
PUSH RO
PoPF RO
LSH -l,RO ;Move F right one bit
PUSHF RO
POP RO
ADD1 HAR1(6) ;Add to F a msb of 1
RETS
NEG POP RO ;Put number in lower 32 bits of RO
BRD CoNT ;Next 3 instructions done before branch
ADD1 HAR1(2) , RO ;Add exponent bias (127)
LSH -l,RO ;Make space for sign bit
ADD1 HAR1(3),RO ;Add the negative sign
RETS

I ms so plenty of time should be available to make all that the memory area used by FFTIN is used to collect
the necessary computations on one pair of blocks while a two new blocks of data and the most recently collected
new pair is being received. The following list suggests a two blocks are used to generate the FFT input. Of course,
method of data collection for your TMS320C30 program the indexes to where the new received samples should be
and the tasks it should perform. put must also be reset.
I. Initialize the TMS320C30 and AIC as in Chapter 7. Convert the values in FFTIN to floating point for-
2. mat using the appropriate assembly language instruction
2. Set up a 512-word array that contains the floating for the TMS320C30.
point samples of the Hamming window. 8. Multiply the samples in FFTIN by the correspond-
3. Set up an array named SAMPLES, of size 2 x ing samples of the Hamming window.
512 = 1024 words to act as a buffer for receiving two 9. Take the complex FFT and use (4.27) to com-
blocks of 512 samples from the AIC. The even numbered pute the sum of their squared magnitudes. Remember
samples in this array should contain successive samples of that when x[n] is real, X k = X N - k , so that the second
one block and the odd numbered ones successive samples half of the FFT is totally redundant. Thus, it is only nec-
of the next block. The even numbered samples are the real essary to compute the sum of the squared magnitudes for
part of the FFT input and the odd ones are the imaginary n = 0, ... , 255. As each value is computed, add it to the
part. corresponding word in SPECTRUM.
4. Set up a 2 x 512 = 1024 word array named 10. Continue to accumulate periodograms in SPEC-
FFTIN. This array will be used to form the input array TRUM until L = 8 have been added and then divide the
for the FFT. 256 elements by the correct integer. You should be aware
5. Set up a 256-word array named, SPECTRUM, to that the signals generated by the signal generator to test
hold the power spectral density estimate. your spectrum analyzer are essentially deterministic peri-
6. Samples should be read from the serial port re- odic signals and not sample functions of a random pro-
ceived data register by an interrupt routine triggered by cess. Therefore, the periodograms should not change sig-
the serial port 0 receiver interrupt. This routine should nificantIy and the averaging process will not have much
read the received data sample and put it into the next of an effect. For random signals you would probably want
even location in SAMPLES if it is the first block or odd to increase L significantly or perform more averaging in
location if it is the second block. the PC.
The routine should detect when SAMPLES is filled II. Stop accumulating periodograms and wait for
with two blocks of received samples. It should then swap the PC to request transmission of the 256 word spectrum
the pointer to SAMPLES with the pointer to FFTIN, so estimate. Send the 256 words by the DMA method de-
The FFT and Power Spectrum Estimation 63

scribed in Appendix A when the request is received from (a) Let met) = Amcos 2n500t and derive the theoretical
the PC. spectrum for x(t). Am is called the modulation in-
12. Wait for the PC to withdraw its request, which is dex for the AM signal. Set the function generator to
the signal that it received the block of data. Then reset all generate a signal of this type with a modulation in-
the appropriate buffers and pointers and begin computing dex of 100%. Compare the theoretical and measured
a new power spectral density estimate. spectra.

(b) Repeat the previous item but change met) to a 200-Hz


Program for the PC square-wave with a 20% duty cycle.
The program for the PC is easy. All it has to do is set 4. If you have the time and interest, experiment with
up the display for graphing spectral estimates and then get the FM signals of the signal generator. These will also be
and plot blocks of 256 values from the TMS320C30. The studied in a future experiment.
received values must be scaled and converted to integers 5. If you still have more time and interest, change
to light the correct pixels on the screen. the Hamming window to a rectangular window in the
The PC should send a command byte to the TMS- TMS320C30 program and compare the results for various
320C30 to send a block of data and wait for the command signals with the two windows.
to be echoed back as acknowledgement. It should then
read the data block. When the entire block has been re-
ceived, it should withdraw its command, which signals 4.7. Additional References
the TMS320C30 to begin computing a new spectrum es-
timate. The theory and properties of the discrete-time Fourier
transform can be found in all the DSP books listed in
the references. In particular, see Oppenheim and Schafer
Testing Your Spectrum Analyzer
[II.C.lO, Sections 2.6-2.9] and Proakis and Manolakis
Now it is time to test and experiment with your spec- [II.C.l2, Sections 3.2-3.4].
trum analyzer. Perform the following exercises. For discussions of data windows see Oppenheim
I. Attach the signal generator output to the EVM and Schafer [II.C.IO, Sections 7.4-7.5, 11.2-11.3], Ra-
AID input and an oscilloscope. Generate a I-kHz sine biner and Gold [II.C.B, Sections 3.8-3.16], and Tretter
wave and observe the spectrum on the PC. Compare the [II.C.14, Sections 8.8 and 11.4-11.5].
result with the theoretical value obtained by using the For detailed presentations of the discrete-Fourier
input amplitude measured on the oscilloscope. transform and its properties see Oppenheim and Schafer
2. Derive a formula for the Fourier coefficients of a [II.C.IO, Chapter 8], Proakis and Manolakis [ILC.12,
nonsymmetric square-wave with one period given by the Chapter 9], and Tretter [II.C.14, Chapter 10].
following equation. Extensive coverage of the FFT can be found in Bur-
rus and Parks [II.C.2], Oppenheim and Schafer [II.C.lO,
A/2 for It I < r/2
x(t) = { -A/2 (4.30) Chapter 9], Proakis and Manolakis [II.C.12, Chapter
for r /2 ~ It I ~ T a/2 9], Rabiner and Gold [II.C.B, Chapter 6], and Tretter
The duty cycle for the square-wave is defined to be riTa. [II.C.14, Chapter 10].
There are many subtleties to the estimation of the
(a) Set the signal generator to generate a 200 Hz square- power spectral density of a random signal. Very complete
wave with a 50% duty cycle and compare the mea- coverage of this topic can be found in the books by Jenkins
sured and theoretical spectra. and Watts [II.C.7] and Kay [ILC.8]. More concise presen-
tations can be found in Oppenheim and Schafer [II.C.9,
(b) Set the duty cycle to 20% and compare the measured
Chapter I1][II.C.lO, Chapter 11], Proakis and Manolakis
and theoretical spectra.
[II.C.l2, Chapter 12], and Tretter [II.C.14, Chapter 11].
3. Test your spectrum analyzer with amplitude mod-
ulated signals. These have the form

x(t) = Ad! + m(t)] cos2nJct (4.31 )

and will be studied extensively in Chapter 5. The wave-


form met) is called the modulating signal and!c the carrier
frequency. IAdl + m(t)] I is called the signal envelope.
In particular, let!c = 2 kHz and do the following:
5

Amplitude Modulation

A very common method of transmitting information is called the carrier wave and has amplitude Ac and fre-
known as amplitude modulation (AM) will be examined quency!c = wcf(27f) Hz. The carrier frequency,!c, should
in this experiment. AM was the first widespread tech- be larger than the highest spectral component in m(t). The
nique used in commercial radio broadcasting. The ap- parameter ka is a positive constant called the amplitude
proaches presented here are particularly suited for imple- sensitivity of the modulator.
mentation by digital signal processors. More complete The signal
discussions of AM and analog implementations can be
found in the textbooks on communication systems sug- (5.3)
gested at the end of this experiment.
is called the envelope of set). When!c is large relative
to the bandwidth of met), the envelope is a smooth signal
5.1. Theoretical Description of that passes through the positive peaks of set) and it can
Amplitude Modulation be viewed as modulating (changing) the amplitude of the
carrier wave in a way related to met). In standard AM
5.1.1. Mathematical Formula for broadcasting, kam(t) is adjusted so that
an AM Signal
1 + kam(t) ~ 0 for all t (5.4)
The purpose of modulation is to transform a mes-
sage met) into another signal set) that can be transmitted In this case, the envelope is
through some medium, such as a radio link or telephone
cable. The transformation must be reversible so that met) (5.5)
can be recovered exactly from set) at the receiver. The
original message m(t) is often called the baseband signal so met) can be recovered from the envelope to within a
and is usually a lowpass signal. The transmitted signal scale factor and constant offset.
set) is usually a bandpass signal with its spectrum cen-
tered in the passband of the communication channel, so
it is often called the passband signal. 5.1.2. Example for Single
An AM signal has the mathematical form Tone Modulation

(5.1) In the special case of the sinusoidal message, met) =


Am sin wmt, the transmitted signal has the form
where
c(t) = Accoswct (5.2) (5.6)

65
66 Chapter 5

where fJ, = kaAm is called the modulation index. For' frequency W. The Fourier transform of the transmitted
o ::; fJ, ::; I, the envelope has the maximum value signal, s(t), is

emax = Ae(l + fJ,) (5.7) S(w)


and minimum value +
(5.8) +
Taking the ratio of these two equations and solving for
An example is shown in Fig. 5.1. Note that the mod-
fJ, gives the following formula for easily computing the ulation adds a spectral line at the carrier frequency and
modulation index from a display of the modulated signal. translates the baseband spectrum, so that it is centered
l-~ about the carrier frequency.
fJ,=1+~
ef'nQX
(5.9)
ernax

5.2. Demodulating an AM Signal


When fJ, = I the AM signal is said to be 100% modu-
by Envelope Detection
lated, and the envelope periodically reaches O. The signal
is said to be overmodulated when fJ, > I. In general, the Commercial radios use a simple, inexpensive, analog
AM signal is said to be overmodulated when I + kam(t) circuit known as an envelope detector to demodulate AM
is negative some of the time and, then, m(t) cannot be signals. This circuit employs a diode, capacitor, and resis-
determined from the envelope without distortion. tors to follow the positive peaks of the AM wave, with the
Using the trigonometric identity for the product of assumption that the signal is less than 100% modulated.
cosines, the transmitted signal can be expressed as Two methods for envelope detection that are particularly
suited to digital signal processing will be studied in this
s(t) Aecoswet + O.5AefJ,cos(we + wm)t experiment. The first method is called square-law detec-
+ O.5AefJ,cos(we - wm)t (5.10) tion and the second method uses the Hilbert transform
to create something called the complex envelope. As a
The first term is a sinusoid at the carrier frequency and designer, you should always evaluate whether the ana-
carries no message information. The other two terms are log envelope detector or DSP implementation is the most
called sidebands and carry the information in m(t). The cost-effective method for accomplishing your task.
total power in s(t) is

(5.11) 5.2.1. Square-Law Demodulation


of AM Signals
while the power in the sidebands due to the message is
The block diagram of a square-law envelope detector
(5.12) is shown in Fig. 5.2. The input s(t) has the form of the
AM signal given by (5.1). It will be assumed that the
and their ratio is baseband message m(t) is a lowpass signal with cutoff
_Pm_~ frequency W. The first block in the detector squares the
P s - 2 + fJ,2
"l -
(5.13) input, resulting in the signal

This ratio increases monotonically from 0 to 1/3 as fJ, S2(t) A~[l + k am(t)]2 COs 2 wet
increases from 0 to 1. Since the carrier component carries O.5A~[1 + kam(t)]2
no message information, the modulation is most efficient
+ O.5A~[1 + kam(t)]2 cos 2wet (5.15)
for 100% modulation.
The first term on the right-hand side of(5.15) is a lowpass
5.1.3. The Spectrum of an signal except that the cutoff frequency has been increased
AM Signal to 2W by the squaring operation. The second term has
a spectrum centered about ±2wc . For positive frequen-
Suppose the baseband message m(t) has a Fourier cies, this spectrum is confined to the interval (2we - 2 W,
transform M(w) and M(w) = 0 for Iwl ;::: W. The message 2we + 2W). For the square-law detector to work properly,
is said to be a lowpass bandlimited signal with cutoff the spectra for these two terms must not overlap. This
Amplitude Modulation 67

M(w)

W
-W 0 W

S(w)
tkaM(w + We) tkaM(w - We)

nAe nAe

W
-We-W -We +W 0 We - W We+ W

Figure 5.1. Spectrum of an AM signal. a) Fourier transform of baseband signal; b) Fourier transform of transmitted AM signal.

requirement is met if dc offset. In many cases, the baseband message has no


spectral components around zero frequency and the dc
2W < 2we - 2W or we > 2W (5.16) offset can be removed by a simple highpass filter.
The sampling rate required to implement the square-
law detector by digital signal processing techniques will 5.2.2. Hilbert Transforms and
now be examined. We saw in the preceding paragraph that the Complex Envelope
the squared AM signal is bandlimited with upper cutoff
frequency 2(we + W). Therefore, the input set) must be Another type of envelope detector is based on the
sampled at a rate of at least 4(we + W) to prevent aliasing Hilbert transform. These transforms are used extensively
and the lowpass filter H( w) must operate on samples of for analysis and signal processing in passband communi-
s2(t) taken at this rate. The output of the lowpass fil- cation systems. Let x(t) be a signal with Fourier transform
ter is bandlimited in the Nyquist band with a cutoff of X(w). The Hilbert transform of x(t) will be denoted by
2 W. Thus, if H( w) is implemented by an FIR filter with x(t) and its Fourier transform by X(w). In the time-
tap spacing corresponding to the required fast input sam- domain, the Hilbert transform is defined by the integral
pling rate, computation can be reduced by computing the
output only at times resulting in an output sampling rate x(t) = x(t) * ~ = ~ j(X) X(T) dT (5.17)
of at least 4W. This technique is called skip sampling or
nt n -(X) t - T

decimation. where * represents convolution. Thus, the Hilbert trans-


The filter H( w) is an ideal lowpass filter with cutoff form of a signal is obtained by passing it through a filter
frequency 2W, so that its output is O.5A~[l + ka m(t)]2. with the impulse response
The final box in the detector takes a square-root resulting
in an output signal that is proportional to met) with a h(t) = ~ (5.18)
nt
68 Chapter 5

Lowpass
Filter

s(t) y(t)
(. )2 H(w) vTI

Figure 5.2. Square-Law envelope detector.

It can be shown that Using (5.20), it can be shown that the Fourier trans-
form of the analytic signal is
H(w) = -j signw
j forw>O X+(w) = 2X(w)u(w)
= { ~ for w =0 (5.19) 2X(w) for w>O
j for w <0 { X(O) for w=O (5.28)
The Hilbert transform filter is an ideal 90 0 phase shifter.
o for w<O
Therefore, in the frequency domain Thus, the analytic signal has a one-sided spectrum, i.e.,
its Fourier transform is 0 for negative w.
X(w) = H(w)X(w)
The complex envelope of a signal x(t) with respect
= ( - j sign w) X (w) (5.20) to carrier frequency We is defmed as
The following Hilbert transform pairs will be useful:
(5.29)

(5.21) and has the Fourier transform

sin wet ~ - cos wet (5.22) X(w) = X+(w + we)


cos (wet + 0) ~ cos (Wet + 0 - ~) (5.23) 2X(w + we)u(w + We) (5.30)

Let m(t) be a lowpass signal with cutoff frequency WI and When these definitions are used, x(t) is usually a bandpass
c(t) a highpass signal with lower cutoff frequency W2 > signal and We is a frequency in the passband. Then x(t) is
WI. Then a lowpass signal. As an example, consider the AM signal
m(t)c(t) ~ m(t)c(t) (5.24) s(t) given by (5.1). Its pre-envelope is

(5.31)
The analytic signal or pre-envelope associated with
x(t) is defined to be and its complex envelope is

:l:f-(t) = x(t) +j x(t) (5.25) s(t) = Ae[l + kam(t)] (5.32)


As an example, the analytic signal associated with x(t) = Motivated by the example in the previous paragraph,
cos wet is we will define the real envelope of a bandpass signal x(t)
to be
:l:f-(t) cos wet + j sinwet
e(t) = Ix(t)1 (5.33)
e jwct (5.26)
Another equivalent formula for the real envelope is
As another example, let m(t) be a lowpass signal with
cutoff frequency W less than the carrier frequency We. e(t) = I:l:f-(t) I = [x 2 (t) + x2 (t)] 1/2 (5.34)
Using (5.24), the analytic signal associated with x(t) =
m(t)cos wet can be shown to be The block diagram of an envelope detector based on
(5.34) is shown in Fig. 5.3. The required sampling rates
:l:f-(t) = m(t) COS wet + j m(t) sin wet will now be investigated when the detector is implemented
= m(t)e jwct (5.27) by digital signal processing techniques. If the input signal
Amplitude Modulation 69

set) is a standard AM signal and the baseband message detector for some combinations of modulating and carrier
met) is bandlimited with cutoff frequency W, then set) is frequencies. Set the signal generator to output a 160 Hz
bandlimited with cutoff frequency W + We. Thus, the in- sine-wave with an amplitude that creates less than 100%
put to the Hilbert transform filter must be sampled at a modulation. Calculate and sketch the spectrum of the
rate of at least 2(W + we) to prevent aliasing. The squared AM signal. Synch the oscilloscope to the signal gener-
envelope is bandlimited with cutoff frequency 2 W so the ator sine-wave and sketch the signal you observe on the
decimation technique described for the square-law enve- oscilloscope. Increase the amplitude of the input signal
lope detector lowpass filter can be applied to the Hilbert until the AM signal is overmodulated and sketch the re-
transform filter when it is an FIR filter. Also, the bound sulting waveform. What is the effect of overmodulation
relating We and W for the square-law detector is not re- on the spectrum?
quired for this detector. Experiment modulating square-wave and triangular
signals that the signal generator can create.

5.3. Laboratory Experiments for AM


Modulation and Demodulation 5.3.2. Making a Square-Law
Envelope Detector
In the following experiments, you will use the EVM
to modulate and demodulate AM signals. This should Write a C and/or assembly language program for the
reinforce your theoretical knowledge. For each of the ex- TMS320C30 to implement the square-law envelope de-
ercises, initialize the TMS320C30 and AIC as in Chapter tector shown in Fig. 5.2. Continue to use an 8-kHz sam-
2. This means you will be using an 8-kHz sampling rate. pling frequency. Take the input samples from the AIC
AID converter and send the demodulated output samples
5.3.1. Making an AM Modulator to the DIA converter. Assume that the carrier frequency
is 1.5 kHz and the baseband message met) is bandlimited
Write a C/assembly language program for the TMS- with a cutoff frequency of 200 Hz. Use a Butterworth
320C30 to lowpass IIR filter for H( w) that has an order sufficient to
suppress the unwanted components around 2!c by at least
I. Read samples m(nT) from the AIC at an 8-kHz rate 40 dB.
2. AM modulate the input samples to form the sequence Assume that mh(t) hasffino spectrhal components below
50 Hz and remove t e dc 0 set at t e output of the square
s (n T) = Ae[1 + k'am, (T)]
n cos 27f f enT root box by a simple highpass filter of the form

where the carrier frequency is Ie = 1.5 kHz and Ae G(z) = 1 + c 1 - Z-l (5.35)
is a constant chosen to give a reasonable size output. 2 1 - cz- 1

3. Send senT) to the AIC D/A converter where c is a constant slightly less than I, chosen so that
the lowest frequency components of met) are negligibly
You should convert the input samples to floating point distorted. Note that this filter has an exact null at 0
numbers, do the modulation using floating point arith- frequency and is 1 at half the sampling rate. Plot the
metic, and then convert the modulated samples back to amplitude response of this filter for various c to select
appropriately scaled integers. an appropriate value. You could also use the program
Remember that the input samples from the AIC are IIR.EXE to design this filter.
16-bit integers with the two Isb's equal to zero. If you Attach the signal generator to the AID input and the
convert these samples to 32-bit TMS320C30 integers by oscilloscope to the DIA output. Set the signal generator
shifting them left 16 bits and then arithmetically right by to create an AM wave with a sinusoidal modulating sig-
18 bits as in previous experiments, the resulting integers nal with a frequency between 50 and 200 Hz. Sketch the
lie in the range ±2 13 . Therefore, you must choose ka or AM input signal and the output of your demodulator. Ex-
scale the I in the AM equation, so that the signal is not periment using various modulating signals on the signal
overmodulated. generator.
Attach the signal generator to the AIC input and the Experiment demodulating signals corrupted by ad-
AIC output to the oscilloscope. You may also find it ditive, zero mean, Gaussian noise. Since the lab does
interesting to attach a speaker to the AIC output and lis- not have hardware continuous-time noise generators, you
ten to the AM signals you will generate. Your ear is a will have to simulate the noise in the TMS320C30. Use
nonlinear system and can act somewhat like a square-law the method described in Appendix B to generate a noise
70 Chapter 5

,... -j signw
.5( t)
(-)2
.5 2 (t)

8( t)

~ vTI
e(t)

(- )2
82(t)

Figure 5.3. Envelope detector using the Hilbert transform.

sample each time a new sample is read from the AID should be implemented by an assembly language func-
converter and add the simulated noise sample to the input tion called from C as described in Section 3.2.4. Again,
signal sample. Use a sinusoidally modulated AM signal assume a carrier frequency of 1.5 kHz and a baseband
as the input. Start with a large signal-to-noise power ra- message bandlimited to 200 Hz. In addition to the com-
tio (SNR) and decrease it until the demodulator output ponents shown in the figure, add the same highpass filter
is very noisy and barely resembles the message sinusoid. you used in the square-law detector after the square root
The degradation will increase relatively smoothly over a box to remove the dc component of the detector output.
range of SNR and you will have to use your judgement as You can design the Hilbert transform filter with the
to what "barely resembles" means. Estimate the SNR in program REMEZ87. Use an odd number N of filter taps.
dB at this point. When the noise becomes larger than the Good results can be achieved by using just one band with
signal, the envelope detector begins to follow the envelope a lower cutoff frequency 11 and upper cutoff frequency
of the noise rather than the envelope of the signal. h chosen to pass the AM signal. Choosing the band to
The average noise power is 0'2. You can estimate be centered in the Nyquist band also seems to improve
the average power of the AM signal samples by making the filter amplitude response generated by REMEZ87. To
the simple power meter shown in Fig. 5.4. The constant center the band, choose the upper cutoff frequency to be
a should be close to, but slightly less than, I to create a h = 0.51s - fi where Is is the sampling frequency. Enter
narrow band lowpass filter. Try a = 0.99, for example. 1 for the magnitude of the Hilbert transform in the band
Notice that the gain of the filter at 0 frequency is I. The and 1 for the weight factor. Select N so that the amplitude
lowpass filter generates an estimate of the true statistical response of the filter is quite flat over the signal passband,
expected value E{s2(n)} by time averaging. Make a loop and ripples caused by incomplete cancellation of the 2!c
to run the power meter for several thousand samples. Put components are essentially invisible in the demodulated
a break point after the loop. Then you can examine the output.
final value of p(n) with EVM30 when the program halts You can also design the Hilbert transform filter with
at the break point. the program WINDOW.EXE. Try using the Hamming and
Kaiser windows. You can make a tradeoff between the
5.3.3. Making an Envelope Detector transition bandwidth and the out-of-band attenuation with
the Kaiser window.
Using the Hilbert Transform
The resulting FIR filter will have a delay equal to
Write a C and assembly language program for the the delay from the input to the center tap of the filter, T(N
TMS320C30 to implement the envelope detector shown in - 1)/2. Therefore, s(nT) must be delayed by this amount
Fig. 5.3. The FIR Hilbert transform filter convolution sum to match the delay in .§(nT). This can be accomplished

Squarer Lowpass Filter

8(71.) x(71.) = 82(71.) I-a


p(71.) = (1 - a)x(71.) + ap(71. - 1)
(-)2 .....
1 - az- 1

Figure 5.4. A simple power meter.


Amplitude Modulation 71

easily by taking senT) from the point in the delay-line of


the Hilbert transform filter at its center tap.
Test your envelope detector using the same steps as
you did for the square-law detector.

5.4. Additional References


There are many good textbooks on communication
systems that include discussions of amplitude modula-
tion. For example, see Gibson [II.C.9, Chapter 5], and
Haykin [1I.D.I7, Chapter 3]. See Haykin [II.D.I7, Sec-
tions 2.10-2.13] for discussions of the Hilbert trans-
form, pre-envelope, complex envelope, and applications
to bandpass systems.
6

Double-Sideband Suppressed-Carrier Amplitude


Modulation and Coherent Detection

The standard AM modulated signal contains a sinusoidal transform of s(t) is


component at the carrier frequency which does not convey
any of the baseband message information. This compo- S(W) O.5AeM(w - we)
nent is included to create a positive envelope which allows + O.5AeM(w + we) (6.2)
demodulation by a simple, inexpensive envelope detector.
From an information theory point of view, the power in This is the same as the AM spectrum but with the discrete
the sinusoidal carrier component is wasted. In this ex- line at the carrier frequency removed. An example is
periment, you will see that it is not necessary to trans- shown in Fig. 6.2b. It will be assumed that m(t) is a
mit the carrier component and that the baseband message lowpass signal with cutoff frequency W. Then, the carrier
can be recovered by a coherent demodulator. In fact, it frequency must satisfy the bound, We > W so that the
can be shown that a coherent demodulator performs better two terms on the right-hand side of (6.2) do not overlap
than an envelope detector when the received signal is cor- as shown in Fig. 6.2b. When they overlap foldover is
rupted by additive noise. The type of modulation that will said to have occurred, and perfect demodulation cannot
be studied in this experiment is called double-sideband be achieved. When m(t) is a real signal, M( -w) = M (w)
suppressed-carrier amplitude modulation (DSBSC-AM). and
A close approximation to an ideal coherent demodulator
S(We - w) = S(wc + w) for 0::; W ::; We (6.3)
called a Costas loop will be implemented.
This equation shows that the component at frequency We +
W contains exactly the same information as the component
6.1. Mathematical Description of at We - w, since one can be uniquely determined from the
the DSBSC-AM Signal other by taking the complex conjugate. The portion of
the spectrum for Iwi > We is called the upper sideband
As usual, let m(t) be a baseband message signal. The and the portion for Iwi < We is called the lower sideband.
DSBSC-AM signal corresponding to m(t) is The fact that the modulated signal contains both portions
of the spectrum explains why the term double-sideband
(6.1 ) is used.

This is the same as the AM signal except with the si-


nusoidal carrier component eliminated. A message m(t) 6.2. The Ideal Coherent Receiver
typically has positive and negative values so it can not be The block diagram for an ideal coherent receiver is
recovered from s(t) by an envelope detector. The Fourier shown in Fig. 6.1. First, the received signal is passed

73
74 Chapter 6

through a bandpass filter centered at the carrier frequency optimum coherent demodulation can be achieved. A mod-
that passes the DSBSC signal and eliminates out-of-band ification of a type of PLL called a Costas loop is shown in
noise. The output of the receive bandpass filter is then Fig. 6.3. This form is particularly suited for DSP imple-
multiplied by a replica of the carrier wave. This replica mentation and the signals shown in the figure are discrete-
is generated by a device called the local oscillator (LO) time signals with sampling period T.
in the receiver. Assuming no noise, the product is To add some generality, let the received signal after
it has passed through a bandpass receive filter have the
Sl(t) 2s(t) cos wet form
2Aem(t) cos 2 wet s(nT) = Aem(nT) cos (wenT + (h) (6.8)
Aem(t) + Aem(t) cos 2wet (6.4) where We is the nominal carrier frequency and (h is a
constant or slowly changing phase angle. When there is
The device that performs the product is often called a a frequency offset between the nominal and actual carrier
product modulator or balanced mixer. frequencies due to Doppler shifts or misalignment of the
The Fourier transform of the product modulator out- transmitter and receiver local oscillators, (h takes the form
put is
(h = D..wnT (6.9)
AeM(w) + O.5AeM(w + 2we)
where D..w is the frequency offset.
+ O.5AeM(w - 2we) (6.5) The first step in the system is to form the complex
envelope
and is illustrated in Fig. 6.2c. The first term on the right-
hand side of (6.4) is proportional to the desired message. s(nT) + js(nT)
The second term has spectral components centered around Ae m (nT)e j (wc nT+6ll (6.10)
-2we and 2we. The corresponding terms can be seen in
Sl (w). The undesired high frequency terms are eliminated The parallel solid and dotted lines in the figure represent
by the final lowpass filter which has cutoff frequency W. complex signals, with the solid line corresponding to the
This is often called a post detection filter. real part and dotted line to the imaginary part.
An alternative method of demodulation is to first The system generates an estimate ¢(nT) of the angle
form the pre-envelope of the received signal. With no of the received signal that can expressed as
additive noise, this is
(6.11 )
s(t) + js(t)
The method for generating this angle will be explained
Aem(t) cos wet shortly. It is passed through the complex exponential box
+ jAem(t) sin wet to give the local oscillator signal e-jq,(nT).
Aem(t)ejwct (6.6) The local oscillator signal is multiplied by the com-
plex envelope resulting in the signal
The baseband message is then recovered to within a scale s+(nT)e-J<I>(nT)
c(nT)
factor by forming the complex product
Ae m (nT)ej[lh -02(nT)) (6.12)
(6.7)
which is separated into its real part

c1(nT) s( nT) cos ¢( nT)


+ s(nT) sin ¢(nT)
6.3. The Costas Loop as a Practical Aem(nT) cOS[Ol - 02(nT)] (6.13)
Approach to Coherent
and imaginary part
Demodulation
A receiver must have perfect knowledge of the car- s(nT) cos ¢( nT)
rier frequency and phase of a received DSBSC-AM sig- s( nT) sin ¢( nT)
nal to perform exact coherent demodulation, and this is Aem(nT) sin[Ol - O2(nT)] (6.14)
almost never the case. However, these parameters can be
estimated and tracked very accurately at the receiver by The loop is said to be in lock when the phase error
devices called phase-locked loops (PLL's), so that nearly 01 - O2 remains small. When the phase error is exacty
Double-Sideband Suppressed-Carrier Amplitude Modulation and Coherent Detection 75

Local
Oscillator

2 cos wet

8 (t) 81 (t) m'1 (t)


B(w) x G(w)
Mlxer
Bandpass Lowpass
Receive Filter Post Detection Filter

Figure 6.1. Block diagram of an ideal coherent receiver.

zero, the demodulated message appears at the point la- that at each new sampling instant the loop's phase es-
belled C1 (nT) = m1 (nT) and c2(nT) = O. A lock detection timate is incremented by the nominal change in carrier
strategy is to lowpass filter c~(nT) and declare that the phase between samples WeT plus a small correction term
loop is in lock when this signal falls below a threshold aq(nT) roughly propotional to the phase error. Note that
for a period of time. when q(nT) = 0 for all n, ¢(nT) is the linear ramp
The real and imaginary parts are multiplied, resulting
in the signal ¢(nT) = WenT + ¢(O) (6.19)

q( nT) C1 (nT)c2 (nT) which has a slope equal to the nominal carrier frequency.
A~m2(nT) cos[8 1 - 82 (nT)] The accumulator block (3/(1 - z-1) is included to allow
x sin[8 1 - 82 (nT)] the loop to track a carrier input phase 81 (nT) that is a
linear ramp with zero steady-state error. The input phase
O.5A~m2(nT) sin{2[8 1
has this form when there is a frequency offset between the
82 (nT)]} (6.15) received and local carrier frequencies. This block, along
with the rest of the lower branch, introduces a second-
Notice that when 81 and 82 differ by less than 90 0 , q(nT)
order pole at z = 1 in the open loop gain, which is equiv-
has the same sign as the phase error 8 1 -82 , so it indicates
alent to a double accumulation in the time-domain. It
in which direction the local phase estimate 82 should be
is well known in automatic control theory that a loop
changed to reduce the phase error to zero. When the loop
with the double accumulation can track a first-order in-
is in lock, the small angle approximation sin x ~ x can
put polynomial (linear ramp) with zero steady-state error
be used to accurately approximate q(nT) by
while with a single accumulation it cannot. The output
q(nT) A~Tn2(nT)[81 - 82(nT)] O"(nT) of the accumulator reaches the steady-state value
.6.w T which is the phase change between samples caused
for 181 - 82 (nT)1 « 1 (6.16) by the frequency offset .6.w.
The lower half of the block diagram generates the The Costas loop is a nonlinear and time-varying sys-
loop's estimate of the phase of the received signal by tem because of the sinO and m 2(nT) terms in q(nT).
computing Therefore, it cannot be characterized by a transfer func-
tion. However, when m(nT) is a stationary process and
¢((n + l)T) ¢(nT) + weT the loop is in lock, it can be accurately approximated by a
linear, time-invariant system by using the small angle ap-
+ aq(nT) + O"(nT) (6.17)
proximation (6.16) and replacing m 2(nT) by its expected
where value. Replacing m 2(nT) by its expected value can be
justified by the fact that the loop filters act as lowpass
O"(nT) = (3q(nT) + O"((n - l)T) (6.18) filters on q(nT), resulting in a time-averaged estimate of
its statistical mean. Let
and a and (3 are small positive constants with (3 < a/50,
typically. The basic philosopy behind these equations is (6.20)
76 Chapter 6

M(w)

-w
~~ o w
w

S(w)

w
o
c

Figure 6.2. Spectra in a DSBSC-AM communication system. a) Fourier transform of baseband message;
b) Fourier transform of DSBSC-AM signal; c) Fourier transform of mixer output.

and further approximate q(nT) by 6.4. Laboratory Exercises and


Experiments for the
q(nT) ::::: kl[OI - O2 (nT)] (6.21 )
Costas Loop
These approximate equations can be represented by the
Now it is time for you to design, implement, and
linearized loop shown in Fig. 6.4. The transfer function
test a Costas loop coherent receiver. The continuous-time
for the linearized loop is
modulated input signal for your receiver can be generated
8 2 (z) by the signal generator. The signal generator should be
H(z)
8 1 (z) set to generate an output voltage of the form

kl(a+{J) (1- a:{Jz-I) s(t) = Aem(t)cos27flet (6.23)

/ {I - [2 - kl(a + (3)]z-1 where


+ (1 - k Ia)z-2} (6.22)
Ae 1
The frequency response is obtained by letting z = ei wT ,
m(t) 1 + OAcos27flmt
and has the shape of a narrowband lowpass filter for small
a and (J. The closed loop gain at zero frequency is H(l) Ie 2000 Hz
=1. 1m 200 Hz
Double-Sideband Suppressed-Carrier Amplitude Modulation and Coherent Detection 77

ml(nT)

s(nT)
-jsignw --------------------------,
c2(nT) = ~m{s+(nT)e-j(wcnT+II2)} I
I
I I
L ______ .J

q(nT)

a(nT)
(3
1- z-l

¢(nT)

Figure 6.3. Second-order Costas loop demodulator.

Actually, s(t) is an AM signal with modulation index J.1 = stants, for example, a = 0.01 and (3 = 0.002. You will
004. However, it can also be considered to be a DSBSC- find that (3 should be small relative to a, perhaps, less
AM signal with m(t) containing a dc value and all the than a150, to get a transient response without excess rip-
theory for the Costas loop still holds. ple. Recursively compute the response of the linearized
loop to a unit step in 81 (nT) using the following formula
which is based on (6.22):
6.4.1. Theoretical Design Exercises
82(nT) k1[(a + (3)B1(nT)
In these exercises you will do theoretical computa- a8 1 ((n -1)T)]
tions to select the Costas loop parameters for a reasonable + [2 - k1(a + (3)]8 2((n - 1)T)
design. Do the following steps:
(1 - k1a)8 2 ((n - 2)T)
1. Compute kl by (6.20).
2. Choose some small values for the loop filter con- Continue the computations until 82(nT) gets close to its

fh(nT)
+ kl

-
82 (nT)

(3
r---
1- z-l

Z-l + 0- a

Figure 6.4. Linearized Costas loop.


78 Chapter 6

fmal value and plot the result. Repeat this step for dif- The linearized equations describe the loop behavior
ferent values of a and f3 until you fmd a pair for which accurately when it is in lock. When there is a large initial
the step response settles to its final value in about 0.5 frequency offset, the behavior is quite different. Exper-
seconds. imentally investigate this behavior by setting the signal
3. Compute and plot the closed loop amplitude re- generator carrier frequency to a value that differs by 30
sponse A(j) = 2010glOIH(&27r f1f s ) I for the values of a Hz or more from the nominal 2-kHz value and starting
and f3 finally selected in the previous step. the Costas loop. The loop may take a much longer time
than you expected to achieve lock. This is called its pull
6.4.2. Hardware Experiments in behavior.
Experiment demodulating signals corrupted by addi-
Write a C/assembly language program for the TMS- tive, zero mean, Gaussian noise. Use the approach de-
320C30 to perform the following steps: scribed in Section 5.3.2. In particular, observe the be-
1. Initialize the TMS320C30 and AIC as in Experiment havior of the coherent demodulator as the signal-to-noise
2. ratio is decreased and make a rough estimate of the SNR
at which the demodulator no longer works. If your loop
2. Read samples from the AIC AID converter at an 8 was designed properly, it should work at lower SNR's
kHz sampling rate. than the envelope detectors. If you are interested in doing
3. Demodulate the input signal with a Costas loop. more and time permits, set up an array and write the first
4. Send the demodulated signal samples to the DIA con- few hundred samples of q(nT) to the array. Do not add
verter. noise to the input samples. Then send the array to the PC
and plot the resulting signal to get a clearer picture of the
Connect the signal generator to the EVM input and loop transient response. You can also do this with other
set it to generate the AM signal set) defined above. Con- signals in the loop.
nect the EVM DIA output to the oscilloscope and debug
your DSP program if the output is not met).
Once your coherent demodulator is working properly,
6.S. Additional References
investigate its performance in the presence of a frequency
offset. First set the signal generator carrier frequency to For more complete presentations of DSBSC-AM, see
the nominal 2-kHz value and let your loop achieve lock. Gibson [II.D.9, Chapter 5] and Haykin [II.D.17, Chapter
Then slowly change the carrier frequency to a slightly 3]. For Costas loop discussions see Gibson [II.D.9, Sec-
different value and see if the loop reacquires lock. Use tion 8.8], Gitlin, Hayes, and Weinstein [II.D.ll, Section
the C Source Debugger, EVM30, to watch a(nT) in your 6.3], and Stiffler [II.D.3l, Section 8.5]. To my knowl-
DSP program and check that it has the correct steady-state edge, the modified Costas loop structure shown in this
value for the frequency offset you are using. experiment cannot be found in other textbooks.
7

Single-Sideband Modulation
and Frequency Translation

AM and DSBSC-AM modulation do not use the frequency which has the Fourier transform
spectrum efficiently. Their spectral components at equal
distances above and below the carrier frequency contain A(w) O.5A eM(w - we)
identical information, because they are complex conju- + O.5AeM(w + we) (7.2)
gates of each other. The portion above the carrier fre-
quency is called the upper sideband and the portion below and is centered around the carrier frequency We'
the lower sideband. In this experiment you will see how The DSBSC-AM signal is then passed through the
a baseband message can be transmitted by using only one fIlter H( w) to select the desired sideband. Upper sideband
of the sidebands and, consequently, half the bandwidth SSB modulation is created with the ideal highpass fIlter
of AM or DSBSC-AM. This type of modulation is called
single-sideband (SSB) modulation. It has been used ex- for Iwi > We
(7.3)
elsewhere
tensively in many radio transmission systems and in the
telephone network. and the lower sideband SSB modulation by the ideal low-
Translating the frequency spectrum of a signal is pass fIlter
closely related to SSB modulation and is commonly used
at various points in communication systems. A technique for Iwi < We
for frequency translation particularly suited to DSP im- elsewhere
(7.4)
plementations will be described in this experiment. No
frequency translation experiments will be performed since It will now be shown that an SSB signal can be ex-
it is actually the same as upper sideband SSB modulation. pressed in terms of the baseband message m(t) and its
Hilbert transform m(t). The pre-envelope of the SSB sig-
nal has the transform '
7.1. Single-Sideband Modulators 2S(w)u(w)
An obvious type of SSB modulator is shown in 2A(w)H(w)u(w)
Fig. 7.1. As usual, we will assume that the baseband mes- AeM(w - we)H(w) (7.5)
sage signal m(t) is band limited with a cutoff frequency
W, which is less than the carrier frequency We. The fIrst and the transform of its complex envelope is
stage of this modulator generates the DSBSC-AM signal
S(w) S+(w+w e)
a(t) = Aem(t) COS wet (7.1) AeM(w)H(w + we) (7.6)

79
80 Chapter 7

m(t) s(t) 7.2. Coherent Demodulation


• of SSB Signals
One approach to demodulating SSB signals is fust to
multiply the received signal by a locally generated replica
of the carrier signal. Multiplying (7.9) or (7.12) by 2cos
wet yields
Figure 7.1. SSB modulation by combining OSBSe-AM and filtering.
b(t) = Aem(t) cos 2 wet
Now consider the upper sideband case. On substi- =f Aem( t) sin wet cos wet
tuting Hu(w) for H(w) in (7.6), it can be seen after a little = O.5Aem(t) + O.5Aem(t) cos 2wet
thought that =f O.5Ae sin 2wet (7.13)

S(w) = AeM(w)u(w) The first term on the right-hand side of (7.13) is propor-
O.5AeM(w)(1 + signw) tional to the desired message. The second and third terms
=
have spectra centered about 2we , and can be removed by
= O.5AeM(w)[1 + j( -jsignw)] passing b(t) through a lowpass filter with cutoff frequency
= O.5AeM(w) + jO.5AeM(w) (7.7) w. The effect in the frequency domain of multiplying by
cos wet in the time domain is to shift S(w) to the right
So, the complex envelope is and left by We and take the sum. This translates the side-
bands around ±we down to baseband and forms M(w),
s(t) = O.5Ae[m(t) + jm(t)] (7.8) which is the desired term and also translates them up to
±2we , which are the terms removed by the lowpass filter.
Therefore, the SSB signal can be expressed as A block diagram for this demodulator has the same form
as Fig. 7.1, except with the input m(t) replaced by the re-
s(t) = lRe{s(t)e jWct } ceived signal 8(t) and the filter H(w) by a lowpass filter.
O.5Aem(t) COS wet In practice, this system should be preceded by a bandpass
filter that passes 8(t) and eliminates out-of-band noise.
- O.5Aem(t) sin wet (7.9)
Another SSB demodulator that uses a Hilbert trans-
form and is well suited to DSP implementation will now
Similarly, in the lower sideband case, it follows that be described. The first step is to take the Hilbert trans-
the transform of the complex envelope is form of the received signal 8(t) and form the pre-envelope.
Using (7.8) and (7.11), the pre-envelope can be expressed
S(w) = AeM(w)u( -w) as
= O.5AeM(w)(1 - signw)
= O.5AeM(w)[1 - j( -jsignw)] s+(t) s(t) + js(t)
= s(t)e jwct
= O.5AeM(w) - jO.5AeM(w) (7.10)
= O.5Ae[m(t) ±jm(t)]ejwct (7.14)
Therefore, the complex envelope is
where the plus sign is for upper sideband and the minus
sign is for lower sideband modulation. Multiplying the
s(t) = O.5Ae[m(t) - jm(t)] (7.11)
pre-envelope by e- jwct generates the complex envelope
The corresponding SSB signal is s(t) = s+(t)e- jwct
= O.5Ac[m(t) ± jm(t)] (7.15)
s(t) = !Re{s(t)d wct }
= O.5Aem(t) COS wet In the frequency domain, this translates the transform of
+ O.5Aem(t) sin wet (7.12) the pre-envelope down to baseband. Taking the real part
of this complex signal gives
Equations (7.9) and (7.12) suggest the SSB modula~
O.5A e m (t) !Re{s+(t)e- jwct }
tor structure shown in Fig. 7.2. Upper or lower sideband
selection is accomplished by simply changing the sign of = !Re{[s(t) + js(t)][coswet - jsinwet]}
the input to the lower side of the output adder. = s(t) cos wet + s(t) sin wet (7.16)
Single-Sideband Modulation and Frequency Translation 81

O.5Ae cos wet

m(t) + s(t)
LO +
- usb
_90°
+ Isb

-jsignw
.r-l
X
O.5A"inw,t

Figure 7.2. A single-sideband modulator using a Hilbert transform.

which is proportional to the desired message signal. This local carrier reference by using a narrow bandwidth band-
demodulator requires taking a Hilbert transform but does pass filter to select the pilot tone and possibly following
not require filtering out terms at twice the carrier fre- this filter by a phase-locked loop.
quency. Figure 7.2 is also a block diagram for a demod-
ulator that implements (7.16) if the input met) is replaced
by the received signal set), the cosine and sine amplitudes
are set to 1, and the plus sign is chosen at the output 7.3. Frequency Translation
adder. In practice, the demodulator would be preceded by
a bandpass filter that passes the signal components and The spectrum of a bandpass signal must often be
rejects out-of-band noise. translated from one center frequency to another in com-
munication systems. One reason is to place the signal
These two demodulators assume that the receiver has spectrum in an allocated channel. Several messages can
perfect knowledge of the received carrier frequency and be multiplexed together by shifting them to nonoverlap-
phase. Unfortunately, this information cannot be derived ping adjacent spectral bands and transmitting the sum of
by a system like the Costas loop, because the SSB signal the resulting signals. This is called frequency division
is the sum of an inphase component m(t)cos wet and a multiplexing (FDM). Another reason is to correct for car-
quadrature component rh(t)sinwet. It can be shown that rier frequency offsets caused by oscillator inaccuracies or
when the demodulator's frequency is correct but the phase Doppler shifts. Of course, AM, DSBSC-AM, and SSB
is in error, the demodulated output is a phase shifted ver- modulators translate signal spectra from baseband to pass-
sion of the transmitted message. Since the human ear band and the coherent demodulators do the reverse.
is relatively insensitive to phase, this does not degrade A method for frequency translation that is well suited
voice or music. However, the result can be severe when to DSP applications will now be described. Let sCt) be
the shape of the message must be maintained, as in dig- a bandpass signal with the frequency Wo somewhere in
ital data communication systems. A frequency error re- its passband. The problem is to translate the spectrum so
sults in a demodulated signal which has all its spectral that Wo is moved to WI = Wo + !:l.w. The first step is to
components shifted by this error. A standard approach to form the pre-envelope
solving this problem is to add a small sinusoidal compo-
nent called a pilot tone whose frequency is not in the SSB s+(t) = s(t) + js(t) (7.17)
signal band and has a known relationship to the carrier
frequency. The pilot tone frequency is often chosen to be The corresponding Fourier transform is
the carrier frequency when the baseband message signal
has no dc components. The receiver can then generate a S+(w) = 2S(w)u(w) (7.18)
82 Chapter 7

The next step is to mUltiply by a complex exponential 7.4.1. Making an SSB Modulator
with frequency tlw to get
Write a C/assembly language program for the TMS-
s+(t)e j 6.wt = [s(t) + js(t)] 320C30 to implement the S8B modulator shown in
Fig. 7.2 and send the output samples to the DIA converter.
x [cos tlwt + j sin tlwt] (7.19)
Use the carrier frequency!c = 2 kHz and amplitude Ae
which has the transform
= 0.5. Generate the message signal m(t) = cos 27rl000t
within the modulator program.
(7.20) Determine the theoretical formulas for the transmit-
ted SSB signals for both the upper and lower sideband
This translates the original spectrum to the right by tlw cases. Observe the signals generated by your program on
and moves the value at Wo to the frequency WI. Taking the oscilloscope for both cases and compare them with
the real part of r + (t) gives the desired translated signal the theoretical results.
Now add a pilot tone p(t) = cos 27r!ct to the 88B
r(t) = s(t) cos tlwt - s(t) sin tlwt (7.21 ) output signal to provide a carrier reference for the de-
modulator you will make next.
The real part of r+(t) can also be expressed as
7.4.2. Coherent Demodulation
r(t) = [r+(t) + if+(t)]/2 (7.22)
of an SSB Signal
so its Fourier transform is
In this exercise you will make a demodulator for the
8SB signal with the added pilot tone. A block diagram
R(w) [R+(w) + R+( -w)J/2
of one possible modulator structure is shown in Fig. 7.3.
S(w - tlw)u(w - tlw) The input signal s(nT) is passed through a highpass filter
+ S( -w - tlw)u( -w - tlw) (7.23) G(w), which rejects the pilot tone but passes the 88B
component in the upper sideband case. G( w) should be
Figure 7.2 is also the block diagram for a frequency replaced by a lowpass filter which passes the 88B signal
translator if the input m(t) is replaced by the bandpass and rejects the pilot tone in the lower sideband case. A
signal s(t), the frequency We is replaced by tlw, O.5Ae is notch filter could also be used to eliminate the pilot tone.
replaced by 1, and the negative sign is used at the output The resulting signal is passed through a Hilbert transform
adder. Because frequency translation is functionally the filter to form the pre-envelope.
same as upper sideband SSB modulation with the appro- The portion enclosed by dotted lines is a pair of band-
priate carrier frequency, no translation experiments will pass filters that extract replicas of the pilot tone and its
be performed. -90 0 phase shift. The transfer functions of these two fil-
Notice that (7.21) can be used even when the pass- ters are
band of the translated signal overlaps that of the original
signal. To do this using real signals would require a dou- BI(Z) =
ble conversion process, where the signal is first shifted to (1 - r)(1 - rz- I cos weT)
(7.24)
a nonoverlapping band by multiplying by cos W3t and se- 1 - 2rz- 1 cos weT + r 2 z- 2
lecting the upper sideband with a highpass filter, and then
repeating the process to translate the spectrum back to the and
desired frequency. This is generally not as convenient as
(7.21) for DSP applications. B2(Z) =
(1 - r)rz- I sin weT
(7.25)

7.4. Laboratory Experiments


The denominators of these filters have the factorization
Initialize the TMS320C30 and AIC as in Chapter
2 for the following SSB experiments. Once again, you 1- 2rz- 1 cos weT + r 2 z- 2
will be using a sampling rate of Is = liT = 8 kHz. The (1- re jwcT z-I)(I- re- jwcT z-I) (7.26)
TMS320C30 will be programmed to both generate and
demodulate SSB signals, since the lab does not have a Thus the filter poles are at z = e±jwcT. The quantity r is
hardware SSB signal generator. a number slightly less than 1 and controls the bandwidth
Single-Sideband Modulation and Frequency Translation 83

Highpass
Filter
s(nT) a(nTL
G(w) -jsignw _______ ~ x __ • lRe(.)

r---------- ----------, Hilbert


I
I Transform
I
l-r I
I
I _________ ,
L

I
I
I
I

I
I Inphase Carrier
I
I
I
I c2(nT)
~----------------
Quadrature Carrier
_______________________________ J

Bandpass Carrier Recovery Filters

Figure 7.3. Using a pilot tone in SSB demodulation.

of the filters. The closer it is to 1, the narrower the This has the same form as the coherent demodulator dis-
bandwidth. cussed above.
Prove that at the carrier frequency We and when r Take the modulated signal at the D/A output and loop
is very close to 1, the transfer functions of the pilot tone it back to the AID input. Delays through the AIC output
extraction filters are approximately and input filters will simulate some distortion effects of
a communication channel. Expand your transmitter pro-
(7.27) gram to include a demodulator that reads input samples
from the AID converter and uses the principles just dis-
and cussed. Use the upper sideband transmitter. Create two
(7.28) arrays of a few hundred words each. As the demodu-
lated samples are generated, write them to one of the ar-
By trial and error, choose a value of r that gives roughly rays. Simultaneously, send the other array to the PC with
a 50-Hz 3-dB bandwidth. A value too close to 1 can
the DMA controller using the techniques of Appendix A.
cause significant computational problems because of the
When the first array is full, swap the two arrays and re-
high internal gain of the filter, which results in numerical
peat the process. Have the PC plot the data blocks on its
overflows and, possibly, instability. A too-small value
screen.
will make the bandwidth too large and the filter will not
sufficiently attenuate the unwanted signal components.
The pre-envelope is then demodulated by the recov- 7.5. Additional References
ered complex carrier reference and the real part is taken
to give the output signal a(nT). Let the signal input to the For more complete discussions of SSB modulation
multiplier be venT) = vl(nT) + jV2(nT). Then and a generalization known as vestigial sideband (VSB)
modulation see Gibson [II.D.9, Sections 5.4 and 5.5] and
a(nT) VI (nT)Cl(nT) Haykin [II.D.17, Sections 3.5-3.9].
V2 (nT)C2 (nT) (7.29)
8

Frequency Modulation

Frequency modulation (FM) was invented and commer- where kw is a positive constant called the frequency sen-
cialized after amplitude modulation. Its main advantage sitivity. An oscillator whose frequency is controlled by its
is that it is more resistant to additive noise than AM. In input met) in this manner is called a voltage controlled os-
addition to commercial radio, it is used as a component cillator. The angle of the FM signal, assuming the value
of television signals, for satellite and microwave com- is 0 at t = 0, is
munications, and for digital data transmission. In this
experiment the basic theory of FM modulation and de-
modulation will be presented and you will implement two
types of demodulators - the frequency discriminator and where
the phase-locked loop.
Bm(t) = kw lot meT) dT (8.4)

8.1. The FM Signal and Some is the carrier phase deviation caused by met). The FM
signal generated by met) is
of Its Properties
set) = Ae cos[wet + Bm(t)] (8.5)
8.1.1. Definition of Instantaneous
A discrete-time approximation to the FM wave can
Frequency and the FM Signal
be obtained by replacing the integral by a sum. The ap-
An FM signal is generated by using the baseband proximate phase angle is
message signal to change the instantaneous frequency of n-l
a carrier sinusoid rather than its amplitude. The instanta- B(nT) Lw(kT)T
neous frequency of a sinusoid cos B(t) is defmed to be k=O
WenT + Bm(nT) (8.6)
d
wet) = -B(t) (8.1)
dt where
n-l

This definition can be justified by observing that when Bm(nT) = kwT L


m(kT) (8.7)
B(t) = wet, its derivative is We, which is the frequency of k=O
cos wet. The instantaneous frequency of an FM wave with The total carrier angle can be computed recursively by the
carrier frequency We is related to the baseband message formula
met) by the equation
B(nT) B((n - l)T) + WeT
wet) = We + kwm(t) (8.2) + kwTm((n - l)T) (8.8)

85
86 Chapter 8

The resulting FM signal sample is sin x c::: x for [xl « 1, the FM signal can be approximated
as follows:
senT) = AecosO(nT) (8.9)
set) Ae cos [wet + Om(t)]
8.1.2. Single Tone FM Modulation Ae cos wet cos Om(t)
Ae sin wet sin Omt
A simple formula for the Fourier transform of the FM
Ae cos wet - AeOm(t) sin wet (8.14)
wave in terms of the transform of the baseband message,
like that for the AM wave, does not exist. However, in the or in complex notation
special case of the sinusoidal message m(t) = Amcos wmt
interesting results can be derived. This is called single (8.15)
tone FM modulation. The FM wave generated by this
message is This is similar to the AM signal except that the discrete
carrier component Aecos wet is 90° out of phase with the
sinusoid Aesin wet multiplying the phase angle Om(t). The
(8.10)
spectrum of narrow band FM is similar to that of AM.
This narrow band approximation is sometimes used in
The modulation index for this FM signal is defmed as analog FM modulators. However, with DSP implementa-
tions there is little reason not to use (8.9) to generate a
fJ = true FM signal.
Wm
peak frequency deviation
modulating frequency (8.11) 8.1.4. The Bandwidth of
an FM Signal
It can be shown [II.D.I7, p. 163] that s(t) has the series
exansion In general, an exact simple formula for the bandwidth
of an FM signal does not exist. The bandwidth depends on
L
<Xl
the form of the baseband message and the peak frequency
set) = Ae In(fJ) cos[(We + nwm)t] (8.12)
deviation. The following formula, known as Carson's
n=-oo
rule, is often used as an estimate of the bandwidth:
where I n(fJ) is the n-th order Bessel function of the first
kind. These functions can be computed by the series BT = 2(lll + 1m) Hz (8.16)

<Xl (1 )n+2m where Ilf is the peak frequency deviation and fm is the
In(x) = 'L..,
"' (-1) m 2I(x )1 (8.13) maximum frequency at which the baseband message has
m=O m. n+m. a component.
For example, commercial FM signals use a peak fre-
More properties of the Bessel functions can be found in quency deviation of Ilf= 75 kHz and a maximum base-
[II.D.I7, Appendix 4] and plots of the first few functions band message frequency of fm = 15 kHz. Carson's rule
are shown on page 164 of the same reference. estimates the FM signal bandwidth as BT = 2(75 + 15)=
Clearly, the spectrum of the FM signal is much more 180 kHz, which is six times the 30-kHz bandwidth that
complex than that of the AM signal. It has compo- would be required for AM modulation.
nents at the infinite set of frequencies {we + nwm ; n =
-00, ... ,oo}. Plots of the spectra for various fJ can be
found in [II.D.I7}, as well as in most other undergraduate 8.2. FM Demodulation by a
communication systems textbooks. The sinusoidal com- Frequency Discriminator
ponent at the carrier frequency has amplitude Jo(f3) and A frequency discriminator is a device that converts a
can actually become zero for some fJ. received FM signal into a voltage that is an estimate of the
instantaneous frequency of its input, without using a lo-
8.1.3. Narrow Band FM Modulation cal oscillator and, consequently, in a non coherent manner.
Typically, the conversion is performed in analog discrimi-
Another case where interesting results can be derived nators by applying the FM signal to a bandpass filter with
occurs when [Om(t)[ « 1 for all t, and is called narrow a relatively wide bandwidth and a center frequency, that
band FM. Using the approximations that cos x c::: 1 and is shifted somewhat from the FM carrier frequency so that
Frequency Modulation 87

the instantaneous frequency of the input signal falls in a as described by (S.6)-{S.9). This input is passed through
band on one side of the filter's amplitude peak where the a Hilbert transform filter to form the pre-envelope
response is monotonically increasing or decreasing. When
the instantaneous frequency changes slowly relative to the s(nT) + js(nT)
time-constants of the filter, its output is approximately Aeej[wcnT+IIm(nTl] (S.21)
an FM signal with the same instantaneous frequency but
with an envelope that varies according to the amplitude The pre-envelope is multiplied by the output of the
response of the filter at the instantaneous frequency. The voltage controlled oscillator (VeO) block. The phase of
amplitude variations are then detected with an envelope the veo one sample into the future is the input to the
detector like the ones used for AM demodulation. This z-l block, which is described by the equation
approach could be used to design a discrete-time discrim-
inator but a better approach will now be presented. ¢((n + l)T) ¢(nT) + WeT
When (}m,(t) is sufficiently small and band-limited, so + k~Ty(nT) (8.22)
that cos (}m,(t) and sin (}m,(t) are essentially band-limited
signals with cutoff frequencies less than We, it can be Starting at n = 0 and iterating the equation, it follows that
shown that the pre-envelope of the FM signal is
s+(t) = s(t) + js(t) (8.23)
= Aeej(wct+llm(tll (8.17) where
The angle of the pre-envelope is n-l

<p(t) = arctan[s(t)/s(t)] {}l (nT) = (}(O) + kv T L y( nT) (8.24)


= wet + (}m,(t) (S.lS) k=O

The derivative of the phase is The veo output is


e-jq,(nTl
s(t)~.§(t)
dt
- s(t) dd s(t)
,t
v(nT)
e-j[wcnT+lh(nTl] (S.25)

(8.19) The multiplier output is


which is exactly the instantaneous frequency. This equa-
tion can be approximated for a discrete-time implemen-
p(nT) = Aeej[(lm(nTl-lh(nTl] (8.26)
tation by using FIR filters to form the derivatives and
Hilbert transform. Note that the denominator is the The phase error between the angle of the FM input
squared envelope of the FM signal. signal and the veo output is the angle of the multiplier
The bandwidth of this and other FM discriminators output p(nT) and can be computed as
must be at least as great as that of the received FM sig-
nal. Thus, the required bandwidth is usually significantly (}m,(nT) (}l (nT)
greater than that of the baseband message. This limits the 8'm,{p( nT)}]
degree of noise reduction that can be achieved by preced- arctan [ ~e{p(nT)} (8.27)
ing the discriminator by a bandpass receive filter.
This is shown in the figure as being computed by the
e library function atan2(y,x), which is a four quadrant
8.3. Using a Phase-Locked Loop arctangent and gives angles between -Jr and Jr. The block
for FM Demodulation consisting of the mUltiplier and arctan function is called
A device called a phase-locked loop (PLL) can be a phase detector.
used to demodulate an FM signal with better performance A less accurate-but computationally simpler-esti-
in a noisy environment than a frequency discriminator. mate of the phase error when the error is small is
The block diagram of a discrete-time version of a PLL is
shown in Fig. 8.1. It is similar to the Costas loop. 8'm{p(nT)} s(nT) cos [wenT + (}l (nT)]
The PLL input shown in the figure is the noisless s(nT) sin [wenT + (}l(nT)]
FM signal Aesin[{}m,(nT) - (}l(nT)]
s(nT) = Ae cos [wenT + (}m,(nT)] (8,20) Ac[{}m,(nT) - (}l(nT)] (8.28)
88 Chapter 8

Loop Filter H(z)


.------------------
u(nT)
1- z-l
Phase Detector I I

___ ~ i~ ~
r---------------'I I

-jsignw atan2(y, x)
-01
::
"-J
Q L.r01--'-:_Y_(r-n_T~)
'--------'s(nT) ~ _ ..! ____________ •: :Om I
L _________________
I
J
I

I e-jt/>(nT) = e- j (w c nT+91 )
-~---------------------------------
I

~
I

e- j (·) z-l kv T 4--

¢(nT)
weT

Voltage Controlled Oscillator (VCO)

Figure 8.1 A discrete-time phase-locked loop.

The phase detector output is applied to the loop filter, be approximated by


which has a transfer function of the form
z-l
L(z)~ - (8.31 )
{3 kv T
H(z) = a + 1- z-l
Thus
l_~z-l z-l
(a + (3) a+.B (8.29) Y(z) ~ 9 m (z) kv T (8.32)
1- z-l
and in the time-domain
The accumulator portion of the loop filter which has the
output u(nT) enables the loop to track carrier frequency ( T) '" O'm((n + l)T) - Om. (nT) (8.33)
Yn - kv T
offsets with zero error. It will be shown shortly that the
output y(nT) of the loop filter is an estimate of the trans- Using (8.7) for Om gives
mitted message m(nT).
The PLL is a nonlinear system because of the char- y( nT) ~ ~w m( nT) (8.34)
acteristics of the phase detector. If the discontinuities in v
the arctangent are ignored, the PLL can be represented by This last equation demonstrates that the PLL is an FM
the linearized model shown in Fig. 8.2. demodulator under the appropriate conditions.
The transfer function for the linearized PLL is The frequency response of the linearized loop has the
characteristics of a band-limited differentiator. The loop
Y(z) H(z) parameters must be chosen to provide a loop bandwidth
8 m (z) =
L(z) =
kvTz-l that is sufficient to pass the desired baseband message
1 + H(z) 1- Z-l signal, but the band~idth should also be kept as small as
possible to suppress out-of-band noise. The PLL performs
= (1- z-l)(a + f3 - az- ) 1
better than a frequency discriminator when the FM signal
/ {I - [2 - (a + (3)kvTlz-l is corrupted by additive noise. The reason is that the band-
+ (1 - akvT)z-2} (8.30) width of the frequency discriminator must be large enough
to pass the modulated FM signal, whereas the PLL band-
At low frequencies, which corresponds to z ~ 1, L(z) can width only has to be large enough to pass the baseband
Frequency Modulation 89

Loop
Filter
BmJnT) y(nT)
+ H(z)
+
-

()l (nT)

kvTz- 1
1- z I

veo
Figure 8.2. Linearized model for the phase-locked loop.

message. With wideband FM, the bandwidth of the mod- the counter switch to external. The carrier frequency can
ulated signal can be significantly larger than that of the be measured by setting the counter switch to internal.
baseband message. Therefore, the PLL can reject more 2. Connect the FM output signal to the oscilloscope
out-of-band noise because of its narrower bandwidth. and observe the resulting waveforms as you vary the am-
The PLL described in this experiment is very similar plitude of the baseband message sinusoid. Unfortunately,
to the Costas loop presented in Chapter 6 for coherent de- the signal generator does not display the frequency sen-
modulation of DSBSC-AM. However, it should be noted sitivity kw or the amplitude of the modulating sine wave.
that there is a significant difference in the loop band- The output of the modulating section is a sine wave with
widths required for these two systems. The bandwidth of fixed amplitude. You should observe that the amplitude
the PLL used for FM demodulation must be large enough of the FM signal does not change as you change the am-
to pass the baseband message signal. On the other hand, plitude of the baseband message.
the Costas loop is used to generate a stable carrier refer- 3. If you did the experiment in Chapter 4 and made a
ence signal, so its bandwidth should be very small and just spectrum analyzer, connect the FM signal from the signal
wide enough to track carrier drifts and allow a reasonable generator to the EVM AID input, and observe the spec-
acquisition time. trum of the sinusoidally modulated FM signal for different
values of the baseband message amplitude. In particular,

8.4. Laboratory Experiments for (a) Watch the value of the 2-kHz carrier component as
Frequency Modulation the modulation index is increased from O. Remember
that this component should be proportional to J6UJ)
The following experiments should give you a deeper on a power basis.
understanding of the theoretical concepts presented above
for FM modulation and demodulation. As usual, initialize (b) Now estimate the modulation index for some setting
the TMS320C30 and AIC as in Chapter 2. of the message amplitude knob. Choose the setting
by first turning the amplitude to 0 and record the
spectrum value at 2 kHz. Increase the amplitude
8.4.1. Experimentally Measuring the slowly and make sure the carrier component does not
Spectrum of an FM Signal become 0, so you know that the modulation index (3
is less than the first zero of Jo(x). Select an am-
Perform the following exercises to experimentally ex- plitude setting in this range and record the value of
plore the nature of an FM signal. the spectrum at the carrier frequency. Estimate the
1. Set the signal generator to FM modulate an!c = corresponding modulation index from the recorded
2 kHz sinusoidal carrier with anfm = 250 Hz sine wave. carrier frequency spectrum values for 0 modulation
You can measure the modulating frequency by connecting index and your selected index, and a graph or table of
the output of the signal generator modulation section to Jo(x). You can generate values of the Bessel function
the input of the generator's counter section, and setting by using the series expansion given by (8.13).
90 Chapter 8

(c) Plot the power spectrum of the FM signal with your to listen to the output with the speaker. Does the perfor-
selected modulation index. mance degrade gracefully as the noise gets large?

4. If you did not do the experiment in Chapter 4, an


alternative is to perform the previous exercise using the 8.4.3. Using a Phase-Locked Loop
commercial spectrum analyzer. for FM Demodulation
5. Another alternative for Exercise 3 above is to
write a program for the TMS320C30 to implement an IIR Design and implement a PLL like the one described
bandpass filter that passes the 2-kHz carrier component in Section 8.3 to demodulate a sinusoidally modulated FM
and strongly attenuates the other FM spectral components. signal with the same parameters used previously in this
The program should send the filter output to the DIA experiment. Let cy = 1 and choose f3 to be an order of
converter, so it can be observed on the oscilloscope. The magnitude or more smaller than CY. Compute and plot the
modulation index can then be computed as explained in amplitude response of the linearized loop using (8.30) for
Exercise 3. different loop parameters, until you fmd a set that gives a
6. Change the baseband message to a square wave reasonable response. Theoretically compute and plot the
and observe the spectrum of the resulting FM signal for time response of the linearized loop to a unit step input for
different square wave amplitudes and frequencies. Note your selected set of parameters, by iterating a difference
that the spectrum does not contain just two spectral lines equation corresponding to the transfer function.
at the carrier frequency, plus or minus the frequency devi- Write a C/assembly language program for the TMS-
ation caused by the square wave. Under what conditions 320C30 to implement the PLL. Test this demodulator by
does the spectrum become concentrated around two fre- connecting an FM signal from the signal generator to the
quencies? EVM input and observing the DIA output on the oscillo-
scope. Once the program is working for sinusoidal mes-
sages, try other types of messages.
8.4.2. FM Demodulation Using a See if your PLL will track carrier frequency offsets
Frequency Discriminator by changing the carrier frequency on the signal generator
slightly and observing the output. Experiment and see
Write a C/assembly language program for the TMS- how large an offset your loop will track. Also observe
320C30 that implements the frequency discriminator de- any differences in behavior when you change the carrier
scribed by (8.19). Design your discriminator assuming frequency smoothly and slowly or make step changes.
the carrier frequency is 2 kHz, the baseband message is Modify your program to add Gaussian noise to the
band limited with a cutoff frequency of 250 Hz, and the input samples and observe the demodulated output as the
sampling rate is 8 kHz. You can use REMEZ87.EXE to noise variance increases. How does the quality of the
design FIR differentiation and Hilbert transform filters. demodulated output signal compare with that of the fre-
You can also use WlNDOW.EXE to design the Hilbert quency discriminator at the same signal-to-noise ratio,
transform filter. Use enough taps to approximate the de- particularly when this ratio gets small? You should fmd
sired frequency responses well, from 600 to 3400 Hz. Be that the PLL works at a lower SNR than the discriminator.
sure to match the delays of your filters in your implemen-
tation. Draw a block diagram for your discriminator.
The program should synchronize its main sample
processing loop with the transmit ready flag (XRDY) of 8.5. Additional References
serial port o. Read samples from the AID converter, apply
them to your discriminator, and write the output samples All the senior level textbooks on communication
to the DIA converter. systems contain sections on frequency modulation. For
Use the signal generator to create a sinusoidally mod- example, see Gibson [II.D.9, Chapter 6] and Haykin
ulated FM signal, as you did for the FM spectrum mea- [II.D.l7, Sections 3.10-3.14]. See the references just
surement experiments. Attach the signal generator to the cited, Gitlin [II.D.ll, Section 6.2], Gardner [II.D.8], and
EVM input and observe your demodulated signal on the Lee and Messerschmitt [II.D.23, Chapter 13] for further
oscilloscope to check that the program is working. Once discussions of phase-locked loops. A brief discussion of
you have the discriminator working, try demodulating an discrete-time PLL's can be found in Lee and Messer-
FM signal with square-wave or triangular modulation. schmitt [II.D.23, Section 13.2]. To my knowledge, the
Modify your program to add Gaussian noise to the PLL structure described in this experiment using the pre-
input samples and observe the discriminator output as you envelope cannot be found in other textbooks.
increase the noise variance. You might find it interesting
9

Pseudo-Random Binary Sequences


and Data Scramblers

This experiment begins a series on digital communica- self-synchronizing digital data scrambler and descrambler.
tions. DSP technology has made a dramatic impact on These scramblers are required to break up long strings
digital communications, particularly narrow band systems of l' s or 0' s to allow tracking loops in the receiver to
like voice-band telephone line modems. In 1970, a plain maintain lock, rather than for secrecy.
9600 bps telephone line modem was the size of a big mi- At very high data rates, these scramblers and de-
crowave oven and cost at least $15,000. Today the signal scramblers can be implemented by very simple VLSI cir-
processing portion of a state-of-the-art V.34 28,800 bps cuits. At moderate data rates like those found in telephone
modem can be bought as a set of two or three chips for line modems, they would be implemented by a few lines
about $40 and the entire modem, which often includes an of simple DSP code. Incorporating this function and as
ordinary microprocessor controller, can be bought for less many others as possible into the DSP code eliminates ex-
than $250. In addition, this modem modem has many tra hardware. This improves reliability and reduces manu-
more features, such as data compression, error detection facturing cost. The ability to manufacture products at the
and correction, trellis coded modulation, fax modes, au- lowest possible cost is extremely important to companies
tomatic dialing, network management functions, a sec- operating in the highly competitive commerical market.
ondary channel, and the ability to do most of the past
popular modem standards ranging from speeds of 300
bps up to 28800 bps. Because of the flexibility of the 9.1. Using Linear Feedback Shift
software approach to implementing signal processing al- Registers to Generate Pseudo-
gorithms with DSP's, new theoretical developments have Random Binary Sequences
almost instantaneously been included in commercial tele-
phone line modems. These techniques have later found An ideal binary random sequence is an infinite se-
their way into higher speed systems that use greater chan- quence of independent, identically distributed, random
nel bandwidths, like high-speed digital subscriber loops variables, each taking on the values 0 or 1 with prob-
and microwave systems. ability 0.5. These sequences are often used as a models
for the data streams generated by binary sources. Ex-
In order to simulate and test digital communication cellent approximations to binary random sequences can
systems, sequences that approximate ideal binary random be generated by linear feedback shift registers. The re-
sequences are required. In this experiment, you will see sulting sequences are called pseudo-random, pseudo-noise
how to generate pseudo-random binary sequences using (PN), maximal length, or m sequences. Suggestions for
linear feedback shift registers. Then you will see how a additional references are included at the end of this ex-
simple variation of these circuits can be used to make a periment.

91
92 Chapter 9

9.1.1. The Linear Feedback Shift Register shown that if the initial state is not 0, the future states can
Sequence Generator never become o. However, the m-component state vector
can take at most 2 m - 1 nonzero values so it must repeat
The block diagram of a linear feedback shift register at some time. Then the output and state sequence will
sequence generator is shown in Fig. 9.1. It is common repeat, so the shift register will generate a periodic output
in digital sequential circuit analysis to represent a delay sequence with period no greater than 2 m - 1.
element by the symbol D, rather than z-l. The D, rep- The properties of a shift register sequence are deter-
resents a single stage of a shift register when the circuit mined by its connection polynomial
is implemented in hardware, or a memory location when m
it is implemented by software. All the adders perform (9.4)
modulo 2 addition, which is equivalent to the exclusive- k=1
or logical function. Addition and subtraction are identical For simulating binary random sequences, shift register se-
in modulo 2 arithmetic. The h's can be 0 or I, with 0 quences with the maximum possible period 2 m - 1 are
indicating no connection to the adder and 1 indicating a of primary interest, and these are often called maximal
connection. The input x(n) is a binary sequence which length sequences. It can be shown that a shift register
will be assumed to be identically 0 in this section. will generate a maximal length sequence if and only if
The z-transform of a binary sequence with z-1 re- its connection polynomial is a special type, known as a
placed by D is called its Huffman transform. The coeffi- primitive polynomial. Primitive polynomials of all de-
cients of D in the transform are interpreted using modulo grees exist and tables of primitive polynomials of degree
2 arithmetic. The Huffman transform has the same basic up to 34 can be found in Peterson and Weldon [II.E.6].
properties as the z-transform, so binary sequences and lin- A necessary but not sufficient condition for a polyno-
ear sequential circuits can be analyzed and represented by mial to be primitive is that it be irreducible. A polynomial
these transforms in the same way as continuous-amplitude with binary coefficients is said to be irreducible over the
discrete-time systems. field of binary numbers if it cannot be factored into the
Assuming that the input x(n) is identically 0, the product of polynomials with binary coefficients and de-
output of the feedback shift register sequence generator is grees at least 1. Otherwise it is called reducible. A very
m simple partial test of whether a polynomial is irreducible
Y(71,) = ~ hkY(71, - k) (9.1) is to check whether 0 or 1 are roots. If 0 is a root, D must
k=1 be a factor, and if 1 is a root, D + 1 must be a factor.
where the summation represents modulo 2 additions. Note that if 1 is a root of h(D), then h(1) = 0 and h(D)
Equivalently, any output sequence must satisfy the ho- must have an even number of 1 coefficients. Thus, irre-
mogenous difference equation ducible .polynomials over the binary field must have an
odd number of 1 coefficients. As an example, consider
m
the polynomial hI (D) = 1 + D + D2. Clearly, 0 and 1 are
Y(71,) +L hky(71, - k) = 0 (9.2) not roots, so D and D + 1 are not factors. Since there
k=1 are no other first-degree factors, h(D) must be irreducible.
In this experiment, addition of binary quantities will al- On the other hand, h 2(D) = hi(D) does not have 0 or 1
ways be understood to be performed by modulo 2 arith- as roots but it is reducible.
metic. Let the state of the shift register generator be The period of a shift register sequence with an irre-
defined to be the m-tuple ducible connection polynomial h(D) of degree m can be
shown to be the smallest nonzero integer N such that DN
8(71,) [Y(71, - 1), Y(71, - 2),···, Y(71, - m)] - 1 is divisible by h(D) using modulo 2 arithmetic for the
[SI (71,), s2(71,),···, sm(71,)] (9.3) coefficients. The period N is called the exponent of h(D).
It can be shown that h(D) always must divide D 2m - 1 - 1.
Given the state at any time, the present and all future However, N may be smaller than 2 m - 1 but must divide
outputs can be uniquely computed from (9.1). it. The polynomial is primitive when N = 2m - 1. For
primitive connection polynomials, the shift register state
9.1.2. The Connection Polynomial goes through all 2m - 1 nonzero values before repeating.
and Sequence Period The situation is more complicated when the connec-
tion polynomial is reducible. Suppose
If the initial shift register state is 0, then the present L
and all future outputs must be 0 and all future states re-
main at o. This is the trivial solution to (9.2). It can be
h(D) = II h(D) (9.5)
k=1
Pseudo-Random Binary Sequences and Data Scramblers 93

~------------~+~--------~

x(n)
-----M + }--.----* D D D
1.....-------' Y (n - 1) y(n - 2) y(n - m)

y(n)

Figure 9.1. Linear feedback shift register sequence generator.

where each factor is irreducible and has exponent nk. In run of m O's, one run of m - 1 O's, and 2Tn - k- 2 runs of
this case, the shift register will generate sequences with k O's for 1 ::; k ::; m - 2.
different periods depending on its initial state. Each pe-
riod will be the product of a subset of the exponents. Correlation Property

In discussing correlation properties, it will be conve-


9.1.3. Properties of Maximal nient to transform sequences of 0' s and l' s into sequences
Length Sequences of + 1's and -1 'so Let yen) be a sequence with period N,
which can have the value 0 or 1. The transformed se-
Maximal length sequences have several properties quence is
that make them good approximations to ideal binary ran-
dom sequences when N = 2 m - 1 is large. Derivations
of these properties can be found in Golomb [1I.E.3, pp.
-(n) _
y -
{+1 -1
if y(n)
if y(n)
=0
=1 (9.6)
43-45].
The periodic autocorrelation function is defmed to be

1 N-l
Frequency of Occurrence
of J 's and O's R(n) = N L y(k)y(n + k) (9.7)
k=O
The number of 1's in one period of a maximal length
where the sum is performed using ordinary addition.
sequence is 2 m - 1 and the number of O's is 2 m - 1 - 1.
For maximal length sequences, N = 2m - 1 and the
Thus, each period contains one more 1 than O. For large
periodic autocorrelation function is
N, 1's and O's essentially appear with equal likelihood.
1 .
R(n) - N for n not a multIple of N
Frequency of Runs of
R(n) 1 for n a multiple of N (9.8)
J's and O's
For ideal binary random sequences, the statistical auto-
Just because 1's and O's are essentially equally likely
correlation function is 1 for n = 0 and 0 otherwise.
for large N does not mean they are randomly arranged in
time. All the 1's could be clumped together. However,
this is not the case. A run of k 1's is defined to be a string 9.2. Self Synchronizing
starting with a 0, followed by k 1's, and ending with a O. Data Scramblers
The probability of this string occurring in an ideal binary
random sequence is 2-(k+2). Similarly, a run of k O's is
9.2.1. The Scrambler
a string starting with a 1, followed by k O's, and ending
with ai, and has the same probability. Long strings of 1's or O's can appear at the output of
In one period of a maximal length sequence, there is devices like terminals and computer serial ports when they
one run of m 1'so There is no run of m - II's. For I ::; are idle. These signals must be randomized before being
k ::; m - 2, there are 2m - k - 2 runs of k 1'so There is no applied to the transmitter in a modem, or else the symbol
94 Chapter 9

clock tracker and adaptive equalizer in the remote receiver From the previous paragraph, it can be seen that
will not work properly. The randomization is frequently when the initial state of the scrambler is all 1's and the
accomplished by a self-synchronizing scrambler. Figure input is 1, the output is always 1 and the state remains all
9.1 is also the block diagram for this kind of scrambler, 1'so This is called a lock-up condition of the scrambler
where x(n) is the scrambler input and yen) is its output. and can easily be detected and corrected. It is the only
A primitive shift register connection polyomial is usually initial state that causes lock-up with an all 1's input. This
used. Two primitive connection polynomials used in all situation is the complement of having an identically 0 in-
recent CCITT standard modems are put and starting in the all O's state. A detailed analysis of
the lock-up phenomenon with periodic inputs is presented
in Gitlin, Hayes, and Weinstein [11.0.11, pp. 454--460].
and
1 +D 5 +D23
D 23 h 1 (D- 1 ) (9.10) 9.2.2. The Descrambler

Notice that one of these polynomials is obtained from the At the receiver, the input is recovered from the re-
other by turning its coefficients around backwards. It can ceived sequence yen) by inverting (9.11). The resulting
be shown that this always turns one primitive polynomial descrambling equation is
into another. With 0 input, the scrambler generates a
maximal length sequence of period 2 23 - 1 if the initial m

state is nonzero. x(n) = y(n) +L hky(n - k) (9.14)


The scrambler input and output are related by the k=l
equation
m
or in transform notation
y(n) = x(n) + L hky(n - k) (9.11 )
X(D) = Y(D)h(D) (9.15)
k=l

In terms of the transform notation


The descrambler is just an FIR filter with m + 1 taps,
X(D) that uses modulo 2 arithmetic. A block diagram of the
Y(D) = h(D) (9.12)
descrambler is shown in Fig. 9.2. If yen) is corrupted by
In CCITT standards the scrambler is defined by saying channel errors, the scrambler output will also contain er-
that the output is generated by dividing the input by h(D). rors. If h(D) has K nonzero coefficients, a single isolated
In some CCITT modem standards, a pseudo-random error iny(n) will cause K output errors as it propagates by
binary sequence is specified to be generated by making the nonzero coefficients. Therefore, a connection polyno-
the scrambler input 1 for an initial training period. Let mial with the least number of nonzero coefficients should
Yh(n) be a solution to the homogeneous equation formed be chosen.
by letting the input x(n) be identically 0 in (9.11). This
is a maximal length sequence. A particular solution to
(9.11) for x(n) == I is yp(n) = I for all n. This can be
9.3. Theoretical and Simulation Exercises
seen as follows. The connection polynomial has an odd
number of nonzero coefficients. Thus the feedback sum
for Shift Register Sequence
on the right-hand side of (9.11) has an even number of Generators and Scramblers
terms which are all 1 and add to 0 modulo 2. Since x(n) =
The goal of this chapter is to introduce the shift reg-
1, the total sum on the right-hand side becomes 1, which
ister sequence method for generating pseudo-random bi-
matches the yp(n) = 1 on the left-hand side. The total
nary sequences so they can be used to simulate binary data
scrambler output is
sources in the remaining experiments on digital commu-
y(n) Yh(n) + yp(n) nications. The "experiments" in this section are really
theoretical and computer simulation exercises to reinforce
Yh(n) + 1 = Yh(n) (9.13)
your understanding of shift register sequence generators
where the over-bar denotes logical complement. Thus, the and self-synchronizing scramblers. The programs you will
scrambler output is the complement of a maximal length write can serve as the basis for ones you may need in fu-
sequence when the input is 1. ture experiments.
Pseudo-Random Binary Sequences and Data Scramblers 9S

x(n)
.-------+1-+ ~---------M+ ~~~

D D D
y(n) L--_....J y(n - 1) y(n - 2) y(n - m)

Figure 9.2. Self-synchronizing descrambler.

9.3.1. Exercises for a Shift Register 9.3.2. Exercises for a Shift Register
Sequence Generator with Sequence Generator with an
a Primitive Connection Irreducible but not Primitive
Polynomial Connection Polynomial

It can be shown that h(D) = I + D2 + D5 is a prim- Let h(D) = 1 + D + D2 + D3 + []4 be the connec-
itive polynomial. Perform the following exercises: tion polynomial for a shift register sequence generator. It
l. Assume the input to the scrambler in Fig. 9.1 is can be shown that h(D) is irreducible but not primitive.
o and that the initial state is not O. Find the period N of Perform the following exercises:
the sequence the shift register generates. 1. Find the period N for this sequence generator.
2. Write a C program to implement the scrambler 2. The four stage shift register can have 24 - 1 = 15
including an input x(n) which is set to O. Store the shift nonzero values. Let y(n) be the sequence generated by a
register state as 5 consecutive bits in a single integer vari- particular nonzero state. Consider y(n) and the sequences
able. Update the state by or-ing each new output into the obtained by delaying y(n) by 1, 2, ... , N - 1 samples to
appropriate bit in this integer variable and then shifting be an equivalence class of N sequences. It can be shown
it with one of the C shift operators. You can use the C that each member of the equivalence class corresponds
compiler for the PC or TMS320C30. to a unique shift register initial state. Thus. there must
3. Set the state of your shift register to a nonzero be (2 4 - 1)/N equivalence classes. Find one member of
value. Generate and record enough outputs to verify your each equivalence class and its corresponding initial shift
calculation of the period. register state.
4. Count the number of 1's and O's in one period of
your sequence and check that the results agree with the
theory. 9.3.3. Exercises for a Shift Register
5. Count the number of runs of 1's and O's of each Sequence Generator with a
possible length in one period of your sequence and make Reducible Connection
a table showing the results. Make sure they agree with Polynomial
the theoretical values.
6. Compute the scaled periodic autocorrelation func- Now let the connection polynomial for the shift reg-
tion NR(n) for n = 0, 1, ...• N - 1 from your sequence and ister sequence generator be
check that it agrees with the theoretical result given by
(9.7). h(D) (1 + D + D2)(1 + D + D 3 )
7. Now write a C program to implement the de- 1 + D4 + D 5 (9.16)
scrambler. Again, store the descrambler shift register as a
string of 5 consecutive bits in a single C integer variable. Perform the following exercises:
Let the input to the scrambler be x(n) = l. Generate a 1. Verify that the product is correct.
scrambled sequence, put it through the descrambler, and 2. It can be shown that both factors are irreducible.
check that the descrambler output is aliI's. Note that the Find the exponents for the two factors.
initial states of the scrambler and descrambler do not have 3. Find initial states that result in sequences with
to be identical if an initial burst of errors is acceptable as periods 3. 7, and 21. Record the states and corresponding
the descrambler shift register fills with received bits. sequences.
96 Chapter 9

9.4. Additional References


The most complete book on binary pseudo-random
sequences is Golomb [1I.E.3]. Other references that dis-
cuss them are Gallager [II.E.2, Chapter 6], Gibson [II.D.9,
Appendix G], and Gitlin, Hayes, and Weinstein [II.D.ll,
Section 6.7]. A detailed analysis of self-synchronizing
scramblers is contained in this last reference.
10

Introduction to the RS-232C Protocol


and a Bit-Error Rate Tester

In this experiment you will learn about a commercial in- or the serial port in a PC. To transmit data over long
strument called a bit-error rate tester, which is commonly distance channels like a voice-band telephone channel, the
used to evaluate the performance of digital communica- DTE is connected to a modem with an RS-232C cable.
tion systems. First, you will be introduced to the EIA RS- The modem is called a data communications equipment
232C interface protocol, which is a very common method which is abbreviated by DCE. Other types of devices can
for serially transmitting digital data between nearby de- also be configured to act as a DCE.
vices. Then you will connect a commercial bit-error rate
The RS-232C signals nominally have the values 12
tester to the EVM, use the TMS320C30 to add noise to
and -12 volts. A logical 0 is called a space and is repre-
the serial bit stream, run a bit-error rate test, and compare
sented by the 12 volt level. A logical 1 is called a mark
measured and theoretical results. See the last section of
and is represented by the -12 volt level. A voltage above
this experiment for additional references on the theory of
3 volts is often quantized to a space and a voltage below
optimum signal detection and bit-error probability.
-3 volts to a mark.
The most important connector signals are described
10.1. The EIA RS-232C Serial in the following paragraphs. Pin 6 is called Data Set
Interface Protocol Ready (DSR) and is controlled by the DCE (modem).
A high voltage (12 V) indicates that the DCE has been
One of the most common methods for serially trans- turned on and is ready to make a connection with a remote
mitting digital data between devices is the EIA RS-232C modem. The term "remote" is used to mean "at the far
interface protocol. EIA stands for Electronics Industries end" of the communications channel. Pin 20 is named
Association and RS for recommended standard. It is typ- Data Terminal Ready (DTR), and is controlled by the
ically used at data rates below 38.4 kbps and between DTE (data terminal). A high voltage on pin 20 indicates
devices that are less than 15 meters apart. It was not de- to the DCE that the DTE is turned on and ready to accept
signed for data transmission over long distances. A full data. Pin 8 is named Data Carrier Detect (DCD), and is
implementation of the standard uses a 25 pin D connec- controlled by the DCE. A high voltage on pin 8 indicates
tor with the pin connections shown in Table 10.1. Often, to the DTE that the local modem has made a connection
only a small subset of the signals is actually used and a with the remote modem and is ready to begin transmitting
9 pin connector is employed. data. The process of making a connection between two
In the data communications jargon, a data terminal is modems is often called handshaking. These basic control
called a data terminal equipment which is abbreviated by signals must usually be high before data transmission can
the letters DTE. Examples of a DTE are a dumb terminal proceed.

97
98 Chapter 10

Table 10.1. RS-232C Interface Table

Pin Name Function Source


1 FG Frame Ground
2 TD Transmitted Data DTE
3 RD Received Data DCE
4 RTS Request to Send DTE
5 CTS Clear to Send DCE
6 DSR Data Set Ready DCE
7 SG Signal Ground
8 DCD Data Carrier Detect DCE
9 Positive Test Voltage DCE
10 Negative Test Voltage DCE
11 QM Equalizer Mode DCE
12 SDCD Secondary Data Carrier Detect DCE
13 SCTS Secondary Clear to Send DCE
14 STD Secondary Transmitted Data DTE
NS New Sync DTE
15 TC Transmitter Clock DCE
16 SRD Secondary Received Data DCE
DCT Divided Clock, Transmitter DCE
17 RC Receiver Clock DCE
18 DCR Divided Clock, Receiver DCE
19 SRTS Secondary Request to Send DTE
20 DTR Data Terminal Ready DTE
21 SQ Signal Quality Detect DCE
22 RI Ring Indicator DCE
23 DRS Data Rate Selector DCE
Data Rate Selector DTE
24 SCTE Serial Clock Transmit External DTE
25 BUSY Busy DTE

The actual data is sent and received over pins 2 and voltage level is stable.
3. Pin 2 is the transmitted data (TD). This is the se-
rial binary data stream sent from the DTE to the DCE for Once DTR, DSR, and DCD are high, the DTE asks
transmission to the remote DCE. Pin 3 is the received data to begin data transmission by raising pin 4, which is
(RD) sent to the local DTE from the local DCE, which named Request to Send (RTS). When the DCE is ready to
has been transmitted by the remote DCE to the local DCE. receive data from the DTE and send it to the the remote
Data is typically transmitted and received independently DCE, the DCE replies by raising pin 5, which is called
and simultaneously, and this is called full duplex opera- Clear to Send (CTS). The DTE then begins sending the
tion. When data flows in one direction at a time over the data timed by the transmitter clock.
same channel, it is called half duplex operation.
The signals just described and pin 7, which is Signal
Pin 15 is named Transmitter Clock (TC) and is gen- Ground (SG), are used in most RS-232C cables. The Ring
erated by the DCE. In many cases, the modem (DCE) con- Indicator (RI) signal on pin 22 is often included when the
trols the data transmission by clocking bits out of the DTE DCE is a telephone line modem. This signal is generated
with TC. In a few cases, the DTE can control the data by the modem and indicates that the modem has detected
transmission by supplying a signal called Serial Clock a ringing signal from a remote site in the dial network
Transmit External (SCTE) to the modem on pin 24. Pin that is trying to make a connection. The communications
17 is named Receiver Clock (Re) and is generated by the software in the DTE can then send a command to the
modem. It clocks received data from the modem into the modem instructing it to connect to the telephone line and
DTE. These clocks are phased so that the data is clocked answer the call. The remaining signals are used only in
into the DTE or DCE in the middle of a bit, where the special situations.
Introduction to the RS-232C Protocol and a Bit-Error Rate Tester 99

10.2. Bit-Error Probability for Binary The probability a decision error is made given that
Signaling on the Additive, White, -A was transmitted is
Gaussian Noise Channel
P(errorls(nT) = -A) P(-A+vn > 0)
The performance of a digital communication system
is often evaluated by measuring its bit-error probability P (~ > : ) (10.4)
as a function of the channel signal-to-noise ratio (SNR),
and comparing the results with theoretical values. The The random variable v n / a is a Gaussian random variable
measured bit-error probability is often called the bit-error with zero mean and variance 1. Therefore,
rate. The theoretical bit-error probability depends on the
modulation and demodulation schemes used to transmit
the digital data over an analog link, as well as the type
P(error Is(nT) = -A) JAlu
oo 1 ,,2

..;2ire- T dv
of noise and distortion the channel introduces. In high- Q(A/a) (10.5)
speed digital communication systems like satellite sys-
tems, an excellent model for the channel is that it sim-
ply adds signal-independent, white, Gaussian noise to the
transmitted signal. The noise and distortion introduced by
where
Q(x) = l
. x
oo 1
. ;;ce- T
v211'
,,2
dv (10.6)

other kinds of channels -like voice-band telephone line Similarly, it can be shown that the probability of an error
links-can be significantly more complicated, but the ad- given that A was transmitted is the same thing. Therefore,
ditive Gaussian noise model is often used as a first-order the average probability of error is
approximation.
As a simple example, we will analyze the case of bi-
nary transmission over an additive Gaussian noise chan- P(error) P(A)P(errorls(nT) = A)
nel. Let the transmitted signal s(t) be a binary waveform + P( -A)P(error Is(nT) = -A)
that can have the value A or -A over each bit period nT ~ Q(A/o-) (10.7)
t < (n + I)T, where Tis the bit duration andji, = liTis the
bit or data rate. In each bit period, the values A and -A are The signal power in the integrator output is A2 and the
equally likely and the values in different bit periods are noise power is a 2 , so the output signal-to-noise ratio is p
independent random variables. Assume the channel adds = A2 /0- 2 . Therefore, the bit-error probability in terms of
white Gaussian noise v(t) with two-sided power spectral the output signal-to-noise ratio is
density No/2 to the signal s(t), so the received signal is
P(error) = Q(JP) (10.8)
ret) = set) + vet) (10.1 )
Different digital communication schemes can be com-
It can be shown that a receiver that is optimum in the sense pared and ranked by evaluating their bit-error probabili-
of minimizing the bit-error probability first computes the ties for a given data rate, channel bandwidth, and channel
statistic signal-to-noise ratio.
The Gaussian tail probability Q(x) can be accurately
1 l(n+1)T approximated for x greater than 2 by
T
1 ..;2ir
rn = ret) dt
. nT '00 1 ,,2

1 l(n+1)T
Q(x) --e-Tdv
±A + -T vet) dt x
. nT 1 _",2
--e 2 ( 10.9)
= ±A+Vn (10.2) x..;2ir
where This is actually an upper bound for Q(x) and becomes
1 l(n+l)T more accurate as x increases.
Vn = T v(t)dt (10.3)
. nT
10.3. The Navtel Datatest 3 Bit-
The integrator is often called a matched filter. It can
be shown that Vn is a Gaussian random variable with
Error Rate Tester
zero mean and variance 0- 2 = No/(21). The receiver then There are many commercial test instruments for mea-
decides that A was transmitted in the n-th bit period if suring bit-error rates. These measurements are often
Vn > 0, and -A was transmitted if Vn ~ O. called BERT tests in the communications jargon. Each
100 Chapter 10

station in this lab has a Navtel bit-error rate tester. These errors according to the additive Gaussian noise channel
instruments are designed to operate in the full duplex model. The corrupted bit pattern will then be sent back
mode at data rates commonly used with RS-232C con- to the Navtel tester. You will generate a graph of the
nections. These rates extend from 50 to 19,200 bps in the bit-error rate versus SNR and compare it with theoretical
normal async/sync mode, and include the rates 56, 57.6, results. Perform the following exercises:
and 64 kbps in the high-speed mode. The Navtel tester 1. Connect the power supply to the converter box
can act as a DCE or DTE. and wall socket.
The Navtel tester performs a BERT test by transmit- 2. Connect one end of the RS-232C cable to the
ting a specified pattern and assumes- the same pattern is DCE socket on the Navtel tester and the other end to the
transmitted from the remote end. It synchronizes to the converter box.
received pattern and then counts errors. The test pattern 3. Connect the conveter box to the IO-pin connecter
selection includes several ASCII text sequences as well on the back of the EVM. WARNING: Make sure to con-
as pseudo-random shift register sequences of length 63, nect pin 1 of the cable to pin 1 on the EVM. Pin 1 on the
511, 2047, and 4095. The test duration can be set to be ribbon cable is marked by the red wire.
a variety of fixed times, fixed number of bits, or con- 4. Tum on the Navtel tester and press the right
tinuous. During the test, the Navtel counts the number and left arrows until BERT blinks. Then press SETUPI
of bits received and the number of errors and continu- CLEAR. Now set the Navtel parameters as follows:
ally computes the bit-error rate as the ratio of the current
cumulative number of errors and the number of bits re- (a) Press the right arrow to make the entry under MES-
ceived. This value can be observed in the tester's display SAGE blink and then press SETUP. Use the arrows
while the test is in progress. Some other variables that can to select 4095 and press SETUP again. This selects
be displayed are the number of bits received, the number the shift register sequence of length 4095.
of bit errors, the number of blocks received, the number (b) Similarly, set the message length to Cont (continu-
of block errors, the number of synchronization losses, and ous).
the elapsed time. See the Navtel manual for more details.
The Navtel tester also has a full RS-232C breakout (c) Set CLOCK to Ext (external). The clocks will be
box. LED indicators show the status of the key RS-232C generated by the TMS320C30 Serial Port 1 and con-
interface leads. Each key lead has a red and green mon- verted to RS-232C levels by the converter box.
itor. An illuminated red LED indicates an ON, space, or
12 volt signal while an illuminated green LED indicates (d) Set the MODE to DTE so the Navtel looks like a
an OFF, mark, or -12 volt signal. Neither LED is illumi- terminal.
nated if the level is between -3 and 3 volts. The tester (e) Set the LEVEL to 8 and PARITY to No. This means
can be connected between a DTE and DCE to monitor that in the async mode each character will consist of
the leads. 8 data bits with no parity bit.
Since the Navtel tester uses RS-232C level signals, it
can not be directly connected to the TMS320C30, which (f) Set SY/ASY to Syn (synchronous). In this mode, a
uses the 0 and 5 V TTL levels. One method for using continuous bit stream with no start and stop bits is
the tester would be to connect it to one of the PC's se- transmitted.
rial port and pass the data to and from the TMS320C30,
as described in Appendix A. A more direct approach is (g) Set the SPEED to 2400.
to connect it to Serial Port 1 of the TMS320C30 whose 5. Write a program for the TMS320C30 to take bits
leads are brought out to a 10 pin connector on the EVM. from the Navtel tester and simply loop them back to the
Each station has a home-made TTL to RS-232C converter Navtel through Serial Port 1. Later you will be asked to
box for connecting the tester to the EVM. Details of the introduce errors into the bit stream.
converter box can be found in Appendix C. Your program should configure Serial Port 1 as de-
scribed in the following items. Details on how to set the
10.4. Bit-Error Rate Test serial port control registers are given in Tables 10.2-10.5.
Experiment You can extract the appropriate programs from the file
serial. src in the directory c: \ UTIL .DSP and modify
In this experiment, you will learn how to use the them to set the serial port control registers to the desired
Navtel bit-error rate tester. Since the lab does not have values.
Gaussian noise generators, the data pattern from the tester
will be sent to the TMS320C30, which will introduce bit (a) Receive and transmit 32-bit words.
Introduction to the RS-232C Protocol and a Bit-Error Rate Tester 101

Table 10.2. Serial Port 1 Global Control Register

Bit Name Value Function


2 FSXOUT 1 Make FSX an output
5 HS 0 Not handshake mode
6 XCLKSRCE Use internal transmit clock and output the clock
7 RCLKSRCE 1 Use internal receive clock and output the clock
8 XVAREN 0 Fixed data rate
9 RVAREN 0 Fixed data rate
10 XFSM Continuous transmit mode
11 RFSM Continuous receive mode
12 CLKXP CLKX active low to undo converter inversion
13 CLKRP CLKR active low to undo converter inversion
19,18 XLEN 11 32-bit transmit word
21,20 RLEN 11 32-bit receive word
~3 XINT Enable transmit interrupt
25 RINT Enable receive interrupt

(b) Generate the transmit and receive clocks for the Nav- receiver continues to shift new data into the Receive
tel tester and TMS320C30 Serial Port 1 by using the Shift Register (RSR) and load it into the Data Re-
serial port timers. The transmit and receive serial ceive Register (DRR), as long as DRR is read before
port timers should be set to the clock mode, to give next word is loaded into it.
50% duty cycle signals that are output on the serial
port clock pins. The frequency of the clocks should 6. To check your initial program, start a bit-error rate
be made as close to 2400 Hz as possible. The clock test. To do this, press RUN on the Navtel tester. Press
frequencies are determined by the Period Registers the up or down arrows until BERT is displayed. If you
according to the following formula: are looping the data back correctly, BERT should remain
O. You can introduce a single error by pressing INSERT
f(clock mode) = f.(Hl). ERROR and observe the effect on the BERT display.
4 x [Penod RegIster] 7. Now modify your program to add errors to the
15 x 106 bit stream. For each of the 16 pairs of bits in a received
Hz (10.10)
4 x [Period Register] 32-bit word, generate a pair of zero mean, uncorrelated,
Gaussian noise samples by the method described in Ap-
(c) Make the transmit frame sync FSX an output. FSX pendix B. Assume that a logical 0 is represented by A
is looped back to the receive frame sync FSR in the volts on the channel and logical 1 by -A volts as dis-
converter box. cussed in Section 10.2. Let the integrator output noise
variance be 0"2 = 1 and adjust A to get the desired output
(d) Set the transmitter and receiver to the continuous signal-to-noise ratio. Then, the SNR in dB is
mode. To start serial transfers, write a dummy word
to DXR. The TMS320C30 will generate a transmit A2
frame sync pulse when DXR is loaded into the trans- s 1010glO ""2"
0"
mit shift register XSR. FSX is looped back to the re- 20 log 10 A (10.11)
ceive frame sync FSR by the converter box. Contin-
uous transmit transfers will proceed as long as new and the required value for A is
data is loaded into DXR before the last word has
been completely shifted out of XSR. Similarly, the A = 108 / 20 ( 10.12)

Table 10.3 Serial Port 1 FSXIDX/CLKX Port Control Register

Bit Name Value Function


o CLKXFUNC CLKX is a serial port pin
4 DXFUNC DX is a serial port pin
8 FSXFUNC FSX is a serial port pin
102 Chapter 10

Table 10.4. Serial Port 1 FSRJDR/CLKR Port Control Register

Bit Name Value Function


o CLKRFUNC CLKR is a serial port pin
4 DRFUNC DR is a serial port pin
8 FSRFUNC FSR is a serial port pin

Table 10.5. Serial Port 1 Receive/Transmit Timer Control Register

Bit Name Value Function


2 XCIP Clock mode for transmit clock
3 XCLKSRC Use internal clock for transmit clock
8 RCIP Clock mode for receive clock
9 RCLKSRC Use internal clock for receive clock

Let a particular pair of Gaussian noise samples be long enough at each SNR to obtain a statistically reliable
denoted by (x, y). According to the theory, a transmitted estimate of the error rate. Plot the BER as the ordinate
I is changed to a 0 if x > A and a transmitted 0 is changed on a logarithmic scale. Plot the SNR in dB on a linear
to a I if x ::; -A. The probabilities of these two events are dB scale.
identical, because the probability density function for the 9. Theretically compute the BER versus SNR plot
zero mean, Gaussian random variables is even. Thus, to and compare it with your experimentally measured curve.
determine when to introduce a bit error, check to see if x
> A. If this is true, an error should be introduced in the
first bit of a pair. Similarly, when y > A an error should 10.5. Additional References
be introduced in the second bit of a pair. The errors can There are many books that discuss digital commu-
be introduced by XOR-ing I's into the error locations in nication systems and have sections on the optimum de-
the received 32-bit serial word to complement the correct tection of signals corrupted by additive Gaussian noise
bits. and how to compute error probabilites for various sig-
8. Now experimentally generate a bit-error rate ver- nal sets. For example, see Gibson [II.D.9, Chapter 10],
sus SNR plot. Start with a 13 dB SNR and work down Gitlin, Hayes and Weinstein [1I.D.ll, Section 2.2], and
to 7 dB in I-dB increments. Make sure to run your test Haykin [II.D.I7, Sections 7.2-7.3].
11

Digital Data Transmission by Baseband


Pulse Amplitude Modulation (PAM)

In this experiment you will be introduced to a common tern is shown in Fig. 11.1. The transmitter input di is a
method for digital data transmission known as baseband serial binary data sequence with a bit rate of Rd bits/sec.
pulse amplitude modulation (PAM). The presentation is Input bits are blocked into J-bit words by the serial-to-
slanted towards transmission over bandlimited channels parallel converter and mapped into the sequence of sym-
and DSP implementation. The concepts learned here will bols an, which are selected from an alphabet of M = 2 J
be generalized to passband digital communication systems distinct voltage levels. These symbols are generated at the
in Chapters 12-16. Some of the concepts and terms you rate of Is = Rd/J symbols/sec and we will designate the
will be introduced to are: baseband shaping filters and interval between symbols as T = 1/fs. The term baud is
raised cosine shaping, intersymbol interference and the commonly used for the symbol rate Is, in honor of Emile
Nyquist criterion, eye patterns, symbol error probability Baudot, who invented a binary code for representing al-
formulas, interpolation filter banks, and a symbol clock phanumeric characters. Baud is also frequently used (or
recovery method. misused) to mean one symbol period. The levels are of-
ten selected to be equally spaced and have an arithmetic
average of zero. In this experiment, we will use levels
11.1. General Description of a Baseband spaced by 2d with the M possible values
Pulse Amplitude Modulation System
d(2i - 1) for

,°' ... '"2M


In pulse amplitude modulation, information symbols M
are transmitted at discrete, uniformly spaced time inter- i -"2+ 1, ... (11.1)
vals. The carrier signal is a train of pulses uniformly
spaced at the same interval as the information symbols. Thus, the minimum level is - (M - l)d and the maximum
The amplitude of each pulse is a one-to-one function of level is (M - 1)d.
the corresponding information symbol. The information It is mathematically convenient to represent the sym-
is recovered at the receiver by measuring the amplitude of bol sequence by the Dirac impUlse train
each pulse and mapping it back to the information sym-
2::
00
bol. In wide-band systems, nonoverlapping, rectangular,
full period pulses are often used. In band-limited systems,
s*(t) = ak 8(t - kT) ( 11.2)
k=-oo
the pulses overlap but are selected so that the information
symbols can be measured by sampling the received signal The Impulse Modulator block forms this function. This
at the symbol rate as will be explained below. impulse train is applied to a Transmit Filter with impulse
The block diagram of a typical baseband PAM sys- response gT(t), which band limits the signal to the channel

103
104 Chapter 11

Serial to Map from Impulse s*(t) Transmit s(t)


Parallel I---r/-* J-bit Words to t----~ Filter I - -
/J Modulator
Converter 2J Levels GT(w)

Transmitter

-------------------------------------------- I
I
I I

r(t) : Channel:
...--------+------i + i 4 - - - - - - - - i Frequency Responsef4----+----...J I

C(w) :
I
I
I I
I v(t) I
I I

: Additive Channel Noise :


L ___________________________________________ I

Channel Model

r------------------------------------------------------------,
I

Receive
I
I x(t) Sampler y(nT)
Adaptive
~ Filter and 1----,----+1 I----~ Quantizerl-----,
I
AjD Equalizer
I
I
GR(w)
I
I
I
I
Symbol Clock
I
L _____________ , -
I
Recovery
I
I
I
I
I Parallel to Map from
I

/ Serial /
/
2J Levels to
1 Converter J J-bit Words
L _____________________________________________ _

Receiver

Figure 11.1. Block diagram of a baseband PAM system.


Digital Data Transmission by Baseband Pulse Amplitude Modulation (PAM) 105

bandwidth. The resulting transmitted signal is sampling period is To = TIN. The transmitter and receiver
time references are not exactly synchronized in frequency
L
00
or phase, and this is indicated by the variable T in the
s(t) = akgr(t - kT) (11.3)
sampler output. The samples are used by the Symbol
k=-oo
Clock Recovery system to lock the receiver symbol clock
which is a superposition of amplitude modulated pulses. to the transmitter clock.
The combination of the impulse modulator and transmit In many instances, the channel frequency response
filter is a mathematical model for a DIA converter fol- is not known exactly and may vary slowly. The Adaptive
lowed by a lowpass filter. Equalizer is a filter that automatically compensates for
In this experiment, the channel will be modelled as nonideal channel characteristics. In addition, it corrects
a linear, time-invariant filter with the frequency response for small deviations in the transmit and receive filter re-
C( w) followed by an additive noise source. sponses from ilieir ideal nominal values. The theory of
At the receiver, the channel output r(t) is first passed operation of the adaptive equalizer is presented in Chapter
through a receive filter, which eliminates out-of-band 14.
noise and, in conjunction with the transmit filter, forms The equalizer output is sampled at the symbol rate
a properly shaped pulse. The combined transmit filter, and quantized to the nearest ideal level. The equalizer
channel, and receive filter frequency response is output samples deviate from ilie ideal levels because of
the additive channel noise and residual intersymbol inter-
G(w) = Gr(w)C(W)GR(W) (11.4)
ference. The quantizer output level is mapped back to the
and the corresponding impulse response is corresponding J-bit binary word and converted back to a
serial output data sequence.
g(t) gr(t) * c(t) * gR(t)
F-l{G(W)} ( 11.5)
11.2. Baseband Shaping and
where * represents convolution. The combined filter rep-
Intersymbol Interference
resented by G(w) is called the baseband shaping filter.
The output of the receive filter is It was shown in the preceding section that the output
00 of the receive filter is the superposition of time shifted
and amplitude scaled versions of the baseband shaping
k=-oo filter impulse response g(t) if the noise is ignored. We
+ v(t) * gR(t) ( 11.6) also learned that when g(t) is zero at the regularly spaced
symbol time instants nT, except for n = 0, where it has the
Now assume that the noise is zero and the combined value 1, the transmitted symbols can be recovered by sam-
impulse response is zero at the time instants nT, except pling the receive filter output at times nT. In this case, the
for n = 0, where it is 1, i.e., pulse generated by the symbol an has amplitude ang(O)
= an at time nT, and the tails of all the other pulses pass
( T) - 8 _ { 1 for n = a (11. 7) through O. So, the pulses generated by different sym-
g n - n,O - a otherwise bols do not interfere wiili each other at the times nT. An
impulse response with this property is said to have no in-
An impulse response with this property is said to have
tersymbol interference (lSI). In this section, a frequency
no intersymbol interference. This property is examined
domain criterion for no lSI will be presented, a class of
in more detail in Section 11.2. With these assumptions, it
lowpass filters with no lSI will be discussed, and a com-
can be seen from (11.6) that the samples of the receive fil-
mon experimental method for observing and measuring
ter output taken at times nT reduce to x(nT) = an, which
lSI will be described.
is exactly the sequence of transmitted symbols. Often, the
transmit and receive filters are designed to give a com-
bined filter with no intersymbol interference, under the
assumption that the channel frequency response is con- 11.2.1. The Nyquist Criterion
stant over the signal bandwidth and, therefore, introduces for No lSI
no distortion.
The output of the receive filter is then sampled at Equation (11.7) states the criterion for no lSI in terms
a rate that is an integer multiple N of the symbol rate of the baseband shaping filter impulse response samples
Is. Typically, N might be 3 or 4. The corresponding g(nT). These samples can be computed from ilie shaping
106 Chapter 11

filter frequency response by the formula raised cosine frequency domain shaping. The frequency

g(nT) = -1
27r
1 -00
00
G(w)e jwnT dw (11.8)
response of a raised cosine filter is

G(w) = T for Iwl ~ (1- a)~S


Let Ws = 27r/s = 27rIT. The integral can be computed by
partitioning the w axis into the infmite set of intervals ~ { 1- sin [~ (Iwl- ~s) ]}
WS Ws
( _ Ws _ kw Ws _ kw ] for ( 1 - a ) "2 ~ Iwl ~ (1 + a)"2
2 s, 2 s
for k = -00, ... ,00 o elsewhere (11.12)

and taking the sum of integrals over the intervals to get where a is a constant in the interval [0, I] and is called
the excess bandwidth/actor. The raised cosine frequency
1
L-Ws response is flat over the central portion of the passband
00

g(nT) = and rolls off sinusoidally to zero at the band edge. It is


k=-oo
down from the 0 frequency value by a factor of2, which is
equivalent to 6 dB, at the frequency ws/2. The frequency
x ws/2 is called the Nyquist frequency.
_ W 8 -kws
It can be shown that the corresponding impulse re-
2
sponse is

L Ws-
00 1 J~
2
1
-G(w
T
- kws) )
g(t =
sin (~t)
~t
cos (a~t)
1 - 4(at/T)2
(11.13)
k=-oo _~
2

X ej(w-kws)nT dw ( 11.9) The program C:\DIGFIL\RASCOS.EXE computes


samples of the raised cosine filter impulse response modi-
Recognizing that e-jknwsT = e- kn27r = 1, and taking the fied by the Hamming window.
sum inside the integral, gives Note that when a = 0, the raised cosine filter be-
comes an ideal flat lowpass filter with cutoff frequency

J
~
2
ws/2. When a = 1, the frequency response has no flat
g(nT) =~ G*(w)e jwnT dw (11.10) region and is one cycle of a cosine function raised up so
Ws
-~
2
it becomes 0 at the cutoff frequency of Ws. As the band-
width is increased by making a closer to 1, the impulse
where response decays more rapidly.

L
00

G*(w) =~ G(w - kws) (11.11)


11.2.3. Splitting the Shaping between
k=-oo
the Transmit and Receive Filters
The function G* (w) is called the aliased or folded spec-
trum and is well known in digital signal processing theory. When the channel amplitude response is flat across
The criterion (11.7) for no lSI is satisfied if and only the signal passband and the noise is white, it can be shown
if G* (w) = 1. This can be seen by evaluating (11.1 0) for [II.D.26, p. 54] that the amplitude response of the com-
this special case. The constraint that the aliased spectrum bined baseband shaping filter should be equally split be-
G* (w) must be a constant for no lSI is known as the tween the transmit and receive filters to maximize the
Nyquist criterion. output signal-to-noise ratio, i.e.,

(11.14)
11.2.2. Raised Cosine Baseband
Shaping Filters Their phases can be arbitrary as long as the combined
phase is linear.
The requirement for no lSI only makes constraints When raised cosine shaping is used, the resulting
on the symbol rate samples of the baseband shaping filter optimum transmit and receive filters are called square-
impulse response. There are an infinite number of impulse root 0/ raised cosine filters. The program C:\DIG-
responses that meet the constraints. One class of filters FIL\SQRTRACO.EXE can be used to compute the im-
that is often specified for use with lowpass channels has pulse response of a square-root of raised cosine filter.
Digital Data Transmission by Baseband Pulse Amplitude Modulation (PAM) 107

L
00
11.2.4. Eye Diagrams g(kT) I
(M -1)d I g(O) (11.16)
The eye diagram is a useful diagnostic tool for eval- k=-oo
k#O
uating qualitatively the optimality of a PAM system. An
eye diagram is formed by superimposing oscilloscope The peak fractional eye closure is defined to be
traces of the receive filter output. Each trace is triggered
at the same phase within a symbol interval, and lasts for a
few symbols. A sketch of some traces in an eye diagram 7]
= D = (M -1)
d
f
k=-oo
I g(kT) I
g(O)
( 11.17)
for a combined channel with no lSI and a two-level input k#O
symbol alphabet is shown in Fig. 11.2. Note that all the
traces pass through the ideal symbol values of ±d at the When 7] is less than 1, the eyes are open.
sampling instants {nT}. The empty area inside the traces
around nT is called an eye opening. With an M level in-
11.3. Implementing the Transmit Filter
put alphabet, there are M - 1 openings stacked vertically
at each symbol instant. The quantizer slicing or decision
by an Interpolation Filter Bank
levels are usually chosen to be the values k2d half way . Designing and manufacturing an analog lowpass fil-
between the ideal symbol levels. Somewhat surprisingly, ter that closely approximates the impulse response or lin-
the optimum time at which to sample the receive filter ear phase frequency response of a desired transmit filter,
output is not at the peaks of the eye diagram with band- like the raised cosine or square-root of raised cosine re-
limited channels. It is somewhat down in a valley. The sponse, is difficult. A solution to this problem is to place
more bandlimited the channel, the more rapidly the eye the burden on the transmitter DSP and perform most of
closes away from the symbol instants, and the higher the the shaping with a discrete-time interpolation filter bank,
peaks between symbols become. which generates L output samples per symbol. These sam-
When intersymbol interference is present, the traces ples, which occur with frequency Lis, are D/A converted
do not all pass through the ideal levels at the sampling and applied to a simple analog lowpass filter to generate
instants, and these points become dispersed. As the lSI in- the continuous-time transmitter output.
creases, the dispersion grows and the eye begins to close. The first step in deriving the desired interpolation
As long as the eye is open, no decision errors are made formula is to replace t by nT + m(T/L) in (11.3), which
when the additive channel noise is zero. However, when gives
noise is present, the error rate increases as the eye closes.
With zero additive noise, the symbol rate samples of
the receive filter output are f
k=-oo
akgt ( nT + m~ - kT)

L
00
for m O,I, ... ,L-l (11.18)
x(nT) = akg(nT - kT) = g(O)x
k=-oo Now let L discrete-time interpolation subfilters be defined
as
~
~ ak
g(nT - kT)]
g(O) (11.15) gr,m(n) gr (nT+m~)
k=-oo
k#n
for m O,I, ... ,L -1 (11.19)
The right-hand summation in (11.15) is the lSI for the
current received symbol. Decision errors are made when Then, the L output samples required during the symbol
the magnitude of this lSI exceeds d, except when the lSI period starting at time nT can be expressed as
carries an outer level outside the eye diagram. We will
assume that g(O) > O. The lSI is a random variable and
depends on the symbol sequence. The worst case, or
k=-oo
peak, lSI occurs when the symbols ak have their maxi-
mum magnitude (M - l)d and the same sign as genT - for m = 0,1, ... , L - 1 (11.20)
kT).
Note that for each m, (ll.20) is equivalent to passing the
Then the sum for the lSI becomes
T-spaced input symbol sequence {an} through aT-spaced
g(nT - kT) I
L
00
digital filter with impulse response gr,m(n). The resulting
D = (M -1)d I g(O) DSP output words are then multiplexed to a D/A converter
k=-oo
k#n at the rate of Lis samples/second. Finally, the D/A output
108 Chapter 11

Figure 11.2. Eye diagram for a channel with no lSI and M = 2.

is passed through a simple analog lowpass filter to elim- It can be shown [II.D.26, pp. 52-53] that the average
inate the unwanted high frequency spectral components transmitted power is
around multiples of Lis. This process is illustrated in
Fig. 11.3. In practice, the transmit filter impulse response
(11.21 )
is truncated to a finite duration by a window function like
the Hamming window, so each sub filter becomes a finite
tap FIR digital filter. With the square-root of raised cosine transmit filter, this
reduces to
(11.22)
11.4. Symbol Error Probability for a
Channel with a Perfect Using (11.1), and the fact that the levels are equally likely,
Frequency Response and the expected squared symbol value is found to be
Additive Gaussian Noise
E{a;,}
An important measure of the performance of a digital 2 M/2
communication system is its error probability as a func-
tion of the channel SNR. A formula for the symbol error
M L [d(2k - 1)]2
k=l
probability of PAM will be derived in this section under d2
the following assumptions: (M2 -1)- ( 11.23)
3
1. The frequency response of the channel is a constant Therefore, the average transmitted power is
over the signal bandwidth.
d2
2. Symbols from the M level alphabet are used with P
s
= (M2 -1)-
3T ( 11.24)
equal probability.
The noise at the output of the square-root of raised
3. Symbols selected at different times are uncorrelated cosine receive filter has the variance
random variables.

4. The additive noise is white and Gaussian with two-


(}2 1
= -2 f=
No 2
-IGR(w)1 dw
7r._= 2
sided power spectral density No/2. No
( 11.25)
2
5. The combined baseband shaping filter has a raised
cosine response with excess bandwidth factor a and Also, the channel noise power in the Nyquist band (-wsI2,
the shaping is split equally between the transmit wsl2) is
and receive filters. Therefore, the transmit and re-
ceive filters both have square-root of raised cosine
P N =
1
27r
W
s/2 No
2 dw
j =
No
2T
( 11.26)
responses. -w s /2
Digital Data Transmission by Baseband Pulse Amplitude Modulation (PAM) 109

gT,o(n)

s(nT)

gT,l(n)

D/ A H L-_ _
Lowpass s(t)
F_il_te_r_:-·~

s(nT+ Lr;lT)
gT,L-l(n)

Figure 11.3. Implementing the transmit filter by an interpolation filter bank.

Since there is no lSI, the samples of the receive filter 11.5. Symbol Clock Recovery
output have the form
In typical PAM systems, the receiver has a reason-
x(nT) = an + vR(nT) (11.27) ably good, but not perfect, knowledge of the transmitter's
symbol clock frequency. It must lock its local symbol
where vR(nT) is a sample of the channel noise filtered
clock frequency and phase to those of the received signal
by the receive filter. When an is one of the M - 2 inner
to maintain the proper sampling instants. A method for
levels, the symbol error probability is
deriving the symbol clock from the received PAM sig-
PI = P(lvR(nT)1 > d) = 2Q(d/(J) (11.28) nal is presented in this section. It is particularly suited to
bandlimited systems. Wideband systems in which the sig-
where Q(x) is the Gaussian tail probability defined in nals have sharp transitions often use other clock recovery
(10.9). For the outer level (M - l)d the error probability methods.
is The block diagram of a clock recovery system is
(11.29) shown in Fig. 11.4. The receive filter output x(t) is first
passed through a prefilter with frequency response B( w).
and for the outer level - (M - l)d the error probability is The prefilter is typically a bandpass filter centered at
/./2, half the symbol frequency. Let the combined base-
Po- P(vR(nT)) > d) band shaping filter and prefilter frequency and impulse
Q(d/(J) = Po+ (11.30) responses be
The total symbol error probabilitiy is G1(w) = G(w)B(w) and
M - 2 1 1 gl(t) = g(t) * b(t) (11.33)
----x;r- PI + M Po+ + M Po- Then, the prefilter output is .
2M - 1 Q(d/(J) (11.31)
00

M (11.34)
k=-oo
Solving (11.24) for d and using (11.25) and (11.26), the
error probability can be expressed in terms of the channel The prefilter output is passed through a squarer whose
signal-to-noise ratio PsiP N as output is
00 00

(11.32) p(t)
k=-oo m=-oo
( 11.35)
110 Chapter 11

The squarer output is passed through a narrowband band- By selecting the prefilter B( w) to be a narrow band
pass filter H( w) whose center frequency is the symbol filter that passes components only near ±ws /2, it can be
rate Is. The output z(t) looks like a sinusoid at the sym- seen from (11.41) that Pk = 0 except for k = -1, 0, or
bol clock frequency with a slowly varying amplitude and 1. By selecting the output bandpass filter H( w) so that it
phase. Its zero crossings tend to cluster together. This only passes spectral components near ±ws, the k = 0 term
signal can then be applied to a narrow band phase-locked is removed and only the symbol frequency components for
loop to generate a stable symbol clock. k = ± 1 remain.
As before, it will be assumed that the symbols are When the baseband shaping filter has zero excess
a sequence of zero-mean uncorrelated random variables. bandwidth, that is, when G(w) = 0 for Iwl ~ ws/2, all
Therefore, the Fourier coefficients Pk are zero for k =J 0 since the
E{akam} = a2 8k,m (11.36) nonzero portions ofG(w) and G(kw s - w) do not overlap.
where a2 is given by (11.23). The expected value of the This timing recovery method then fails.
squarer output is Franks and Bubrouski [ILD.7] have also derived for-
mulas for E{z2(t)} and var z(t). They show that when
00 00
G 1 (w) is symmetric about ws/2 and is bandlimited to the
E{p(t)} interval wsl4 < Iwl < 3ws14, and H(w) is symmetric
k=-oo m=-oo about ws , the variance of z(t) is zero and perfect timing
x gl(t - kT)gl(t - mT) (11.37) recovery is possible. When these symmetry conditions are
nearly met, the variations in the zero crossings of the tim-
On using (11.36), this reduces to ing wave z(t) are very small, and the receiver can track the
symbol clock frequency by locking to the zero crossings.
L
00

E{p(t)} = a 2 9I(t - kT) ( 11.38) The filters in the timing recovery system can introduce a
k=-oo phase shift in the timing wave, which must be taken into
account. The fractionally spaced equalizer can automati-
The expected value of the squarer output is periodic
cally correct for this phase shift, as long as the recovered
with period equal to the symbol period T. Therefore, it
symbol clock frequency is correct.
can be expressed as a Fourier series of the form

L
00

E{p(t)} = Pkejkwsf (11.39) 11.6. Simulation and Theoretical


k=-oo Exercises for PAM
where These exercises are designed to improve your under-

Pk = -
1j.T E{p(t)}e-Jkwsf dt
. standing of PAM by generating signals with C programs
(11.40) before doing real-time implementations in C or assembly
T 0 language and having to deal with the hardware as well
After several lines of manipulations, it can be shown that as the software. You will generate four-level PAM sig-
nals using raised cosine and square-root of raised cosine
Pk = a 2 jOO
gI(t)e-jkwsf dt shaping and create eye diagrams. You will also be asked
to make plots of the symbol error probability for several
T -00
cases.
~ roo G1(W)G1(kw s _ w) dw (11.41)
T27r .1- 00

The expected value of the output bandpass filter is 11.6.1. Generating Four-Level
also periodic with the Fourier series expansion Pseudo-Random PAM Symbols

L Write a C function to generate pseudo-random four-


00

E{z(t)} = zkejkwsf (11.42) level symbols. The function should use a 23-stage self
k=-oo synchronizing shift register sequence generator with the
where connection polynomial (9.9) or (9.10), as discussed in
Chapter 9, to generate the binary sequence dn . Generate

i:
a2 the four-level sequence an from pairs of binary symbols
PkH(kws) = H(kws) T27r
(d2n , d2n +1) according to the rule
x G1(W)G1(kws - w) dw (11.43)
(11.44)
Digital Data Transmission by Baseband Pulse Amplitude Modulation (PAM) 111

--
x(t) Prefilter q(t) p(t) Bandpass z(t) Phase- p( t)
Squarer Filter Locked ---+-
B(w)
q2(t) H(w) Loop

Figure 11.4. Block diagram of a clock recovery system.

where d is a desired scale factor. two eye diagrams and comment on how the excess band-
Draw a vertical axis and show the 4 levels. Label width factor affects the required symbol sampling time
each level with its value, and also the corresponding pair accuracy in the receiver.
of binary digits. Observe that the binary labels for ad-
jacent levels differ in only one bit. This is called Gray
coding. With additive Gaussian noise, the most likely 11.6.3. Eye Diagram for a PAM Signal
symbol decision error in the receiver is to an adjacent Using a Square-Root of Raised
level. Gray coding minimizes the bit-error probability at Cosine Shaping Filter
the receiver.
Repeat the exercises of the previous section for a
square-root of raised cosine baseband shaping filter, but
11.6.2. Eye Diagram for a PAM Signal only for 0: = 0.l25. Also, compute the peak fractional eye
Using a Raised Cosine closure defined by (11.17) from the shaping filter impulse
response.
Shaping Filter

Write a C program to generate samples of a PAM 11.6.4. Theoretical Error Probability


signal using the four-level symbol sequence of the previ-
for a PAM System
ous section and a raised cosine baseband shaping filter.
Use a symbol rate of Is = liT = 2 kHz. First, use an Plot the symbol error probability P e given by (11.32)
excess bandwidth factor of 0: = 1.0. Truncate the shaping for M = 2, 4, and 8 as a function of the channel signal-
filter impulse response to the interval [-4T, 41] with a to-noise ratio PsIP N . Plot P e on a logarithmic scale and
Hamming window. Generate L= 16 samples of the PAM 1010glO(PsIPN) dB on a linear scale.
signal per symbol interval, that is, generate the sequence
s(kTI16).
Generate data for an eye diagram that extends over 11.7. Hardware Exercises for PAM
two symbol intervals. Do this by writing enough pairs
(mod(k, 32), s(kTI16)) to a file to form a reasonably filled Now use the TMS320C30 to generate a PAM signal
out 4-level eye diagram. The function, mod(k, 32), is the and synthesize the symbol clock recovery system. Use a
remainder when k is divided by 32 and ranges from 0 to symbol rate of Is = 2 kHz. Generate L = 4 PAM signal
31. As k increases, mod(k, 32) cycles throught the values samples per symbol with an interpolation filter bank, so
0, 1, ... , 31. This performs the function of resetting the the D/A sampling rate should be set to 2 x 4 = 8 kHz.
trace to the left-hand side every two symbols. When k Your program should be a combination of C and assem-
reaches a mUltiple of 32 and mod(k, 32) = 0, you should bly language. Configure the TMS320C30 and AIC with
write the three extra points (32, s(kTI32)), (32, 0), and (0, the C program code used in most of the previous exper-
0) to the file before writing (0, s(kTI32). The first point iments. Perform the computationally intensive functions
continues the trace to the right edge of the plot, the second like the interpolation filter bank using assembly language
for efficiency. In fact, you might want to jump entirely to
°
point moves the trace vertically to 0, and the third point
moves the trace horizontally at from the right edge back
to the origin. Otherwise, lines will be drawn through the
assembly language after performing the C configuration
functions.
eye diagram from the last point on the right-hand side
to the first point on the left-hand side. These lines are 11.7.1. Generating a PAM Signal
blanked out on an oscilloscope when it retraces. Print the
and Eye Diagram
eye diagram using your favorite plotting program.
Now change 0: to 0.l25 and generate a new eye dia- Generate a four-level PAM signal using a raised
gram. Print the new diagram. Discuss differences in the cosine baseband shaping filter. Generate the four-Iev-
112 Chapter 11

el pseudo-random input symbol sequence by the same the sweeps with the symbol period. One way to generate
method used in Section 11.6.1. Choose a = 0.5 for the a synch signal is to set Serial Port 1 to generate a 2-kHz
excess bandwidth factor of your shaping filter and trun- transmit clock (CLKXI) which can be observed on the
cate the impulse response to the interval [-4 T, 41] by a RC pin of the TTLIRS-232C converter box. See Chapter
Hamming window. Generate L = 4 output samples per 10 and Appendix C for details on how to set the clock
symbol period by the interpolation method. frequency and the converter box.
Let the impulse response of the baseband shaping You will probably observe some eye closure as a
filter, viewed as an FIR filter with T/4-tap spacing, be result of the amplitude and phase distortion of the AIC
filters. Also remember that there is a blocking capaci-
for n = -16, -15, ... ,16 tor between the D/A output and the RCA jack. If the
elsewhere four-level eyes are closed, try generating a two-level PAM
(11.45) signal instead.
The frequency response of this filter is

16
G(w) = L gne-jwnT/4 11.7.2. Testing the Square-Law Symbol
n=-16
Clock Frequency Generator
16
Write a program for the TMS320C30 to implement
go+2LgncOs(wnT/4) (11.46) the symbol clock recovery system discussed in Section
n=1
11.5. Use the same raised cosine baseband shaping filter
The right-hand expression is a result of the fact that the you designed in Section 11.7.1. Do not write the out-
impulse response has even symmetry. Compute and plot put samples to the D/A converter. Instead, pipe them
the amplitude response of the filter in dB over the fre- to your clock recovery system. For the prefilter B(w),
quency range of 0 to 4 kHz. design a second-order IIR filter with a center frequency
There are a variety of ways to structure a program ofls/2 = 1 kHz and roughly a lO~-Hz 3-dB bandwidth.
to generate the real-time output signal. Here is one ap- The sampling rate for all operations in the clock recovery
proach to try. Write output samples to the Serial Port 0 system should be 4fs = 8 kHz. For the postfilter H(w),
data transmit register (DXR), with an interrupt routine that design a second-order bandpass IIR filter with a center
is triggered by the serial port transmit interrupts (XlNT) frequency of 2 kHz and a 3 dB bandwidth of roughly 25
that occur when the data transmit register is loaded into Hz. You should experiment with these bandwidths and
the serial port transmit shift register (XSR). Determine observe how they affect the system performance. Write
the symbol timing by counting interrupts modulo 4. Set the clock recovery system output samples z(nT/4) to the
up an 8-word circular buffer as a "mail box." One half AIC.
of the buffer (4 words) will be used to hold the output To test your program, first drive your shaping fil-
samples for the current symbol period, and the remaining ter with the alternating two-level symbol sequence an =
half will be used to store the four samples for the next ( _l)n d and observe the output on the oscilloscope. This
symbol period. Each symbol period, the input and output is called a dotting sequence in the modem jargon. Notice
halves will be swapped. Initialize an output pointer to the that
address of the first word, word 0, in the buffer and an ( -1) n= cos (~s nT) ( 11.47)
input pointer to fifth word, word 4. Before starting data
transmission, set the interrupt count to 0 to indicate the which are symbol rate samples of a cosine wave that has
start of a symbol. At the start of each symbol period, gen- a frequency of half the symbol rate. According to DSP
erate four output samples, and write them to the mailbox. theory, the sampled signal has spectral components at the
Do this in the main routine. The input pointer should be set of frequencies {w s/2 + IMs; k = -oo, ... ,oo}. The
incremented circularly after each sample is written to the shaping filter will pass the I-kHz component and heavily
mailbox. After the four samples are written to the mail- attenuate the other components in the [0, 4)-kHz band.
box, the main routine should wait for the interrupt count In other words, the AIC output should be very close to a
to become O. When a transmit interrupt occurs, write the I-kHz sine wave.
sample addressed by the output pointer to the DXR, in- Next, use a two-level pseudo-random symbol se-
crement the output pointer circularly, and increment the quence having values ±d. Use the shift register generator
interrupt count modulo 4. to select the levels. Observe the output on the oscilloscope
Test your program by observing the eye diagram on and comment on how it looks compared to the output with
the oscilloscope. You will need a signal to synchronize the dotting sequence.
Digital Data Transmission by Baseband Pulse Amplitude Modulation (PAM) 113

Finally, use the full four-level pseudo-random input sheets for details on how to bump the sampling phase for-
symbol sequence. Observe the output on the oscilloscope ward and backward by small increments. You will also
and compare it with the previous cases. have to devise a strategy to make one of the four samples
for each symbol occur at the center of the eye.
Quantize the selected symbol rate samples to a binary
11.7.3. Optional Team Exercise sequence. Descramble this sequence using the method
If you are interested in doing more with PAM, team described in Section 9.2.2. If your system is working
up with an adjacent group. Have one group setup a PAM properly, the descrambler output should be all O's except
transmitter and the other a PAM receiver. This exercise for a possible transient as the descrambler shift register
is nontrivial and should be considered to be equivalent to fills up.
a complete experiment.
For simplicity, put all of the raised cosine shaping
in the transmitter. Transmit a two-level PAM signal. The 11.8. Additional References
transmitted levels should be selected by the output of the For a very complete discussion of baseband digital
23-stage scrambler described in Section 9.2.1 with an in- data transmission by PAM, see the classic book by Lucky,
put of o. Again, use a 2 kHz symbol rate. Connect the Salz, and Weldon [II.D.26, Chapter 4]. Also see Gibson
AIC output of the transmitter to the AIC input of the [II.D.9, Chapter 8], Gitlin, Hayes, and Weinstein [II.D.ll,
receiver. Chapter 4], Lee and Messerschmitt [II.D.23, Chapter 6],
At the receiver, disable the AIC's input highpass fil- and Proakis [II.D.29, Chapter 6]. All these references
ter since it could severely distort the PAM signal. Sample discuss the basic idea of PAM, baseband shaping filters,
the received signal at 8 kHz. Pass the received signal sam- intersymbol interference, eye diagrams, Nyquist's crite-
ples through your own discrete-time highpass filter with rion for no lSI, raised cosine pulses, and symbol error
a very low cutoff frequency to remove any dc component probability formulas.
introduced in the analog path. Try a filter like the one in Discussions of interpolation filter banks can be found
Chapter 5, with the transfer function given by (5.35) and in Crochiere and Rabiner [II.C.3, Section 3.3] and Proakis
c very close to 1. and Manolakis [II.C.12, Chapter 10]. A very thorough
The transmitter and receiver symbol clocks will be analysis of the symbol clock recovery scheme described
slightly different in frequency because of different tem- in this experiment is presented in Franks and Bubrouski
peratures and oscillator component values. You will have [II.D.7]. Further discussions of this scheme and others
to devise a phase-locked loop to make the receiver's sam- can be found in Gitlin, Hayes, and Weinstein [II.D.ll,
pling time lock to the zero crossings of the timing recovery Section 6.5] and Lee and Messerschmitt [II.D.23, Chapter
system output. See Table 3.1 and the TI TLC32044 data 15].
12

Fundamentals of Quadrature
Amplitude Modulation

Quadrature amplitude modulation (QAM) is a widely channel symbol from a 2 J element alphabet resulting in
used method for transmitting digital data over bandpass a channel symbol rate of Is = Rd/J baud. As in PAM,
channels. It can be considered to be a generalization of T = Ills will be used to denote the symbol period. The
PAM to bandpass channels. All current telephone line alphabet consists of pairs of real numbers representing
modems based on the CCITT V series recommendations points in a 2-dimensional space, and is called the signal
for transmission at rates of 2400 bps or more use QAM. constellation. More will be said about constellations later.
These include fax modems. QAM is also used in high- It will be convenient to consider the 2-dimensional space
speed cable, microwave, and satellite systems. It is a pop- to be the complex plane and represent the channel symbol
ular choice because it uses bandwidth efficiently and lin- sequence by the sequence of complex numbers C n = an +
ear channel distortions can be corrected by adaptive equal- jb n . It is customary to call the real part, an, the inphase
ization at the receiver. In addition, QAM fits in nicely or I component and the imaginary part, bn , the quadrature
with a popular combined coding and modulation scheme or Q component.
called trellis coded modulation (TCM) and a method for The inphase and quadrature symbol components are
selecting transmitted symbols known as shell mapping, passed through separate PAM modulators identical to the
which is included in the ITU (the new name for CCITT) one described in Chapter 11. Thus, they are fIrst passed
V.34 modem recommendation, whose final draft was ap- through impulse modulators resulting in the signals
proved in June 1994.
L
00
This experiment primarily deals with the QAM trans-
a*(t) = ako(t - kT) (12.1 )
mitter. However, a brief introduction to the QAM receiver k=-oo
is included. The subsystems required to construct a prac-
tical receiver are described in the following experiments. and
L
00

b*(t) = bko(t - kT) (12.2)


k=-oo
12.1. A Basic QAM Transmitter
These signals are passed through identical baseband trans-
The block diagram of a basic QAM transmitter is mit shaping filters, each with impulse response gT(t). The
shown in Fig. 12.1. It has many similarities to the PAM properties required for gT(t) are exactly the same as the
transmitter shown in Fig. 11.1. The transmitter input is ones required for the PAM shaping filter discussed in
a serial binary data stream dn arriving at the rate of Rd Chapter 11. The outputs a(t) and b(t) of the shaping fil-
bps. The Serial to Parallel Converter groups the input ters are called the inphase and quadrature components of
bits into J-bit binary words. Each J-bit word selects a the continuous-time transmitted signal, s(t), and are given

115
116 Chapter 12

by the equations 12.2. Two Constellation Examples


00 Examples of two common constellations are de-
a(t) = L
k=-oo
akgT(t - kT) (12.3) scribed in this section. The first is a rectangular 16-point
constellation and the second is a 4-point subset of the
first. A method for assigning data bits to the constella-
and
00 tion points, so that the system is transparent to 90° carrier
b(t) = L
k=-oo
bkgT(t - kT) ( 12.4) ambiguities, is described.

The baseband shaping filter is typically a lowpass 12.2.1. The 4 X 4 16-Point


filter approximating the raised cosine or square-root of Constellation
raised cosine response, so its cutoff frequency is some-
what greater than 1s12. Consequently, aCt) and bet) are A 16-point constellation with points on a 4 x 4 rect-
lowpass signals with power spectra extending down to 0 angular grid is shown in Fig. 12.3. It is used in the CCITT
Hz. In order to translate the spectra up to the passband of V.22bis modem for transmitting 2400 bps with a symbol
a bandpass channel, aCt) and bet) are DSBSC-AM modu- rate of 600 baud and in the V.32 uncoded option for trans-
lated by the quadrature carriers cos wet and sin wet, and mitting 9600 bps at 2400 baud. This symbol alphabet uses
subtracted to form the transmitted QAM signal J = 4 bits per symbol. The assignment of input bits to the
4-bit point labels is discussed below.
s(t) = a(t) COS wet - b(t) sin wet (12.5) The 4 x 4 constellation is invariant to 90° rotations.
That is, a 90° rotation of the constellation results in the
The carrier frequency We must be greater than the shaping same set of points. It can be seen from (12.9) that a 90°
filter cutoff frequency, to prevent spectral fold-over. For carrier phase offset, that is, changing wet to wet + n12,
example, a typical voiceband telephone line channel has has the effect of multiplying the constellation point an +
a passband extending from about 300 Hz to 3100 Hz, jbn by j which rotates it by 90°. With this symmetry,
the symbol rate might be Is = 2400 Hz, and the carrier carrier tracking loops in the receivers can only determine
frequency might be!c = 1800 Hz. the correct phase to the nearest multiple of 90°. The
By using (5.24), it can be shown that the pre- system can be made transparent to 90° phase offsets by
envelope of the QAM signal is a combination of differentially encoding two of the input
bits to specify the quadrant, and assigning the remaining
s(t) + js(t)
two input bits to points within a quadrant, so that a 90°
[a(t) + jb(t)]e jwct (12.6) rotation leaves them unchanged.
A block diagram of the method for assigning input
Therefore, the transmitted QAM signal can be expressed
bits to constellation points is shown in Fig. 12.4. The
as
input data bits di arrive at Rd bps. This bit sequence
s(t) ~e{ s+(t)} is passed through a scrambler like the one described in
Chapter 9, resulting in the scrambled sequence qi. The
~e{[a(t) + jb(t)]e jwct } ( 12.7)
reason for using the scrambler is to break up long strings
The complex envelope of set) is of 1's or O's in the input data sequence and cause the
constellation points to be chosen pseudo-randomly. This
s(t) = s+(t)e- jwct = a(t) + jb(t) (12.8) randomization causes the transmitted spectrum to be dis-
tributed and have a shape like the transmit filter indepen-
Combining (12.6), (12.3), and (12.4) yields dent of the unscrambled input data sequence. Systems in
the receiver, like an adaptive equalizer, and carrier and
L
00
symbol clock tracking loops, require this symbol varia-
s+(t) (ak + jbk)
k=-oo tion to operate properly. The V.22bis scrambler uses the
difference equation
(12.9)
(12.10)
Therefore, the QAM modulator can be compactly rep-
resented in terms of these complex signals as shown in where EB represents modulo 2 addition or the exclusive-or
Fig. 12.2. The complex envelope set) is simply a complex logical function. The corresponding connection polyno-
PAM signal generated by the complex input symbols en mial is
= an + jbn. h(D)=1+D 14 +D 17 (12.11)
Fundamentals of Quadrature Amplitude Modulation 117

an a* (t) Baseband
Impulse Transmit
SModulator Filter
dn Serial to Map to 2D gT(t)
/
Parallel / Constellation
'i Converter
/

Point
J
'L Impulse
Modulator
Baseband
Transmit
Filter
t--

bn b* (t) gT(t)

x
b(t)
sin wet Quadrature Component
-

Local
s(t) + Oscillator
+ Inphase Component
cos wet
a(t)
x

Figure 12.1. A basic QAM transmitter.

Actually, the V.22bis scrambler is slightly more compli- parallel converter, which groups the serial stream into the
cated in that it contains a means for detecting a string of 4-bit words
64 I's at its output and complementing the next output
bit. This prevents the all 1's scrambler lock-up condition (Q1n, Q2n, Q3 n , Q4 n )
when the input is all 1'so Since the lock-up probabil- = (Q4n,Q4n+1,Q4n+2,Q4n+3) (12.14)
ity is small, we will ignore this addition to the Y.22bis
scrambler. The V.32 calling modem uses the scrambler These words are generated at the symbol rate Is = Rd14.
connection polynomial The ftrst two bits (Qln' Q2n) are used to specify
the change in quadrant relative to the quadrant of the
( 12.12) previously transmitted symbol. Table 12.1 shows the re-
lationship between the current input bits (Qln, Q2n), the
and the Y.32 answer modem uses the connection polyno-
previous absolute quadrant bits (Yin-I, Y2 n- I ), and the
mial
new absolute quadrant bits (YIn, Y2n). This function is
(12.13)
most easily implemented in a DSP by table look-up. This
The scrambler output qi is passed to a serial-to- operation is called differential encoding. The receiver can

c*(t) s(t) s(t)


Impulse 1------* gT(t) ~e(·)
Modulator

Figure 12.2. Representation of the QAM modulator in terms of complex signals.


118 Chapter 12

b
1011 1001 1110 1111
• • 3 • •

1010 1000 1100 1101


• • 1 • •
-3 -1 1 3
a

0001 0000 0100 0110


• • -1 • •

0011 0101 0111


• • -3 • •

Figure 12.3. The 16-point rectangular QAM constellation with labels (Yin, Y2 n , Q3 n , Q4 n ).

uniquely detennine the input bit pair (Q1n, Q2n) by de- The remaining pair of bits (Q3 n , Q4 n ) are used to
tennining the quadrant change between the current and select a point in the quadrant specified by (Yin, Y2n). If
previously received symbols. This angle difference is un- you examine Fig. 12.3, you will see that (Q3 n , Q4 n ) are
affected by any constant constellation rotation. The dif- assigned so that they do not change with 90° constellation
ferential decoding in the receiver can also be perfonned rotations. The combination of the differential quadrant
by a 16-entry look-up table whose inputs are the quadrants encoding and this bit assignment makes the overall system
of the current and previous received symbol. transparent to 90° rotations.

Q4 n Q4 n

Serial to Q3 n Q3 n Symbol an

-
di
~
Scrambler
qi
Parallel Q 2n r----------------,
I I
Y2 n
Point ~

Converter I I Map
QI n I Table 12.1 I YIn bn
I
I
I
Y2 n - 1 I
I

---@- I
I
I
Yl n - 1 I
I
I
D I

Differential Encoder :
________________ J

Figure 12.4. Mapping input bits to constellation points.


Fundamentals of Quadrature Amplitude Modulation 119

Table 12.1. Differential Quadrant Coding for V.22bis and V.32 Uncoded Options

Inputs Previous Outputs Quadrant Outputs


Q1n Q2n Yl n- 1 Y2 n - 1 phase change YIn Y2 n
0 0 0 0 +90° 0 1
0 0 0 +90° 1
0 0 0 +90° 0 0
0 0 1 +90° 1 0
0 1 0 0 0° 0 0
0 1 0 1 0° 0 1
0 1 1 0 0° 1 0
0 1 1 1 0° 1
1 0 0 0 +180° 1
1 0 0 1 +180° 0
0 0 +180° 0 1
0 1 +180° 0 0
1 0 0 +270° 0
1 0 1 +270° 0 0
1 0 +270° 1
1 +270° 0

12.2.2. A 4-Point Four-Phase The selection of these four points may seem odd at first,
Constellation but the standards committee selected them to make the
4-point constellation an easily generated subset of the 16-
A 4-point constellation can be formed from the 4 x 4 point constellation, and also to have about the same aver-
constellation by selecting the subset of points with labels age power as the 16-point constellation.
{(11O 1), (1001), (0001), (010 I)} . Notice that these points
lie on a circle and are separated by 90°. This constellation
is sometimes called a 4PSK constellation. PSK is an 12.3. A Modulator Structure Using
abbreviation for phase shift keying. This constellation is Passband Shaping Filters
used in many low- and high-speed modems. In particular, In this section, an alternative QAM modulator that
it is used in the V.22bis modem for transmission at 1200 uses passband shaping filters will be derived. This struc-
bps with a symbol rate of 600 baud and in the V.32 modem ture is slightly more efficient computationally than the
for transmission at 4800 bps with a symbol rate of 2400 one shown in Fig. 12.1. As a starting point, (12.9) can
baud. be modified to
This constellation is also invariant to 90° rotations. 00

It can be made transparent to these rotations by using the


same differential quadrant encoding scheme as for the 4 x k=-oo
4 constellation. The Y.22bis and Y.32 schemes for map- x 9T(t - kT)ejwc(t-kT) (12.16)
ping input bits to constellation points using 2 bits/symbol
is a simple modification of Fig. 12.4. For these modems, where gT(t) is the real baseband shaping filter impulse
the input data sequence d i is again passed through the response. Let
scrambler to generate the sequence qi. The serial-to-
h(t) 9T(t)e jwct
parallel converter groups the scrambler output into the
2-bit blocks (Q1n, Q2n) = (q2n, q2n+l). These pairs hJ(t) + jhQ(t) ( 12.17)
are differentially encoded exactly as for the 4 x 4 con- where
stellation. To select the desired constellation points, the
uncoded bits used in the 4 x 4 constellation are always 9T(t) COS wet and
set to (Q3 n , Q4 n ) = (01). Therefore, the inputs to the 9T(t) sin wet (12.18)
symbol point mapper are
This filter is a bandpass filter with the frequency response
(YIn, Y2 n , Q3 n , Q4 n ) H(w) = GT(W - we). Let
(YIn, Y2 n , 0,1) ( 12.15) (12.19)
120 Chapter 12

where generate the pre-envelope s+(t). Then, according to (12.9)

a~ Re{cD s(t)

L
00
ak coswekT - bk sinwekT (12.20)
(ak + jbk )9T(t - kT) (12.24)
k=-oo
and
If gT(t) has no intersymbol interference,
b~ = ~m{c~}
= ak sinwekT + bk coswekT (12.21) s(nT) = an + jbn (12.25)

Substituting these definitions into (12.16) gives which is exactly the transmitted symbol.
A block diagram of the second demodulator is shown
in Fig. 12.8. It is based on (12.5) and uses a pair of
L
00

s+(t) = c~h(t - kT) (12.22) DSBSC-AM coherent demodulators, which are discussed
k=-oo in Chapter 6. The output of the product modulator in the
upper branch is
and
s(t)2coswet a(t) + a(t) cos 2wet
L
00

s(t) = Re{s+(t)} = a~hI(t-kT)-b~hQ(t-kT) b(t) sin 2wet (12.26)


k=-oo
( 12.23) Remember that a(t) is a lowpass signal with a cutoff fre-
A block diagram for the modulator in terms of the com- quency around !s/2. The second and third terms have
plex signals is shown in Fig. 12.5. The form based on spectra centered around 2w e , and do not overlap the base-
(12.23), which is the equation that would actually be im- band signal spectrum, since the carrier frequency must be
plemented, is shown in Fig. 12.6. chosen to be greater than the cutoff frequency of the base-
The shaping filters, either baseband or passband, can band signal. The unwanted highpass terms are eliminated
be implemented by interpolation filter banks as described by the lowpass post detection filter F( w), which has a
in Chapter 11. These banks generate L sampleslbaud. For cutoff frequency selected to pass a(t) and eliminate the
example, Y.32 modems use a symbol rate of 2400 baud, unwanted terms. The output of the product modulator in
so L might be chosen to be 3 or 4, resulting in an output the lower branch is
sampling rate of 7200 or 9600 samples/sec. In the orginal
modulator structure using baseband shaping filters, each -s( t)2 sin wet b(t) - b(t) cos 2wet
filter output sample must be multiplied by the appropriate a(t) sin 2wet (12.27)
inphase and quadrature carrier samples. In the modulator
with passband shaping filters, the input symbols en must Again, the undesired second and third terms can be elim-
be rotated (modulated) before being applied to the pass- inated by an identical post detection filter. The resulting
band shaping filters. This operation is required just once inphase and quadrature components, a(t) and b(t) can then
per symbol, resulting in a slight computational savings. be sampled at the symbol instants to recover the transmit-
ted symbols. This second demodulator is not as popular
in DSP implementations, because it requires two post-
12.4. Ideal QAM Demodulation detection filters operating at a sampling rate dictated by
the 2we terms. The first demodulator requires one fil-
Two QAM demodulators will be described in this ter to form the Hilbert transform and the 2we terms are
section, using the assumption that the receiver has exact automatically cancelled.
knowledge of the carrier and symbol clock phases and
frequencies. Methods for tracking these signals will be
presented in the next chapter. In addition it will be as- 12.5. QAM Modulator Experiments
sumed that the channel is perfect and that all the shaping In this experiment, you will make a substantial part
is performed at the transmitter by filters with no intersym- of a V.22bis calling modem transmitter. The Y.22bis mo-
bol interference. dem was designed primarily for full duplex data transmis-
A block diagram of the first demodulator is shown sion at 1200 or 2400 bits per second over ordinary dial-up
in Fig. 12.7. It is based on (12.9). At the receiver input, 2-wire telephone lines. The V.22bis modem uses a symbol
the Hilbert transform of the received signal is formed to rate ofIs = 600 symbols/sec. Full duplex means that one
Fundamentals of Quadrature Amplitude Modulation 121

s(t)
Impulse
h(t) 1Re(-)
Modulator

Figure 12.5. QAM modulator using a passband shaping filter.

modem transmits to a second and the second transmits Perform the following steps to make your transmitter:
to the first simultaneously, and the transmissions in both 1. Write a C main program to initialize the
directions are independent. Two modems communicate in TMS320C30 as in Chapter 2. Initialize the AIC TA and
what is called a point-to-point fashion. The modem that TB registers, to get a sampling rate as close as possible to
initiates the transmission by placing a call to the other 7200 Hz, with a lowpass filter cutoff frequency oflel p =
modem is referred to as the calling or originate modem 1.80589 kHz. Use (3.29) and (3.28) to compute TB and
and the called modem is referred to as the answer modem. TA. With a 7200 Hz sampling rate and a symbol rate of
Frequency division multiplexing is used to achieve 600 baud, you will have to generate 7200/600 = 12 output
the full duplex transmission. The calling modem transmits samples per symbol. You will be asked below to write
a QAM signal using a carrier frequency of 1200 Hz, and the output samples to the Serial Port 0 data transmit reg-
the answer modem transmits using a 2400 Hz carrier. The ister (DXR), with an interrupt service routine activated by
baseband shaping filters are specified to have a square- the transmitter XRDY flag. You can generate the 600 Hz
root of raised cosine frequency response with an excess symbol rate timing by counting interrupts in the interrupt
bandwidth factor of a = 0.75. Therefore, the spectrum of service routine.
the calling modem is nominally confmed to the band 675 2. Implement the scrambler defmed by (12.10). Set
5,/5, 1725, and the answer modem spectrum to 1875 5, the initial shift register state to all O's and use the input
/5, 2925. A typical voiceband telephone line has a useful sequence di = 1 for all i. Check that your scrambler is
bandwidth extending from about 300 to 3100 Hz. Hybrids working by computing an initial segment of the output
and bandpass filters are used to separate the transmit and sequence by hand and comparing it with your scrambler
receive signals at the receivers. output. Your program should contain the options of gen-
erating two scrambled output bits per symbol for 1200 bps
transmission, or four scrambled output bits per symbol for
12.5.1. Steps to Follow in Making 2400 bps transmission.
a Transmitter 3. Implement the differential encoder shown in
Fig. 12.4 and Table 12.1. Your program should contain
In making your transmitter, you should do all the nu- options for both the 1200 and 2400 bps modes. At 1200
merically intensive computations using assembly language bps the output of your function should be (Yin, Y2 n , 0,
routines. In fact, you should consider using C just for ini- 1), and at 2400 bps it should be (YIn, Y2 n , Q3 n , Q4 n ).
tializing the TMS320C30 and AIC and then jumping to 4. Map the 4-bit differential encoder output to a
an assembly language program for all the remaining tasks. constellation point by looking up the values for an and

a'n Impulse
hI(t)
Modulator
s(t)
--,
I Impulse
b'n I.. - I 1
Modu ator

Figure 12.6. Expanded block diagram of the new QAM modulator.


122 Chapter 12

I
I
I
r(t) Receive s(t) I
s(t) = a(t) + jb(t)
~
Filter ,------- x -----~
I
Hilbert _.J
I s(t)
~
Transform

Figure 12.7. QAM demodulator using the complex envelope.

bn in a table corresponding to Fig. 12.3. Section 11.3 to generate the L = 12 output samples from
5. Now implement the modulator using passband the inphase and quadrature passband shaping filters each
shaping filters as shown in Fig. 12.6. You should generate symbol period. Combine the filter outputs to form 12
12 output samples per symbol resulting in a 7200 Hz out- samples of the modulated signal set) for the next symbol
put sampling rate. Use the program C:\DIGFIL\SQRT- period and write the samples to a "mailbox." The samples
RACO.EXE along with (12.18) to generate the impulse put in the mailbox should be integers suitable for sending
response samples of your inphase and quadrature pass- to the AIC and they should be scaled so that the AIC
band shaping filters. The filter impulse responses should output is limited to ±0.5 V. The mailbox should be a 24-
be limited to the time interval [-3T, 3T] where T is the word array. One half of the array should contain the 12
symbol period. Since you are making a calling modem output samples for the symbol currently being transmitted,
transmitter, use the carrier frequency of 1200 Hz. Note and the other half should contain the 12 new samples for
that the symbol rotation shown at the input to the modu- the next symbol period. The halves of the array should
lator of Fig. 12.6 is not required in this case since be swapped after each symbol period. The mailbox can
be implemented as a circular buffer.
ej27rnfcl /.,

ej27rn1200j600 = e j47rn 6. Write an interrupt service routine to load output


1 ( 12.28) samples into the Serial Port 0 DXR. The interrupt should
be triggered by the XRDY flag of Serial Port O. The
For testing purposes, also generate the baseband routine should contain a pointer to the next output sample
shaping filter coefficients for a raised cosine response with in the mailbox. It should write the sample to the DXR
the a and duration of the passband filters. You can use and then increment the pointer. If the pointer is initialized
the program C: \DIGFIL \RASCOS.EXE to generate the to the start of the mailbox array, during the first symbol
impulse response. period it will be incremented through the first half of
Use the interpolation filter bank method presented in the array. During the next symbol it will be incremented

a(t)
~xr-" F(w)
2 cos wet
Post Detection
r(t) s(t) Filter
Receive Local
Filter Oscillator
Post Detection
-2 sin wet Filter
b(t)
x F(w)

Figure 12.8. A second form of QAM demodulator.


Fundamentals of Quadrature Amplitude Modulation 123

through the second half of the array. Before the start of constellation and alternates between two points separated
the next symbol, the pointer must be reset to the beginning by 90°. The two points are generated by making the
of the array. differential encoder dibit inputs (Ql"" Q2n) alternate be-
The interrupt service routine should also maintain tween (0, 0), which causes a +90° phase change, and (1,
a count of the number of interrupts that have occurred 1), which causes a -90° phase change. The exact pair
modulo 12 to provide the 600 Hz symbol timing. of points used depends on the initial value (Ylo, Y2o) of
the absolute quadrant, and is not specified in the V.22bis
standard. For example, the Sl sequence could alternate
12.5.2. Testing Your Transmitter
between the points (0001) and (0101) shown in Fig. 12.3.
Test your transmitter to verify that it is operating Make your transmitter send the S 1 sequence continuously
properly by performing the following steps: and observe the signal on the oscilloscope. Measure the
1. First select the 1200 bps option. Clear the scram- spectrum with the spectrum analyzer. Determine the spec-
bler shift register and make its input di = 1 for all i. trum theoretically, and compare your measured and theo-
Set the coefficients of the inphase passband shaping filter retical results.
equal to those of the baseband raised cosine shaping filter
designed for this experiment. Make the quadrature com- 12.5.3. Optional Exercise- Testing Your
ponent zero by setting the coefficients of the quadrature
Transmitter by Sending to a
passband shaping filter to zero. Observe the eye diagram
on the oscilloscope for the resulting signal. Eye diagrams Commercial Modem
are discussed in Section 11.2.4, and a method for gen- Your transmitter is working correctly with high prob-
erating a symbol rate trigger signal for the oscilloscope ability if it passes the tests in Subsection 12.5.2. How-
sweep by outputting a 2400-Hz clock signal from Serial ever, a more comprehensive test is to see if it talks to a
Port 1 is suggested in Section 11.7.1. Explain the number commercial modem. In this optional exercise, you will
of levels you observe in the eye diagram. connect your transmitter to a Penril Alliance V.32 mo-
Next make the inphase passband shaping filter coef- dem, or equivalent, and test the Y.22bis 2400 bps option
ficients zero and make the quadrature passband shaping using the 4-wire leased line configuration. Perform the
filter equal to the baseband raised cosine filter. Observe following items to check your transmitter.
the resulting eye pattern on the oscilloscope. 1. Before two modems begin transmitting customer
2. Select the 2400 bps option and repeat the previous data to each other, they must go through a startup sequence
step. to agree on the transmission speed, to adjust their auto-
3. Once you are convinced your basic program flow matic gain controls (AGC), to train their symbol clock and
is correct, put in the correct inphase and passband shaping carrier tracking loops, and to train their adaptive equal-
filter coefficients. Observe the nature of the transmitted izers. The startup sequence is also called the handshake
signal on the oscilloscope for the 1200 and 2400 bps op- sequence. Program your transmitter to generate the fol-
tions. Measure the spectrum of the transmitted signal with lowing three segment startup sequence:
the spectrum analyzer and sketch the results. Check that
it has square-root of raised cosine shaping. (a) First, send the Sl sequence described in item 6 of
4. Select the 1200 bps option and make the differ- Section 12.5.2 for 100 ms
ential encoder input (Ql"" Q2n) = (1, 1) for all n. The
CCITT standard calls this the unscrambled binary 1 's se- (b) Second, send scrambled binary 1 using the 1200 bps
quence, and it is used by the answer modem in one seg- constellation for 700 ms; i.e., clear the scrambler
ment of the handshaking sequence between the modems. shift register and make its input identically 1
The resulting sequence of transmitted constellation points (c) Third, send scrambled binary 1 using the 2400 bps
continuously rotates by -90°. You should observe a peri- constellation for 200 ms
odic signal on the oscilloscope. Measure its fundamental
frequency. Also measure the spectrum of the transmitted After the startup sequence, continue to send scrambled
signal with the spectrum analyzer. Explain your results binary 1 using the 2400 bps constellation.
mathematically. 2. Attach the eight-pin RJ-45 modular connector
5. Repeat the previous step with the input to the end of the eight-conductor cable to the Alliance modem
differential encoder set to all O's. This causes continuous connector labelled DIAG on the back panel. This is the
+90° phase shifts. diagnostic port and will be used to observe the equalized
6. Another pattern called the S 1 sequence is also signal constellation at the output of the demodulator in
used during handshaking. This pattern uses the 1200 bps the receiver. Pin 1 of the connector is the constellation X
124 Chapter 12

output, pin 2 is the Y output, and pin 4 is signal ground. V.22bis modem, communicating at 2400 bps. Press ENT
Attach pin 1 to the X input channel of the oscilloscope, enough times to make the modem save the new parameters
pin 2 to the Y input, and pin 4 to the oscilloscope ground. and return to the EIA screen.
Turn the SECIDIV knob on the oscilloscope to the X-Y
position and make the voltage sensitivities of the channels
4. Attach the six-pin modular connector end of the
the same. Also, center the display.
four-conductor cable supplied with the Alliance modem
To check that the constellation display is connected
to the modem connector labelled LEASED LINE on the
properly, press the ENT button on the front panel to
back panel. The yellow and black wires are the RECEIVE
get the MAIN MENU and then press button 2 to se-
pair, and the green and red wires are the TRANSMIT
lect QUICK. Press the right arrow repeatedly until 4-
pair. Since the modem is going to be used as a receiver,
W LEASED (ANS) appears on the screen. Select 4-W
connect the DIA output of the EVM to the yellow and
LEASED (ANS) from the QUICK submenu by pressing
black wires of the cable. 5. The Alliance receiver and
button 2, which should make the option blink. Then press
transmitter should begin operating after you have selected
ENT enough times to return to the original top level EIA
the 4-W LEASED (ANS) option from the QUICK sub-
screen and save the new options. By these actions, you
menu and returned to the EIA screen. The QUICK setup
have configured the Alliance modem to operate as an an-
forces the EIA DTR (data tenninal ready) signal high
swer modem on a 4-wire leased line with the maximum
inside the Alliance modem, and this is indicated by the
default speed of 9600 bps. Next press ENT to get to the
TR displayed on the LCD screen. The modem will not
MAIN MENU, followed by the right arrow until TEST
transmit or receive unless DTR is on. You can turn the
appears in the LCD display. Then select TEST, followed
Alliance transmitter off by turning DTR off. Assuming
by ALB from the TEST submenu, followed by ON from
you are at the EIA screen, you can do this by first press-
the ALB submenu. This causes the modem to perfonn an
ing ENT to get to the MAIN MENU. Then press the right
analog loopback test, where its transmitter analog output
arrow until SETUP appears. Select SETUP and press the
is internally looped back to its receiver and scrambled bi-
right arrow until EIA appears. Select EIA and press the
nary 1 is transmitted. The resulting received constellation
right arrow until DTR appears. Finally, select DTR and
is also displayed during the ALB test. You should observe
then NORMAL from the DTR submenu. Turn DTR on
a 32-point constellation on the oscilloscope, consisting of
if you turned it off and press ENT to get back to the
points on a 6 x 6 rectangular grid rotated 45°, with the
EIA screen. Start your transmitter and observe the con-
four comer points deleted. This is the constellation for
stellation display. You should be able to see the startup
V.32 9600 bps transmission using trellis coding. The sym-
sequence consisting of the 2-point S 1 alternations, the
bol rate is 2400 baud. The ALB test can be tenninated
4-phase scrambled binary 1 segment, and then the full
by selecting the OFF option.
16-point constellation. Disconnect the constellation dis-
Observe the constellations used for various speeds
play from the oscilloscope and connect the received data
and CCITT modem standards. You can do this by chang- EIA pin of the Alliance modem to the oscilloscope. If the
ing the setting for the maximum speed. First get to the top
transmitter is working properly, the received data should
level EIA screen by pressing ENT enough times. Then be all logical 1's, which are mapped to the -12 V EIA
press ENT to get to the MAIN MENU, followed by the
level.
right arrow until SETUP appears. Then select SETUP,
followed by SPEED, followed by MAX. Change the maxi-
mum speed to 7200 and go back and perfonn an ALB test. 6. (Optional Exercise) If you are interested in per-
You should see the 16-point rectangular constellation for fonning additional tests with your transmitter, connect a
V.32 using 2400 baud and trellis coding. Next change the bit-error rate test set to Serial Port 1 of the EVM as de-
maximum speed to 4800 and turn on the ALB test. You scribed in Chapter 10. Use the bit stream from the test set
should see the 4-point constellation for V.32 using 2400 as the input to the scrambler of your transmitter. Attach
baud with no coding. Then change the maximum speed another test set to the Alliance modem. Configure both
to 2400, tum on the ALB test, and you should observe test sets to generate the same pseudo-random sequence
the 16-point rectangular constellation used by V.22bis at at 2400 bps and start bit error rate tests. The test set
600 baud. Finally, set the maximum speed to 1200, turn connected to the Alliance modem should synchronize and
on the ALB test, and you should observe the 4-point con- show no errors if your transmitter is working correctly.
stellation used by V.22bis at 600 baud. Tum off the ALB You could also add noise to the transmitted samples gen-
test and press ENT to return to the top level EIA screen. erated in the TMS320C30, and observe the effect on the
3. Now use the SPEED menu to set the MAX and received constellation and plot a curve of the bit-error rate
MIN speeds to 2400, which will force the Alliance to be a versus signal-to-noise ratio.
Fundamentals of Quadrature Amplitude Modulation 125

12.6. Additional References

The book by Bingham [II.D.3] presents a good sur-


vey of the theory and practice of telephone line digital
data modems, most of which use QAM modulation. More
comprehensive presentations of the theory can be found
in Gitlin, Hayes, and Weinstein [II.D.ll, Chapter 5] and
Lee and Messerschmitt [I1.D.23, Sections 604 and 6.5].
These presentations include transmitters, receivers, con-
stellations, and error probabilities for various constella-
tions corrupted by additive Gaussian noise. For complete
details of the CCITT V series modem recommendations,
see the CCITT Blue Book [I1.DA]. A new recommenda-
tion for the V.34 modem was approved in draft form in
June 1994 [I1.D.20]. This modem has data rates ranging
from 2400 up to 28,800 bps, and state-of-the-art modula-
tion and coding techniques.
13

QAM Receiver I. General Description


of Complete Receiver Block Diagram
and Details of the Symbol Clock
Recovery and Other Front-End
Subsytems

In this and the next experiment you will make a QAM telephone cable, the signal is often significantly attenu-
receiver. You should not do these experiments until you ated. Therefore, the output of the Receive Filter is scaled
have completed Chapter 12 and have made a working by the automatic gain control (AGC) to increase its am-
QAM transmitter. The basic subsystems required in the plitude to a level that fully loads the AID converter. This
receiver are briefly described in this chapter. Then the re- scaled signal ret) is sampled at a rate fo = liTo = nolT,
ceiver front-end components, in particular a symbol clock which is no times the symbol rate Is = liT, and is at
recovery method, are described in detail. These front-end least twice the highest frequency component in the QAM
subsystems are what you will implement in this experi- signal to satisfy the sampling theorem. The AID output
ment. samples r(nTo) are used to adjust the AGC gain. These
samples are also used by the Carrier Detect block to de-
termine when a QAM signal is actually present at the
13.1. Overview of a QAM Receiver receiver input, and not just channel noise. Many of the
receiver functions are not started until an input signal is
The block diagram of a QAM receiver is shown in detected. The proper sampling times for the AID con-
Fig. l3.1. We will call the top half of the figure the verter are determined from the AID output samples by
receiver front-end. The input signal ro{t) represents the the Symbol Clock Recovery subsystem. The frequency
signal at the receiver input, which is the transmitted QAM and phase of the symbol clock must be tracked by this
signal distorted by the nonideal frequency response of the subsystem. Finally, the receiver front-end forms the pre-
channel and additive noise. This signal is passed through
envelope r+(nTo) of the received signal. The subsystem
the Receive Filter which is a bandpass filter that passes that forms the pre-envelope is often called a phase splitter.
the QAM signal and eliminates out-of-band noise. The
Receive Filter can also be used in combination with the A real channel does not have a flat amplitude re-
transmitter filters to perform the spectral shaping required sponse and constant envelope delay, and this causes inter-
for no intersymbol interference with a perfect channel. symbol interference in the received signal. The Passband
In transmission through a communications channel like a Adaptive Equalizer compensates for the channel response

127
128 Chapter 13

AGC Logic Carrier


Detect
ro(t) Receive rl(t) r(t) r(nTo)
x AID
Filter r--~

AGC Hilbert I

Symbol ~ oJ
Transform f(nTo )
Clock
Recovery

r + (nTo) Passband 0"+ (nT) o-(nT) an


------. Adaptive _____ "'x ------ -r------· Slicer - - - -- -I-;:-~

,,
Equalizer I
I
I
I
I
bn
&
I
I
e- jCPn I en I
I
I
I
J
Ideal
Passband E+(nT) I
I
I
I Reference ---~ I

Error
+
I I
I I
e- j (·) -
+
I
L _________________ ~

I
I I
'II' I
e jCPn
x;; ____
I
~ Carrier Phase Baseband
.. - - --
I
ejO .J
Generator I
Error
I 'Pn I
I I
I I €( nT)
IL _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .JI

Figure 13.1. Block diagram of a QAM receiver.

to minimize intersymbol interference. An adaptive filter is The equalizer output a +(nT) is multiplied by the lo-
used because the exact frequency response of the channel cally generated carrier reference e-i'P n to demodulate it
is rarely known. For example, in the switched telephone to the baseband signal a(nT). If all the system compo-
network, a different channel can be selected each time a nents were perfect, the baseband signal samples would
new call is made. The equalizer is an adaptive FIR filter be ideal constellation points. In practice, they deviate
that operates on samples spaced by Tlnl and generates from the ideal points due to noise and intersymbol inter-
output samples spaced by the symbol period T. The con- ference. The Slicer quantizes the baseband samples to the
stant no, which determines the input sampling period To nearest ideal constellation points, which are used as the
= Tlno, must be divisible by nl. This is called afraction- receiver's estimates of the transmitted symbols. When the
ally spaced equalizer. In our experiments we will use nl adaptive equalizer is working well and the carrier refer-
= 2. The equalizer input sequence r +(nTlnl) is obtained ence is good, the quantized output symbols will be the
by skip sampling the sequence r+(nTo) = r+(nTlno). Ac- same as the transmitted symbols with high probability. It
tually, this sampling rate reduction can be performed by will be shown in the next chapter how the local carrier
having the FIR Hilbert transform filter operate on the To reference can be synchronized with the received signal's
spaced samples r(nTo), and computing its output only at carrier by using the transmitted constellation sequence Cn
the desired times nTlnl' The equalizer is discussed in and the baseband error Cn - a(nT) between the transmit-
detail in the next chapter. ted sequence and baseband equalizer output. The Carrier
QAM Receiver I 129

Phase Generator block performs this function. During an When no QAM signal is present, the receiver is kept in
initial training period, the Ideal Reference generator is a default state waiting for a known training sequence to
used to create a local replica of the known transmitted begin. When no carrier is detected, some of the things the
training sequence. After that, the outputs of the slicer are receiver does are: 1) set the AGe to a higher gain; 2) set
used as good estimates oftne transmitted symbols. This is the EIA RS232 output levels for clear-to-send (CTS) and
called decision directed operation. The equalizer coeffi- carrier detect (CD) to the off state; 3) clamp the output
cients are adjusted by a least mean-square error algorithm, data to steady marks; 4) keep the equalizer taps cleared
which uses the passband error. A significant portion of to zero and set the equalizer adaptation speed control to
the initial training sequence is used to adjust the adaptive a fast value; 5) keep the frequency offset variable cleared
equalizer. The carrier recovery loop typically converges in the carrier tracking loop; and 6) put the symbol clock
much faster than the equalizer. tracking loop in a fast mode.
The receiver described here is one of several ap- One approach to carrier detection is to form a run-
proaches. Some modem designers prefer to remove the ning estimate of the received signal power. This power
Hilbert Transform block, and force an adaptive equalizer estimate can be formed by passing the squared AID out-
that operates on the real samples r(nTo) with two sets put samples through a first-order recursive lowpass filter,
of real coefficients, to perform both the equalization and with the transfer function
phase splitting simultaneously [II.D.27][II.D.24].
1-c
H(z) = 1 _ cz-1 (13.1)
13.2. Details about the Receiver
The constant c is a number slightly less than 1. The closer
Front-End Subsystems
c is to 1, the more narrowband the lowpass filter is, but
In this section, more details about how to implement the slower it is to reach steady state. The numerator 1 -
most of the receiver front-end subsystems are presented. c was chosen to make the gain 1 at zero frequency. The
With this information and some ingenuity you should be resulting equation for the power estimate is
able to implement these blocks with the TMS320C30.
p(n) (1 - c) r2(nTo)
13.2.1. Automatic Gain Control + cp(n - 1) (13.2 )

The purpose of the automatic gain control (AGC) is This is sometimes called exponential averaging. When
to scale the analog input voltage to a level that almost the power estimate exceeds a predetermined threshold for
fully loads the AID converter but avoids clipping. Vari- a period of time, a received modem signal is declared to be
ous combinations of strategies can be used. For example, present. Once a carrier is detected, the threshold should be
the peak magnitude of the digitized samples can be mon- reduced by 5 dB according to the Y.22 recommendation.
itored for a fixed time period, and the analog gain can Another function of the Carrier Detect box is to de-
be adjusted to load the AID converter to a desired level tect when the received modem signal stops. This is called
with some margin against clipping. This peak detection loss of carrier. Loss of carrier is declared when p(n) falls
method can be combined with a scaling function that ad- below the reduced threshold for a period of time. The
justs the average power of the sequence of samples to a threshold hysteresis is used to avoid false detection of
desired level. carrier loss caused by the random fluctuations of p(n).
Only a coarse AGC function can be implemented According to the Y.22bis recommendation, the carrier de-
with the TMS320C30 EVM. The only choices are to set tect (CD) RS-232C connector signal should be turned off
the gain of the AIC for ± 1.5 V or ±3 V peak-to-peak 40 to 65 ms after the power level of the received input
full scale values. signal falls below the lower threshold. It should be turned
off in 10 to 24 ms for the Y.22 modem.

13.2.2. The Carrier Detect


Subsystem 13.2.3. Symbol Clock Recovery

The purpose of the Carrier Detect subsystem is to At the receiver, the transmitter's symbol clock fre-
determine when a QAM modem signal is present at the quency is known quite accurately, but not perfectly. The
receiver input and not just channel noise. In the mo- clock phase is completely unknown and can be modelled
dem jargon, people say that a carrier has been detected as a random variable uniformly distributed over one sym-
when it is decided that a modem signal is being received. bol period. The fractionally spaced adaptive equalizer,
130 Chapter 13

which will be discussed in the next chapter, can auto- The accumulator is included to make the timing recovery
mati cally correct for the unknown clock phase. However, loop track frequency offsets.
any error in the clock frequency will cause the equal- Using the correct polarity for the clock phase ad-
izer timing reference to drift towards one end of its de- justment is critically important. Using the wrong phase
lay line, and fall off that end at which point the receiver results in an unstable loop. When p(n) is positive, the
crashes. Therefore, the clock frequency must be tracked sampling instants are occurring too late. In this case,
very closely. the time to the next sample should be reduced by p(n).
A symbol clock recovery scheme described by Go- Similarly, when p(n) is negative, the sampling instants are
dard [II.D.13] is used in some commercial wireline occurring too early and the time to the next sample should
modems. An idealized block diagram for this scheme be increased by lP(n) I = -pen).
is shown in Fig. 13.2. The AID converter samples the To see how this system generates symbol clock con-
analog input signal ret) at the frequency 10 = liTo = nols trol information, suppose the transmitted symbol sequence
where Is = liT is the symbol rate and no is chosen so the is
sampling frequency satisfies the Nyquist criterion. Thus,
the sampling instants are nTo + T, where T represents (-It = cosmf
the clock phase. This phase varies with time because of cosO.5wsnT (13.7)
clock frequency offsets between the transmitter and re-
ceiver and adjustments made by the receiver's tracking If the baseband transmit filter has raised cosine spectral
algorithm. The goal of the tracking loop is to adjust the shaping, so that it has no intersymbol interference, the
sampling frequency so that it is no times the true symbol baseband complex envelope of the transmitted signal is
frequency, and then drive T to zero. s(t) = cosO.5wst (13.8)
The samples are applied to two bandpass filters op-
erating at the sampling rate of 10 = nols. One filter is Note that the correct sampling instants are at times nT
tuned to the upper Nyquist frequency Wu = We + 0.51s where the pre-envelope has the values (_I)n. The trans-
and the other to the lower Nyquist frequency We = We - mitter output has the pre-envelope
0.51s. Let the responses of these filters over the Nyquist
band Iwi < 0.510 be cos(O.5 wst)e jwct
O.5e j (wc+O.5ws)t
for Iw - wul < B/2 + O.5e j (wc-O.5ws)t
(13.3) (13.9)
elsewhere
Thus, the transmitted signal is the sum of sinusoids at the
and
upper and lower Nyquist frequencies. The output of the
for Iw - wil < B/2 upper Nyquist frequency bandpass filter is
(13.4)
elsewhere
(13.10)
The bandwidth BI2 should be reasonably small, for ex-
ample, 100 Hz for als = 2400 baud modem. Notice that and the output of the lower Nyquist frequency bandpass
these filters only pass positive frequency components and filter is
have complex impulse responses. 9i(nTo + T) = ej(wc-O.5ws)(nTo+r) (13.11)
The complex output of the upper Nyquist frequency
bandpass filter is multiplied by the complex conjugate The multiplier output is
of the output of the lower Nyquist frequency bandpass
filter. The imaginary part of this product is sampled at q(nTo + T) 9u(nTo + T)gi(nTO + T)
the symbol rate Is = liT. It will be shown in an example = ejws(nTo+r)
below that the resulting sequence v(n) gives an estimate ( 13.12)
of the timing phase error. During each symbol period, the
clock phase is advanced or retarded by an amount a times Replacing n by nno to evaluate this signal once per symbol
the phase error plus an amount (3 times the accumulated and taking the imaginary part gives
phase error. That is, the phase advancement increment is
v(n) '2sm q(nT + T)
p(n) = av(n) + f3"((n) (13.5) sin WsT (13.13)
where When IWsTI < Jr, v(n) has the same polarity as the sam-
"((n) = v(n) + "((n - 1) (13.6) pIing phase error T. Also, when IWsTI « I the sine
QAM Receiver I 131

Upper Nyquist Frequency


Bandpass Filter

--------, I
I
r(t)
--~ AID t-- r(nTo +T) x ______ • ~m(·) -
T

_________ JI
*
gt(nTo + T) v(n)
Lower Nyquist Frequency
Bandpass Filter {3
1-z- 1

Clock Phase p( n)
'-----i + -14----1
Adjustment

Figure 13.2. General block diagram of symbol clock tracking loop.

function is closely approximated by the linear function This recursion must be computed at the fast input sam-
W sT. pling rate fo = no Is. The real and imaginary parts of the
The block diagram for a practical realization of the output are computed as
symbol clock tracking loop is shown in Fig. 13.3. The
upper Nyquist frequency bandpass filter is approximated 7](n) - vcos(wuTo)
by a filter with a single complex pole at z = v&Wu To. Its x 7](n - 1) (13.16)
transfer function is
and
1
1 - vejwuTo z-l
1 - ve-jw"To z-l
~m{gu(nTo + Tn vsin(wuTo)
x 7](n -1) (13.17)
(1- vejwuToz-1)(1- ve-jwuToz 1)
1 - z-lvcoswuTo The real and imaginary parts only have to be computed
1- z- 1 2vcoswu T o + v 2 z- 2 at the symbol rate Is.
. z-l vsinwu To The lower Nyquist bandpass filter is implemented
+ J
1- z- 1 2vcoswuT o + v 2 z- 2
(13.14) in a similar manner by simply replacing u by e in the
previous equations.
The amplitude response of this filter has a peak value The imaginary part of the product gu(nTo + T)·
of 1/(1 - v) at the upper Nyquist frequency Wu. The 9t(nTo + T) is computed once per symbol, as shown in
bandwidth of the filter is determined by the parameter v, Fig. 13.3, to form the timing error signal v(n). This signal
which should be in the range [0, 1). The closer v is to 1, has significant variability when random data is transmit-
the narrower the bandwidth. The method used to compute ted. The variability increases as the number of points in
the complex output from the real input p(n) = r(nTo + T) the constellation increases. The philosophy for adjust-
is suggested by (13.14). The first step is to compute the ing the symbol clock sampling phase is similar to the
intermediate real variable approach used in the phase-locked loops in previous ex-
periments. The variability in v(n) is lowpass filtered by
7](n) p(n) + 2vcos(wuT o )7](n -1) incrementing the clock phase by a small fraction 0: of v(n)
v 27](n-2) (13.15) each symbol. In addition, v(n) is accumulated to detect
132 Chapter 13

any dc component caused by a clock frequency offset, and


and a small fraction f3 of the accumulation is added to
the clock phase increment. For good transient response, y(n) for ly(n)1 < L
f3 should be a factor of 50 to 100 times less than a. x(n + 1) = { y(n) - L for y(n) 2:: L (13.22)
The tracking loop becomes more narrowband as a is de- y(n) + L for y(n) :::; -L
creased.
When y(n) exceeds the positive threshold L, this indicates
that the sampling phase is too late, so the AIC phase must
Including a Random Walk be advanced. When y(n) is algebraically less that the
Filter in the Symbol Clock negative threshold, -L, the AIC phase must be retarded.
Tracking Loop The phase is not changed while y(n) remains between the
thresholds.
In practice, it has been found that the signal p(n)
shown in Fig. 13.3 must be additionally filtered to reduce
symbol clock jitter, particularly when the signal constella- Adjusting the Sampling
tion contains many points. A technique called a random Phase of the AIC
walk filter has been found to work well and is shown in Hardware details of the AIC are presented in Section
Fig. 13.4. First, the output of the Godard band edge filter 3.4.1. The D/A sampling frequency is determined by the
cross-correlator is hard limited to form the signal TA and TB registers and the AID sampling frequency
by the RA and RB registers according to (3.28). Tables
v(n) sign v(n)

{j
=
3.1 and 3.2 show how to configure the AIC registers and
for v(n) > 0 functions. The two Isb's of the 16-bit words transmitted
for v(n) = 0 (13.18) to the AIC from the TMS320C30 Serial Port 0 control the
for v(n) < 0 AIC function as shown in Table 3.1. In each of the four
cases, the 14 msb's are sent to the D/A converter. The
The hard limiting provides a simple AGC action that
AIC actions for the four cases shown in Table 3.1 are:
keeps the loop gain constant independent of the input sig-
1. When the Isb's are 00, TA is used for the transmit
nal level. This signal is then passed through the same
A value and RA for the receive A value.
kind of second-order loop filter as shown in Fig. 13.3,
2. When the Isb's are 01, the transmit A value is
resulting in the signal p(n).
replaced by TA + TA' and the receive A value by RA +
The output of the second-order loop filter is then
RA/. The effect is to increase the time interval to the next
applied to the random walk filter. The random walk filter
sample by the amount
is basically an accumulator that gets reset when its output
exceeds a positive or negative threshold. The random !:l.T A' x period(MCLK)
walk filter accumulator output is
A'
7.5 J-Lsec (13.23)
y(n) = x(n) + p(n) (13.19)

where for the appropriate transmit or receive A'. Remember that


TA' and RA' are two's complement integers in the range
x(n + 1) y(n) - q(n) [-32, 31). Thus, for a positive A' the time interval to the
next sampling instant is iricreased and for negative values
= x(n) + p(n) - q(n) (13.20)
it is decreased.
The signal q(n) is generated by the Threshold Detector 3. When the two Isb's are 10, the transmit A value
and is zero most of the time. When the accumulator out- is replaced by TA - TA' and the receive A value by RA
put y(n) exceeds the thresholds of L or -L, the accumlator - RA/. The effect is to decrease the time interval to the
value is reset and the AIC sampling phase is advanced or next sample by the amount !:l.T.
retarded. As long as the accumulator output remains be- 4. When the two Isb's are 11, TA is used for the
tween the thresholds, the sampling phase is not changed. transmit A and RA for the receive A. After the AIC re-
This significantly reduces clock jitter. The exact rules ceives the 16-bit sample word from the TMS320C30, it
describing the Threshold Detector and accumulator are: requests a secondary transmission. The function of the
secondary transmission is selected by its two Isb's ac-
for ly(n)1 < L cording to Table 3.2. The four functions are: (00) set
q(n) = { ~ for y(n) 2:: L (13.21) the A registers, (01) set the A' registers, (10) set the B
-L for y(n) :::; -L registers, and (11) set hardware configuration. Normally,
QAM Receiver I 133

__--------4 + l4---------,

2vcosw"To
p(n)

'I7(n-2)
'I7(n) 'I7(n-1)
~---------------,
-vcosw"To vsinw"To

Tlno
r(t)
- - - * AID 1-----1
!Re g" ~m gu.

!Re gL
~-----~+ ~---------+------*

-VCOSWLTO vsinWLTo

~m gL

Z-l/no ~--t----w z-l/no

2VCOSWLTo

~--------4 + ~------~ T

-y(n) -y(n - 1) v(n)

(J
Symbol Clock p(n)
~---~
Generator
~------4 + ~------------------~

Figure 13.3. Practical realization of symbol clock tracking loop.


134 Chapter 13

Godard
v(n) Hard v(n)
Timing Tone t----~
Limiter i(n)
Generator

jJ(n)

Advance/Retard
Control for AI C Threshold y(n)
t+-----.,-------------{ + }04---;--'
Detector
+
1.--_ _ _ _ _ _.... + )-___*
q(n) x(n + 1) x(n)
Random Walk Filter

Figure 13.4. Including a random walk filter in the clock tracking loop.

functions (00) and (10) are used to set the sampling rate to provide rapid initial convergence followed by slow fme
to its nominal value at system initialization. Function (01) adjustments. At the start of each symbol, the phase in-
is used while the clock tracking loop is running to change crement p(n) is computed and its polarity is recorded. At
the size of the phase increments. the next sampling instant, the clock phase is stepped by
A word transmitted from the TMS320C30 to the AIC the fixed increment corresponding to the value of the RA'
can cause the AIC to increment the time to the next sam- register in the direction determined by the recorded po-
pling instant, or load new values into the A' registers, but larity. These operations are performed once per symbol.
not both. Remember that the desired sampling phase in-
crement p(n) is computed once per symbol, but the AIC
samples the received analog signal no times per symbol.
Also, the increment must be quantized to a 6-bit two's 13.3. Experiments for the QAM
complement integer to fit in the RA' register. Receiver Front-End
An approach to approximating the ideal phase control In this experiment you will build the front-end for a
is: Y.22bis receiver operating in the answer mode. Use the
1. At the start of a symbol, say at time nT, compute V.22bis calling mode transmitter you made in Chapter 12
the clock phase increment p(n) and convert it to an integer as the signal source. Set the transmitter to the 1200 bps
suitable for loading into the AIC RA' register. data rate and 4-phase constellation option. Run the trans-
2. At the next sampling instant nT + Tlno, load the mitter on an adjacent station and connect its DIA output to
phase increment into the RA' register. the AID input of the receiver station. Remember that the
3. At the next sampling instant nT + 2Tlno, incre- signal transmitted by the calling modem uses a 1200 Hz
ment the time interval to the next sample. carrier and a symbol rate of 600 baud. It uses 75% excess
4. The nominal sampling period can be used for bandwidth square-root of raised cosine spectral shaping,
the remaining samples during the symbol or additional so the transmitted signal is theoretically band limited to
increments determined by the value loaded into the RA' the interval (675, 1725) Hz. Perform the following items
register in Step 2 can be used for all or some of the to build and test your receiver front-end. All numerically
remaining samples. intensive computations should be performed by assembly
A simpler approach to adjusting the clock phase is to language functions, or else the receiver will not be able to
load a small value into the RA' register at system initial- function in real time. In fact, you should consider using C
ization. This value is not changed afterwards except pos- just to initialize the TMS320C30 and AIC and then jump
sibly for a change from a larger value to a smaller value, entirely to an assembly language program.
QAM Receiver I l3S

1. Initialize Serial Port 0 as in Chapter 2. is set to send the S 1 sequence described in item 6 of Sec-
2. Initialize the AIC so that the nominal receiver tion 12.5.2 continuously. You should observe a 600 Hz
sampling rate is /0 = 3600 Hz, which is no = 6 times sinewave. Once this function is working, set the trans-
the symbol rate. Set the cutoff frequency for the AID mitter to send scrambled 1's and observe the result on
antialiasing receiver lowpass filter to felp = 1.80589 kHz the oscilloscope. You might also set the transmitter to
and enable the input highpass filter. The combination of the 2400 bps mode and observe the result. When you are
the lowpass and highpass filter will serve as the Receive sure the bandpass filters and complex multiplier are work-
Filter. ing properly, change the program to generate the product
3. In Chapter 12, it was specified that the transmitted once per symbol. Generate the phase error signal p(n) and
signal should be limited to ±0.5 V, so set the AIC gain close the loop by incrementing the time between samples
option to ± 1.5 V. Since the AIC only has two gain options, appropriately. You can send p(n) to the D/A converter to
forget about implementing the AGC function. observe its behavior.
4. Write an interrupt service routine for the TMS- 7. To complete the receiver front-end, design and
320C30 triggered by the Serial Port 0 Receiver Ready Flag implement the phase splitter. Design the Hilbert transform
(RRDY) to read samples from the Data Receive Regis- filter so its amplitude response is quite flat over the signal
ter (DRR). Count interrupts modulo 6 to determine the passband. The Hilbert transform FIR filter should operate
symbol timing. You can use this count to control when on samples spaced by To = lifo = Tina. However, compute
various receiver functions are performed during a symbol its output at the slower rate 21s =/0/3, that is, compute two
period. equally spaced output samples per symbol. Pass these pre-
5. Implement the Carrier Detect function using the envelope samples on to the adaptive equalizer in Chapter
approach presented in Section 13.2.2. Keep the accumu- 14.
lator register in the symbol clock tracking loop cleared
until a carrier is detected. You can write the output of
the carrier detector to the DIA converter to check that is
functioning properly. 13.4. Additional References
6. Implement the symbol clock tracking system See Godard [II.D.13] for a detailed analysis of the
shown in Fig. 13.3 and discussed in Section 13.2.3. symbol clock tracking method described in this experi-
Choose the bandpass filter parameter v to achieve a 3- ment. He calls it the band edge component maximiza-
dB bandwidth of about 50 Hz. tion (BECM) approach. Additional discussions of timing
Initially, do not close the loop and modify the AIC recovery can be found in Bingham [II.D.3, Chapter 7],
sampling intervals. For testing purposes, generate the Gitlin, Hayes, and Weinstein [II.D.ll, Chapter 6], and
imaginary part of the complex multiplier output at the Lee and Messerschmitt [II.D.23, Chapter 15].
same rate as the input samples, that is, six times per sym- See Section 5.5.2 of Chapter 5 (Amplitude Modula-
bol. Send the resulting samples to the DIA converter and tion) for an introduction to Hilbert transforms and Section
observe the result on the oscilloscope when the transmitter 5.3.3 for tools for designing FIR Hilbert transform filters.
14

QAM Receiver II. The Passband


Adaptive Equalizer and Carrier
Recovery System

An important milestone in high-speed data transmission 14.1. The Complex Cross-Coupled


over narrow-band channels, like the voice-band telephone Passband Adaptive Equalizer
channel, was the invention and commercialization of the
FIR adaptive equalizer by R. W. Lucky at AT&T Bell Lab-
oratories in the early 1960's [II.D.25]. The purpose of the A type of equalizer that operates on samples of the
adaptive equalizer is to remove the intersymbol interfer- pre-envelope of the received signal is shown in Fig. 14.1.
ence caused by the amplitude and phase distortions of the The input to the equalizer is the sequence r + (nT1nl), ob-
channel. Adaptive filters are used because the frequency tained by evaluating the output of the Hilbert transform
response of the channel is not known accurately in many filter in the receiver front end at the desired times. Thus,
situations. Lucky's original equalizers used the zero forc- the equalizer operates on samples taken at the rate h =
ing algorithm. Other people soon replaced this algorithm nlis, wherels = liTis the symbol rate. The blocks in the
by Widrow's [II.D.37] more powerful least-mean square figure containing z-l/nl represent complex signal delays
(LMS) algorithm. Another major influence has been the of Tl = T1nl. Remember that the spectrum of the QAM
remarkable advances in VLSI technology. This has led pre-envelope is confined to the positive frequency interval
to ever-more powerful DSP's which allow complex algo- I!c - 0.5(1 + Q)Is ~ f ~ Ic + 0.5(1 + Q}fs], where Ic is
rithms to be implemented very inexpensively. For exam- the carrier frequency and Q is the excess bandwidth fac-
ple, modems that include data rates of 300 bps, 1200 bps, tor. The width of this interval is (1 + Q)Is. The integer nl
and 2400 up to 28,800 bps in steps of 2400 bps, as well should be chosen to prevent aliasing of the pre-envelope.
as error correction, data compression capabilities, and fax Since 0 ~ Q ~ 1, nl must be greater than or equal to
modes can be bought for around $200. 2, so that no aliasing occurs. In this experiment, we will
use nl = 2 and the resulting structure is commonly called
a TI2 spaced equalizer. An equalizer which operates on
In this experiment, you will complete the QAM re- samples spaced by less than the symbol period T is called
ceiver by making the adaptive equalizer and carrier re- a fractionally spaced equalizer. Early equalizers used nl
covery system. You will make two kinds of equalizers = 1, which corresponds to T spaced samples. It was soon
- the complex cross-coupled passband equalizer and the recognized that fractionally spaced equalizers performed
phase-splitting fractionally spaced equalizer. You will im- better and, in particular, could act as interpolators and
plement the LMS equalizer adjustment algorithm and a compensate for any fixed symbol clock timing phase off-
technique known as blind equalization. set.

137
138 Chapter 14

The equalizer output at time nTlnl is and the instantaneous passband error is
N-l
'E(nT)ej'Pn
cy+(nT/nd = L hkr+((n - k)T/nl) (14.1 )
[c n - nd - a-(nT)] ej'P n
k=O
cn - nd ej'P n - cy+(nT) (14.5)
The equalizer coefficients ho, ... , h N - l are complex num-
bers and are sometimes called the equalizer tap values. The mean-squared error to be minimized is
It will soon be shown how to adjust adaptively the tap
values to minimize lSI. The Down Sampler selects ev- A E{I'E(nT)12}
ery nl th equalizer output sample to generate the symbol
E{IE+(nTW}
spaced sequence cy+(nT). Replacing n by nnl in (14.1)
gives E{!cn-nd - a-(nT)12} (14.6)

N-l where E denotes statistical expectation. Similar results


cy+(nT) = L hkr+(nT - kT/nl) (14.2) are obtained when E is thought of as a sum over n. Let
k=O the complex tap values have the representation
In practice, the fractionally spaced equalizer and down
sampler are implemented by just evaluating (14.1) once
hk = hR,k + j hI,k
per symbol period. Note that this sum involves pre- where hR,k = ~e{hd
envelope samples spaced by Tlnl. The remainder of the and hI,k = ~m{ hd (14.7)
receiver operates on symbol spaced samples.
The optimum coefficients can be found by setting the
derivatives of A with respect to the tap value compo-
14.1.1. The LMS Method for Adjusting the nents equal to zero. Since the mean-squared error is a
Equalizer Tap Values quadratic function of the tap components, the error func-
tion is convex and a unique solution exists. The derivative
The equalizer output samples are demodulated to
with respect to hR,m is
baseband using the carrier angle CPn generated by the
carrier tracking system. For the time being, it will be
assumed that the carrier phase is known exactly. The E {ah~,m ['E(nT)'E(nT)]}
demodulated samples are

a-(nT) = cy+(nT) e-j'P n (14.3) E {'E(nT) a~


R,m
+ 'E(nT) ~~nT)}
R,m
The goal of the equalizer is to make the baseband output
samples as close as possible to a delayed version C n - nd
of the transmitted input symbol sequence. With a perfect
2E { ~e ['E( nT) ~~ 1}
channel, this can be accomplished by setting hnd to 1 and -2 E{~e['E(nT)ej'Pn
all other taps to O. The choice of nd effectively sets the
time reference for the receiver. The symbol at tap nd is (14.8)
considered to be the current received symbol. The time
reference nd is usually selected to be near the center of the In terms of the passband instantaneous error, this result
equalizer delay line. Then, the equalizer can be thought can be written as
of as a non causal system, where the taps before nd operate
on future samples and the taps after nd operate on past = -2E{~e[E+(nT)
samples. With real telephone lines, it has been found
experimentally that nd should be chosen to be closer to x r+(nT-mT/nd]} (14.9)
N - 1 than O. The optimum placement depends on the
channel frequency response. Similarly, it can be shown that
A mathematically tractable criterion for selecting the
equalizer tap values is to choose them to minimize the
mean-squared baseband or passband error. The instanta-
E {ah~,m ['E(nT)E(nT)]}
neous baseband error is

E(nT) = C n - nd - a-(nT) (14.4)


2E {~e ['E(nT)a~l} =
QAM Receiver II 139

ho
L ______ _ Down
Sampler ----~

Figure 14.1. The complex cross-coupled passband equalizer.

-2 E{~e[E(nT)( _j)ej'Pn xr+(nT - mT/nd}


-.,.---;::::-----c=-;-_____
= E{Cn_ndej'Pn r+(nT - mT/nd}
x r+(nT-mT/nd]} for m=O, ... ,N-1 (14.14)
-2 E{~m[E(nT)ej'Pn
These are called the normal equations in estimation the-
(14.10) ory, and the fact that the error sequence must be uncor-
related with the data samples is called the orthogonality
So, in terms of the passband error signal principle. Assuming that the channel and baseband sym-
bol sequence information required to compute the expec-
-2E{~m[E+(nT) tations is available, this is a set of N linear equations in
the N unknown equalizer coefficients. Let the transpose
x r+(nT-mT/nl)]} (14.11) of the N-dimensional coefficient column vector be
Let the "derivative" with respect to the complex tap value
(14.15)
hm be defined as
oA . oA Let the N x N correlation matrix R for the received sam-
--+J-- ples in the equalizer delay line have the elements
OhR,m oh/,m
-2E{E+(nT)

( 14.12)
x r +(nT - mT/nd}
Thus, the derivative with respect to tap hm is propor- for k,m = O, ... ,N -1 (14.16)
tional to the average of the product of the instantaneous
passband error E+(nT) and the complex conjugate of the Also, let the N x I column vector p of cross-correlations
passband data sample r+(nT - mT1nl) sitting at tap m at between the desired equalizer output and delay line sam-
time nT. ples have elements
The optimum equalizer tap values must satisty the
equations

x r +(nT - mT/nd}
for m=0, ... ,N-1 (14.17)
x
°
r +(nT - mT/nd}
for m=O, ... ,N-1 (14.13) Then, the linear set of equations can be written as the
matrix equation
Substituting (14.5) for the passband error and rearranging
Rh=p (14.18)
yields the set of equations
N-l When R is nonsingular, the solution for the optimum tap

L
k=O
values is
(14.19)
140 Chapter 14

and it can be shown that the resulting minimum mean- form the passband output signal a+(nT). The passband
squared error is output is demodulated to the baseband signal a(nT) us-
ing the angle 'Pn generated by the carrier tracking system.
( 14.20) The Slicer quantizes its input to the closest ideal constel-
lation point. During initial training, a known sequence
Cn is transmitted and a delayed version cn - nd is gener-
In many real-world applications, like data transmis- ated in the receiver by the Ideal Reference block. The
sion over voice-band telephone channels in the switched exact baseband error signal E(nT) can be formed during
telephone network, the channel frequency response and the initial training period. This error signal is modulated
noise statistics are known only roughly at the transmitter to passband, and correlated against the data sample at the
and receiver. Therefore, the correlation matrices cannot tap being adjusted and scaled by 11, to form the tap up-
be computed and the optimum tap values cannot be cal- date increment. After the equalizer converges to the point
culated by (14.19). A solution to this problem is to use where the baseband output symbols a(nT) are close to
an adaptive tap adjustment algorithm. The most popu- the ideal constellation points, the switch can be moved
lar algorithm is the least-mean square (LMS) or stochas- to the slicer output, and cn - nd can be used as an accu-
tic gradient algorithm. The basic philosophy is to it- rate estimate of the delayed transmitted symbol sequence.
eratively minimize A by incrementing the tap values by This mode is called decision directed equalization. Deci-
small amounts in the directions opposite the derivatives sion directed equalization is required in practice because
given by (14.12). This is a form of gradient search al- the receiver does not know the random symbol sequence
gorithm known as the method of steepest descent. The transmitted during normal data transmission. If the ma-
expected value required to compute a derivative cannot jority of decisions are correct, the equalizer will converge
be evaluated when the channel is unknown. However, because of the averaging effect of a small 11. Infrequent
a known training sequence is usually sent at the begin- errors cannot move the equalizer taps very far from their
ning of transmission, so E+(nT) and r+(nT - mT1nl) are optimum values.
known to the receiver, and a time average of the products
of these quantities can be used as an unbiased estimate
of the true expected value. These ideas suggest using the 14.1.2. Theoretical Behavior of
following tap adjustment formula: the LMS Algorithm

The behavior of the LMS algorithm has been exten-


sively analyzed [II.D.ll,18,23,29,37]. It has been shown
x r+(nT-mT/nl) by invoking an independence approximation that the be-
for m=O,,,.,N-l(14.21) havior depends on the eigenvalues of the correlation ma-
trix R. Let these eigenvalues - arranged in order of in-
where hm(n) is the value of the mth tap at time n and 11 is creasing size-be {AI"", AN}, so Al = Amin is the
a small positive constant. This is the LMS tap adjustment smallest and AN = Amax is the largest eigenvalue. Then
algorithm. it has been shown that the mean of a tap value error,
The parameter 11 controls the speed and smoothness E{hm(n) - hm }, is the sum of exponential modes of the
of the convergence of the taps to their optimum values. A form (1 - I1Ai)n. Therefore, the mean tap values converge
large value of 11 gives rapid initial convergence but large to the optimum tap values if
variations about the theoretically optimum final value, be-
cause of the small averaging effect. A small value results ( 14.22)
in slow convergence but small tap variations around the
optimum values. Very large values of J.L cause the algo- or
2
rithm to become unstable, while very small values can O<J.L<-A- (14.23)
result in arithmetic underflow, which causes the adjust- max

ments to stop. In practice, the adaptation is often started It is shown in Lee and Messerschmitt [II.D.23] that the
with a moderately large value of J.L to get rapid initial con- value for J.L which maximizes the speed of convergence is
vergence for a period of time, and then "gear shifted" to
2
a small value for precise final adjustment. J.Lopt = \ \ (14.24)
The block diagram of a section of an adaptive pass- "min + "max
band equalizer illustrating the LMS algorithm for adjust- Then
ing one tap is shown in Fig. 14.2. The outputs of all
the tap multipliers are summed in the box labelled "+" to
QAM Receiver II 141

-lin! ...
-------. z --- ,-----------------------r------~
I
I
I
"

r ____________ ~x

I
I
I
~ hm(n+ 1)
+ _______ 1 z-l

IL ________________ J

"
+ I
I
I
I 0'+ (nT)
I
ejCPn e- jCPn I

~'t4--------i Carrier ______________ x


X ~

Recovery
I I
I
I
I
r--------- ~ u(nT)
I
I

~i4--­ Slicer
~
I
.... ____ J

: €(nT) ~
L ________________________~~-~-~

........- - - - 1 Ideal
.... ------ Reference

Figure 14.2. Block diagram illustrating the LMS algorithm in a passband equalizer.
142 Chapter 14

Amax where
---1
Am in (14.25) N
Amax +1 J.t 2: Ad(2 - J.tAi)
A min i=l
Aex Amin
Therefore, the maximum speed of convergence is deter- N

mined by the ratio of the maximum and minimum eigen- 1 - J.t 2: Ad(2 - J.tAi)
values. This ratio is called the eigenvalue spread. Max- i=l
N
imum speed of convergence can be achieved when the
eigenvalue spread is 1, which implies that all the eigen- J.t 2: Ai
values are the same. i=l
Amin
N
Convergence of the mean tap values does not imply
convergence of the mean-squared equalizer output error. 2 - J.t 2: Ai
i=l
It is shown in Haykin [ILD.IS, p. 329] that the mean-
if IJ.tAi I «1 for all i (14.29)
squared error converges if and only if
2 2 is the excess mean-squared error. In practice, J.t is usually
0<J.t<--=-- (14.26) switched to a very small value after an initial training
N trace R
2: Ai period to minimize the tap jitter and excess mean-squared
error.
i=l
The denominator of this upper bound is
14.1.3. Adding Tap Leakage to the
N-l
LMS Algorithm
trace R = 2: Rk,k =
k=O Convergence problems can occur with fractionally
N-l spaced equalizers because R is nearly singular. It can be
2: E{lr+(nT - kT/nl)1 2 } (14.27) shown that the eigenvalues of R are proportional to the
k=O amplitude spectrum of r+(nT1nl) for large N. For nl > 1
All of the eigenvalues of R are real and positive since it is and no additive channel noise, this spectrum is zero over a
a Hermitian matrix. Therefore, (14.26) is a tighter bound region around half the sampling rate. When R is singular,
on J.t than (14.23). the normal equation (14.IS) does not have a unique solu-
Physically, the denominator is the sum of the aver- tion for the tap vector since the sum of any solution and
age power of the received samples in the equalizer delay a vector in the null space of R is another solution and all
line. When a T spaced equalizer (nl = 1) is used, these solutions have the same mean-squared error. In practice,
samples form a stationary random sequence and the sum the taps can slowly drift as a result of computational bi-
is N times the average power of the received signal at ases while the mean-squared error remains small. When a
the symbol instant nT. For fractionally spaced equalizers, tap gets too large for its fmite-word-Iength hardware rep-
the sequence is cyclostationary and the average powers resentation and overflows, the system crashes. A solution
vary periodically as a function of k and have period nl. to this problem is to modify the LMS algorithm to include
In the limit as the excess bandwidth factor 0: approaches tap leakage. The modified tap adjustment algorithm is
zero, the fractionally spaced samples become a stationary
(1- "f)hm(n)
sequence. In any case, the denominator increases mono-
+
-~------...,--...,...

tonically and nearly linearly with the equalizer length N. J.te+(nT) r +(nT - mT/nl)
Therefore, the stability constraint on the tap update factor for m = O, ... ,N -1 (14.30)
J.t becomes tighter as the equalizer becomes longer.
The mean-squared error does not converge to the the- where "f is a small positive constant. Thus, with each
oretical minimum value with the LMS algorithm, as a iteration, the current tap value is shrunk slightly before
result of the noisy gradient estimates. These noisy esti- adding the estimated gradient increment.
mates cause the taps to jitter about their optimum values
in steady-state and this increases the mean-squared error. 14.2. The Phase-Splitting Fractionally
It is shown in Haykin [II.D.IS, p. 327] that the mean- Spaced Equalizer
squared error converges to
The phase-splitting fractionally spaced equalizer
(I4.2S) shown in Fig. 14.3 is commonly used in current telephone
QAM Receiver II 143

(JR(nT/no)
hR,o hRl
, h R,2 hR,N-l
r(nT/no) (J+(nT)
Down
z-l/n o z-l/no z-l/n o
Sampler ----~

hIO
, hIl
, hJ2
, hI,N-l
(JI(nT Ina)

Figure 14.3. The phase-splitting fractionally spaced equalizer.

N-l
line modems. Mueller and Werner [II.D.27] observed
that the real and imaginary outputs of the cascade of the L
hI,kr(nT - kT/no) (14.32)
Hilbert transform FIR filter and complex cross-coupled k=O
equalizer are linear combinations of the input samples Therefore, the output of the Down Sampler block is
to the Hilbert transform filter. Therefore, they suggested
combining the two functions into the structure shown in
aRCnT) +j aI(nT)
N-l
Fig. 14.3. The phase-splitting equalizer is computation-
ally more efficient than the complex cross-coupled equal-
L
hkr(nT - kT/no) (14.33)
k=O
izer because the complex products, which require four real
multiplications, are replaced by two real products. Ling where the complex equalizer taps are defined to be
and Qureshi [1I.D.24] show that the price paid is slower hk = hR,k + j hI,k
convergence.
for k = 0, ... , N - 1 (14.34)
When the phase-splitting equalizer is used, the
Hilbert transform filter shown in the receiver front end Notice that the complex tap value hk is multiplied by the
block diagram in Fig. 13.1 is removed and the signal real data sample renT - kTlno) which requires only two
r(nTo) is connected directly to the equalizer input. The real products. On the other hand, a complex tap is multi-
input sampling rate 10 = liTo must be at least twice the plied by a complex data sample in the complex cross-
upper cutoff frequency of the received signal to satisfy the coupled equalizer and this requires four real products.
Sampling Theorem. As usual, we will use T to denote the The equalized passband samples a+(nT) are processed
symbol period and Is = liT to denote the symbol rate. It in exactly the same way as shown in the bottom half of
is convenient to let To = Tlno, and then fo = nofs. For Fig. 14.2. Each sample is demodulated to baseband and
example, a Y.32 modem uses a carrier frequency of!c = quantized to the nearest constellation point. The baseband
1800 Hz, a symbol rate of fs = 2400 Hz, and square-root error f(nT) is formed using the ideal reference sequence
of raised cosine shaping with a = 12% excess bandwidth or slicer decision, and remodulated to the passband error
resulting in an upper cutoff frequency of about 3144 Hz. E+(nT).
Therefore, a convenient choice is to let no = 3, resulting As in the case of the complex cross-coupled equal-
in a sampling rate of fo = 7200 Hz. The z-l/no blocks izer, the tap values can be chosen to minimize the mean-
in Fig. 14.3 represent delays of To. squared baseband or passband error defined by (14.6).
The output of the upper filter in the phase-splitting Using the same approach as before, it can be shown that
equalizer at time nT is the derivatives of A with respect to the tap values are

~e{a+(nT)} -2E{~e[E+(nT)lr(nT - mT/no)}


N-l
L hR,kr(nT - kT/no) (14.31)
for m = 0, ... ,N - 1 (14.35)
k=O and
and the output of the lower filter at time nT is 8A
-2E{~m[E+(nT)lr(nT - mT/no)}
8h I ,m
for m = 0, ... , N - 1 (14.36)
144 Chapter 14

Thus, where We is the carrier frequency and e is a fixed unknown


fJA . fJA phase offset. Replacing hR,m bye in (14.8), we find that
--+]-- the derivative of the mean-squared error with respect to
fJhR,m fJhI,m
the phase offset is
-2E{E+(nT) r(nT - mTjnd}
for m = 0, ... , N - 1 (14.37) fJA =
fJe
2E{Re [-( nT) fJE(fJenT)] }
E (14.42)
These derivatives suggest using the following LMS
algorithm with tap leakage for adapting the taps: Remember that the baseband error is
(1 - 'Y)hm(n) E(nT) Cn- nd - a(nT)
+ 1.lE+(nT) Cn- nd - 0"+ (nT)
x r(nT - mTjno) (14.38) x e-j(wcnT+Ii) (14.43)
where l' is a small positive leakage constant and J.L is a Therefore,
small positive update scale factor. In terms of the indi-
vidual tap components, this formula is equivalent to fJA
= 2E{Re[E(nT)jO"+(nT)e- j (W cnT+Ii)]}
fJe
(1- 'Y)hR,m(n)
+ J.LRe{E+(nT)} = -2 E {SSm [ E(nT) a (nT)]} (14.44)

x r(nT - mTjno) (14.39) On replacing E(nT) by c n- nd - a(nT), the following al-


and ternative formula for the derivative is obtained:

(1 - 'Y)hI,m(n) ( 14.45)
+ J.LSSm{f+(nT)}
x r(nT - mTjno) (14.40) This derivative has an interesting physical interpre-
tation. Let
Note that the complex passband error is multiplied by
a real data sample to update the complex tap, and this and
requires two real products. In the complex cross-coupled a(nT) ( 14.46)
equalizer, the complex error is multiplied by a complex
data sample, and this requires four real products. be the polar form representations for these two complex
A block diagram for LMS updating of the phase- numbers. Remember that the equalized baseband output
splitting equalizer taps would be very similar to Fig. 14.2. sample a(nT) is supposed to be a close approximation to
The main difference would be that the complex signal the ideal symbol cn - nd . Then
r+(nT - mTlnl) would be replaced by the real signal r(nT
- mTlno), so the complex Tlnl spaced delay line would (14.47)
become a real Tlno spaced delay line. The (complex x
so
complex) products involving r + (.) for updating the taps
and computing the equalizer output would be replaced by
(real x complex) products involving r(·). Also, the tap ( 14.48)
leakage is not shown in Fig. 14.2.
This has the same sign as the phase error between the
ideal constellation point cn - nd ' and the equalized base-
14.3. Decision Directed band received point a(nT) if the phase error is not too
Carrier Tracking large, and is nearly a linear function of the error for small
phase errors.
Up to this point, it has been assumed that the carrier
phase is known exactly. An approach to estimating and This phase error measure can be used in a phase-
tracking the carrier phase can be motivated by minimizing locked loop to iteratively adjust e so the baseband equal-
the mean-squared error A with respect to the parameters ized points are aligned in angle with the ideal constellation
of the phase sequence generated by the receiver's Carrier points. Changing e by some angle has the effect of rotat-
Recovery block. Suppose this sequence has the form ing the baseband equalized points by the negative of the
angle. In practice, cn- nd and a(nT) become close when
(14.41) the equalizer converges, so R" can be replaced by Re in
QAM Receiver II 145

o-(nT) _ _ _ _ _ ______ • Slicer _ _ _ _ _ _ ,


I

,
I
I
I

Ideal
~
---~

.
Reference
~-----

. . -----------------~ +
: E(nT)
"..,
.---"'-..........

n
I
I

~------------------~~~-4
L ________________ _
X __ • ~m(-) 1-----.. x

t
'Pn 'Pn+l
Z-l + kl
!J.()(n)

T
'ljJ(n)
k2

Z-l

'ljJ(n - 1)
Figure 14.4. Decision directed carrier tracking system.

(14.48). These observations suggest adjusting 0 according During initial startup, a known symbol sequence is often
to the formula transmitted, and the Ideal Reference generator in the re-
ceiver replicates these symbols. After the equalizer and
O(n+1) B(n) carrier tracking loop have converged, the outputs of the
Slicer are substituted for the known sequence and the sys-
+ k ~m{i(nT)a(nT)} (14.49)
tem operates in the decision directed mode. The phase
1 Icn - nd l2
estimate generated by the lower part of the block diagram
where kl is a small positive constant. A practical real- is
ization for a second-order carrier tracking loop based on
CPn+l CPn + WeT
this equation and including carrier frequency offset track-
ing is shown in Fig. 14.4. First, an approximation to
+ kl~B(n) + 1jJ(n) (14.51 )
the phase error is computed from the baseband equalizer where
output sample a(nT) by the formula
1jJ(n) = 1jJ(n - 1) + k2~e(n) ( 14.52)

~B(n) = ~m{~a(nT)} (14.50) Notice that weTis the nominal change in the carrier phase
ICn - nd 12 angle between symbols. When ~B(n) is zero for all n
146 Chapter 14

and the z-l delay elements are initially cleared, the phase section in this chapter for additional references.
generated is Godard's 2nd-order blind equalization algorithm is
(14.53) the one most commonly used in commercial modems.
Jablon [II.D.21] experimentally compared this 2nd-order
The philosophy behind the carrier tracking loop is to in-
CMA algorithm with the RCA algorithm and concluded
crement the phase angle predicted for the next symbol
that the CMA algorithm converges faster when carrier
instant, CPn + WeT by a small fraction, kl' of the current
phase and symbol timing are also being estimated. Only
phase error estimate /lB(n). In addition, a fraction, k2' of
Godard's algorithm will be presented in this chapter.
the phase error is accumulated to measure any bias caused
Godard's class of CMA algorithms operates directly
by a frequency offset, and added to the phase increment.
on the passband equalizer output a+(nT) shown in Figs.
The system is a second-order phase-locked loop, similar
13.1, 14.1, and 14.3. The equalizer taps are adjusted to
in behavior to the ones discussed in previous experiments.
minimize the dispersion of order p, which is defmed as
It will track a constant phase and frequency offset with
zero final error. The ratio kllk2 should be on the order of
(14.54)
100 for good transient response.
where p is a positive integer and Rp is a positive con-
stant, for which a formula will be given soon. Since the
14.4. Blind Equalization demodulated equalizer output is a(nT) = a+(nT)e-i<Pn,
In most cases, the adaptive equalizer in a QAM the dispersion can also be expressed as
receiver is initially trained during handshaking with a
known ideal reference sequence. There are times when (14.55)
ideal reference training is not possible or desirable. For
example, if a tributary modem in a multi-drop network Note that the dispersion is independent of the locally
goes offline because of a power failure or for repairs, it generated carrier phase. Therefore, the constellation can
would be desirable to bring the modem back online with- emerge rotated by any angle as the algorithm converges.
out having to retrain all the tributary modems on the net- The job of the carrier recovery loop is to rotate it to the
work. With a simple constellation like the four-phase V.22 correct angle. The carrier recovery loop is effectively
constellation, it is sometimes possible to achieve equal- a one-tap complex equalizer with the tap constrained to
ization using the decision directed mode. However, with have magnitude 1. An equalizer with a small number
16 or more constellation points, starting LMS adaptation of taps can adapt faster than one with many taps, so the
in the decision directed mode almost always fails with carrier recovery loop can converge much faster than the
typical channels. A variety of algorithms - called blind equalizer. The fact that the CMA algorithm does not have
equalization-have been discovered, which use only very to rotate the constellation to the correct angle may account
general knowledge of the transmitted constellation and not for the better performance Jablon observed for the CMA
the exact transmitted sequence. These algorithms coverge algorithm over the RCA algorithm.
much slower than the LMS algorithm with ideal reference
training and the final output constellation remains fuzzy,
14.4.1. Blind Equalization with the
but the underlying ideal constellation becomes clearly ap-
parent. After the constellation emerges with blind equal- Complex Cross-Coupled Equalizer
ization, the equalizer can be switched to LMS decision The equalizer taps can be adapted iteratively by tak-
directed training for fine equalization.
ing small steps in the direction opposite to the gradient
Blind equalization was first disclosed by Sato [II. of DP with respect to the taps. With some work, it can
D.30] in 1975 for the special case of one-dimensional be shown that in the case of the complex cross-coupled
multilevel PAM. Godard [II.D.l4] in 1980 was the first passband equalizer
to disclose and thoroughly analyze a class of blind equal-
ization algorithms for QAM. Treichler and Agee inde- 8DP 8DP
pendently developed a similar approach in the classified --+j--
8h R ,m 8h I ,m
world, and their work was published in the open litera-
ture in 1983 [II.D.34]. This method has become known -2pE { (Rp -la+(nT)IP)
as the constant modulus algorithm (CMA). Another ap-
proach is presented by Benveniste in [II.D.2] and is called x la+(nT)IP-2
a reduced constellation algorithm (RCA). It is a general-
x a+(nT) r(nT - mT/nl) } (14.56)
ization of Sato's method to two dimensions. See the last
QAM Receiver II 147

Godard shows that the value of Rp required to give to zero, except for the reference tap, at some position L
the correct constellation size is near the center of the delay line. This tap must satisfy the
inequality
(14.57)
( 14.62)
Remember that en is the baseband symbol sequence ran-
domly selected from the ideal constellation.
The statisical expectation in (14.56) is not known in 14.4.2. Blind Equalization with the
practice, but can be approximated by time averaging the Phase-Splitting Equalizer
product inside the expectation operator. This leads to the
following stochastic gradient algorithm for adapting the The CMA algorithm for the phase-splitting equalizer
equalizer taps: is almost identical to the one for the complex equalizer.
It can be shown that the gradient of the dispersion with
hm(n) + J.L (Rp -IO"+(nTW) respect to tap m for the phase-splitting equalizer is
x 10"+ (nT) IP - 2 0" + (nT) Ll (lDP 8VP
x r(nT-mT/nl) --+j--
8h R ,m 8h I ,m
for m = 0, ... , N - 1 ( 14.58) -2pE{(Rp - 100+(nTW)
where J.L is a small positive constant as in the LMS algo- x 10"+(nT)I P - 2
rithm. x 0"+ (nT) r(nT - mT/no)} (14.63)
Even after convergence, the term Rp - 100+(nT)IP
in the estimated gradient will fluctuate significantly, and This suggests the following stochastic gradient tap adjust-
the blind equalized constellation will be somewhat fuzzy. ment formula:
The constant J.L must be chosen significantly smaller for
the CMA algorithm than for the LMS algorithm. After the
hm(n) + J.L (Rp -IO"+(nTW)
equalizer converges with the blind equalization algorithm, x 10"+ (nT) Ip- 2 0"+(nT)
a switch to decision directed LMS training can be made x r(nT-mT/no)
to achieve precise equalization. for m = 0, ... , N - 1 (14.64)
The most commonly implemented algorithm is the p
= 2 case. Then, the tap update formula reduces to The value required for Rp is again specified by (14.57).
For p = 2, the tap update formula reduces to
hm(n) + IJ, (Rp - 10"+(nT)12)
x 0"+ (nT) r(nT - mT/nl) hm(n + 1) hm(n) + J.L (Rp - 10"+(nT)12)
for m=0, ... ,N-1 (14.59) x 0"+ (nT) r(nT - mT/no)
for m = 0, ... , N - 1 ( 14.65)
and the required value of R2 is
At the start of blind equalization, the real taps should
( 14.60) all be set to zero, except for the reference tap at position L.
The imaginary taps should be set to approximate a Hilbert
transform with the reference tap at position L. The scaling
The computational complexity for this adaptation algo-
should be adjusted to satisfy the convergence condition for
rithm is essentially the same as for the LMS algorithm. the complex equalizer.
In both cases, an error signal is multiplied by the complex
conjugate of the received signal sample at the tap being
adjusted. In this case the error signal is 14.5. Complex Cross-Coupled Equalizer
and Carrier Tracking
(14.61) Loop Experiments
Godard derives some convergence properties for the Now it is time to complete the QAM receiver you
CMA algorithms. Let g(O) be the channel impulse re- began in Chapter 13, by building an adaptive equalizer
sponse sample with the largest magnitude. Then for the and carrier tracking loop. You should implement these
p = 2 case, a sufficient but not necessary condition for functions in assembly language to maximize the compu-
convergence is that all the equalizer taps be initially set tational efficiency of your program, and be sure that all
148 Chapter 14

the required steps are completed during each T = 11600 This transfonnation rotates the ideal points to the near-
second symbol period. You will be directed through a est 45° line and scales them to the four points ±5 ±
step-by-step approach to completing the receiver. First, j5. Then the slicing operation amounts to detennining in
you will make a 4-point and, optionally, a 16-point slicer. which quadrant the transfonned point lies, and this can be
Then you will make the carrier tracking loop with the detennined by simply examining the sign bits of x~ and
equalizer bypassed. Once the carrier loop is operating, y'n" In your slicer function, also do the following tasks:
you will build a complex cross-coupled equalizer. Fi- 1. Fonn the unrotated baseband error lenT) = Cn -
nally, you will make the descrambler and check that all a(nT) where Cn is the unrotated ideal constellation point
l's are received when they are transmitted. Optionally, corresponding to the slicer decision.
you can implement the phase-splitting passband equalizer 2. Generate and store the differentially encoded data
after successfully completing the complex equalizer. You bits (YIn, Y2n).
can also experiment with blind equalization. 3. Differentially decode the data bits by using the
This is a long experiment involving the implementa- inverse of Table 12.1.
tion of a number of subsystems. It would be reasonable to Test your slicer by using EVM30 to single-step
team up with one or more other groups and work jointly on through your code with a made-up sequence of baseband
this experiment. You will have to decide how to partition input samples.
the tasks among the team members, make sure the pro-
grams fit together, and manage the progress of subgroups.
Making the 16-Point Slicer
These are things you will have to do as an engineer on a
product design and development team in industry. As an optional task, make a I6-point slicer for the
Continue to use the V.22bis transmitter you made for Y.22bis constellation. The slicer should quantize the base-
Chapter 12 as the signal source. Program the transmitter band equalizer output sample to the nearest ideal constel-
to initially send the S 1 alternating sequence described in lation point. The slicer program should contain a table
item 6 of Section 12.5.2 for 600 symbols (l second) to that has a record for each of the 16 constellation points.
allow the symbol clock recovery loop to lock up. Then Each record should include the coordinates of the ideal
continuously send scrambled I's using the 4-point V.22 point, the data bits (YIn, Y2 n , Q3 n , Q4 n ) associated with
constellation. Optionally, after sending 2400 (4 seconds) the point, and the quantity Iller. 12 for use in the carrier
4-point symbols, switch to sending scrambled 1's using tracking algorithm. In addition, the slicer should perfonn
the 16-point Y.22bis constellation shown in Fig. 12.3. the following tasks:

1. Fonn the baseband error.


14.5.1. Implementing the Slicer
2. Generate and store the differentially encoded bits
The Slicer outputs are required to generate the base- (YIn, Y2n).
band error sequence used by both the adaptive equalizer
and carrier tracking loop in the decision directed mode. 3. Differentially decode the data bits by using the in-
Therefore, the first logical step in completing the QAM verse of Table 12.1.
receiver is to implement the slicers.
Test your slicer by using EVM30 to single-step through
your code with a made-up sequence of baseband input
Making the 4-Point Slicer samples.
The V.22 constellation consists of the 4 points shown
in Fig. 12.3 with the coordinates (3, I), (-I, 3), (-3, -I), 14.5.2. Making a Demodulator and
and (1, -3). These points lie on a circle and are separated Carrier Tracking Loop
by 90°, but are rotated by an odd angle relative to the
axes. Make a 4-point slicer to quantize each baseband As the next step in building the QAM receiver,
equalizer output sample to the nearest ideal constellation implement the demodulator and carrier tracking system
point. To simplify the quantization operation, rotate the shown in Figures 13.1 and 14.4. Design your software to
received baseband samples a(nT) = Xn + jYn so that the include a I6-tap TI2 complex cross-coupled equalizer. To
ideal points lie on 45° lines. You can do this by using reduce the interaction between subsystems for debugging
the transfonnation purposes, effectively bypass the equalizer. To do this,
set up the necessary circular buffers to hold the complex
X~ +jy~ (Xn + j Yn)(2 + j) passband samples for the equalizer delay line coming from
(2x - y) + j(x + 2y) (14.66) the front end phase splitter, and create the arrays for the
QAM Receiver II 149

complex equalizer coefficients hQ, • •• , h 15 . Set all the tion display. In the rest of this experiment, use the initial
equalizer coefficients to 0 + jO, but make hs = 1 + jO. equalizer tap setting that gives the best results.
Implement the equalizer convolution sum with the taps Once the carrier tracking loop is basically working,
frozen at these values, so the equalizer input samples will experiment using different values of kl and k2 . When
simply be passed to its output with a delay. Always load kl is large, the constellation will appear to jitter, due to
samples from the phase splitter into the equalizer delay the large random perturbations. When kl is very small,
line, regardless of whether or not the Carrier Detect sys- convergence will be slow.
tem indicates the presence of a received modem signal.
The Godard clock recovery system implemented in Chap-
ter 13 should make the times at which its cross-correlator
14.5.3. Making a Complex Cross-Coupled
outputs are computed nearly optimum times at which to
sample the received symbols. The equalizer output should Adaptive Equalizer
be computed at these symbol spaced times.
Now implement the LMS with leakage equalizer tap
Monitor the Carrier Detect signal generated by the
adaptation algorithm defmed by (14.30). Keep the taps
receiver front end, and when a carrier is detected, begin
frozen at their initial values until the Carrier Detect count
incrementing a counter once per symbol period. Keep the
reaches 608 symbols, by making "y and J.t zero until this
2nd-order accumulator state variable 'ljJ(n - 1) stored in
time. Then tum on the update algorithm by setting J.t to a
the z-I block shown in Fig. 14.4 cleared until the count
small number like 0.001. The leakage constant "Y should
reaches 608. At this time, the SI sequence should be
be very small, so the approximate gradient updates sig-
finished and the equalizer delay line should be filled with
nificantly outweigh the tap reduction by the factor 1 -
received samples of the 4-point scrambled 1's signal. In
"Y. Observe the equalizer convergence on your constella-
this part of the experiment, the equalizer taps should be
tion display. If the equalizer and carrier tracking loop are
frozen at the initial values specified above, independent
working properly, the clouds caused by intersymbol inter-
of the Carrier Detect signal.
ference should converge to four tight points. Experiment
Write an assembly language program to implement
with several values of the update constant J.t and observe
the carrier tracking loop. Before a received modem signal
the convergence speed and tightness of the steady-state
is detected, let the carrier loop phase free run. That is, let
constellation.
kl = k2 = 'ljJ(n - 1) = 0 so that

(14.67)
14.5.4. Bit-Error Rate Test
To test your program, scale and convert the real and imag-
inary parts of the baseband equalized sample a(nT) into Once the equalizer and carrier tracking loop are
16-bit integers. Send this pair of integers to the PC once working, add the descrambler to your receiver. The de-
per symbol, using the methods described in Appendix A. scrambler output should be steady l' s. Send the descram-
Use the PC to generate a constellation display by making bier output to the DIA converter and look for a constant
an x-y plot of the pairs of received samples on the screen. level trace on the oscilloscope.
Erase points more than about 200 symbols old so the cur- Add Gaussian noise samples to the AID input sam-
rent constellation behavior can be observed. Always make ples using the method presented in Appendix B. Observe
a constellation display independent of the state of the Car- the dispersion of the constellation caused by the noise for
rier Detect signal. If everything is working properly, you different SNR.
should observe four distinct clouds of points separated by Experimentally, generate a plot of the bit-error rate
90° on the constellation display. versus SNR. Do this by waiting until the equalizer has
You were instructed above to make all the equalizer converged, and then counting the number of O's in the
taps zero except for hs. It is possible because of a sam- descrambled bit stream for a fixed duration at each SNR.
ple delay unaccounted for in your program that this is the Make sure the count duration is long enough to give a
wrong tap to pick as a time reference, and your constel- statistically reliable estimate of the bit-error rate.
lation display samples are being taken half way between Derive a theoretical formula for the symbol error
the correct sampling instants. In this case, you probably probability versus SNR and plot the results. Compare
will not observe four distinct clouds of points. In any this plot with your experimental bit-error rate plot. The
case, test for the best sampling time by setting h7 to 1 + general shape should be the same, but the curves will be
jO and all the rest of the taps to zero. This advances the different because one is for symbol errors and the other
sampling instants by T12. Observe the resulting constella- is for bit errors.
150 Chapter 14

14.5.5. Optional Experiment-Receiving izer for the V.22bis receiver. First strip the phase split-
the 16-Point V.22bis Constellation ter out of the receiver front end. Continue to use the
sampling rate!o = 61s = 3600 Hz. Then, the phase-
As an optional experiment, program the transmitter splitting equalizer must be a TI6 equalizer. The 16-tap
to send the S 1 sequence for 600 symbols, followed by the complex cross-coupled equalizer spans eight symbols. A
4-point constellation for scrambled l' s for 2400 symbols, TI6 phase-splitting equalizer must have 6 x 8 = 48 com-
followed by the 16-point constellation for scrambled 1's plex taps to span eight symbols. However, remember that
indefinitely. Use a counter as above to start the equalizer the complex equalizer must be preceded by a Hilbert trans-
and carrier tracking loop 608 symbols after carrier detec- form filter, which gives the cascade a longer memory span.
tion, using the 4-point slicer. After an additional 2400 In any case, make a 48 complex tap phase-splitting equal-
symbols, switch to the 16-point slicer. If your timing is izer. The carrier tracking loop and slicer do not have to
off by a few symbols, it should have a negligible effect be changed from the previous design.
when the carrier tracking loop and equalizer update con-
stants are small. The equalizer taps must be initially set to make it a
Perform a bit-error rate test for the 16-point constel- phase splitter when the decision directed startup mode is
lation and plot the results. Compare the plots for the 4 and used. Do this by initially setting all the real taps {h R, n} to
16-point constellations. Find in the literature, or derive, zero, except for one near the center of the delay line which
a theoretical formula for the symbol error rate and plot should be set to 1. Design a 47-tap Hilbert transform
the results. Compare the results for the 4 and 16-point filter using REMEZ87.EXE or WlNDOW.EXE, and set
constellations. the imaginary taps {hI, n} to these values. Align the center
tap of the Hilbert transform filter with the nonzero real
tap.
14.5.6. Optional Experiment-Ideal
Reference Training
The position you pick for the initial main tap (the one
You were directed to set the scrambler to the all 0 with real part equal to 1) may not give the optimum sam-
state at the start of scrambled l' s transmission. Therefore pling phase. There are 6 choices for the symbol spaced
the transmitted training sequence is known and ideal ref- sampling phase. Determine the optimum phase in a way
erence training can be performed. Make a replica of the similar to what you did for the TI2 complex equalizer.
scrambler and constellation point selector in the receiver. That is, freeze the equalizer taps at their initial values.
About 600 symbols after carrier detect, start generating Set the transmitter to send 600 symbols of S I followed
the ideal reference symbol sequence and use it to train by the 4-point constellation for scrambled I's indefinitely.
the equalizer and carrier loop. Initialize all the equalizer Observe the constellation display for each of the 6 phases
taps to zero for ideal reference training. Once the equal- when the 4-point constellation is transmitted. Choose the
izer is trained, halt the receiver and examine the equalizer phase that results in the tightest constellation.
tap magnitudes using EVM30. Adjust the time at which
you start the ideal reference training to center the largest Also experiment with ideal reference training. Set all
tap in the equalizer delay line. If your initial timing phase the equalizer taps to zero initially in this mode. The taps
is too far off, the main tap will want to be off one end should automatically adjust for any timing phase offset,
or the other of the delay line, and the equalizer will not and converge to a set of values that perform the equaliza-
converge. After the equalizer has converged, switch back tion and phase-splitting functions. After a period of time
to decision directed adaptation. when the equalizer has converged, switch to the decision
One of the virtues of a fractionally spaced equalizer directed mode.
is that it can adjust for any symbol timing phase off-
set. Start the ideal reference training TI2 seconds (half a You could also test your receiver with the 16-point
symbol period) later than before and observe the system constellation. As before, begin the training with the 4-
convergence. point constellation and then switch to the 16-point con-
stellation after the equalizer has converged.

14.6. Optional Experiment - Phase-Splitting


Perform a bit-error rate test for your receiver. Com-
Fractionally Spaced Equalizer
pare the tightness of the constellation and the bit-error rate
If you are interested in pursuing adaptive equalizers performance of your complex cross-coupled and phase-
further, build a phase-splitting fractionally spaced equal- splitting equalizers.
QAM Receiver II 151

14.7. Optional Experiment-Blind W. Lucky [II.D.25] at AT&T Bell Laboratories in the mid
Equalization 1960's. This approach is also discussed in Lucky, Salz,
and Weldon [II.D.26, Chapter 6] and is based on a zero
Use the V.22bis transmitter you made for Chapter 12 forcing criterion. These two references are primarily of
as the signal source for the blind equalization experiments historical interest, since the zero forcing approach was
of this subsection. You might want to pass the signal soon replaced by the more powerful LMS algorithm. For
through the commercial telephone channel simulator to detailed presentations of the complex cross-coupled LMS
introduce additional intersymbol interference by selecting algorithm for adaptive equalization, see Gitlin, Hayes, and
a bad line. Perform the following tasks: Weinstein [II.D.ll, Chapter 8], Haykin [II.D.18, Chapter
I. Program the transmitter to first send the S I al- 9], Lee and Messerschmitt [II.D.23, Chapter 9], Proakis
ternations for 600 symbols, to allo)V your symbol clock [II.D.29, Chapter 6], Treichler, Johnson, and Larimore
tracking loop to lock up. Then switch to sending scram- [II.D.35, Chapter 4], and Widrow and Steams [II.D.37,
bled I's using the 16-point constellation. Chapter 10].
2. Compute the required value for R2 using (14.60) The tap leakage algorithm is proposed and investi-
to make the equalized constellation have the correct scal- gated in Gitlin, Meadors, and Weinstein [II.D.l2]. Tre-
ing for your 16-point slicer. ichler, Johnson, and Larimore [II.D.35, Section 4.2.6.2]
3. Modify your complex cross-coupled equalizer to also analyze the behavior of the LMS algorithm with tap
use Godard's p = 2 tap update algorithm given by (14.59). leakage.
Initialize all the taps to zero, except for the reference tap The phase-splitting passband equalizer is not dis-
near the center of the delay line that you experimentally cussed in existing textbooks but Mueller and Werner
selected in the previous exercises. Set the reference tap [II.D.27] and Ling and Qureshi [II.D.24] are good ref-
to a value you think will satisfy (14.62). Note that if all erences for this topic.
the taps are set to zero, the equalizer output will be zero, Discussions of carrier recovery techniques for QAM
the tap update increments will all be zero, and adaptation systems can be found in Gitlin, Hayes, and Wein-
will not occur. stein [II.D.II, Section 6.4] and Lee and Messerschmitt
4. Wait for 608 symbols after carrier detect and [II.D.23, Chapter 14]. An addition to the carrier tracking
then begin CMA updating of the equalizer taps. Tum on loop presented in this experiment that allows tracking of
the carrier tracking loop at this time also. The 16-point sinusoidal phase jitter is discussed in Sugar and Tretter
constellation with the correct rotation should emerge. If [II.D.32].
the constellation display does not converge to the expected Blind equalization was first disclosed by Sato [II.
picture but to some different stable pattern, try adjusting D.30] for one-dimensional multilevel PAM. The next ma-
the initial value of the reference tap. You might want jor publication was by Godard [II.D.14], which presented
to wait to tum on the 2nd-order integrator in the carrier a thorough analysis of a class of blind equalization al-
loop for some time after adaptive equalization is started gorithms and carrier tracking for QAM receivers. Tre-
so random slicing errors do not drive its output far from ichler and Agee [II.D.34] independently discovered the
the correct value. If this happens the constellation will 2nd-order case of Godard's class of algorithms. Ben-
spin rapidly. veniste and Goursat [II.D.2] presented additional blind
5. Repeat the previous task with the carrier loop equalization algorithms. More recent papers on blind
free-running at the nominal carrier frequency. The con- equalization include Foschini [II.D.6] and Picchi and Prati
stellation should emerge but spin at the carrier offset fre- [II.D.28]. Books with discussions of blind equalization
quency. include Gitlin, Hayes,and Weinstein [II.D.ll], Haykin
6. Devise and implement a strategy for switching [II.D.18, Chapter 20], Proakis [II.D.29, Chapter 20], and
from CMA to LMS training and watch the received con- Treichler, Johnson, and Larimore [II.D.35, Chapter 6].
stellation converge to 16 tight points.
7. If you are interested in experimenting with blind
equalization further, implement it for the phase-splitting
fractionally spaced equalizer.

14.8. Additional References


The use of adaptive transversal equalizers in data
modems was first investigated and commercialized by R.
15

Echo Cancellation for


Full-Duplex Modems

An important relatively recent advance in the design .of there will be used as the signal source.
high speed voice-band telephone line modems for the ~Ial
network was the introduction of echo cancellers to achIeve
full-duplex data transmission over 2-wire circuits. .This 15.1. The Echo Sources in a Dialed
technique was studied in the early 1980's and then WIdely Telephone Line Circuit
introduced in commercial products in the mid 1980's,
A typical full-duplex dialed telephone line circuit is
when the CCITT V.32 recommendation for a 9600 bps
shown in Fig. 15.1. The Transmitter, Receiver, and Hy-
modem was approved. A few years later, the V.32bis rec-
brid boxes shown on the left are all contained in the left
ommendation for 14.4 kbps modems was approved, and
modem, and the ones on the right are in another modem.
the V.34 recommendation for rates up to 28.8 kbps was
The left transmitter sends to the right receiver while the
approved in June 1994. These also use echo cancellers.
right transmitter simultaneously sends to the left receiver.
Echo cancellers are also used in high-speed digital sub-
The transmissions in both directions are independent of
scriber lines at data rates of 64 kbps or more. They were
each other. Both modems are connected to ordinary 2-
used with analog voice transmission to eliminate annoying
talker echo prior to the inclusion in digital data modems.
wire voice-band telephone line circuits which go from the
modem site to the local office and are called 2-wire local
The voice echo cancellers are placed at different points in
loops.
the telephone circuit than the ones for data transmission,
and are disabled during data transmission by a special A modem transmits and receives over the same pair
signal in the modem handshake sequence. The technique of wires. The function of the Hybrid box is to isolate the
is also used in speaker phones to eliminate annoying re- transmit and received signals at the 4-wire to 2-wire in-
flections back to the far end talker. terfaces. An ideal hybrid routes the signal on the transmit
terminal pair on the 4-wire side only to the 2-wire loop,
In this experiment, you will learn the fundamentals and not to the receive pair on the 4-wire side. Similarly,
of echo cancellation for voice-band modems. You will the received signal on the 2-wire loop is routed only to
build an echo canceller for near-end echo and observe the receive terminal pair on the 4-wire side.
its behavior without a far end transmitted signal. You Signals are transmitted between offices within the
will also build a far-end canceller with frequency offset telephone plant using 4-wire circuits. One pair is used to
correction. Suggestions for additional references on echo transmit in one direction, and the other pair in the opposite
cancellation are included at the end of this chapter. direction. Again, hybrids are used at the 2-wire to 4-wire
You should do the experiment in Chapter 12 before interfaces. The 4-wire circuit can consist of combinations
this experiment, because the V.22bis transmitter you make of ground lines, fiber optic cables, microwave links, and

153
154 Chapter 15

satellite circuits. A large percentage of the transmissions is called the rotated symbol sequence. The echo canceller
between offices is in digital form. is basically an adaptive tapped delay-line filter with near
Real-world hybrids are not perfect. They are de- and far-end sections. It is driven by the rotated symbols
signed to work with a nominal impedance on the 2-wire and synthesizes a replica of the real passband echo. For
loop, and actual loops differ from the nominal. Therefore, these reasons, it is called a data-driven, in-band canceller.
some of the transmitted signal at a local modem leaks Since the synthesized echo is subtracted directly from
through the hybrid back to the local transmitter. This is the received signal, echo samples must be generated, and
known as near-end echo. When the impedance imbalance the received signal sampled at a rate that is at least twice
is large, the near-end echo power can be 30 dB above the the highest frequency component in the received signal,
power of the desired signal received from the transmitter so the Nyquist criterion is satisfied. The received signal
of the far-end modem. The impulse response of the near- is typically sampled at L times the symbol rate Is = liT, as
end echo path typically has a duration of from 5 to 18 indicated in the AID block in the figure. For example, the
ms. Another source of echo is leakage through the hybrid symbol rate for a V.32 modem is 2400 Hz with a carrier
at the far end of the 4-wire circuit and is called far-end frequency of 1800 Hz, and uses 12% excess bandwidth
echo. The far-end echo is delayed by the propagation square-root of raised cosine shaping, so the upper cutoff
time through the echo path. This delay can range from frequency is 3144 Hz. The smallest choice for L that sat-
a few milliseconds, up to as much as 1.5 seconds, when isfies the Nyqist criterion is L = 3 resulting in a sampling
the transmission path contains a couple of satellite hops. rate of 7200 Hz and is the most efficient choice in terms
The duration of the impulse response of the far-end echo of minimizing the required number of computations per
path, ignoring the bulk delay, is typically no more than second.
20 ms. The level of the far-end echo is typically at least The canceller also includes a far-end frequency offset
15 dB below that of the near-end echo. In addition, there correction phase-locked loop. Without frequency offset
can be frequency offsets on the far-end echo when carrier correction, the received constellation appears to pulsate
circuits are in the path. Additional echos can circulate at the offset frequency and the error rate performance is
around the 4-wire circuit but are usually attenuated to the severely degraded.
point of being negligible. The synthesized echo samples are subtracted from
Techniques used for eliminating the echos depend the received signal samples to give what is called the
on whether the modems are low or high speed. The residual signal sequence. The remaining echo component
voice-band circuit has a useable bandwidth extending in the residual is typically required to be at least 30 dB be-
from about 300 to 3200 Hz. Low-speed modems like low the received data signal component for adequate error
the V.22bis separate the transmit and receive paths by rate performance. The echo canceller and received signal
frequency division multiplexing and bandpass filtering. sampling instants are synchronized to the transmitter sym-
Higher speed modems like the V.32 use a symbol rate of bol timing. The signal received from the far-end modem
2400 Hz or more, so the signal spectrum fills most of the has the same nominal symbol rate. However, it will have
available bandwidth and frequency division mUltiplexing a slightly different frequency because of minor hardware
cannot be used. The near and far-end modems use the differences. Therefore, the residual sampling instants are
same carrier frequency, so the transmitted and received not synchronized with the desired receiver symbol tim-
spectra completely overlap. Echo cancellation was cho- ing. This problem is solved by the Receiver Interpolator
sen as the solution to this problem. block, which generates output samples synchronized with
the receiver timing. The interpolator can be implemented
by converting the residual samples back to a continuous-
15.2. The Data-Driven, Nyquist,
time signal and resampling the analog lowpass reconstruc-
In-Band Echo Canceller
tion filter output at times synchronized with the receiver
timing. Recently, modem analog front end chips that per-
15.2.1. General Description form the interpolation using numerical DSP techniques
The architecture for a practical echo canceller is have become commercially available. These chips also
shown in Fig. 15.2. The transmitter uses the passband include the AID and DIA converters, the analog lowpass
shaping filter approach presented in Section 12.3 and transmit and bandpass receive filters, and clock genera-
shown in Fig. 12.6. As in Chapter 12, Cn = an + jb n tion circuits. The interpolated residual sequence is sent
is the sequence of constellation points selected by the in- to the receiver which has the same structure as described
put data and in Chapters 13 and 14.
The echo canceller problem is simpler than the equal-
(15.1) izer problem in one way. The modem's transmitter and
Echo Cancellation for Full-Duplex Modems 155

4-Wire

r
Carner C ·t
IrcUl
Transmitter Transmitter

~ 2-Wire
Loop
2-Wire
Loop
Hybrid Hybrid Hybrid Hybrid

Receiver 4- ~ Receiver

Figure 15.1. Typical full-duplex dialed telephone line connection without echo cancellation.

receiver are located in the same box, and may even be im- subcanceller are denoted by
plemented .as subroutines in the same DSP. Therefore, the
local receiver has exact knowledge of the locally transmit- O!R,m(n) +jO!I,m(n)
ted symbol sequence and the exact error signal, the resid- for n = 0, ... ,Nl - I
ual, is formed. The adaptive equalizer must use decision and m = 0, ... , L - 1 (15.2)
directed adaptation algorithms after the initial handshak-
ing sequence. The canceller problem, is more difficult The subcancellers all use the same delay-line, which
in another way. In the equalizer problem, the received stores the present and Nl - I past rotated symbols. After
signal to noise ratio is usually rather high. In the echo each new rotated symbol c~ arrives, the L subcanceller
canceller problem, it is usually low because the desired outputs are computed as
received signal from the far-end modem can be at a signif-
icant level relative to the echos that need to be cancelled.
Therefore, a large amount of averaging must be performed PR (nT + mT/ L)
in the adaptation algorithm to suppress the far end sig-
nal which looks like noise to the canceller. When both Nl-l

modems are transmitting simultaneously, they are said to L O!R,m(k)a~._k


be double talking. In practice, the local and remote echo k=O
cancellers are usually separately trained in the half-duplex O!I,m(k)b~_k
mode during an initial handshake sequence. The data sig- for m = 0, ... , L - 1(15.3)
nals transmitted in both directions are statistically inde-
pendent. Different scramblers are used in the near and far The residual for the mth subcanceller is
end modems to ensure this independence. This allows the
echo impulse response to be tracked during double talking p(nT + mT/L) v(nT+mT/L)
with enough averaging. PR(nT + mT/ L)
qR(nT + mT/ L) (15.4)
15.2.2. The Near-End Echo Canceller
where qR(nT+ mTIL) is the far-end echo canceller output.
The inputs to the near-end echo canceller are the ro- As with adaptive equalizers, choosing the subcanceller
tated symbols c~, which occur at the symbol rate Is = coefficients to minimize the L mean-squared residuals has
liT. The canceller must generate outputs at a rate Lis that been found to be a good strategy. The derivatives of the
satisfies the Nyquist criterion for sampling the received mth residual with respect to the ith real and imaginary tap
signal v(t). The canceller can be implemented by gen- components are
eralizing the interpolation filter bank structure discussed
in Section ll.3. The canceller requires L FIR subfilters, () 2
() (") p (nT + mT / L)
each of which is called a subcanceller. Suppose each sub- O!R,m Z
canceller has Nl complex taps and the taps for the mth = -2p(nT + mT/L)a~_i (15.5)
156 Chapter 15

c'n
Passband T/L
x m()t--~
-- ~---~ Shaping Filter ----~ 3le . D/A

I
~--------------- ,
~
Bulk Lowpass
Delay Filter

I r----------~x I
s(t)
Frequency I
'II' 'II'
r-~-...,
2-Wire
Offset PLL Far End Near End Loop
f4-----r"--~ Hybrid i+---+-
~
I
Canceller Canceller
I
I I I

L_ ~m(.)f4---- ~q(nT/L) : p(nT/L)


~ ~

~e(·) ~e(·)
Bandpass
Filter
....q_R_(n_T_/L_)--+J_ _-*&R(nT/ L)

v(t)
Receiver
~---~---~+
+ TIL
Interpolator AID
To Receiver '--_ _ _ _..... p(nT/L)
Residual

Figure 15.2. A data-driven, nyquist, in-band, echo canceller.

and + J-Lp(nT + mT/ L) a~_i


{) 2 for i=0, ... ,Nl -1(15.7)
{)
D!J,m
(") P (nT
2
+ mT/ L)
= 2p(nT + mT/L)b~_i (15.6) D!J,m(i;n+1) D!J,m(i;n)
Therefore, using the LMS strategy presented in Chapter - J-Lp( nT + mT/ L) b~_i
14, the coefficients' of the mth subcanceller can be ad- for i = 0, ... ,Nl -1(15.8)
justed by the following fonnulas:
where J-L is a small positive constant. These fonnulas
D!R,m(i;n+1) = D!R,m(i,n)+ can be expressed in tenns of the complex coefficients and
Echo Cancellation for Full-Duplex Modems 157

rotated data symbols by the single equation Note that this reduces to the standard LMS algorithm for
M = 1. With the BLMS algorithm, the taps are adjusted
Am(i; n + 1) Am(i; n) every M samples. The stability and convergence rate for-
+ p,p(nT + mT/ L) c'n_i mulas are the same as for the LMS algorithm.
for i = 0, ... ,N1 - 1 (15.9) It is very likely that, with current DSP technology,
all the echo canceller taps cannot be updated during one
Some simple stability and rate of convergence for- symbol period, especially when the DSP is performing
mulas can be derived for this LMS algorithm. Suppose other transmitter and receiver tasks in addition. A stan-
the constellation points are selected with equal likelihood, dard solution to this problem is to update just a portion
are an uncorrelated sequence, and are located so that of the taps each symbol period.

(15.10)
15.2.3. The Far-End Echo
Then, it can be shown [II.D.36] that this LMS adaptation Canceller
algorithm is stable if the update scale factor p, satisfies
the bounds The impulse response of the echo path usually con-
sists of an initial period of activity caused by the near-end
(15.11)
echo, followed by a period of silence, followed by a period
The scale factor that gives the most rapid convergence of of activity caused by the far-end echo. No echo canceller
the mean-squared error is filter taps are required to model the silent period caused
by the round-trip propagation time of the far-end echo.
1 It is only necessary to include a bulk delay to model the
(15.12)
p,o = 2N1a 2 round-trip delay. A portion of the handshake sequence is
used to measure the round-trip delay in V.32, V.32bis, and
Let ~(nT + mTIL) be the portion of the received signal V.34 modems. The far-end echo may have a frequency
v(nT + mTIL) exclusive of the echos. It includes the re- offset in addition to the delay. The frequency offset is
ceived far-end data signal and channel noise. Then, the corrected by multiplying the output of the Bulk Delay by
steady-state mean-squared residual value, assuming the eJf3n. The details of the offset correction are presented
far-end echo is not present, is in the following subsection. The structure of the far-end

iL L-1 echo canceller FIR filter is exactly the same as for the
E{e(nT + mT/L)} near-end canceller, except that it will have more taps be-
m=O cause the far-end echo is usually dispersed more than the
Roo = --~~----~~------ (15.13)
1 - p,N1a 2 near-end echo.
Suppose the measured bulk delay is do symbols.
This equation shows that as p, is reduced to zero, the Then, the input to the far-end echo canceller is
steady-state residual power reduces to the power of the
interference signal. When p, is chosen to give the fastest c"n = c'n-~ ej f3n = a"n + J. bl!n (15.15)
speed of convergence, the steady-state residual power is
double that of the interference signal. Let the taps for the mth far-end echo subcanceller be
During double talking, p, must be made very small to
average out the effects of the interference from the far-end Gm(n) = rR,m(n) + j rI,m(n)
data signal. This can result in an underflow problem and for n = 0, ... , N2 - 1
cause the adaptation to stop, particularly with fixed point and m = O, ... ,L -1 (15.16)
DSP's. A solution to this problem is to sum several past
products to form the gradient estimate and is called the Then, the mth subcanceller output is
block least mean-square (BLMS) algorithm. The formula
for adjusting the ith complex tap of the mth subfilter using qR(nT + mT/L) = ~e{q(nT+mT/L)}
a block depth of M is

Am(i;n+M) = Am(i;n)
lie {~' Gm(k)<'.:_k}
M-1

L
N2- 1
+ P,
k=O
p(nT+kT+mT/L) L bR,m(k)a~_k
k=O
-,--
x Cn +k _ i (15.14) rI,m(k)b~_kl (15.17)
158 Chapter 15

Using the same approach as for the near-end canceller, Let


the LMS tap adjustment formula for the mth subcanceler
L-1
is found to be
-L p(nT + mT/L)
Gm(i; n) + pp(nT + mT/L) c'Li m=O
x ~m{q(nT + mT/ L)} (15.23)
for i=O, ... ,N2-1 (15.18)
Then, a second-order phase-locked loop update formula
for the far-end echo phase correction angle suggested by
15.2.4. Far-End Frequency Offset
these results is
Compensation
(15.24)
In experiments with actual telepone circuits, it has
been found that it is important to compensate for the far- where the second-order accumulator output is
end echo frequency offset to achieve satisfactory modem
performance. As a first approximation, suppose this effect (15.25)
can be removed by letting
and k3 and k4 are small positive constants with k31k4 ::::;
e
f3n = + wonT (15.19) 100. The structure for this PLL is essentially the same as
the lower part of the QAM carrier tracking loop shown
Then, the complex output of the mth far end echo sub- in Fig. 14.4 with weT = O.
canceller is In order to save computation time, the phase update
N2- 1 can be performed once per symbol period using the resid-
q(nT + mT/ L) LGm(k)C~_do_k ual from
residual
just one subcanceller. For example, suppose the
for subcanceller m = 0 is used. Then, the only
k=O
x ej[(l+wo(n-k)T] change required in the formulas is to replace 6. n by
ej(B+wonT)
6. n = -p(nT)~m{q(nT)} (15.26)

L
N2-1
x Gm(k)e-jwokT
k=O
I
X cn-do-k (15.20)
15.3. Echo Canceller Experiments
The derivative of the squared residual with respect to e is You will be asked to make a near-end echo canceller
a
a()p2(nT + mT/L) = -2p(nT + mT/L)
and a far-end echo canceller with frequency offset correc-
tion in these experiments. No interfering data signal from
a a far-end modem will be included. All programs except
x ae'Re{q(nT + mT/ L)} for possibly the initialization routines should be written
-2p(nT+mT/L) in assembly language, to make sure all the required com-
putations can be performed in real time.
x 'Re{ :eq(nT+mT/L)}

-2p(nT+mT/L) 15.3.1. Making a Near-End Echo


x 'Re{j q(nT+mT/ L)} Canceller
2p(nT + mT/L) Use the V.22bis transmitter you made in Chapter 12
x ~m{q(nT + mT/L)} (15.21) as a starting point for your near-end echo canceller pro-
gram. Connect the DIA output to the AID input to simu-
where late the near-end echo. Your transmitter uses a passband
shaping filter with an impulse response that spans 6 sym-
~m{q(nT + mT/L)} bols. Therefore, your near-end echo canceller will have
N2-1 to span at least 6 symbols, which is equivalent to 10 ms
L 'YI,m(k)a~_k at 600 baud.
k=O Use a 3600-Hz sampling rate for the echo canceller.
+ 'YR,m(k)b~_k (15.22) This requires using L = 3600/600 = 6 samples per symbol
Echo Cancellation for Full-Duplex Modems 159

or 6 subcancellers. The transmitter for Chapter 12 uses a shaping filter by e1 27r f dnTO before sending its real part to
7200-Hz D/A sampling rate corresponding to 12 samples the DIA converter. The parameter To is the filter bank
per symbol. You can achieve a 3600-Hz sampling rate for sampling period and /d is the frequency offset. Choose a
the receiver in several ways. You can set the AIC in the frequency offset of/d = 0.5 Hz. For simulation purposes,
synchronous mode and make the AID and DIA sampling assume the far-end propagation time is zero and ignore
rates both 7200 Hz, and then discard every other received the Bulk Delay block. Add the frequency correction func-
AID sample. Another alternative is to set the AIC to the tions to your near-end echo canceller and pretend it is a
asynchronous mode and set the D/A sampling rate to 7200 far-end canceller. Do not implement a near-end canceller
Hz and the AID rate to 3600 Hz. Still another alternative also. Update the far-end frequency offset tracking loop
is to redesign the transmitter passband shaping filter bank only once per symbol when processing subcanceller m =
to generate 6 samples per symbol rather than 12. This o using (15.24), (15.25), and (15.26).
is the most efficient option in terms of reducing the total
Send the residual to the PC and display it on the
number of computations required per symbol.
PC screen. Experiment with the system parameters and
You will have to figure out a strategy for interleaving observe the residual behavior. When you have found a
the transmitter and echo canceller subfilter computations good set of parameters, measure the input and residual
each symbol. Consider using the interrupts for transmitted powers and compute the ratio in dB.
samples somehow to generate the required timing.
Implement the echo canceller with 6 subcancellers
using (15.7) and (15.8) to update the taps. Pass the resid- 15.4. Additional References
ual signal to the PC and plot it on the PC screen. Ex-
periment with different values of the update scale fac- Werner [II.D.36] gives a very good presentation of
tor J.L and observe the convergence rates and steady-state echo cancellers for digital data modems. This work had
residual variations. Measure the power of the received a significant influence on the round trip delay estimation
sequence before the echo canceller subtraction node and method chosen for the V.32 recommendation. Also see
the power of the residual, and calculate the ratio of the Gitlin, Hayes, and Weinstein [II.D.11, Chapter 9], and
input to residual power in dB. Lee and Messerschmitt [II.D.23, Chapter 18] for compre-
hensive theoretical treatments and alternative structures
for echo cancellers.
15.3.2. Making a Far-End Echo Canceller
with Frequency Offset Correction

Simulate a frequency offset far-end echo by mul-


tiplying the complex output of the transmitter passband
16

Suggestions for Additional


Experiments

It would take a long time (perhaps a couple of years) 16.2. Fast Equalizer Training
to complete all the experiments in this book. However, Using Periodic Sequences
in light of the recent trend in engineering education to
require capstone design projects, several additional topics Equalizer training using the LMS algorithm with an
for experiments related to current data modem techniques ideal reference sequence takes a significant amount of
are described very briefly below. References to get you time. The training time can be reduced very significantly
started on each project are included. by transmitting a sequence with a period equal to the
equalizer duration in symbols, and using FFT methods to
compute the optimum equalizer coefficients. The train-
ing signal probes the channel with a bank of sinusoids,
whose frequencies are multiples of the repetition rate of
16.1. Elementary Modem Handshake the sequence. The equalizer is switched to the LMS de-
Sequence cision directed mode after the initial fast training. This
fast training method has been included in a modem stan-
As an introduction to modem handshake procedures, dard for the first time in the V.34 recommendation. A
implement the V.22bis transmitter and receiver handshake clear and detailed explanation of the method is presented
sequences. Build the transmitter in one station and the by Chevillat, Maiwald, and Ungerboeck in [II.D.5]. As a
receiver in another. See the CCITT V.22bis recommen- project, you could incorporate this fast train technique into
dation [1I.D.4] for a detailed specification of these se- the modem transmitter and receiver you built in Chapters
quences. You will have to figure out methods for detect- 12-14.
ing critical points in the sequences.
After you have the V22.bis transmitter and receiver
working in separate DSP's, integrate the two into a single 16.3. Trellis Coded Modulation
DSP. The challenge will be to figure out how to time-
share the DSP between the transmitter and receiver pro- Ungerboeck [1I.E.7] made a major breakthrough in
grams. Remember that the transmitter and receiver in a coding for narrow-band channels in the late 1970's, now
single modem must operate independently in a full duplex called trellis coded modulation. It has been included in
fashion, so assume that the transmit and receive symbol every V series modem recommendation since its discov-
clocks will be different in phase, and slightly different in ery. The method involves doubling the normal number of
frequency. After completing this project, you will have points in the constellation, using a convolutional code in
built almost a complete V.22bis modem. the transmitter to select constellation points, and perform-

161
162 Chapter 16

ing soft-decision Viterbi decoding in the receiver. Perfor- equal likelihood. With shell mapping, the points in
mance gains of 4-5 dB are readily achieved. See Unger- the two-dimensional constellation nearest the origin are
boeck [1I.E.8] for a more recent and tutorial version of his more likely than the outer points. The two-dimensional
original paper. The book by Biglieri, et at., [1I.E.l] gives points approximately have a circular Gaussian distribu-
a detailed presentation of trellis coding. Other references tion. See the lTU V.34 Draft Recommendation of June
to trellis coding and soft decision Viterbi decoding can 1994 [11.0.20] for a cookbook formula for shell mapping.
be found in Lee and Messerschmitt [11.0.23, Section 7.4 An explanation of the theory can be found in Laroia, Far-
and Chapter 12], Gitlin, Hayes, and Weinstein [11.0.11, vardin, and Tretter [1I.EA][II.E.5].
Sections 3.5 and 5.7], and Proakis [11.0.29, Sections 5.3.2 As a project, you could implement the Y.34 shell
and 504]. mapping algorithm and its inverse. You should weigh
As a project, you could implement the V.32 trel- using pre-computed tables against on-the-fly computation
lis code and a soft decision Viterbi decoder. See the to achieve the required processing speed. This trade-off
CCITT V.32 recommendation [11.004], Lee and Messer- between memory and computation often arises in DSP
schmitt [11.0.23, p. 517], or Proakis [11.0.29, p. 504] for applications.
complete details on the V.32 encoder. This encoder was
invented by Lee-Fang Wei [1I.E.9] at AT&T Bell Labora-
tories. To avoid processing time problems in the receiver, 16.5. Nonlinear Precoding
you could implement the system using the V.22 symbol for V.34
rate of 600 baud. This would also allow you to use most The V.34 modem can use a noise whitening filter
of the programs you have previously generated. in the receiver to improve the Viterbi decoder perfor-
If you are interested in pursuing trellis coding further,
mance. The intersymbol interference introduced by the
implement one or more of the V.34 4-dimensionaI16, 32, noise whitening filter is compensated for at the transmitter
or 64 state codes. See Wei [1I.E.I0] for a discussion of by a nonlinear precoding technique. Nonlinear precoding
multidimensional trellis codes. was first suggested by Tomlinson [11.0.33] and Harashima
[11.0.16]. The method was generalized to QAM systems
and improved by Laroia [11.0.22], and quickly further im-
16.4. V.34 Constellation Shaping
proved by Laroia and Betts of AT&T and, independently,
by Shell Mapping
by Cole of General DataComm during development of the
Additional performance can be gained by shaping V.34 recommendation. The result was presented at a TIA
the constellation to minimize the average signal power, meeting in July 1993 [11.0.15]. The fmal version of the
while maintaining the minimum distance between points. nonlinear precoder can be found in the V.34 Recommen-
For example, in two dimensions a circle with the same dation of June 1994 [11.0.20].
area as a square has less average power. In N dimen- As a project, implement the V.34 shell mapper, pre-
sions, a sphere has less average power than any other coder, and 4D 16-state trellis encoder in the transmitter.
figure with the same volume. The new V.34 recom- Implement the inverses in your receiver. Transmit the
mendation specifies a 16-dimensional shaping technique signal through the TAS channel simulator with additive
called shell mapping, that closely approximates the gains noise, and compare the bit-error rate performance of the
of ideal spherical shaping. In previous V series modems, system with and without precoding. Also compare the
the two-dimensional constellation points are used with performance with and without shell mapping;
Appendix A. Communicating
between the PC and EVM

This appendix describes how to transfer data between the transfer data between the PC and EVM. The source code
PC and EVM and vice versa, so that each can perform the is available in this directory and is also listed at the end
tasks it does best. For example, the analog interface chip of [1.A.5].
(AIC) on the EVM does AID and DIA conversion and
the TMS320C30 does high-speed floating point computa-
tions. On the other hand, the PC can store large amounts A.1. Overview of the PCIEVM
of data on disk and display data graphically on its screen. Interface
An overview of the PCIEVM hardware interface is pre-
A block diagram of the EVM is shown in Fig. 1.2.
sented, a command passing protocol is described, and us-
The EVM card fits in an 8 bit PCIAT computer slot. The
ing the TMS320C30 DMA for data transfers is discuss~d.
PC communicates with the EVM by inputting or out-
The information about the EVM presented below was dis-
putting 8 or 16 bit words to locations in the PC's 110
tilled from the TMS320C30 Evaluation Module Technical
space. The 16 bit transfers are performed by inputting or
Reference [I.AA] and Digital Signal Processing Applica-
outputting pairs of bytes which are stored in registers on
tions with the TMS320C30 Evaluation Module [I.A.5].
the EVM. The Borland C functions inp 0 and outp 0
You are asked to make an elementary oscilloscope in
can be used for the 8 bit transfers, and inport () and
the experiment at the end of this appendix to learn how
outport () for the 16 bit transfers. A list of 110 loca-
to transfer blocks of data from the TMS320C30 to the
tions is shown in Table A.I, and the entries are described
PC. This appendix and experiment were included primar-
more fully below. A set of C macros for the PC to access
ily for documentation purposes, since the main goal of
the EVM contol points is given in the following program
the course is to explore the digital signal processing and
segment, which was taken from the program PC_I.H on
communication system concepts learned in regular related
page 81 of[I.A.5]. Additional locations not listed are used
courses. So that you do not have to waste time on sec-
to communicate with the Test Bus Controller (TBC). The
ondary tasks, a complete set of working programs for the
TBC is used by the Debugger to load programs and to
PC and TMS320C30 that accomplishes this experiment is
monitor the TMS320C30.
included in the subdirectory C:\UTIL.DSP\SCOPE that
you can use when required to perform data transfers in
the previous experiments. The file README.TXT in A.I.t. The Data Transfer Register
this subdirectory explains the purpose of each file.
The data acquisition program OSC_* in the C: \ A 16-bit bidirectional register in the block labelled
APPS.DSP directory presents another example of how to "C30 host port" is used in transferring 8 or 16-bit words

163
164 Appendix A

Program A.I. Macros for the PC to Access the EVM Registers

#define NONE OxOO 1* Byte to signal withdrawal of command

1*-----------------------------------------------------------------------*1
1* PC I/O Addresses for EVM Control Registers *1
1*-----------------------------------------------------------------------*1
#define iobase Ox0240 1* Default base address for EVM registers *1
#define CONTROL5 iobase + OxOOOA 1* Control register *1
#define STATUSO iobase + Ox0400 1* STATUSO register *1
#define COM_CMD iobase + Ox0800 1* Command register *1
#define COM_DATA iobase + Ox0808 1* Data transfer register *1
#define SOFT_RESET iobase+ Ox0818 1* Reset EVM and TMS320C30 *1
#define MINOR_CMD iobase + OxOO14 1* Minor command register *1
1*-----------------------------------------------------------------------*1
1* Bit Masks for Read and Write Acknowledge bits in STATUSO Register *1
1*-----------------------------------------------------------------------*1
#define MREAD_ACK Ox0002
#define MWRITE_ACK Ox0004
#define UPDATE_REQ Ox6044

1*-----------------------------------------------------------------------*1
1* I/O Macros *1
1*-----------------------------------------------------------------------*1
#define WRITE_CMD(x) outp(COM_CMD,x) 1* Write byte to trans. reg *1
#define READ_CMD inp(COM_CMD) 1* Read byte from transfer reg*1
#define WRITE_DATA (x) outport (COM_DATA, x) 1* Write 16-bit word *1
#define READ_DATA inport(COM_DATA) 1* Read 16-bit word *1
#define RESET_EVM outport(SOFT_RESET,O) 1* Reset EVM *1
#define RESET_C30 outport(CONTROL5,Ox808) 1* Put C30 in reset *1
#define RUN_C30 outport(CONTROL5,Ox800) 1* Pull C30 out of reset*1
#define READ_STATUSO inport(STATUSO) 1* Read status word *1
#define WRITE_MINOR_CMD(x) outport(MINOR_CMD,x) 1* Control status word *1

1*-----------------------------------------------------------------------*1
1* Checks for Read/Write Acknowledgement by TMS320C30 *1
1*-----------------------------------------------------------------------*1
#define IS_READ_ACK (READ_STATUSO & MREAD_ACK)
#define IS_WRITE_ACK (READ_STATUSO & MWRITE_ACK)

1*-----------------------------------------------------------------------*1
1* Manipulate Status Bits *1
1*-----------------------------------------------------------------------*1
#define CLR_READ_ACK WRITE_MINOR_CMD(MREAD_ACK)
#define CLR_WRITE_ACK WRITE_MINOR_CMD(MWRITE_ACK)
#define UPDATE_STATUSO WRITE_MINOR_CMD(UPDATE_REQ)
Communicating between the PC and EVM 165

Table A. I. PCIEVM Interface Memory Map

Name PC 110 Base offset TMS320C30 mapping PC access


CONTROL5 OxOOA None 16-bit write
MlNOR_CMD OxOl4 None 16-bit read/write
STATUSO Ox400 None 16-bit read/write
COM_CMD Ox800 Ox804000 - Ox805FFF 8-bit read/write
COM-.DATA Ox808 Ox804000 - Ox805FFF 16-bit read/write
SOFT-RESET Ox818 None Control point write
Note: The default base address is Ox240.

to or from the PC. The 8-bit words are stored in the reg- Notice that 8-bit PC reads ofCOM_CMD do not gen-
ister's least significant byte. This transfer register is at- erate interrupts. This will be important in the command
tached to the 16 Isb's, XD15-XDO, ofthe TMS320C30's processing protocol that will be presented shortly.
32-bit expansion bus. The TMS320C30 always reads 32-
bit words, so the upper 16 bits, XD31-XD16, are garbage
and should be ignored. The PC and TMS320C30 have
one-way communications through the data transfer reg- A.1.3. Flags that Indicate to the PC
ister. That is, the TMS320C30 can read only what the when the TMS320C30
PC wrote and vice versa. Neither can read what it wrote.
has Read or Written
The TMS320C30 can use any ofthe addresses in the range
the Transfer Register
Ox804000-0x805FFF to read and write the data transfer
register.
The TMS320C30 transfers data to the PC by writing The TMS320C30 can determine how the PC has ac-
words to the data transfer register through its Expansion cessed the transfer register by processing the interrupts
Bus. Again, only the 16 Isb's of the TMS320C30 word described in Table A.2. How does the PC know when
get written into the transfer register. 32-bit reads and the TMS320C30 has written to or read from the transfer
writes must be accomplished by transferring pairs of 16- register? The answer is that transfer register accesses by
bit words. the TMS320C30 set flag bits in STATUSO, which can be
tested by the PC. The TMS320C30 accesses cause the
Using the TI conventions, the host PC transfers 8-
following results:
bit data words by inputting or outputting to the 110 port
named COM_CMD. The host transfers a 16-bit word by I. When the TMS320C30 writes to the transfer reg-
inputting or outputting the lower byte to the 110 port ister, bit I of STATUSO gets set to I. This is called the
COM-.DATA, and the upper byte to port COM-.DATA + MREAD..ACK flag from the PC's point of view, because
1. each PC read is typically followed by a TMS320C30
The 8-bit transfers are designed to send commands write, until an entire data block is transferred.
to the program running in the TMS320C30 on the EVM. 2. When the TMS320C30 reads from the transfer
Therefore, the name COM_CMD was used to suggest that register, bit 2 of STATUSO gets set to I. This is called the
this is a command port. These commands are called major MWRITE..ACK flag from the PC's point of view, because
commands in the TI literature. The protocol for process- each PC write is typically followed by a TMS320C30
ing commands will be described shortly. read.
Once set, the flag bits remain set until they are manu-
ally reset by the PC. The PC resets the MREAD..ACK flag
A.1.2. EVM Interrupts to by writing Ox0002 to MlNOR_CMD and the MWRITE_-
the TMS320C30 ACK flag by writing Ox0004 to MlNOR_CMD. One ad-
ditional step must be performed by the PC to actually
Data transfers between the PC and TMS320C30 can put the current status in the STATUSO register. The PC
be synchronized by interrupts to the DSP generated by must write Ox6044 to MlNOlLCMD to update the status
the EVM. The three interrupts shown in Table A.2 are each time before it reads STATUSO. These actions are
generated. summarized in Table A.3.
166 Appendix A

Table A.2. Interrupts to the TMS320C30 Generated by the EVM

Cause TMS320C30 interrupt


8-bit PC write to COM_CMD INTO
16-bit PC write to COM--DATA INTI
16-bit PC read from COM--DATA INT2

A.1.4. Resetting the EVM acknowledge to the PC that it received the new command.
The reason that 0 cannot be used for a command is that it
Any write to SOFLRESET restarts the TBC and is the code the TMS320C30 uses to tell the PC it is ready
places the TMS320C30 in a reset state. Writing Ox800 for the next command.
to CONTROL5 pulls the TMS320C30 out of reset. Also,
the TMS320C30 can be placed in reset without restarting 4. When it receives the acknowledgement that the
the TBC, by writing Ox808 to CONTROL5. TMS320C30 received the new command, the PC removes
its command request by writing 0 to COM_CMD.

5. After completing its command, the TMS320C30


A.2. A Command Passing Protocol waits for the PC to withdraw its command request by
A strategy for passing commands from the host PC waiting for the transfer register to be cleared by the PC.
to the TMS320C30 will be described in this section. In This is necessary so that the TMS320C30 does not repeat
this approach, all commands are initiated by the PC and the same command.
the TMS320C30 must execute them. The PC is called
6. After the TMS320C30 sees that the PC has with-
the master and the TMS320C30 a slave in the technical
drawn its command request, it writes 0 to the transfer
jargon. Typical commands to the TMS320C30 might be:
register to signal the PC that it is ready for a new com-
initialize the AIC, send a block of data to the PC, read a
mand.
block of data from the PC, etc. All commands are repre-
sented by 8-bit words except that the all O's word must be The Program A.2 below gives an example of how
excluded from the command set. The TMS320C30 sends the PC can perfonn the steps described in the list above.
a message to the PC after it has completed the last com- This segment is taken from the program PC.C in [1.A.5,
mand and it is ready to execute another. The strategy for p. 84].
processing a command to the TMS320C30 are as follows:
1. The PC waits for the message from the TMS- Program A.3 shows how the TMS320C30 should
320C30 that it has finished the last command and is ready process a command. Data transfers are assumed to be ac-
to process another. More specifically, when the TMS- complished by the DMA controller so no reads or writes
320C30 completes a command, it writes 0 to the transfer appear in the program. The TMS320C30 first waits for
register. The PC checks for the transfer register to clear by any DMA transfer to finish by waiting for the DMA
reading a byte from COM_CMD. Remember that reading counter to count down to O. It then checks for a new
COM_CMD does not cause interrupts to the TMS320C30. command byte from the PC, and takes the appropriate
2. After receiving the message that the TMS320C30 action. If the command byte is not 0, the TMS320C30
is ready to process another command, the PC writes the echoes it to the transfer register as an acknowledgement of
byte corresponding to the desired command to COM_- receipt. After processing the command, the TMS320C30
CMD. waits for the PC to withdraw the command and writes
3. Once the TMS320C30 reads the new command 0 to the transfer register, to acknowledge receipt of the
word, it writes the word back to the transfer register to withdrawal message.

Table A.3. PC Actions to Read and Control Flags from TMS320C30 Actions

PC action Purpose
Test STATUSO bit 1 (MREAD-ACK) Detect TMS320C30 transfer register write
Test STATUSO bit 2 (MWRITE-ACK) Detect TMS320C30 transfer register read
Write Ox0002 to MINOR_CMD Clear STATUSO bit 1
Write Ox0004 to MINOR_CMD Clear STATUSO bit 2
Write Ox6044 to MINOR_CMD Update STATUSO for next PC read
Communicating between the PC and EVM 167

Program A.2 PC Function for Processing a Command to the EVM

/*-----------------------------------------------------------------------*/
/* PC Function to Process a Command */
/*-----------------------------------------------------------------------*/
void send_command(int i)
{
while(READ_CMD); /* Wait for EVM to be free */
WRITE_CMD(i) ; /* Send command to TMS320C30 */
while (READ_CMD != i); /* Wait for TMS320C30 to acknowledge command */
WRITE_CMD(NONE); /* Withdraw the command request */
}

Program A.3 TMS320C30 Function to Process a Command

#define NONE OxOO


volatile int *host = (volatile int *) Ox804000;
void command_process(void)
{
int i,j; /* Temporary variable */
while(dma[TRANSFER]); /* Wait for DMA counter to reach 0 */
i = *host & OxFF; /* Look for command from PC -- read
transfer register and mask to least
significant byte */
if(i) /* Check to see if it is a command */
{
*host i; /* Echo back command as acknowledgement */
{

Perform functions requested by the command

}
while(*host & OxFF);/* Wait for PC to withdraw request */
*host = NONE /* Signal PC that C30 ready for new command
by acknowledging PC command withdrawal*/
}

A.3. Using DMA for Data write the correct configuration word into the DMA global
Transfers control register to start the transfers. PC to TMS320C30
and TMS320C30 to PC transfer protocols are described
The EVM interface hardware is designed to facilitate
in the following two subsections.
data transfer between the PC and TMS320C30, by using
the DMA controller of the TMS320C30. The DMA con-
troller needs a source address, destination address, and A.3.1. TMS320C30 to PC Data
the number of words to transfer. In the protocol de- Transfers
scribed for this experiment, it is assumed that the PC
and TMS320C30 know the number of words to trans- Data transfers from the TMS320C30 to the PC are
fer a priori and do not have to pass this information to controlled by PC reads of the COM..DATA register. Each
each other. Once these three values have been loaded into time the PC reads COM..DATA, the EVM generates INT2
the appropriate registers, the TMS3020C30 program must to the TMS320C30. The DMA is set up to transfer a word
168 Appendix A

from a source array to the transfer register, and increment predetermined number of words is transferred. Note that
the source address when INT2 occurs. This write sets the no dummy write by the PC is required.
MREAD-ACK flag for the PC which then reads another Program A.7 shows how the TMS320C30 can re-
word. PC reads continue until the predetermined number ceive data from the PC. First, it clears any pending in-
of words is transferred. terrupt flags from PC actions. Then it enables DMA in-
Program A.4 shows a C example of how the PC can terrupts on PC writes to COM-DATA (INTI). It sets the
read a block of data from the TMS320C30. The PC first source address to the address of the transfer register, the
waits for the TMS320C30 to be ready for a new com- destination address to the starting address of the array to
mand, by waiting for the value read from COM_CMD to receive the data block, and loads the transfer counter with
become o. The PC then writes the getblk_cmd command the predetermined number of words to be received. Then
byte to COM_CMD and waits for the value read from the word OxOD43 is written to the DMA global control
COM_CMD to equal getblk_cmd, which indicates that register to setup the four modes listed in the program.
the TMS320C30 has acknowledged receiving the com- This word is explained in Table A.5.
mand by echoing it back to the transfer register. At this At this point the TMS320C30 is ready to accept
time, the TMS320C30 has not yet written the first data data, so it acknowledges the PC's command by echo-
word of the block to the transfer register. The PC must ing it back to the transfer register. The PC then writes
perform a dummy read of COM-DATA to generate INT2, the first word to COM-DATA which generates INTI to
which causes the DMA to write the first data word to the the TMS320C30, which causes the DMA to read the data
transfer register. The PC then continues reading words from the transfer register and write it to the receiving ar-
until the entire block has been received. ray. The read causes the MWRITE-ACK bit to be set in
Program A.5 shows an example of a TMS320C30 C STATU SO, the PC resets this bit and writes the next word
function for sending a block of data to the PC. The pro- to COM-DATA, etc.
gram uses the asm function of the TI C compiler. First,
any pending interrupts are cleared by zeroing the corre-
sponding bits in the interrupt flag register (IF). Then the A.3.3. Turning off the DMA
bit in the interrupt enable register (IE) that enables INT2
In the previous examples, the DMA global control
to the DMA controller is set. Then the address of the
register has been set so that a TMS30C30 CPU inter-
start of the source array is set; the destination address is
rupt occurs when the DMA transfer counter reaches o.
set to the address, host, of the transfer register; and the
Program A.8 shows an interrupt service routine for this
transfer count, buffer, is loaded. Next the correct con-
interrupt (INTI 1). It waits for the PC to withdraw its
figuration word, OxOE13, is loaded into the DMA global
command request. Then it writes 0 to the transfer reg-
control register. This word sets up the four conditions
ister, to signal the PC it is ready for another command.
listed in the program and is explained in Table A.4.
Finally, the program disables all interrupts to the DMA.

A.3.2. PC to TMS320C30 A.4. Laboratory Experiments on


Data Transfers Transferring Data between
Program A.6 shows how the PC can transfer data the TMS320C30 and PC
to the TMS320C30. Again, the PC waits for the Now it is time to put the concepts presented in the
TMS320C30 to be ready for a command by reading previous sections into action. You will be asked to write
COM_CMD until it becomes o. Then the PC writes the programs to transfer data blocks from the TMS320C30 to
sendblk_cmd command byte to COM_CMD, and waits the PC, and to display the blocks graphically on the PC
for it to be echoed back by the TMS320C30. When screen.
the acknowledgement is received, the PC clears the ac-
knowledgement bits in STATUSO. The PC begins trans-
ferring data by writing a word to COM-DATA which A.4.1. Functions the TMS320C30
generates INTI to the TMS320C30. The DMA con- Program Must Perform
troller in the TMS320C30 reads the word from the transfer
register, which sets bit 2 in STATUSO, which we have Write a C program for the TMS320C30 that performs
previously called MWRITE-ACK. The PC waits until the following items.
MWRITE-ACK becomes I, clears it, and writes another I. Initialize the TMS320C30 and AIC as in Chapter
word to COM-DATA. The process is repeated until the 2.
Communicating between the PC and EVM 169

Program A.4 PC Program to Get a Data Block from the TMS320C30

#define buffer 512 /* Assume 512 word data blocks

void getblk(int getblk_cmd)


{
int i; /* Loop counter */
while(READ_CMD); /* Wait for TMS320C30 to be ready */
WRITE_CMD(getblk_cmd); /* Write command to COM_CMD */
while(READ_CMD != getblk_cmd);/* Wait for ack from C30 */
CLR_READ_ACK; /* Clear STATUSO bit 1 which shows
C30 writes to transfer reg. */
READ_DATA; /* Dummy read to start DMA */
for(i=O; i < buffer; i++)
{
/*----------------------------------------------------------*/
/* Wait for EVM to write new data word */
/*----------------------------------------------------------*/
do
{

}
while{lIS_READ_ACK);
/*----------------------------------------------------------*/
CLR_READ_ACK; /* Clear STATUSO bit 1 */
in_array[index++] = READ_DATA;/* Put received data word into
PC memory array */
}
WRITE_CMD(NONE); /* Withdraw command request
}

2. Modify the linker command file c30. cmd to map buf2 [] . Initialize a pointer named input to point to
the . bss section into SRAM, the external static RAM. bufi[O], and another pointer named output to point to
3. Data blocks of size BUFFER = 512 will be trans-
buf2 [0]. The array pointed to by input should be used
ferred from the TMS320C30 to the PC. Set up two inte- to store samples received from the AIC, and the array
ger arrays of 512 words each, for example, buf 1 [] and pointed to by output should be used to send data to the

Table A.4. DMA Global Control Register Value for Sending Data to PC

Bit Value Name Function


0- 1 11 START Reset DMA
2-3 Read-only STAT Unused
4 1 INCSRC Increment source address on each transfer
5 0 DECSRC Do not decrement source address on transfer
6 0 INCDST Do not increment dest. address on each transfer
7 0 DECDST Do not decrement dest. address on each transfer
8-9 10 SYNC Synchronize writes with enabled interrupt
10 TC Stop transfers when transfer counter reaches 0
11 TCINT Generate CPU interrupt when transfer counter
reaches 0
170 Appendix A

Program A.S TMS320C30 Program for Sending Data to PC Using DMA

void sendtopc(int *source,int getblk_cmd)


{
asm(" AND OFFF8h,IF"); 1* Clear any pending PC interrupts *1
asm(" or @_dma_int2,IE"); 1* Synchronize DMA to INT2 *1
dma[SOURCE] = (int) source; 1* Base source address *1
dma[DEST] (int) host; 1* Destination address *1
dma[TRANSFER] = buffer; 1* Number of words to transfer *1
1*--------------------------------------------------------------------*1
1* DMA setup parameters for sending data to PC *1
1* 1. Increment source address only on each transfer. *1
1* 2. Synchronize writes with INT2 caused by PC read *1
1* 3. Transfer counter stops on reaching 0 *1
1* 4. Enable DMA interrupt to CPU when transfer counter *1
1* becomes O. *1
1*--------------------------------------------------------------------*1
dma[GLOBAL] = OxOE13;
1*--------------------------------------------------------------------*1
*host = getblk_cmd 1* Send command acknowledgement to
host PC by echoing it to transfer
register. *1
}

PC by the DMA. The protocol described in the previous by writing 0 to the transfer register.
sections should be used. 6. After perfonning the initialization functions, the
4. Enable CPU interrupts by the serial port receiver. main program should go into an endless loop that:
When an interrupt occurs, the TMS320C3.0 interrupt ser- (a) Waits for the input buffer to become full. This
vice routine (ISR) should load the received word into the event can be detennined by checking for index to become
input array at an offset given by the variable, index. This O. When the buffer is full, the input and output buffers
ISR should increment index after each new sample is should be swapped. Remember that samples are written
stored. When index reaches the array size, BUFFER, it into the input buffer at an 8-kHz rate. Samples are sent to
should be reset to O. the PC from the output buffer by DMA transfers caused by
5. Signal the PC that initialization has been com- PC reads of COM -DATA and these transfers should occur
pleted and the TMS320C30 is ready to receive a command at a much higher rate than 8 kHz. Thus, the output buffer

Table A.5. DMA Global Control Register Value for Receiving Data from PC

Bit Value Name Function


0-1 11 START Reset DMA
2-3 Read-only STAT Unused
4 0 INCSRC Do not increment source address on each transfer
5 0 DECSRC Do not decrement source address on each transfer
6 I INCDST Increment destination address on each transfer
7 0 DECDST Do not decrement dest. address on each transfer
8-9 01 SYNC Synchronize reads with enabled interrupt
10 TC Stop transfers when transfer counter reaches 0
11 TCINT Generate CPU interrupt when transfer counter
reaches 0
Communicating between the PC and EVM 171

Program A.6 PC Program to Send a Data Block to the TMS320C30

void sendblk(int sendblk_cmd)


{
int i; /* Loop counter */
while(READ_CMD); /* Wait for TMS320C30 to be ready */
WRITE_CMD(sendblk_cmd); /* Write command to COM_CMD */
while(READ_CMD != sendblk_cmd);/* Wait for ack from C30 */
CLR_WRITE_ACK; /* Clear STATUSO bit 2 which shows
C30 reads of transfer reg. */
for(i=O; i < buffer; i++)
{
/*----------------------------------------------------------*/
/* Write data word from PC array to COM_DATA */
/*----------------------------------------------------------*/
WRITE_DATA(out_array[index++]);
/*----------------------------------------------------------*/
/* Wait for EVM to read data word */
/*----------------------------------------------------------*/
do
{
UPDATE_STATUSO;
}
while{!IS_WRITE_ACK);
/*----------------------------------------------------------*/
CLR_WRITE_ACK; /* Clear STATUSO bit 2 */
}
WRITE_CMD(NONE); /* Withdraw command request
}

should have been completely transferred to the PC before When the serial port transmitter is empty and the AIC
the input buffer becomes full. Swapping the addresses tries to read a word, the serial port transmitter output tri-
stored in input and output causes the most recent block states. Then the bits read by the AIC can have random
of received samples in the output block to be transferred values. When the two least significant bits of the word
to the PC, and new received samples are written over the read by the AIC are not 0, the AIC interprets the word
old output block, which has already been sent to the Pc. as a command. When certain non allowed commands are
Finally, the "wait for full buffer" routine should wait for received, the AIC shuts down and stops sending clocks to
index to become nonzero, indicating that the first sample the serial port. Then the system hangs up and no further
has been loaded into the input buffer. This assures that words are read or written until the AIC is reset. Therefore,
the "wait for full buffer" routine triggers only once for write a word, even if it is just all O's, to the serial port
each new buffer. transmitter every time you read one.
(b) Checks for a new command from the PC and
takes appropriate action using the protocol described
above. A.4.2. Functions the PC Program
WARNING: Even though you may only want to read Must Perform
samples from the AIC, you must also write words to the
AIC at the same rate you read them. The reason for this The PC should read blocks of 512 samples from the
is that the AIC supplies the transmit and receive clocks TMS320C30 and display them graphically. Write a C
to the serial port shift registers, and always reads a word program for the PC that performs the following tasks:
from the serial port at the same time it writes one to it. 1. Wait for the signal from the EVM that the
172 Appendix A

Program A.7 Program to Receive a Block of Data from the PC

void receivefrompc(int *dest,int sendblk_cmd)


{
asm(" AND OFFF8h,IF"); /* Clear any pending PC interrupts */
asm(" or @_dma_int1,IE"); /* Synchronize DMA to INT1 */

dma[SOURCE] = (int) host; /* Transfer register address */


dma[DEST] (int) dest; /* Destination address */
dma[TRANSFER] = buffer; /* Number of words to transfer */
/*--------------------------------------------------------------------*/
/* DMA setup parameters for receiving data from PC */
/* 1. Increment destination address only on each transfer. */
/* 2. Synchronize reads with INT1 caused by PC write */
/* 3. Transfer counter stops on reaching 0 */
/* 4. Enable DMA interrupt to CPU when transfer counter */
/* becomes O. */
/*--------------------------------------------------------------------*/
dma[GLOBAL] = OxOD43;
/*--------------------------------------------------------------------*/
*host = sendblk_cmd /* Send command acknowledgement to
host PC by echoing it to transfer
register. */
}

Program A.S DMA Interrupt Service Routine

void c_int11(void)
{
while«*host & OxFF)); /* Wait for PC to withdraw request */
*host = NONE; /* Signal PC that C30 ready for command */
dma[GLOBAL] = 0; /* Turn off DMA */
asm(" AND OFFFF,IE"); /* Turn off DMA interrupts */
}

TMS320C30 is ready to receive commands. This is done plot before the new block is plotted. (See page 101 of
by waiting for the MREAD.ACK bit in STATUSO to be- [LA.5].)
come 1. The TMS320C30 causes this flag to be set when 4. After the initialization process, create an unending
it writes 0 to the transfer register after it has completed loop to do the following:
its initialization routines.
2. Initialize the graphics display to the VGA 640 x (a) Check for and process any commands from the key-
board
400 mode, using the graphics routines in Borland C++.
(See page 97 of [I.A.5]). (b) Read a block of data from the PC into rec [ ]
3. Set up two 512 word arrays rec [ ] and y [ ].
The array re c [ ] will be used to store the most recent (c) Plot the block on the screen. For each i, fIrst erase
block of words received from the TMS320C30. The array the old point by plotting the pixel (i, y [i)) with
y [ ] will be used to store samples that have been adjusted color black. Then adjust the new sample rec [i]
for the screen display, and are used to erase the previous for plotting and save it in y [i]. Then plot y [i]
Communicating Between the PC and EVM 173

A.4.3. Testing Your PC and TMS320C30


Software
To test your programs, apply a signal to the AID
input with the signal generator. Also apply this signal to
an oscilloscope. Check that the signal displayed on the
PC screen is the same as the one on the oscilloscope.
Appendix B. Generating Gaussian
Random Numbers

This appendix describes how to convert a sequence of V can be generated by calling rand, converting the re-
uniformly distributed random numbers into a pair of se- turned integer to a floating-point number, and dividing
quences that approximate a pair of white, uncorrelated, the result by 2 31 - 1 = 2147483647. The random vari-
Gaussian random sequences. These sequences can be able V can be converted into R by the transformation
used to simulate the inphase and quadrature noise compo-
nents in passband communication systems. This method R = j -2a 2 1og e (1 - V) (B.3)
is convenient because many programming languages have Note that this function is the inverse of the cumulative
a function for generating uniformly distributed random distribution function FR(r). A proof that this gives the
numbers. desired result can be found in most introductory probabil-
The TMS320C30 C compiler library contains the in- ity textbooks.
teger function rand(void) which generates integers uni- The next step is to convert V into a pair of uncor-
formly distributed over the range [0, RMAX] where related Gaussian random variables. Let 8 be a random
RMAX = 2147483646 = 2 31 - 2. The function srand· variable uniformly distributed over [0, 21f) and indepen-
(unsigned int seed) sets the value of the random number dent of V. 8 can be generated by calling rand again,
generator seed so that subsequent calls of rand produce dividing the result by (2 31 - 1) to get a random number
a new sequence of pseudorandom numbers. The srand uniformly distributed over [0, 1), and then mUltiplying the
function does not return a value. If rand is called be- result by 21f. Finally, it can be shown that
fore srand is called, it generates the same sequence as if
srand was called first with a seed value of 1. The func- x = Reos8 (BA)
tion rand generates the same sequence whenever srand
sets the same seed. and
The first step is to convert a random variable V, Y = Rsin8 (B.5)
which is uniformly distributed over [0, 1), into a ran- are two uncorrelated Gaussian random variables, each
dom variable R that has the Rayleigh probability density with zero mean and variance a 2 • That is, they each have
function a probability density function of the form
r r2
fR(r) = -e-~u(r) (B.l) 1
a2 f(x) = --e-~
30 2

(B.6)
and cumulative distribution function av'2if
FR(r) = [1 - e-~ ] u(r) (B.2)
This method is good for simulating noise in com-
munication systems, because it approximates the tails of

175
176 Appendix B

the Gaussian distribution well. Note that as V approaches


1, R, X, and Y approach infmity in magnitude. Other
methods that are based on the Central Limit Theorem,
and involve taking the sum of a fixed number of uniform
independent random variables, approximate the peak of
the pdf well but appoximate the tails poorly. Problems
in communication systems are usually caused by infre-
quently occurring large values of the noise, that is, the
tails of the pdf.
Appendix C. A TTLIRS-232C Interface
for Serial Port 1

Serial Port 1 of the TMS320C30 is brought out to a 10- Transmitted Data on the RS-232C side is sent to the
pin header on the EVM card bracket. The signal levels Receive Data pin of the TMS320C30 serial port. Sim-
have the TTL values of 0 and 5 volts. Some experiments ilarly, Transmit Data of the serial port is routed to Re-
require the use of this port to exchange serial data with the ceived Data of the RS-232C connector. A similar name
Navtel bit-error rate tester, which uses RS-232C levels. swap occurs with the clocks. This is because the RS-
In the RS-232C protocol, a logical 0 is called a space 232C connecter on the box is configured to look like a
and is represented by + 12 V while a logical 1 is called a modem or DCE. In this case, pin 3 is data received by
mark and is represented by-12 V. The RS-232C interface the modem and pin 2 is data transmitted by the modem.
protocol is described in detail in Chapter 10. The circuit Transmit Frame Sync (FSX) is looped back to Re-
diagram for a TTL to RS-232C converter for use with the ceive Frame Sync (FSR) on the 10 pin header connector.
Navtel tester is shown in Fig. C.l. The serial port should be configured to run in the contin-
The converter uses a MAXIM MAX238 RS-232 uous mode when exchanging data with the Navtel tester.
Driver/Receiver chip. The MAX238 just requires a sin- A write to the Data Transmit Register (DXR) generates
gle +5 V power source and three external capacitors. It a Transmit Frame Sync pulse, and starts the transmis-
contains a voltage doubler and inverter to generate the sion. Transmissions continue as long as data is written
± 12 V levels. The package contains four TTL to RS- to DXR before the word in the Transmit Shift Register
232C drivers and four RS-232C to TTL receivers. The (XSR) is completely sent. A Receive Frame Sync pulse
+5 V source is generated by using a LM7805 3-pin volt- is required to start the serial port receiver. Once the re-
age regulator powered by an ac to dc converter with a 12 ceiver is started, it continues without frame sync's, as
V output. long as the data in the Data Receive Register (DRR) is
The box uses a DB25 connector for the RS-232C read before the Receive Shift Register (RSR) fills with a
cable. The Received Data, Transmitted Data, Receiver new word. Looping FSX back to FSR generates the pulse
Clock, and Transmitter Clock leads are connected to the required to start the receiver.
MAX238 chip. Request to Send (RTS) is looped back The transmit and receive clocks for the TMS320C30
to Clear to Send (CD) and Data Carrier Detect (DCD) serial port and Navtel tester are generated by the timers in
on the connector. Also, Data Terminal Ready (DTR) is the serial port. The serial port must be set to provide the
looped back to Data Set Ready (DSR). In this way, when clocks as outputs. To compensate for the inversion in the
the Navtel tester is turned on and a bit-error rate test MAX238 chip, the serial port should be configured to use
is selected, it raises RTS and DTR, which automatically active low clocks. Details on how to set the Serial Port 1
raise CTS, DCD, and DSR. control registers are provided in the tables in Chapter 10.

177
178 Appendix C

--
J8.3V
+5 VI 9
~ 10/11
10
Vcc II
4.7ILI ~
Cl+
+5 V to +10 V V+
LM7805CP I I
8.3V ~ Cl - Y,0Itage Doubler 11 Voltage Regulator +12 V
13 -------------------- 10 ILl ac/dc 110 V
4.7ILI C2+ +10Vto-lOV 16 V -
16 V
~ V- Converter ac
Gs-1~11
~ C2-
Voltage Inverter
--------------------
5 DXl 5 Tlin Tlout 2 Received Data
~
RD 3

~
9 CLKRI 18 T2in +5 V. T20ut 1 Transmitter Clock TC 15

~
3 CLKXl 19 T3in +5 T30ut 24 Receiver Clock RC 17
-
$
21 T4in +5 V. ~
T40ut 20

4DRI 6 +tv Rlin 7 Transmitted Data TD 2

4
Rlout
i- R2in 3
10 pin
-
Header
onEVM 22
R20ut
,..
i- R3in 23

17
R30ut
i- R4in 16
-
R40ut
GND
i-
7 FSXl Request to Send RTS 4
~
2 FSRI I MAXIM MAX238
-
Clear to Send
Data Carrier Detect
CTS 5
DCD 8
1 or 10 GND RS-232 Drivers/Receivers Signal Ground SG 7
~ Data Terminal Ready DTR20
- IData Set Ready DSR 6

DB25 RS-232 Connector


Figure C.l. TIL to RS-232C converter.
Appendix D. Equipment List for
Each Station

This equipment list is included to provide guidance to • Tektronix 2205 Oscilloscope


those setting up a similar laboratory, and is not intended
to be an endorsement of any particular manufacturer. Dual channel oscilloscope
Clearly, many companies make equipment, with equiv-
alent capabilities, that can be substituted for the specific • BK Precision 3040 Signal Generator
items listed below.
Sine, triangular, and square wave outputs; frequency
• 80486/33MHz PC counter; AM and FM modulated signals

- 4 MB system RAM, 64 K Cache RAM • Navtel DATATEST3 - bit error rate tester

- 1.2 MB 5 1141/ and 1.44 MB 3 1121/ floppy U of MD home-made RS232/TTL converter to inter-
drives face Navtel with TMS320C30 serial port 1 on EVM
- 80 MB hard drive board

- 1024 x 768 non-interlaced super VGA color • Penril Alliance Y.32 modem
monitor
A V.32 and V.22bis modem with built in diagnostic
16-bit VGA video controller with 1 MB RAM
constellation X-Y outputs.
1 parallel, 2 serial ports
• Microphone
- Microsoft mouse
- 101 keyboard • Speaker

• Texas Instruments TMS320C30 Evaluation Module • Two BNC to BNC (50 ohm) 3 foot cables
(TMS320C30 EVM)
• One BNC to BNC (50 ohm) 6 foot cable
32-bit floating point DSP module which includes • Two RCA male to BNC female (50 ohm) 6 foot
AID and DIA converters installed in each PC cables

• Novell network cards installed in each PC • BNC to alligator clip cable

179
180 Appendix D

• Two BNC T connectors

• Two BNC female to banana/screw connectors

Additional Shared Equipment

• Two TAS III Telephone Network Emulators

Emulate amplitude and phase disortion, nonlinear


distortion, additive noise, frequency translation and
carrier phase jitter

• Two Tektronix 495P Spectrum Analyzers

• Two Okidata 391 + dot matrix 15 in. carriage printers


Appendix E. Software and
Directory Structure

C:\GROUPn Working directory for group at setup n • MATHASM.SRC Archive of source modules for
math functions
C:\DOS DOS 5.0
C:\WINDOWS Windows 3.1 C: \ UTIL.DSP
C:\SYS Novell network software This directory contains the TMS320C30 periph-
eral control utilities described in Appendix B of the
C: \BORLANDC Borland C++ compiler for PC
TMS320C3x DSP Design Workshop Student Guide. Also,
C:\C.DSP the source code for the initialization functions and head-
This directory contains the TI C compiler, assembler, ers required for TMS320C30 C programs is included here.
and linker for the TMS320C30. Some of the files are: In addition, a working set of programs for sending data
blocks from the EVM to the PC are included. Some of
• CL30.EXE The C compiler the files are:
• OPT30.EXE C code optimizer • README.DOC A description of the utilities
• ASM30.EXE The C30 assembler • BUS.H, BUS.LIB Header and library for bus utilities
• LNK30.EXE The linker
• DMA.H, DMA.LIB Header and library for DMA
• AR30.EXE Archiver to create archives (libraries) of utilities
source or .obj files
• SERIAL.H, SERIAL.LIB Header and library for
• MK30.EXE Makes libraries from collections of .asm serial port utilities
modules
• TIMERS.H, TIMERS. LIB Header and library for
• RTS.SRC Archive of source programs for run time timer utilities
library
• VECTORS.ASM Defmes interrupt vectors
• RTS30.LIB Run-time library
• INTS.C Dummy interrupt handlers
• PRTS30.SRC Archive of source modules for the Pe-
ripheral Control Library described in the manual of • C30.CMD A sample linker command file with mem-
the same name ory map

181
182 Appendix E

• AIC.H Macros and structures for AIC control • LPC_*. * PC and EVM programs for a linear pre-
dictive voice digitizer
• C30START.C Sample C program showing how to
initialize the TMS320C30 and AIC. It can be used • EVMLOAD.EXE A simple EVM loader
as a starting point for lab programs.
C:\DIGFIL
• CONVOL.ASM 31-tap FIR assembly language con- This directory contains programs for designing digi-
volution function, that is called from and returns to tal filters.
C
• C:\DIGFIL\REMEZ\REMEZ87.* Program for
• SCOPE\*.* PC and TMS320C30 programs for
designing FIR filters by the McClellan-Parks method
sending data blocks from the EVM to the PC.
README.TXT explains what the programs do • C:\DIGFIL\ WINDOW\ WINDOW. * Program
for designing FIR digital filters by the window func-
C: \DEBUG.DSP tion method
This directory contains the TMS320C30 C Source
• C:\DIGFIL\RASCOS.EXE Program for design-
Debugger and related executable and example source pro-
ing an FIR digital filter with a raised cosine fre-
grams. The Debugger interfaces with the TMS320C30
quency response
EVM module and allows programs to be downloaded from
the PC to the EVM and then run and monitored. In addi- • C:\DIGFIL\SQRTRACO.EXE Program for de-
tion, if the C30 programs are written and compiled using signing an FIR digital filter with a square-root of
the TI C30 compiler, the Debugger can trace the EVM raised cosine frequency response
execution of the C statements. These programs include:
• C:\DIGFIL\IIR\IIR.* Program for designing
• EVM30.EXE The DOS version of the Debugger classical (Butterworth, Chebyshev, Elliptic) analog
and IIR digital filters
• EVM30W.EXE The WINDOWS version of the De-
bugger C:\GRAPHER Programs for plotting (x, y) data
• EVMLOAD.EXE A simple stand-alone loader for F:\
EVM programs
This directory is on the network server. It contains
C:\SIM.DSP many applications programs such as word processors,
spreadsheets, drawing programs, C compilers, MATH-
This directory contains the TMS320C30 software CAD, MATLAB, etc. Type CM to get the menu for the
simulator. Its interface is identical to that of the Debugger. available software.
The simulator does not use the EVM.
• F:\COMM_l, ... , F:\COMM_6. These are work-
• SIM3X.EXE The DOS version of the Simulator
ing directories for the 6 lab groups.
• SIM3XW.EXE The WINDOWS version of the
• F:\LABNOTES This subdirectory is primarily
Simulator
for use of the instructors. STUDENTS SHOULD
C: \APPS.DSP NEVER CHANGE FILES IN THIS SUBDIREC-
TORY OR WRITE FILES INTO IT.
This directory contains source and executable pro-
grams for examples that show how to use the EVM. - F:\LABNOTES\C30PROG\FFT\FFT.EXE
FFT.EXE is a self extracting zipped file that
• EVMHOST.C,EXE PC program to interface to contains several C callable assembly language
the EVM FFT and IFFT functions. It came from the
TI bulletin board mirror, which can be ac-
• EVMINIT.ASM,OUT,BAT Program to initialize
cessed through the Internet using the com-
and test EVM
mand FTP TI. COM, and is in the directory Imir-
• OSC_*. * PC and EVM programs to display data rors/tms320bbs.
read from the EVM AID converter on the PC screen
like an oscilloscope, and also to output the data sam-
ples to the EVM DIA converter.
References

I. List of Manuals 9. Brian W. Kernighan and Dennis M. Ritchie, The


C Programming Language, second edition, Prentice
A. Manuals for the Hall (1988).
TMS320C30 Tools
10. Texas Instruments, TMS320C3x Periperal Control
Library, User's Guide, revision *, September 1992.
1. Texas Instruments, TMS320C3x DSP Design Work-
shop, Student Guide, DSP3-NOTES-2.2, April 1992. 11. Texas Instruments, TMS320 Floating-Point DSP
Code Generation Tools, Release 4.50, Release Notes,
2. Texas Instruments, TMS320C3x DSP Design Work- revision C, November 1992.
shop, Instructors Guide, DSP3-lNST-2.2, April
1992. B. Manuals for
Borland C++
3. Texas Instruments, TMS320C3x User's Guide, revi-
sion F, July 1992.
1. Borland C++, Programmer's Guide, version 3.1
4. Texas Instruments, TMS320C30 Evaluation Module, (1992).
Technical Reference, revision B, October 1990. 2. Borland C++, Users' Guide, version 3.1 (1992).
5. Texas Instruments, Digital Signal Processing Ap- 3. Borland C++, Tools and Utilities Guide, version 3
plications with the TMS320C30 Evaluation Mod- (1992).
ule, Selected Application Notes, revision A, January
1991. 4. Borland C++, Library Reference, version 3.1
(1992).
6. Texas Instruments, TMS320 Floating-Point DSP As-
sembly Language Tools User's Guide, revision A, 5. Borland, Turbo Assembler 3.0, User's Guide (1991).
September 1991.
6. Borland, Turbo Assembler 3. 0, Quick Reference
7. Texas Instruments, TMS320C3x C Source Debugger, Guide (1991).
User's Guide, revision F, September 1991.
7. Borland, Turbo Debugger 3.0, User's Guide (1991).
8. Texas Instruments, TMS320 Floating-Point DSP Op- 8. Borland, Turbo Profiler 2.0, User's Guide (1991).
timizing C Compiler, User's Guide, revision A, Oc-
tober 1991. 9. Borland, Resource Workshop, User's Guide (1991).

183
184 References

C. Assorted Manuals for 4. Paul M. Embree and Bruce Kimble, C Language


Lab Test Equipment Algorithms for Digital Signal Processing, Prentice
Hall (1991).
II. Selected Reference Books
and Papers 5. IEEE Press, Programs for Digital Signal Processing
(1979).
A. DSP Laboratory Books
Using DSP Hardware 6. Leland B. Jackson, Digital Filters and Signal Pro-
cessing, Kluwer Academic Publishers (1986).
1. Rulph Chassaing, Digital Signal Processing with C
7. G.M. Jenkins and D.G. Watts, Spectral Analysis and
and the TMS320C30, Wiley Interscience (1992).
Its Applications, Holden-Day (1968).
2. Rulph Chassaing and Darrell W. Homing, Digital
8. Steven M. Kay, Modern Spectal Estimation: Theory
Signal Processing with the TMS320C25, Wiley In-
and Application, Prentice Hall (1988).
terscience (1990).

3. Vinay K. Ingle and John G. Proakis, Digital Signal 9. Alan V. Oppenheim and Ronald W. Schafer, Digital
Processing Laboratory Using the ADSP-2JOJ Mi- Signal Processing, Prentice Hall (1975).
crocomput€!r, Prentice Hall (1991).
10. Alan V. Oppenheim and Ronald W. Schafer, Dis-
4. Douglas L. Jones and Thomas W. Parks, A Digital crete-Time Signal Processing, Prentice Hall (1989).
Signal Procesing Laboratory, Prentice Hall (1988).

B. DSP Laboratory Books 11. T. W. Parks and C.S. Burrus, Digital Filter Design,
Using Software Wiley-Interscience (1987).
Simulation
12. John G. Proakis and Dimitris G. Manolakis, Digital
Signal Processing, Macmillan (1992).
1. Oktay AIkin, PC-DSP, Prentice Hall (1990).
13. Lawrence R. Rabiner and Bernard Gold, Theory and
2. Alan Kamas and Edward A. Lee, Digital Signal Application of Digital Signal Processing, Prentice
Processing Experiments Using a Personal Computer Hall (1975).
with Software Provided, Prentice Hall (1989).
14. Steven A. Tretter, Introduction to Discrete-Time Sig-
3. Russell M. Mersereau and Mark J.T. Smith, Digital nal Processing, Wiley (1976).
Filtering: A Computer Laboratory Textbook, Wiley
(1994).
D. Books and Papers
4. Mark J.T. Smith and Russell M. Mersereau, Digi- on Communications
tal Signal Processing, A Computer Laboratory Text-
book, Wiley (1992). 1. John B. Anderson and Seshadri Mohan, Source
and Channel Coding, Kluwer Academic Publishers
C. Books on Digital (1991).
Signal Processing
2. Albert Benveniste and Maurice Goursat, "Blind
1. Maurice Bellanger, Digital Processing of Signals, Equalizers," IEEE Transactions on Communications,
2nd ed., Wiley (1989). Vol. COM-32, No.8, August 1984, pp. 871-883.

2. Charles Sidney Burrus and Thomas W. Parks, DFTI 3. John A.C. Bingham, The Theory and Practice ofMo-
FFT and Convolution Algorithms, Wiley-Intersci- dem Design, Wiley-Interscience (1988).
ence (1985).
4. CCITT Blue Book, Volume VIII-Fascicle VIII.l,
3. Ronald E. Crochiere and Lawrence R. Rabiner, Data Communication Over the Telephone Network,
Multirate Digital Signal Processing, Prentice-Hall Series V Recommendations, IX-th Plenary Assem-
(1983). bly, November 1988.
References 185

5. Pierre R. Chevillat, Dietrich Maiwald, and Got- 16. Hiroshi Harashima and H. Miyakawa, "Matched-
tfried Ungerboeck, "Rapid Training of a Voiceband Transmission Techniques for Channels with Inter-
Data-Modem Receiver Employing an Equalizer with symbol Interference," IEEE Transactions on Com-
Fractional-T Spaced Coefficients," IEEE Transac- munications, Vol. COM-20, No.4, August 1972,
tions on Communications, Vol. COM-35, No.9, pp. 774-780.
September 1987, pp. 869-876.
17. Simon Haykin, Communication Systems, 3rd ed.,
Wiley (1994).
6. GJ. Foschini, "Equalization Without Altering or
Detecting Data," Bell System Technical Journal, 18. Simon Haykin, Adaptive Filter Theory, 2nd ed.,
Vol. 64, October 1985, pp. 1885-1911. Prentice-Hall (1991).
19. Simon Haykin, Digital Communications, Wiley
7. L.E. Franks and J.P. Burbrouski, "Statistical Prop-
(1988).
erties of Timing Jitter in a PAM Timing Recovery
Scheme," IEEE Transactions on Communications, 20. ITU - Telecommunications Standardization Sector,
Vol. COM-22, No.7, July 1974, pp. 913-920. "Clean Final Draft of Recommendation V.34," Tem-
porary Document 57-E, Study Goup 14/WPS, June
8. Floyd M. Gardner, Phaselock Techniques, 2nd ed., 1994.
Wiley-Interscience (1979).
21. Neil K. Jablon, "Joint Blind Equalization, Car-
rier Recovery, and Timing Recovery for High-Order
9. Jerry D. Gibson, Principles of Digital and Analog
QAM Signal Constellations," IEEE Transactions
Communications, 2nd ed., Macmillan (1993).
on Signal Processing, Vol. 40, No.6, June 1992,
pp. 1383-1398.
10. R.D. Gitlin and J.F. Hayes, "Timing Recovery and
Scramblers in Data Transmission,"The Bell System 22. Rajiv Laroia, "lSI Coder - Combined Coding & Pre-
Technical Journal, Vol. 54, No.3, March 1975, coding," Subcommittee Contribution, Technical Sub-
pp. 569-593. committee TR30.1, TIA meeting, Baltimore, MD,
June 1993.
11. Richard D. Gitlin, Jeremiah F. Hayes, Stephen
23. Edward A. Lee and David G. Messerschmitt, Dig-
B. Weinstein, Data Communications Principles,
ital Communication, Kluwer Academic Publishers
Plenum (1992).
(1988).
12. R.D. Gitlin, H.C. Meaders, Jr., and S.B. Weinstein, 24. F. Ling and S.U.H. Qureshi, "Convergence and
"The Tap-Leakage Algorithm: An Algorithm for the Steady-State Behavior of a Phase-Splitting Fraction-
Stable Operation of a Digitally Implemented, Frac- ally Spaced Equalizer," IEEE Transactions on Com-
tionally Spaced Adaptive Equalizer," The Bell Sys- munications, Vol. 38, No.4, April 1990, pp. 418-
tem TechnicalJournal, Vol. 61, No.8, October 1982, 425.
pp. 1817-1839.
25. R.W. Lucky, "Automatic Equalization for Digital
Communication," The Bell System Technical Jour-
13. Dominique N. Godard, "Passband Timing Recovery
nal, Vol. XLIV, No.4, April 1965, pp. 547-588.
in an All-Digital Modem Receiver," IEEE Transac-
tions on Communications, Vol. COM-26, No.5, 26. Robert W. Lucky, J. Salz, and EJ. Weldon, Jr.,
May 1978, pp. 517-523. Principles of Data Communication, McGraw-Hill
(1968).
14. Dominique N. Godard, "Self-Recovering Equali-
27. K.H. Mueller, and U. Werner, "A Hardware Effi-
zation and Carrier Tracking in Two-Dimensional
cient Passband Equalizer Structure for Data Trans-
Data Comunication Systems," IEEE Transactions on
mission," IEEE Transactions on Communications,
Communications, Vol. COM-28, No. 11, November
Vol. COM-30, No.3, March 1982, pp. 538-541.
1980, pp. 1867-1875.
28. G. Picchi and G. Prati, "Blind Equalization and Car-
15. Yuri Goldstein, Vedat Eyuboglu, and S. Olafs- rier Recovery Using a Stop-and-Go Decision Di-
son, "Precoding for V.fast," Subcommittee Contribu- rected Algorithm," IEEE Transactions on Commu-
tion, Technical Subcommittee TR30.1, TIA meeting, nications, Vol. COM-35, September 1987, pp. 877-
Newton, MA, July 1993. 887.
186 References

29. John G. Proakis, Digital Communications, 2nd ed., 5. Rajiv Laroia, Nariman Farvardin, and Steven
McGraw-Hill (1989). A. Tretter, "On Optimal Shaping of Multidimen-
sional Constellations," IEEE Transactions on Infor-
30. Y. Sato, "A Method of Self-Recovering Equaliza-
mation Theory, Vol. 40, No.4, July 1994, pp. 1044-
tion for Multilevel Amplitude-Modulation Systems,"
1056.
IEEE Transactions on Communications, Vol. COM-
23, June 1975, pp. 679-682. 6. W.W. Peterson and E.J. Weldon, Jr., Error Correcting
Codes, MIT Press (1972).
31. U. Stiffler, Theory ofSynchronous Communications,
Prentice-Hall (1971). 7. Gottfried Ungerboeck, "Channel Coding with Multi-
32. Gary L. Sugar and Steven A. Tretter, "Convergence levellPhase Signals," IEEE Transactions on Infor-
Properties of Optimal Adaptive Carrier Phase Jitter mation Theory, Vol. IT-28, No.1, January 1982,
Predictors of Sinusoidal Jitter," IEEE Transaction pp.55--67.
on Communications, Vol. 43, Nos. 2/3/4, February 8. Gottfried Ungerboeck, "Trellis-Coded Modulation
1995, pp. 225-228. with Redundant Signal Sets," Pts. I and II, IEEE
33. M. Tomlinson, "New Automatic Equaliser Employ- Communications Magazine, Vol. 25, February 1987,
ing Modulo Arithmetic," Electronics Letters, Vol. 7, pp.5-21.
Nos. 5/6, March 25, 1971, pp. 138-139. 9. L.-F. Wei, "Rotationally Invariant Convolutional
34. J.R. Treichler and B.G. Agee, "A New Approach to Channel Coding with Expanded Signal Space - Part
Multipath Correction of Constant Modulus Signals," II: Nonlinear Codes," IEEE Journal on Selected Ar-
IEEE Transactions on Acoustics, Speech, and Signal eas in Communications, Vol. SAC-2, No.5, Septem-
Processing, Vol. ASSP-31, April 1983, pp. 459-472. ber 1984, pp. 672--686.

10. L.-F. Wei, "Trellis-Coded Modulation with Multi-


35. John R. Treichler, C. Richard Johnson, Jr., and dimensional Constellations," IEEE Transactions on
Michael G. Larimore, Theory and Design of Adap- Information Theory, Vol. IT-33, No.4, July 1987,
tive Filters, Wiley-Interscience (1987). pp. 483-501.

36. J.J. Werner, "An Echo-Cancellation-Based 4800 Bit!


s Full-Dup!ex DDD Modem," IEEE Journal on Se-
lected Areas in Communications, Vol. SAC-2,
No.5, September 1984, pp. 722-730.
37. B. Widrow and S.D. Steams, Adaptive Signal Pro-
cessing, Prentice-Hall (1985).

E. Books and Papers on


Error-Correcting Codes

1. Ezio Biglieri, Pariush Divsalar, Peter J. McLane,


and Marvin K. Simon, Introduction to Trellis-Coded
Modulation with Applications, Macmillan (1991).

2. Robert G. Gallager, Information Theory and Reliable


Communication, J. Wiley (1968), Chapter 6.
3. S.W. Golomb, Shift Register Sequences, Holden-Day
(1967).
4. Rajiv Laroia, Nariman Farvardin, and Steven Tret-
ter, "On SVQ Shaping of Multidimensional Con-
stellations - High-Rate Large-Dimensional Constel-
lations," Proceedings of the 26th Annual Conference
on Information Sciences and Systems, Princeton Uni-
versity, March 1992, pp. 527-531.
Index

Adaptive equalizer, see Equalizer 66-67 raised cosine, 106


AGC, 127 modulation index, 66 excess
AIC,8 overmodulated, 66 bandwidth
adjusting the sampling pre-envelope, 68 factor, 106
phase, 132-134 sidebands, 66 frequency
filter cutoff frequencies, single tone, 65 response, 106
45 spectrum, 66 impulse
must continuously receive Analog Interface Chip, see AIC response, 106
samples, 171 Analytic signal, 68 splitting between transmit
setting input clock Fourier transform of, 68 and receive filters, 106
frequency, 17 Archiver, 17 square-root of raised
setting the sampling ar30 command line cosine, 106
rate, 45 example, 17 in V.22bis
aic.h,18 ASM30.EXE, 9 modem, 121
ALU, 5 sl options, 13 Baud,103
internal buses, 5 Autocorrelation function, 55 Baudot, 103
AM, see Amplitude modulation Automatic gain control, 127-129 Benchmarking, 12,46--47
Amplitude modulation, 65-71 Auxiliary register, 5 BERT test, 99
carrier frequency, 65 arithmetic units Bit-reversed addressing, 54
carrier wave, 65 (ARAU's),5 Blind equalization, 146-147
complex envelope, 68 Break point, 12
envelope, 65 Balanced mixer, 74 Buses, external
envelope detector, 66 Barrel shifter, 5 expansion, 6, 23
using Hilbert Baseband shaping filter primary, 19
transform, 68 in PAM transmitter, 105 primary bus, 6
square-law, in QAM transmitter, 115 Butterfly, 53

187
188 Index

C Compiler program for FIR filter, 33 Costas loop, 74-76


Borland,60 C implementation, 33 linearized loop transfer
Borland C, 163 hardware circular function, 76
for TMS320C30, 9 addressing, 33 CPU
calling assembly mail box for PAM register file, 5
language transmit samples, 112 auxiliary
function, 36 CL30.EXE,9 registers
\#include, 19 command line example, (ARO-AR7), 5
optimizer, 48 14,17,24,25 extended
C Source Debugger, 8-11, 24 -i option, 19 precision
benchmarking, 12 -x option, 26 registers, 5
break point, 12 -z option, 14 index registers, 5
commands Coherent receiver interrupt enable
go, 11 for DSBSC-AM, 73 register (IE), 5
load, 11 Complex envelope, 68 stack pointer
reset, 11 with Costas loop, 74 (SP),5
restart, 11 Fourier transform of, 68 status register
runb,12 lower sideband SSB, 80 (ST),5
wa,12 of QAM signal, 116
modes SSB Fourier transform, DCE,97
Assembly, 10 79 Decimation-in-time,53
Auto, 10 upper sideband SSB, 80 DFT, see Discrete Fourier
Mixed,10 Constellation, 115 transform
windows inphase component, 115 Differential encoding
CALLS, 10 a 16-point QAM for V.22bis and V.32
COMMAND, example, 116-118 modems, 117
10 90° rotational Digital filter
CPU, 10 invariance, 116 amplitude response, 29
DISASS- mapping input FIR filters, 30-40
EMBLY, bits to design program
10 constellation REMEZ-
DISP, 10 points, 87.EXE,31
FILE,10 116, 119 design program
MEMORY, 10 a 4-point QAM example, WINDOW.
PROFILE,10 119 EXE,30
WATCH,10 mapping input frequency response, 29
c30start.c, 20 bits to IIR filters, 40-44
Cache, 23 constellation design program
cache_on (), 23 points, 119 IIR.EXE,41
Circular buffers 32-36 quadrature component, type 0 direct
assembly language 115 form, 40
instructions, 33 Constellation shaping, 162 type 1 direct
assembly language Convolution, 29 form, 41
Index 189

type 2 direct tracking, 158 communicating with PC,


form, 41 LMS adaptation, 156 163
Discrete Fourier transform, 52 near-end canceller, Data Transfer Register
Discrete-time Fourier transform, 155-157 163-165
51 near-end echo source, 154 DSP read/write flags for
DMA,6 subcanceller, 155 the PC, 165
C callable utility EIA,97 interrupts to
functions, 27 Envelope TMS320C30, 165
data transfers between PC of AM signal, 65 macros for PC to access
and EVM, 167-168 complex, 68 EVM registers, 163-164
interrupts to CPU, 26 pre-envelope, 68 PCIEVM control register
read/write operation, 26 real,68 map, 165
registers Envelope detector, 66 EVM, see Evaluation Module
Destination using Hilbert EVM30.EXE, 8, 9, 24
Address, 26 transform, 68 EVM30W.EXE, 9
Global Control, square-law, 66-67 EVMLOAD.EXE, 10
26 Environment variables exp_wait (), 23
Source Address, C\_DIR, 19 Eye diagram, 107
26 C,-OPTION, 14, 19
Transfer Equalizer Fast Fourier transform, 53-59
Counter, 26 blind, 146-147 butterfly, 53
synchronization to decision directed training, computational
interrupts, 26 129, 140 complexity, 54
Dotting sequence, 112 fast training, 161 decimation-in-time
Double-sideband suppressed fractionally spaced, algorithm, 53
carrier AM, see DSBSC-AM passband, complex, bit reversed
DSBSC-AM,73-78 127-128, 137-142 input order, 54
Fourier transform of ideal reference training, to estimate a power
signal,73 140 spectrum, 54-59
ideal coherent receiver, the LMS adaptation R2DIT.ASM, 60
73-74 algorithm, 140-142 radix-2 C function, 54
signal equation, 73 theoretical FFT, see Fast Fourier transform
DTE,97 behavior, FIR filters, see Digital filter
140-142 Floating point format
Echo canceller, 153-159 minimum mean-squared conversion from TI to
block LMS adaptation, error tap values, IEEE,60
157 138-140 FM, see Frequency modulation
data-driven, Nyquist, phase-splitting Fourier transform
in-band, 154-158 fractionally discrete, 52
far-end canceller, spaced, 142-144 discrete-time, 51
157-158 tap leakage, 142 fast Fourier transform,
far-end echo source, 154 Evaluation Module, 7, 44-46 53-59
far-end frequency offset amplifier gains, 44 Frequency discriminator, 86-87
190 Index

Frequency division multiplexing, Hilbert transform, 67-68 lSI, see Intersymbol interference
81, 121 at Costas loop input, 74 ITU,1I5
Frequency modulation, 85-90 in envelope detector, 68
Carson's rule for filter design by Kaiser window, 30
bandwidth, 86 REMEZ87, 31, 70
demodulation by filter design by Laroia, 162
frequency WINDOW,30, 70 Linker, 9
discriminator, 86-87 infrequency aligning named sections,
formula for FM signal, 85 discriminator, 87 33
frequency sensitivity, 85 in frequency translator, 81 command file, 9
instantaneous frequency, at PLL input, 87 example, 15
85 in QAM demodulator, -i option, 19
linearized model for PLL, 120 -I option, 19
88 in SSB modulator, 80 memory map, 15
modulation index, 86 Huffman transform, 92 section
narrow band FM, 86 Hybrid,153 allocation, 15
phase-locked loop Lissajous figure, 44
demodulator, 87-89 IEEE floating point format, 60 LMS, see Equalizer and echo
signal pre-envelope, 87 IIR filter, see Digital filter canceller
single tone example, 86 IIR.EXE,IO LNK30.EXE, 9
Bessel function Impulse modulator Local loop, 153
series, 86 in PAM transmitter, 103 Local oscillator, 74
Frequency translation, 81-82 in QAM transmitter, 115 Lucky, 137
Full duplex, 120 Include directive, 19
Instantaneous frequency, 85 m sequence, 91
Gaussian noise, 99 Interpolation filter bank, 107-108 Mail box, 112
additive Gaussian noise for QAM passband Matched filter, 99
channel,99 shaping filter, 120 Maximal length sequence, 91-92
bit-error Interrupts, 6 Memory map in linker command
probability for CPU interrupt by DMA, file, 15
binary symbols, 26 Modem
9 dummy C interrupt answer, 121
approximation for tail handler, 16 calling or originate, 121
probability,99 handling by TMS320C30, V.22bis, 116, 120--121
Godard 25 carrier
blind equalization, 146 interrupt enable register frequencies,121
QAM clock recovery (IE),5 S 1 sequence,
method,130 by serial port, 25 123
Gray coding, III vectors, 13 V.32,116
Intersymbol interference, 105- V.32bis, 153
Hamming window, 30, 52 107 V.34,153
Hanning window, 52 time-domain criterion for Modulation index for AM, 66
Harashima, 162 no lSI, 105 Multiplier,S
Index 191

Nyquist criterion for no lSI, Pulse amplitude modulation, modulation


105-106 103-113 Quadrature amplitude modulation
Nyquist frequency, 106 baseband shaping filter, automatic gain control,
105 129
pO_init (), 17 criterion of no a basic transmitter,
pO_xmit (), 17 intersymbol 115-116
PAM, see Pulse amplitude interference, 105 baseband
modulation Nyquist criterion inphase
Passband shaping filter, 119-120 for no lSI, and quadrature
Periodogram, 54 105-106 signal
Phase detector, 87 raised cosine, components, 15
Phase-locked loop, 74 106 baseband shaping filter,
for FM demodulation, split between 115
87-89 transmit carrier detect block, 127
for QAM carrier tracking, and receive carrier detect subsystem,
144-146 filter, 106 129
for symbol clock square-root of carrier frequency
tracking, 129-132 raised cosine, requirement, 116
for tracking frequency 106 channel symbol rate, 115
offset of far-end echo, block diagram of PAM constellations
158 system, 104 4-point example,
Phase splitter, 127 dotting sequence, 112 119
Pilot tone, 82 example of uniformly 16-point
PLL, see Phase-locked loop spaced symbol levels, example,
PN sequence, 91 103 116-118
Post detection filter, 74 eye diagram, 107 90° rotational
Power meter, 70 formula for transmitted invariance, 116
Power spectral density estimation, signal,105 differential
54-59 impulse modulator, 103 encoding
Pre-envelope, 68 intersymbol interference, for V.22bis and
of DSBSC-AM signal, 74 105-107 V.32,117
for FM signal, 87 receive filter, 105 mapping input
in FM PLL demodulator, symbol clock recovery, bits to constell-
87 109-110 ation points,
Fourier transform for SSB symbol error probability, 118-119
signal,79 108-109 decision directed carrier
ofQAM signal, 116 transmit filter, 103 tracking, 144-146
pri_wait (), 23 implementing by equalizer
Primitive polynomial, 92 interpolation decision directed
two degree 23 primitive filter bank, training, 140
polynomials, 94 107-108 fractionally
Product modulator, 74 spaced com-
PSK,119 QAM, see Quadrature amplitude plex, 127-128,
192 Index

137-142 filter, 132 for maximal


ideal reference length,92
training, 140 Raised cosine baseband shaping forV.32
theLMS filter, 106 scramblers, 94
algorithm, excess bandwidth factor maximal length, 92
140-142 n,106 period, 92-93
minimum frequency response, 106 properties of maximal
mean-squared impulse response, 106 length sequences, 93
error tap Random walk filter, 132 correlation
values, 138-140 RASCOS.EXE, 11 property, 93
phase-splitting Rectangular window, 52 frequency of l's
fractionally Relocatable object file, 13 and O's, 93
spaced, REMEZ87.EXE, 10 runs of l's and
142-144 RS-232C interface, 97-98 O's, 93
tap leakage, 142 25-pin connector signals, recurrence formula, 92
equation for transmitted 97-98 Sideband
signal, 116 mark voltage level, 97 lower, 73
ideal demodulators, 120 space voltage level, 97 upper, 73
using Hilbert Single-sideband modulation, 79-
transform, 120 SI sequence, 123 83
using product Scrambler, self synchronizing, coherent demodulation,
modulators, 120 93-94 80-81
impulse modulator, 115 connection polynomials complex envelope
modulator in terms of for V.32, 94, 117 lower sideband
complex signals, 117 descrambler, 94 case, 80
passband shaping filter, input/output equation, 94 upper sideband
119-120 lock-up condition, 94 case, 80
pre-envelope of signal, for V.22bis modem, 116 complex envelope Fourier
116 Serialports,6 transform, 79
a receiver block diagram, control register settings for lower
128 for Chapter 10, 100-101 sideband case,
receive filter, 127 formula for timer 80
slicer frequency, 10 1 for upper
for 4-point Global Control Register, sideband case,
V.22bis 17 80
constell- XRDY flag, 17 demodulation using a
ation, 148 Transmit Data Register, pilot tone, 82-83
symbol clock recovery, 17 lower sideband filter, 79
129-132 Shell mapping, 162 lower sideband signal
adjusting AIC Shift register sequence generator, using Hilbert
sampling phase, 92-93 transform, 80
132-134 connection polynomial, mixer and filter
random walk 92-93 modulator, 79
Index 193

modulator using Hilbert internal buses, 6


transform, 80 memory organization, 5
pre-envelope Fourier serial ports, 6
transform, 79 timers, 6, 17
upper sideband filter, 79 Tomlinson, 162
upper sideband signal Trellis coded modulation, 161
using Hilbert
transform, 80 V.22bis modem, 116, 120-121
Slicer, 128 carrier frequencies, 121
for 4-point V.22bis and S1 sequence, 123
V.32 constellations, 148 V.32 modem, 116
SQRTRACO.EXE, 11 V.32bis modem, 153
Square-root of raised cosine V.34 modem, 153
shaping filter, 106 VCO, see Voltage controlled
in V.22bis modem, 121 oscillator
SSB modulation, see Voltage controlled oscillator, 85,
Single-sideband modulation 87
Stack pointer, 5
Wait states, 6
to_init (), 17 setting number, 19
tOyeriod (), 17 Widrow,137
to_reset (), 17 Window functions, 51-52
Tap leakage, 142 Hamming, 30, 52
TI bulletin board, 60 Hanning, 52
Timers, 6, 17 Kaiser, 30
Counter Register, 17 rectangular, 52
Global Control Register, WINDOW.EXE, 10
17
Period Register, 17
setting frequency, 11
TIMERS.Lffi, 17
TMS320C30
bit-reversed addressing,
54
cache,23
CPU,5
ALU,5
multiplier, 5
DMA,6
external buses, 6
expansion, 6, 23
primary,6,19
instruction set, 6

Вам также может понравиться