Follow us on Facebook
Follow us on Twitter
Signalogic on LinkedIn

Modifying Hypersignal DSP Source Code

Following is general information concerning modification of the DSP Source Code Interfaces used by Hypersignal software. The information is given in general terms; for information on specific devices supported, such as ADSP-21xx, ADSP-2106x, DSP32C, DSP5600x, DSP9600x, and TMS320C2x/C3x/C4x/C5x, please refer to the Hypersignal-Macro Series Hardware Reference Guide, chapter 4.

Below are the subjects on this page:

Introduction

The Hypersignal DSP Source Code Interfaces include DSP and math library routines and also real-time, interrupt-driven structures that allow foreground and background processing in conjunction with analog I/O or digital I/O sample interrupts. Initially, the source code supports standard Hypersignal operation, including instrumentation displays, continuous transfer to/from disk, and file-based function acceleration, with no programming required. In other words, if you were to assemble and link the source code for a specific DSP chip as it was shipped, without any changes, you would end up with the distribution object file that is sent with every basic Hypersignal package. However, the source code could then be modified and/or added to in order to enhance the baseline Hypersignal operations or add new functions entirely. Changes can be as simple as interfacing to new analog converters or as complicated as simulating and testing complete algorithms by transferring data between the DSP board and Hypersignal software resources (including hard disk and video display) using pre-defined buffer-switching mechanisms and real-time interrupt structures.

Important Notes

Application Examples

DSP Source Code Interfaces include DSP and math library routines and also real-time, interrupt-driven structures that allow foreground and background processing in conjunction with analog I/O or digital I/O sample interrupts. Initially, the source code supports standard Hypersignal operation, including instrumentation displays, continuous transfer to/from disk, and file-based function acceleration, with no programming required. In other words, if you were to assemble and link the source code for a specific DSP chip as it was shipped, without any changes, you would end up with the distribution object file that is sent with every basic Hypersignal package. However, the source code could then be modified and/or added to in order to enhance the baseline Hypersignal operations or add new functions entirely. Changes can be as simple as interfacing to new analog converters or as complicated as simulating and testing complete algorithms by transferring data between the DSP board and Hypersignal software resources (including hard disk and video display) using pre-defined buffer-switching mechanisms and real-time interrupt structures.

A simple example might be to create user-written DSP source code that might perform some algorithm or feature extraction. Following this, Hypersignal can be instructed to use the new executable DSP file(s) as needed, causing the new user-written algorithm(s) to execute. This type of modification process basically allows you to concentrate on the problem at hand, since the Hypersignal high-level host software performs all of the housekeeping associated with controlling the DSP board, downloading executable code, and transferring blocks of real-data between host and DSP board memory. Furthermore, if you maintain compatibility with internal Hypersignal data and waveform file formats, then more housekeeping tasks such as file creation, graphical analysis, etc. can be left to Hypersignal.

Following are some more detailed examples of using the DSP Source Code Interface. Lets suppose that you had one of the DSP boards that is supported by Hypersignal, but needed to interface the board to a target analog section of your own design. If you had the DSP source code for the appropriate chip family, this would be trivial. First, you would change the interrupt service routine for the Hypersignal function that you wanted to get working. Depending on the chip family there is generally a few different interrupt service routines for each function, organized by board manufacturer. The changes you would make here would be minor: ensuring that the code read your A/D port address instead of the supported board's standard address. Next, you might have to change the system initialization module if the interrupt source/level for your analog hardware is different. Everything else would be left alone: buffering of the data, transfer to the high-level host software, and processing of the data (although you might want to change that, too, at some point). Next, you would assemble the modules changed using the "ASM" batch file provided for each chip family. Finally, you would invoke the "LNK" batch file, and copy the resulting linker output file (".OUT" is default output filename extension for linkers provided by most DSP chip manufacturers) to your working Hypersignal directory. When you next invoked Hypersignal, this file would be ready for downloading and subsequent execution without any further effort.

As another example, let's suppose you wanted to take a supported board, and working with the board's standard analog I/O, implement all or part of a time domain algorithm on the board and stream the real-time results to hard disk for later evaluation and display. If you first make the assumption that when running this function from Hypersignal you will ask for two-channel operation, you could simply alter the foreground processing to apply your algorithm to every other sample in the input buffers as they become ready. This is possible because multichannel data in Hypersignal is always transferred and processed in interleaved form; indeed, the high-level host software can be instructed to acquire/generate N channel data whether the board has N channels or not. Whether this works depends totally on the low-level DSP source code. After modification of the foreground module, and/or addition of new, user-defined routines, subsequent execution of Hypersignal with 2-channel operation specified would produce raw input data on the first channel, and processed data on the second channel. FFT operation on such a waveform would be automatic, since Hypersignal still thinks this is a "stereo" waveform, allowing convenient comparison viewing and evaluation in the frequency domain as well.

As a third example, consider using a supported board to simulate an entire project, maintaining just enough of the Hypersignal interface and real-time data transfer mechanism to allow real-time display of data, debug modes, and possible streaming of data to disk. After transferring code to your target system (via EPROM), there can be no doubt as to whether encountered problems are due to the software or the target hardware design--the Hypersignal simulation can always be easily run at any time as a check against the software design.

Other examples include adding DSP source code to support multiprocessing, interconnections between multiple boards, and other peripheral bus standards such as DT-Connect, measuring algorithms or parts of algorithms against a particular real-time sampling rate, evaluating the effects of finite word-length, and more.

Source Code Overview

In addition to basic DSP and math routines and analog I/O drivers for supported boards, DSP Source Code Interfaces also include basic "modes" of real-time or file-based acceleration operation shown below:
-

DSP Source Code Interface Operational Modes

Module

Hypersignal Function

oper. "mode"

MODUL0

Analog Conversion

mode=0

MODUL1

Analog Conversion, Playback from Waveform Display

mode=1

MODUL2

Digital Oscilloscope

mode=2

MODUL3

FFT file-based acceleration

mode=3

MODUL4

iFFT file-based acceleration

mode=4

MODUL5

Spectrum Analyzer

mode=5

MODUL6

Stimulus & Response operation

mode=6

MODUL7

Convolution/Correlation file-based acceleration

mode=7

MODULn

User-Defined function

mode=n


Interrupt Service Routines (ISRs)

There are various interrupt service routines that respond to interrupts on supported boards and generally match up with the foreground processing modules above. Interrupt service routine module names consist of "ISRn", where n indicates the operating mode (see above) that they support, for example "ISR0". Inside each interrupt service routine there are different entry points that contain hardware-specific input/output code for individual boards. These hardware-specific sections are kept as small as possible, so that the great majority of the routine is common for all boards. Examine the interrupt vector and mask initialization in the initial setup code in "xxxBEG", depending on board type (see host-shared variable "BOARD"), to locate the correct interrupt service routine for a particular function.

DSP Source Code Interface Partial File List

Source code (.asm files*) and related files contained in DSP Source Code Interfaces typically include:
-

Partial DSP Source Code Interface File List

xxxDEF.ASM

variable & constant definition module

xxxBEG.ASM

initialization, including ISR vectors

ISR0.ASM

A/D to disk ISR for all boards

ISR1.ASM

D/A from disk ISR for all boards

ISR2.ASM

Digital Scope ISR for all boards

ISR5.ASM Spectrum Analyzer ISR for all boards

ISR6.ASM

stimulus & response ISR for all boards

MODUL0.ASM

foreground A/D to disk processing (operating mode=0)

MODUL1.ASM

foreground D/A from disk processing (operating mode=1)

MODUL2.ASM

foreground Digital Oscilloscope processing (operating mode=2)

MODUL3.ASM

FFT file-based acceleration processing (operating mode=3)

MODUL4.ASM

iFFT file-based acceleration processing (operating mode=4)

MODUL5.ASM

foreground Spectrum Analyzer process (operating mode=5)

MODUL6.ASM

foreground stimulus & response process (operating mode=6)

MODUL7.ASM

convolution/correlation file-based acceleration (operating mode=7)

ARCTAN.ASM

arctangent routine

CONVLV.ASM

convolution/correlation routine

DIVF.ASM

floating-point divide routine

FFT.ASM

variable N (N=2m) FFT routine

FFTOUT.ASM

post-FFT processing (mag, phase, etc.)

LOG.ASM

log approximation routine

MAG.ASM

magnitude routine (complex input)

MAX.ASM

find maximum-in-buffer routine

MIN.ASM

find minimum-in-buffer routine

PHASE.ASM

4-quadrant phase routine (-π to +π; complex input)

SINTAB.ASM

sine value lookup-table for FFT use

SPAOUT.ASM

post-FFT processing for Spectrum Analyzer function, including mag, phase, power-spectra, log, scaling, and data manipulation

SQRT.ASM

squareroot routine

WINDOW.ASM

apply pre-defined window (used with FFTs)

FILTER.ASM

filter control routine for real-time filtering

FIR.ASM

FIR filter routine

IIR2.ASM

IIR (cascade sections, modified direct form) filter routine

IIR3.ASM

IIR (cascade sections, balanced pole-zero structure) filter routine

XFER.ASM

complex-ratio routine used for transfer function

USERPROC.C

entry point for user-defined real-time 'C' code

ASM.BAT

batch file used to assemble any source module: type "ASM filename" (no extension needed)

LNK.BAT

batch file used to link all source modules: type "LNK"

xxxLINK.CMD**

link control file (command file for linker)

*filename extension is ".s" for DSP32C or DSP3210, ".dsp" for ADSP-21xx, and ".src" for NEC 77220
**filename extension is ".ctl" for DSP5600x and DSP9600x

Source Code Modification Process

Below are the steps taken to modify, add, and integrate new source code:

1) Make changes to DSP source code, keeping in mind the necessary shared variables between Hypersignal and the DSP device (the xxxDEF.ASM file is well-documented in this area).

2) Assemble all modules changed and any new modules created to ensure a new object (.OBJ, .O, etc.) file is generated for each altered module. For convenience, an "ASM.BAT" batch file is been provided which you may use in the form of:

ASM filename <>

to assemble source code modules (entering an ".ASM" extension after "filename" is optional). This file executes a

ASMxxx -L %1

statement, where %1 is the filename.

If a new module has been created, be sure to add it to the xxxLINK.CMD or xxxLINK.CTL control file (use an ASCII text-editor to update linker control files).

3) Re-link all modules using the DSP chip vendor linker. A "LNK.BAT" batch file is provided which you may use by invoking:

LNK <>

to link all necessary object files. LNK.BAT executes a

LNKxxx xxxLINK.CMD

statement, where "xxxLINK.CMD" or "xxxLINK.CTL" is an ASCII linker-control file that specifies object files to be linked.

4) Copy the resulting ".OUT" file to the directory with Hypersignal software, run Hypersignal, and invoke the appropriate functions. Hypersignal reads the "COFF" file format directly, downloads all code and data, and begins execution at the reset vector (location zero).

Access and Control of User-Defined Source Code From Hypersignal

The Hypersignal-Macro family of software packages and the Hypersignal macro language contain features and functions that facilitate access and control of user-defined DSP source code, such as:

  • 1) The ability to specify different executable DSP files as the file to load and run when a DSP-based function or display is invoked from Hypersignal. In the System Configuration menu, entering a filename, such as "new.out", after the board designator will override the Hypersignal default filename.

  • 2) A macro language function (WriteDSPVal) that allows a macro to cause Hypersignal menu and internal values to be written to arbitrary locations in DSP memory.

  • 3) A macro language function (WriteDSPMem) that allows a macro to cause arbitrary values to be written to arbitrary locations in DSP memory.

For more information about the latter two functions, see Hypersignal-Macro Series Users Manual section 7.10, Macro Commands and Functions.

Note that both the WriteDSPMem and WriteDSPVal functions always make full-word accesses, depending on the natural word-length of the DSP device. This can affect the address value used, if the DSP is capable of accessing data pieces smaller than full-word length. Also, note that both functions are capable of accessing all memory types supported by the DSP chip. For a complete list of internal Hypersignal values that can be written to arbitrary DSP source code memory, see Appendix A, WriteDSPVal Constants, and for fully detailed information about the syntax and usage of these functions, see Hypersignal Users Manual section 7.10, Macro Commands and Functions.

Access and Control of User-Defined Source Code From DirectDSP DLL

For Windows C/C++ development, the DirectDSP DLL is strongly recommended, as it provides a thorough and flexible interface for user-defined C/C++, MATLAB®, and Visual Basic programs. DirectDSP includes several C/C++ demo programs and source code examples; project files are included for Borland C/C++ v3.1 and v4.5, Microsoft C/C++ v1.5, and Watcom C/C++ v10.0. Demo programs include digital oscilloscope, spectrum analyzer, strip-chart recorder, and digital tape recorder.

Click here for more information about DirectDSP® DLL software.

Click here to see excerpts from DirectDSP® DLL include (".h") files.