|
CD2450 Debugger Matlab Interface

Many system designers developing their products from algorithms may need
system level simulator. MATLAB is one of the most common tools for such
demands and yet reasonable enough for even individual usage. Clarkspur's
BUGSFINDER S/W debugger can be controlled from MATLAB through one simple
DLL program on Windows based PC. You can submit any BUGSFINDER command from
MATLAB command line with this DLL program in the command form of "CD2450('BUGSFINDER_command')"
. You can directly type in this command from the MATLAB prompt, or use it
in your XXX.m MATLAB script file.
1. MATLAB Control.
The MATLAB is a powerful algorithm
development tool widely used. You can reach MATH
WORK to get the product information.
You can construct your algorithm
using MATLAB support with its library without getting into a tricky DSP
program coding. After you confirm your algorithm with the MATLAB, you
need to get into the firmware coding for your target DSP. If you choose
the CD2450 DSP core as your target DSP, you can enjoy the BUGSFINDER S/W
debugger for this purpose. However, you probably wish to stay in MATLAB
and control the BUGSFINDER from MATLAB domain, so that all the works you
have done would be utilized to develop the DSP code. You might replace
only the part of your full algorithm with the real DSP code, and still
confirm the full algorithm.. etc.. You can check the function of one or
whole block by comparing the results from both MATLAB and DSP coding.
Even after you finish the DSP coding, you can use the MATLAB power as
the test bench of your firmware.
Fig.1 shows the idea of MATLAB
interface to an example program (G.726 ADPCM program).
Fig.1 CD2450 BUGSFINDER
MATLAB Interfacing.
2. An example.
Let's see how we can control
the BUGSFINDER from the MATLAB. This example uses the MATLAB as a simple
test bench that shows the input and output waveform for the CD2450 DSP
program: G726.X. The MATLAB loads a WAV file (inp.wav) and shows it on
your PC screen graphically, starts the BUGSFINDER to obtain the resulted
WAV file (out.wav), then shows the result waveform onto the same graphic
window for comparison. Actually, we can type every command step by step
from the MATLAB console window to follow this entire process. But, it
is far more practical to prepare a script file (demo.m) for repetitive
operation with minor trimming in the process. The Fig.2 is an example
of this demo.m script file for the MATLAB. The blue parts describe in
MATLAB intrinsic language, while the other black parts are using CD2450.DLL.
%---------------------------------------------------------------
%------ G.726 Evaluation MATLAB script 1999.2
%---------------------------------------------------------------
%------------ Show source file in graphic mode --------------
yin=wavread('inp.wav',120);
x=0:1:length(yin)-1;
plot(x,yin,'-b')
fprintf('Pause... Press \n')
pause
%----------------- load Clarkspur' BugsFinder -----------------
cd2450('init')
%----------------- DSP program load demo -----------------
cd2450('load g726.x')
%----------------- Breakpoints set demo ------------------
cd2450('disp brk')
cd2450('brk N=4000 always interrupt:2')
cd2450('brk read:ext3 always Read:ext3=inp.wav/wav')
cd2450('brk write:ext4 always Write:ext4=out2.wav/wav')
cd2450('brk prom:0x30d always refresh:2')
cd2450('brk prom:0x319 always write:ram0:0x15=data.hex/hex')
%---------- Set G726 Parameters -----------------
cd2450('set prom:0x35D=2')
cd2450('set prom:0x336=1')
%------------------ Start program demo ---------------------
cd2450('set pc=0')
cd2450('start')
%-----------------
cd2450('close data.hex')
cd2450('log history.log')
cd2450('res counter')
%----------------- Another Operation Mode -----------------
cd2450('brk N=4000 always interrupt:2')
cd2450('brk read:ext3 always Read:ext3=inp.wav/wav')
cd2450('brk write:ext4 always Write:ext4=out5.wav/wav')
cd2450('set pc=0')
cd2450('set prom:0x35D=5')
cd2450('set prom:0x336=1')
cd2450('start')
%----------------- Terminate Clarkspur' BugsFinder ---------
cd2450('exit')
%---------------- Show result file in graphic mode ---------
%----- DSP generates two samples for every input samle by
%----- simple interpolation. So, we need to decimate the
%----- output in 2 to 1 to match with the input file scale.
hold on
clear yout2 yout2c yout5 yout5c
yout2=wavread('out2.wav');
yout5=wavread('out5.wav');
for i=1:2:length(yout2)
yout2c(fix(i/2)+1)=yout2(i)*4;
end
for i=1:2:length(yout5)
yout5c(fix(i/2)+1)=yout5(i)*4;
end
x=0:1:length(yout2c)-1;
plot(x,yout2c,'-r')
x=0:1:length(yout5c)-1;
plot(x,yout5c,'-k')
hold off
|
Fig.2 MATLAB scriptfile
example.
When you see "cd2450('xxxx')"
in a line, that means "Execute the command xxxx on the CD2450 BUGSFINDER".
Other lines are MATLAB intrinsic command lines. You need to install the
CD2450.DLL program in your current path to enable the "cd2450('xxxx')"
commands.
We'll get a graphic window
like Fig.3 on the PC screen after the execution of the demo.m script file
on MATLAB.
Fig.3 MATLAB outputs a
graphic window to show the I/O waveforms.
|