Disclosure of Invention
The invention aims to provide a method for jointly verifying a DSP code, which improves the reliability and efficiency of a DSP code verification process and saves time and manpower resources.
The technical scheme for achieving the purpose is as follows:
a method of jointly verifying DSP codes, based on MATLAB and CEVA DSP chips, comprising:
step S1, a DSP use case parameter table set is created;
step S2, utilizing MATLAB to create a MATLAB reference model of the DSP code to be verified;
step S3, defining data interacted with MATLAB in the DSP code;
step S4, the MATLAB sequentially reads one use parameter of the DSP and generates random data as input data, and calls a CEVA DSP debugging process to operate after each reading, and the operation result is reserved;
s5, calling the written MATLAB reference model to operate by using the same use case parameters and input data, and reserving an operation result;
step S6, comparing the operation result of the MATLAB reference model with the operation result of the CEVA DSP debugging process, and storing the current comparison result, if the comparison result is inconsistent, the current use case parameters, the input data, the operation result of the MATLAB reference model and the operation result of the CEVA DSP debugging process are also needed to be stored;
and S7, if the current use case parameter is not the end of the use case parameter table set, returning to the step S4, reading the next use case parameter to continue verification, and otherwise, terminating the verification.
Preferably, the step S1 includes: and 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 refers to: analyzing the function of the DSP code to be verified, and writing an MATLAB reference model with the same function by using MATLAB.
Preferably, the data interacted in step S3 refers to: the method is used for transmitting input and output data and parameters of the use case parameters to be verified between MATLAB and DSP processes.
Preferably, the step S4 includes:
MATLAB reads the current use case parameters;
MATLAB generates random data as input data of the current use case;
the MATLAB calls a session establishment interface provided by 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;
MATLAB calls a command line interface provided by CEVA to load a DSP executable program;
MATLAB calls a command line interface provided by CEVA to run a DSP program;
the MATLAB calls a data acquisition interface provided by CEVA, reads the DSP running result from the output data segment planned by the DSP into MATALB and stores the MATALB;
MATLAB invokes the command line interface provided by CEVA to reset the CEVA DSP debug process.
Preferably, the step S5 includes:
reading the current use case parameters;
and configuring the current use case parameters and the input data to the 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;
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 use case parameters, the input data, the operation result of the MATLAB reference model and the operation result of the CEVA DSP debugging process.
The beneficial effects of the invention are as follows: the invention utilizes the advantages of MATLAB and CEVA DSP, and realizes the verification of the DSP code function by comparing the operation result of MATLAB reference model with the operation result of CEVA DSP debugging process, thereby realizing simple realization, full coverage of use cases, improving the reliability and efficiency of the DSP code verification process and saving time and manpower resources.
Detailed Description
The invention will be further described with reference to the accompanying drawings.
Referring to fig. 1, the method for jointly verifying DSP codes of the present invention is based on MATLAB and CEVA DSP chips, and includes the following steps:
step S1, a DSP use case parameter table set is created. Namely: find all expected parameters of the DSP and analyze the number of parameter combinations. And 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.
And S2, utilizing MATLAB to create a MATLAB reference model of the DSP code to be verified. Namely: analyzing the function of the DSP code to be verified, and writing an MATLAB reference model with the same function by using MATLAB.
And step S3, defining data interacted with MATLAB in the DSP code. The data refer to: the method is used for transmitting input and output data and parameters of the use case parameters to be verified between MATLAB and DSP processes. For example: the following structures are 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 MATLAB, out is output data interacted with MATLAB, and para is use case parameter interacted with MATLAB. The DSP uses the data in in, out, para as the input, output and parameters for the current verification, respectively.
And S4, the MATLAB sequentially reads one use parameter of the DSP and generates random data as input data, and calls a CEVA DSP debugging process to operate 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 use case set
Currentpara=para { i }; the i-th line in the% use case set is used as the current parameter, i being the number of the currently executed use case.
2) MATLAB generates random data as input data for 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 calling the established session interface provided by CEVA by the MATLAB to establish the session between the MATLAB and the DSP, and opening the CEVA DSP debugging process.
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 invokes the command line interface provided by CEVA to load the DSP executable program.
6) MATLAB invokes the command line interface provided by CEVA to run the DSP program.
7) And the MATLAB calls a data acquisition interface provided by CEVA, reads the DSP running result from the output data segment planned by the DSP into MATALB and stores the MATALB. 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 of input, output and parameters of current use case of DSP
setData('in_var',in);
setData('out_var',out);
setData('para_var',para);
% execution of the current use case
runCliCmd('run');
% acquisition of DSP running results
DspOut=getData('out_var',1);
res(i)=DspOut;
8) MATLAB invokes the command line interface provided by CEVA to reset the CEVA DSP debug process. The code is for example:
runCliCmd('reset')。
and S5, reading the current use case parameters and the input data, configuring the current use case parameters and the input data to the MATLAB reference model for operation, and storing an operation result. And calling the MATLAB reference model in the MATLAB, wherein the code is as follows: matlabOut = dstfixemodel (in, para).
And 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 use case parameters, the input data, the operation result of the MATLAB reference model and the operation result of the CEVA DSP debugging process for later positioning and comparing the inconsistent reasons. And whether the comparison results are consistent or not, writing the comparison results 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
the save_normal_log is a function for storing log files of normal use cases, and key codes are as follows:
fid=fopen(‘log.dat’,’a’);
fprintf (fid, 'case% d success\n', i); % i is the current use case number
fclose(fid);
The save_wrong_case is a function for storing abnormal 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 current use case number
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 S7, if the current use case parameter is not the end of the use case parameter table set, returning to the step S4, reading the next use case parameter to continue verification, and otherwise, terminating the verification.
The above embodiments are provided for illustrating the present invention and not for limiting the present invention, and various changes and modifications may be made by one skilled in the relevant art without departing from the spirit and scope of the present invention, and thus all equivalent technical solutions should be defined by the claims.