Disclosure of Invention
The invention aims to provide a method for jointly verifying DSP codes, which improves the reliability and efficiency of a DSP code verification process and saves time and human resources.
The technical scheme for realizing the purpose is as follows:
a method for jointly verifying DSP codes is based on MATLAB and CEVA DSP chips and comprises the following steps:
step S1, creating a DSP use case parameter table set;
step S2, creating an MATLAB reference model of the DSP code to be verified by using the MATLAB;
step S3, defining data interacting with MATLAB in DSP code;
step S4, the MATLAB reads the parameters of one instance of the DSP in sequence and generates random data as input data, calls a CEVA DSP debugging process to carry out operation after each reading, and keeps the operation result;
step S5, using the same use case parameters and input data to call the compiled MATLAB reference model to carry out operation, and keeping the operation result;
step S6, comparing the operation result of the MATLAB reference model with the operation result of the CEVA DSP debugging process, storing the current comparison result, and if the comparison result is inconsistent, storing the current case parameters, the input data, the operation result of the MATLAB reference model and the operation result of the CEVA DSP debugging process;
and step S7, if the current use case parameter is not the end of the use case parameter table set, returning to step S4, reading the next use case parameter to continue verification, otherwise, terminating verification.
Preferably, the step S1 includes: establishing an Excel file, and writing all use case parameters into the Excel file, wherein each set of use case parameters in the Excel file corresponds to one verification use case.
Preferably, the step S2 is: and analyzing the functions of the DSP codes to be verified, and writing an MATLAB reference model with the same functions by using MATLAB.
Preferably, the data interacted in step S3 refers to: and the input and output data and parameters are used for transmitting the parameters of the case to be verified between the MATLAB process and the DSP process.
Preferably, the step S4 includes:
MATLAB reads the parameters of the current use case;
MATLAB generates random data as input data of the current use case;
the MATLAB calls a session establishing interface provided by the CEVA to establish a session between the MATLAB and the DSP, and opens a CEVA DSP debugging process;
the MATLAB calls a data writing interface provided by the CEVA to write the use case parameters and the input data into the parameter section and the input data section planned by the DSP;
the MATLAB calls a command line interface provided by the CEVA to load a DSP executable program;
the MATLAB calls a command line interface provided by the CEVA to run a DSP program;
the MATLAB calls a data acquisition interface provided by the CEVA to read the DSP operation result into the MATALB from the output data segment planned by the DSP and store the DSP operation result;
MATLAB calls a command line interface provided by CEVA to reset the CEVA DSP debugging process.
Preferably, the step S5 includes:
reading the current case parameters;
and configuring the current use case parameters and the input data to an MATLAB reference model for operation, and storing an operation result.
Preferably, in the step S6,
if the operation result of the MATLAB reference model is consistent with the operation result of the CEVA DSP debugging process, directly writing the comparison result into a log file;
and if the operation result of the MATLAB reference model is inconsistent with the operation result of the CEVA DSP debugging process, writing the comparison result into a log file, and storing the current case parameters, the input data, the operation result of the MATLAB reference model and the operation result of the CEVA DSP debugging process.
The invention has the beneficial effects that: the invention utilizes the respective advantages of the MATLAB and the CEVA DSP, realizes the verification of the DSP code function by comparing the operation result of the MATLAB reference model with the operation result of the CEVA DSP debugging process, has simple realization and complete case coverage, improves the reliability and efficiency of the DSP code verification process, and saves time and manpower resources.
Detailed Description
The invention will be further explained with reference to the drawings.
Referring to fig. 1, the method for jointly verifying DSP codes according to the present invention, based on MATLAB and CEVA DSP chips, includes the following steps:
and step S1, creating a DSP use case parameter table set. Namely: find out all the expected parameters of the DSP and analyze the number of parameter combinations. Establishing an Excel file, and writing all use case parameters into the Excel file, wherein each set of use case parameters in the Excel file corresponds to one verification use case.
Step S2, create an MATLAB reference model using MATLAB that requires verification of DSP code. Namely: and analyzing the functions of the DSP codes to be verified, and writing an MATLAB reference model with the same functions by using MATLAB.
Step S3, data interacting with MATLAB is defined in the DSP code. The data refer to: and the input and output data and parameters are used for transmitting the parameters of the case to be verified between the MATLAB process and the DSP process. For example: the following structure is declared in the DSP code:
int in __attribute__((section(".DSECT in_var")))
int out __attribute__((section(".DSECT out_var")))
struct para_t para __attribute__((section(".DSECT para_var")))
wherein in is input data interacted with the MATLAB, out is output data interacted with the MATLAB, and para is a use case parameter interacted with the MATLAB. The DSP uses the data in, out, para respectively as the input, output and parameters of the current verification.
And step S4, the MATLAB reads the parameters of one instance of the DSP in sequence and generates random data as input data, the CEVA DSP debugging process is called to carry out operation after each reading, and the operation result is reserved. The method specifically comprises the following steps:
1) MATLAB reads the current use case parameters. The code is for example:
para ═ xlsread ('para.xlsx'); % read-in case set
CurrentPara ═ Para { i }; the ith row in the% use case set is used as the current parameter, and i is the number of the currently executed use case.
2) MATLAB generates random data as input data of the current use case. The code is for example:
in=randi([0 1],Length,1);
the Length is the Length of the generated data and is determined by the configuration in Para.
3) And the MATLAB calls a session establishing interface provided by the CEVA to establish a session between the MATLAB and the DSP, and opens a debugging process of the CEVADSP.
4) And the MATLAB calls a data writing interface provided by the CEVA to write the use case parameters and the input data into the parameter section and the input data section planned by the DSP.
5) MATLAB calls the command line interface provided by CEVA to load the DSP executable.
6) MATLAB calls a command line interface provided by CEVA to run a DSP program.
7) And the MATLAB calls a data acquisition interface provided by the CEVA to read the DSP operation result from the output data segment planned by the DSP into the MATALB and store the DSP operation result. The code is for example:
% set session and open process in background
openDbg3('example',0,'cevax16');
% load DSP executable
runCliCmd('load coff expdbg.a');
% setting input, output and parameters of DSP current case
setData('in_var',in);
setData('out_var',out);
setData('para_var',para);
% execution of current use case
runCliCmd('run');
% obtaining DSP operating results
DspOut=getData('out_var',1);
res(i)=DspOut;
8) MATLAB calls a command line interface provided by CEVA to reset the CEVA DSP debugging process. The code is for example:
runCliCmd('reset')。
and step S5, reading the current use case parameters and the input data, configuring the current use case parameters and the input data to an MATLAB reference model for operation, and storing the operation result. The MATLAB reference model is called in MATLAB, the code is as follows: MatlabOut ═ dspfix model (in, para).
And step S6, comparing the operation result of the MATLAB reference model with the operation result of the CEVA DSP debugging process, storing the current comparison result, and if the comparison result is inconsistent, storing the current case parameters, the input data, the operation result of the MATLAB reference model and the operation result of the CEVA DSP debugging process for subsequently locating and comparing the inconsistent reasons. Whether consistent or not, the comparison result is written into the log file. The code is as follows:
if(isequal(DspOut,MatlabOut))
save_normal_log(i);
else
save_wrong_case(i,in,DspOut,MatlabOut,CurrentPara);
end
wherein, the save _ normal _ log is a function for saving normal use case log files, and the key codes are as follows:
fid=fopen(‘log.dat’,’a’);
fprintf (fid, 'case% d success \ n', i); % i is the number of the current case
fclose(fid);
Wherein, save _ wrong _ case is a function for saving abnormal use case log files, and the key codes are as follows:
fid=fopen(‘log.dat’,’a’);
fprintf (fid, 'case% d fail \ n', i); % i is the number of the current case
fclose(fid);
fid=fopen([‘case_’num2str(i)’_in.dat’],’w’);
for idx=1:length(in)
fprintf(fid,'0x%08X\n',in(idx));
end
fclose(fid);
fid=fopen([‘case_’num2str(i)’_out.dat’],’w’);
for idx=1:length(out)
fprintf(fid,'0x%08X\n',out(idx));
end
fclose(fid);
fid=fopen([‘case_’num2str(i)’_para.dat’],’w’);
for idx=1:length(CurrentPara)
fprintf(fid,'0x%08X\n',CurrentPara(idx));
end
fclose(fid);
And step S7, if the current use case parameter is not the end of the use case parameter table set, returning to step S4, reading the next use case parameter to continue verification, otherwise, terminating verification.
The above embodiments are provided only for illustrating the present invention and not for limiting the present invention, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, and therefore all equivalent technical solutions should also fall within the scope of the present invention, and should be defined by the claims.