IEEE TRANSACTIONS ON EDUCATION, VOL. 43, NO. 1, FEBRUARY 2000 19 Rapid Prototyping System for Teaching Real-Time Digital Signal Processing Woon-Seng Gan, Member, IEEE, Yong-Kim Chong, Wilson Gong, and Wei-Tong Tan Abstract A low-cost rapid-prototyping system using Texas Instruments' (TI) TMS320C30 Evaluation Module (EVM) based on the MathWorks' development software is presented in this paper. The rapid prototyping system serves as an educational tool in learning digital signal processing (DSP) and seeing the concept realized in real time. The development software modules, Simulink, uses graphical block diagrams to create models for real-time implementation and the real-time workshop (RTW), generates C code to be downloaded onto the EVM. The entire building process is fully automatic. This includes compiling, assembling, and downloading of the real-time algorithms. The system was found to be well suited for learning real-time DSP algorithms for both undergraduate and postgraduate levels. Index Terms Real-time signal processing, real-time workshop, simulink. I. INTRODUCTION DIGITAL signal processing (DSP) is an area of science and engineering that has developed rapidly over the past 30 years. DSP is becoming an important area in multimedia, digital communication, and consumer electronic products. It has enabled us to clean up noisy signals, speed up communications, store more data and much more. Unfortunately, the development of signal processing algorithms for real-time purposes are still difficult and often requires specialized training in a particular assembly language for the targeted DSP. Moreover, even if the skill is acquired, the process of project development is tedious and time consuming as the level of complexity increases. Hence, fast development tools for testing of new DSP algorithms are necessary, as the need to shorten the design cycle for new applications becomes critical. This is also true in conducting DSP courses, where students are required to develop and test various real-time DSP algorithms quickly on actual physical systems. One of the DSP development tools which produces code directly from block-set models is the real-time workshop (RTW) [1] for use with MATLAB and Simulink [2]. It automatically builds programs that can be run in a variety of environments, including real-time systems and stand-alone simulations. The RTW allows rapid prototyping, a process that conceptualizes solutions using a block diagram-modeling environment. It reduces algorithm coding to an automated process, which includes coding, compiling, linking, and downloading to the targeted Manuscript received July 29, 1998; revised November 3, 1999. The authors are with the School of Electrical and Electronic Engineering, Nanyang Technological University, Singapore. Publisher Item Identifier S 0018-9359(00)01447-3. hardware. Thereby, it shortens the development cycles and in turn, reduces cost. The code produced via RTW is in standard ANSI C code. The C language is a valuable programming tool for real-time computation. It has high-level language capabilities (such as structures and functions), as well as low-level assembly language capabilities (such as direct hardware input output and macros), which makes C an ideal language for digital signal processing. This paper presents the use of RTW with the TMS320C30-EVM [3] manufactured by Texas Instruments (TI) as the targeted hardware for general-purpose real-time applications. The use of integrated graphics allows visualization, which is very valuable in the rapid prototyping of DSP system. II. SYSTEM OVERVIEW The rapid prototyping system connects the MathWorks' development software Matlab, Simulink, and RTW with TI's plug-in board to form an integrated and ready-to-use development environment for real-time applications. It provides an automatic and seamless implementation of Matlab and Simulink graphical models onto real-time hardware systems for real-time signal processing. All Simulink models for which code can be generated by means of the RTW can be implemented. The package includes application modules that allow user to build complete programs targeting a wide variety of environments. The plug-in board also provides a low cost hardware implementation for the purpose of system integration. Program building is fully automated as shown in Fig. 1. The key aspect of rapid prototyping is automatic code generation. It reduces algorithm coding to an automated process; this includes coding, compiling, linking, and downloading to the targeted hardware. This automation allows design changes to be made directly to the block diagram and is ready for new test within seconds. A typical development and test session for a real-time application based on the implemented system comprises the following steps. Begin in the Simulink environment by creating DSP models. Run the model in Simulink; use Matlab, Simulink and toolboxes to develop algorithms and analyze the results. Once achieved the desired simulation results, use the RTW to generate C codes for real-time application. The RTW runs through all the necessary steps to prepare the application. Finally the application is downloaded to the floatingpoint TMS320C3x plug-in for real-time implementation. 0018 9359/00$10.00 2000 IEEE
20 IEEE TRANSACTIONS ON EDUCATION, VOL. 43, NO. 1, FEBRUARY 2000 A. The DSP Hardware TMS320C30 Evaluation Module (EVM) The TMS320C30-EVM has the ability to perform, in a single cycle, parallel multiplies and adds (subtracts) an integer or floating-point data. It gives the EVM its peak computational rate of 33.3 MFLOPS. Key features of the EVM include: 60-ns single cycle instruction time, 33.3 MFLOPS, 16.7 MIPS; 16-bit bidirectional PC host communications port; Voice quality analog data acquisition via the TLC32044 (AIC). Standard RCA jacks for line-level analog input and output; Two 1 K 32 single-cycle dual access RAM blocks; One 4 K 32 single-cycle dual access on-chip ROM blocks; 64 32-bit instruction cache; 32-bit instruction and data words, 24-bit addresses; 32/40-bit floating-point and integer multiplier; 32/40-bit floating-point, integer, and logical ALU; Eight extended precision registers (accumulators); Two address-generators with eight auxiliary registers; On-chip direct memory access (DMA) controller for concurrent I/O and CPU operation; Two serial ports. Serial port 0 is used for the on-board AIC. Two 32-bit timers Two general-purpose external flags; four external interrupts. Fig. 1. Development environments of the MathWorks and Texas Instruments' plug-in board. B. The MathWorks' Development Software The MathWorks' development software consisting of Matlab, Simulink, and RTW with the targeted hardware form an integrated and ready-to-use development environment for real-time applications. Simulink is a software package for modeling, simulating, and analyzing dynamic systems. It supports linear and nonlinear systems, modeled in continuous time, sampled time, or hybrid of the two. Systems can also be multirate, having different parts that are sampled at different rates. With this interface, models are built in a hierarchical form, using both top-down and bottom-up approaches. Simulink includes comprehensive block libraries that are grouped in separate libraries as illustrated in Fig. 2. The MathWorks offers block-sets for use with Simulink. Block-sets are collections of blocks for use in rapid prototyping and simulation of systems. With RTW, Simulink models can be run in real time on targeted DSP processor. It provides a real-time development environment that features: a rapid and direct path from system design to hardware implementation; seamless integration with Matlab and Simulink; a simple and easy to use interface; an open and extensible architecture; fully configurable code generator using target language compiler (TLC) [4]; fast design cycle by editing block diagrams and automatically building a new executable file. Fig. 2. The main Simulink library. The RTW includes a set of target files that are compiled by the TLC to produce ANSI C code. The target files are ASCII text files that describe how to convert the Simulink model to code. To create a target-specific application, RTW also requires a template makefile (*.tmf) that specifies the appropriate C compiler and compiler options for the building process. Target-specific versions of the run-time interface (a main file) must also be included to conform to the target specific requirements such as the interrupt service routine (ISR). III. SYSTEM CONFIGURATIONS FOR REAL-TIME PROGRAM BUILDING The program building process is initiated from Simulink's graphical user interface. After proper setup, the real-time algorithm is automatically generated using various software drivers described before. To automate the building process, proper system configurations on the hardware and the software drivers are necessary, as shown in Fig. 3. A. Configuration of Template Makefile The RTW uses *.tmf [2] to build the executable file from the generated code. A makefile is created from the *.tmf by copying each line from the latter. The makefile is then passed to a make utility which builds an executable file (*.out) from a set of files (e.g., model.c, *.h, etc.). The make utility will perform date
GAN et al.: RAPID PROTOTYPING SYSTEM FOR TEACHING REAL-TIME DIGITAL SIGNAL PROCESSING 21 Fig. 4. Make utility flow diagram. Fig. 3. The automatic build process for a real-time system. checking on the dependencies between the object (*.obj) and C files and rebuilds the object files if needed. The user may configure the building process by modifying the template makefile. When program building is invoked, the template makefile will be used to create a set of macro definitions and rules describing how to generate the executable file from the C-coded files. This automates the building of real-time program onto TMS320C30 EVM board, which involves definitions and rules declaration in the template makefile. Fig. 4 describes the flow of the make utility. B. Run-Time Interface Building the real-time program requires a number of source files in addition to the generated code. The run-time-interface [1] serves as an entry point for RTW to build the model code into a complete, stand-alone program. The main program is responsible for managing the execution of the real-time program created from the Simulink block diagram. It contains the program's main function main(), the ISR, and the step function. The main function controls program timing, creates tasks, installs interrupt handlers and performs error checking. The ISR is catered for use with the TMS320C30-EVM serial port. It fetches data, initiates data process function, and outputs data. The step Fig. 5. The interrupt timing. function performs computation of output values and updates the states of the blocks. C. Program Timing Real-time programs require careful timing of interrupts to ensure that model code executes to completion before another interrupt occurs. This timing duration includes reading and writing to/from external devices. The RTW supports both single-tasking and multitasking modes of execution for the generated code. Fig. 5 illustrates the requirements of the interrupt timing of a single-tasking system. The sample interval must be long enough to allow model code execution between interrupts. The left diagram shows an example of a real-time program that can complete one step within the interval. The rest of the duration may be utilized for other background tasks such as data logging. On the other hand, the one on the right results in an execution error. The sample interval is too short to complete one step of the generated code. Hence, it is important to set a suitable base sample time of the model to ensure real-time execution of the generated code.
22 IEEE TRANSACTIONS ON EDUCATION, VOL. 43, NO. 1, FEBRUARY 2000 Fig. 6. Fifth-order FIR implementation in Simulink. Fig. 9. Real-time waveforms observed using oscilloscope. the Simulink, the programs are automatically built by invoking the RTW. The models may be used for real-time application. Fig. 7. Passing a chirp signal through the fifth-order FIR Filter. A. The Direct-Form Finite Impulse Response (FIR) Filter Fig. 6 shows a fifth-order direct-form FIR filter. This model is created using elementary blocksets from Simulink libraries. Before the real-time application is generated, the filter model is put under test by passing a chirp signal through the FIR filter, as shown in Fig. 7. Observe the outcome with the scope in the diagram. Once the outcome satisfies the requirement, terminates the filter block with proper input output terminators. Then invokes the RTW to generate real-time application and automatically downloads to the targeted EVM hardware. Fig. 8 below shows the input and output waveforms observed under the simulation model, while Fig. 9 shows the actual real-time signals observed using an oscilloscope. Table I shows the various sample rates achievable for the real-time implementation of fifth-, tenth-, and 50th-order direct-form FIR filters: It must be pointed out that the C code generated by this first version of rapid prototyping tool is not the most efficient. The RTW has generated several redundant modules that are unnecessary and increase software overheads. We have taken steps to improve and modify the C code generated by the RTW and have achieved a substantial increase in performance. These techniques will be reported in a later publication. Fig. 8. Waveforms observed under simulation model. IV. BUILDING REAL-TIME DSP SYSTEMS This rapid prototyping platform has been assessed at the Nanyang Technological University and found to be well suited for learning real-time DSP algorithms for both undergraduate and postgraduate levels. In this paper, two practical DSP models, i.e., a finite impulse response (FIR) filter and a power spectrum estimation model using fast Fourier transform are illustrated. After testing the models by running simulations on B. Power Spectrum Estimation Using Fast Fourier Transform (FFT) The Fourier transform of the autocorrelation function yields the power density spectrum (PSD) [7], providing the transformation from the time domain to the frequency domain. The direct method of the energy density spectrum of a signal from its sample may be computed using the Fourier transform of
GAN et al.: RAPID PROTOTYPING SYSTEM FOR TEACHING REAL-TIME DIGITAL SIGNAL PROCESSING 23 TABLE I SAMPLING RATE ACHIEVABLE IN IMPLEMENTING DIRECT-FORM FIR FILTER Fig. 11. Model for power spectrum estimation of a signal. Hence, can be obtained using FFT, which is a common and important algorithm in DSP. Figs. 10 and 11 illustrate the implementation of the PSD of a signal using the structure of a radix-2 8-point FFT. The model was tested and downloaded onto the EVM board for real-time execution. It involved 6390 machine cycles in the ISR, which had a maximum achievable sampling rate of about 2.5 khz. This example shows that the FFT may also be easily implemented using this graphical approach. Fig. 10. The eight-point decimation-in-frequency FFT graphical structure and the basic butterfly for radix-2 FFT. The spectrum can be computed numerically at a set of frequency points by means of discrete Fourier transform (DFT). Thus V. CONCLUSION In the implementation of the rapid-prototyping system, the template makefile and the run-time interface file were highlighted. These files can be viewed as the drivers of the system, which links to the targeted hardware. The proper configurations of the targeted hardware TI's C30-EVM are crucial in implementing the general-purpose DSP system. The above discussion illustrated the use of the rapid prototyping system, where DSP concept may be implemented in real-time, using TI's TMS320C30-EVM system. It is a fully automated program building process, where the system is tested
24 IEEE TRANSACTIONS ON EDUCATION, VOL. 43, NO. 1, FEBRUARY 2000 prior to the generation of the executable file. This saves tremendous amount of time, besides reducing the hardware cost. In the continued effort to train more DSP engineer, the rapid prototyping system can help to speed up the learning and implementation of real-time DSP applications. We have used this rapid prototyping tool to teach a group of 30 undergraduates in learning fundamental DSP theory and real-time DSP concept. From the students' response, they can easily use this tool to construct different structures, size of digital filter and FFT s and change their parameters instantly. Furthermore, they can actually plug in real signals to the EVM and see how these signals are modified in real time. They were able to explore more challenging problems within the short lab session. Our experience has shown that this teaching platform has clearly heightened student interest in the learning of DSP algorithms. ACKNOWLEDGMENT The authors would like to acknowledge the support from TechSource Systems Pte Ltd. in sponsoring the software tools. They would also like to thank F. Hong for his valuable comments in this project. REFERENCES [1] For Use with SIMULINK: User's Guide Version 2.1, Real-time Workshop, The MathWorks Inc., 1997. [2] SIMULINK Dynamic System Simulation for MATLAB: User's Guide Version 2.1, The MathWorks Inc., 1997. [3] TMS320C3x: User's Guide, Texas Instruments, 1996. [4] SIMULINK Dynamic System Simulation for MATLAB: Target Language Compiler Reference Guide Version 1, The MathWorks Inc., 1997. [5] TMS320C30 Evaluation Module: Technical Reference, Texas Instruments, 1990. [6] Chassaing and Rulph, Digital Signal Processing with C and the TMS320C30. New York, NY: Wiley, 1992. [7] J. Proakis and D. Manolakis, Digital Signal Processing Principles, Algorithms, and Applications, 2nd ed. New York: Macmillan, 1992. Woon-Seng Gan (M 93) received the B.Eng. (1st Class Hon.) and Ph.D. degrees from the University of Strathclyde, U.K., in 1990 and 1993, respectively. He is currently an Associate Professor in the Nanyang Technological University, Singapore. His main interests include real-time DSP implementation for adaptive and audio signal processing applications. Yong-Kim Chong received the B.Eng. (Hon.) degree in electrical engineering from the National University of Singapore in 1986 and the M.S. degree in computer engineering from the University of Southern California in 1993. He is currently an Assistant Professor in the School of EEE at the Nanyang Technological University of Singapore. His research interests include computer architecture, parallel processing, and digital signal processing. Wilson Gong received the Bachelor of Engineering (electrical) degree from the Nanyang Technological University, Singapore. His area of interest is in audio signal processing and software programming. He has written several software products for leading semiconductor companies. Wei-Tong Tan received the Bachelor of Engineering (electrical) degree from the Nanyang Technological University, Singapore. His area of interest includes the wireless communications and DSP implementation for real-time systems. He has been involved in a few projects involving DSP implementation.