CN112596735A - Code generation and integrated compiling method of encryption model - Google Patents

Code generation and integrated compiling method of encryption model Download PDF

Info

Publication number
CN112596735A
CN112596735A CN202011511657.6A CN202011511657A CN112596735A CN 112596735 A CN112596735 A CN 112596735A CN 202011511657 A CN202011511657 A CN 202011511657A CN 112596735 A CN112596735 A CN 112596735A
Authority
CN
China
Prior art keywords
model
file
encryption
code
code generation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011511657.6A
Other languages
Chinese (zh)
Inventor
王婧宇
严鉴铂
刘义
王鹏
王昱
尹欣欣
郝刘丹
崔强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Fast Auto Drive Co Ltd
Original Assignee
Xian Fast Auto Drive Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Fast Auto Drive Co Ltd filed Critical Xian Fast Auto Drive Co Ltd
Priority to CN202011511657.6A priority Critical patent/CN112596735A/en
Publication of CN112596735A publication Critical patent/CN112596735A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/47Retargetable compilers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/20Design optimisation, verification or simulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven

Abstract

The invention discloses a code generation and integrated compiling method for an encryption model, and belongs to the field of model development. The invention comprises the following steps: 1) establishing an algorithm model in an MATLAB environment, and preparing related options for automatically generating codes in the algorithm model; 2) setting the algorithm model, and exporting the algorithm model to an encryption model with the extension name of slxp; 3) compiling a script file for generating a make file corresponding to the encryption model; 4) compiling a script file for automatically calling an embedded compiler under an MATLAB environment; 5) writing an m file which can run in an MATLAB environment, putting the script files in the step 3) and the step 4) into the m file to run, and realizing one-key model generation codes and integrated compiling of the encryption model. The method is based on the design development process of the model in the MATLAB environment, and can generate embedded codes while protecting the model in the cooperative development process; not only meets the technical secrecy, but also facilitates the circulation of the model.

Description

Code generation and integrated compiling method of encryption model
Technical Field
The invention belongs to the field of model development, and particularly relates to a code generation and integrated compiling method for an encryption model.
Background
At present, a design and development process based on a MATLAB/Simulink model is widely applied and accepted in the field of automotive electronics. The code of the design and development process based on the MATLAB/Simulink model is generated by the model, the model is connected with the requirement in a hanging mode, and the embedded code can be directly generated once the embedded code is verified in the simulation.
In actual project application, as projects are larger and finer, work division is finer and finer, cooperative development becomes a normal state, mutual technical secrecy work also often occurs, a model or code made by one party cannot be seen by the other party, but the other party is required to run and generate an embedded code. There are several protection methods for the model/code in the collaborative development process, for example, the model is converted into S-Function to be delivered to another party for use, but this method cannot generate embedded code, or the code generated by the model is compiled into object code (. obj), but the other party can use the compiler and the embedded compiler under Windows for two times of compilation, so that the other party can use the model/code in simulation and perform embedded deployment in the Simulink environment.
Disclosure of Invention
The invention aims to overcome the defect that a model of a design development process partner of an MATLAB/Simulink model cannot run and generate embedded codes while being kept secret, and provides a code generation and integrated compiling method of an encryption model.
In order to achieve the purpose, the invention adopts the following technical scheme to realize the purpose:
a code generation and integrated compilation method for an encryption model comprises the following steps:
1) establishing an algorithm model in an MATLAB environment, and preparing related options for automatically generating codes in the algorithm model;
2) setting the algorithm model, and exporting the algorithm model to an encryption model with the extension name of slxp;
3) compiling a script file for generating a make file corresponding to the encryption model;
4) compiling a script file for automatically calling an embedded compiler under an MATLAB environment;
5) writing an m file which can run in an MATLAB environment, putting the script files in the step 3) and the step 4) into the m file to run, and realizing one-key model generation codes and integrated compiling of the encryption model.
Further, the specific operation in step 2) is as follows:
and packaging the algorithm module into an atomic unit, converting the atomic unit into a reference model, setting the reference model as a ProtectedModel, and outputting the algorithm module to be encrypted to a working path to form an encryption model with the extension name of slxp.
Further, the encryption model in the step 2) is read-only, simulation-only or only used for generating codes;
further, the generated code may be readable or unreadable.
Further, in the step 5), the one-key model generation code and the integrated compiling of the encryption model are realized by writing m files which can run in the Matlab environment.
Furthermore, a model-related initialization command and a data operation command are written in the m file, a model loading command and a model generation code command are written, and a copy command is written to organize generated codes in corresponding folders;
and then calling the command line program in the step 3) in the m file, and finally calling the command line program in the step 4) in the m file to finish the output of the whole project executable file.
Compared with the prior art, the invention has the following beneficial effects:
the code generation and integrated compiling method of the encryption model is based on the design development process of the model in the MATLAB environment, and can generate embedded codes while protecting the model in the cooperative development process; not only meets the technical secrecy, but also facilitates the circulation of the model.
Drawings
FIG. 1 is a flow chart of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The invention is described in further detail below with reference to the accompanying drawings:
referring to fig. 1, fig. 1 is a flowchart of the present invention, and the method for code generation and integrated compilation of an encryption model of the present invention includes the following steps:
1) formulating an automatic code generation configuration template based on a model, wherein the template is provided with a tlc template file required by the generation of the model code, a variable naming rule of the model generation code, a module generation code rule and other parameters;
2) and setting a required encryption module in the model. The invention uses a model encryption method, selects a model File-export model-ProtectedModel, and exports the model to an encryption model with the extension of slxp. The encryption can be selected from different levels, the encrypted model can be read only, simulated only or used for generating codes by the other side, the generated codes can also be selected to be readable or unreadable, and all the operations can be controlled in a password form, so that the realization is more convenient;
3) compiling script files, and automatically generating corresponding make files according to different encryption modules; the method avoids the problem that the make file used by calling a compiler in the Matlab environment needs to be rewritten every time due to different models developed by different developers and different model names and then different generated encryption models and code naming modes;
4) compiling a script file, realizing that an embedded compiler is directly called under a Matlab environment, completing the compilation of the whole project and obtaining an executable binary file;
5) and writing the encryption model into an m file which can run in a Matlab environment, and realizing one-key model generation codes and integrated compiling of the encryption model.
Examples
1) According to project requirements, establishing a corresponding algorithm model in a Matlab/Simulink environment, and setting a code-related configuration item automatically generated by the model under a Modelconfiguration parameters option in the model, wherein the code generation configuration item selects ert.tlc as a system target file and selects only generated codes;
2) according to different work assignments of project group members, the algorithm module needing encryption is set as follows: firstly, packaging an algorithm module into an atomic unit, converting the atomic unit into a reference model, and setting the reference model as a ProtectedModel, so that a module needing encryption is output to a working path to form an encryption model with an extension name of slxp;
3) writing related instructions in the m files, copying codes generated by the whole engineering model and codes generated by the encryption module into a specified folder;
4) writing a command line executive program to realize the automatic generation of the make file, wherein the specific mode is as follows: traversing all files c and h in the code folder, extracting file names to cache files, and writing the file names into corresponding positions in a make file template to complete the updating of the current project make file;
5) compiling a command line executive program to call a compiler under the Matlab environment and finish the code compilation of the whole project;
6) the method is characterized in that the method comprises the following steps of compiling an m file which can run in a Matlab environment, wherein the m file can run by one key to finish automatic code generation and integrated compilation of a model with an encryption module, and the specific mode is as follows: firstly, writing model-related initialization commands and data operation commands in m files, then writing model loading commands and model generation code commands, writing copy commands and the like to organize generated codes in corresponding folders, then calling the command line program in the step 3) in the m files, and finally calling the command line program in the step 4) in the m files to finish the output of the whole project executable file.
The above-mentioned contents are only for illustrating the technical idea of the present invention, and the protection scope of the present invention is not limited thereby, and any modification made on the basis of the technical idea of the present invention falls within the protection scope of the claims of the present invention.

Claims (6)

1. A code generation and integrated compilation method for an encryption model is characterized by comprising the following steps:
1) establishing an algorithm model in an MATLAB environment, and preparing related options for automatically generating codes in the algorithm model;
2) setting the algorithm model, and exporting the algorithm model to an encryption model with the extension name of slxp;
3) compiling a script file for generating a make file corresponding to the encryption model;
4) compiling a script file for automatically calling an embedded compiler under an MATLAB environment;
5) writing an m file which can run in an MATLAB environment, putting the script files in the step 3) and the step 4) into the m file to run, and realizing one-key model generation codes and integrated compiling of the encryption model.
2. The method for code generation and integrated compilation according to claim 1, wherein the specific operations in step 2) are:
and packaging the algorithm module into an atomic unit, converting the atomic unit into a reference model, setting the reference model as a ProtectedModel, and outputting the algorithm module to be encrypted to a working path to form an encryption model with the extension name of slxp.
3. The method for code generation and integrated compilation according to claim 1, wherein the encryption model in step 2) is read-only, emulation-only or only used for code generation.
4. The method for code generation and integrated compilation according to claim 3, characterized in that the generated code is readable or unreadable.
5. The method for code generation and integrated compilation of cryptographic models of claim 1, wherein the step 5) is implemented by writing an m-file operable in a Matlab environment to generate the code of the cryptographic model and integrate the compilation.
6. The method for code generation and integrated compilation of cryptographic models as recited in claim 5, wherein the model-related initialization command and the data execution command are written in an m-file, the model loading command and the model generation code command are written, and the copy command is written to organize the generated codes in corresponding folders;
and then calling the command line program in the step 3) in the m file, and finally calling the command line program in the step 4) in the m file to finish the output of the whole project executable file.
CN202011511657.6A 2020-12-18 2020-12-18 Code generation and integrated compiling method of encryption model Pending CN112596735A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011511657.6A CN112596735A (en) 2020-12-18 2020-12-18 Code generation and integrated compiling method of encryption model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011511657.6A CN112596735A (en) 2020-12-18 2020-12-18 Code generation and integrated compiling method of encryption model

Publications (1)

Publication Number Publication Date
CN112596735A true CN112596735A (en) 2021-04-02

Family

ID=75199624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011511657.6A Pending CN112596735A (en) 2020-12-18 2020-12-18 Code generation and integrated compiling method of encryption model

Country Status (1)

Country Link
CN (1) CN112596735A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190877A (en) * 2021-04-29 2021-07-30 网易(杭州)网络有限公司 Model loading method and device, readable storage medium and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365638A (en) * 2012-03-29 2013-10-23 北京九州华海科技有限公司 Single-chip microcomputer development system and method based on ECUCoder
US8843906B1 (en) * 2006-10-16 2014-09-23 The Mathworks, Inc. Inferring data types from compiler call site
US9417853B1 (en) * 2014-10-27 2016-08-16 Dspace Digital Signal Processing And Control Engineering Gmbh Method for generating a code for an electronic control unit
CN106371813A (en) * 2015-07-23 2017-02-01 广州汽车集团股份有限公司 Simulink-based motor controller software generation method for electric vehicle
CN106980499A (en) * 2017-02-16 2017-07-25 陕西法士特齿轮有限责任公司 A kind of integrated approach that upper layer logic and bottom code are realized based on MATLAB/Simulink
CN107656731A (en) * 2017-10-10 2018-02-02 株洲欧格瑞传动股份有限公司 An a kind of key Compilation Method for Matlab models

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8843906B1 (en) * 2006-10-16 2014-09-23 The Mathworks, Inc. Inferring data types from compiler call site
CN103365638A (en) * 2012-03-29 2013-10-23 北京九州华海科技有限公司 Single-chip microcomputer development system and method based on ECUCoder
US9417853B1 (en) * 2014-10-27 2016-08-16 Dspace Digital Signal Processing And Control Engineering Gmbh Method for generating a code for an electronic control unit
CN106371813A (en) * 2015-07-23 2017-02-01 广州汽车集团股份有限公司 Simulink-based motor controller software generation method for electric vehicle
CN106980499A (en) * 2017-02-16 2017-07-25 陕西法士特齿轮有限责任公司 A kind of integrated approach that upper layer logic and bottom code are realized based on MATLAB/Simulink
CN107656731A (en) * 2017-10-10 2018-02-02 株洲欧格瑞传动股份有限公司 An a kind of key Compilation Method for Matlab models

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
酒仙桥北路: "甲方乙方合作开发中的Simulink算法保护", pages 1 - 2, Retrieved from the Internet <URL:http://www.360doc.com/content/20/0105/15/67105325_884301178.shtml> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190877A (en) * 2021-04-29 2021-07-30 网易(杭州)网络有限公司 Model loading method and device, readable storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN106371813B (en) A kind of electric vehicle motor controller method for producing software based on Simulink
CN103838584B (en) The development approach and device of a kind of mobile terminal application
CN104572237A (en) Automatic quick generation system and method for UKey installation package
CN106293664A (en) Code generating method and device
CN104298534B (en) Programmed method and device based on Lua language
CN104317589A (en) Automatic code generating method and automatic code generating device for loading dynamic link library
EP2503457A1 (en) Loading and debugging method and debugging system thereof
CN110196720B (en) Optimization method for generating dynamic link library by Simulink
CN102375778A (en) Method and system for automatically testing digital signal processor (DSP)
Stocks et al. Test template framework: A specification-based testing case study
CN105912334A (en) Internal behavior object code generation method of AUTOSAR software assembly
CN106021118B (en) Test code generating method and device, test frame code execution method and device
CN112148278A (en) Visual block chain intelligent contract framework and intelligent contract development and deployment method
CN112596735A (en) Code generation and integrated compiling method of encryption model
CN111985055A (en) Model packaging method and device and electronic equipment
CN106095668B (en) The generation method of C++ test case based on event and movement
CN107122219A (en) The acquisition methods and device of installation file
Estublier et al. Composing domain-specific languages for wide-scope software engineering applications
CN110908730A (en) Cloud platform configuration file management method and management system
CN113238834A (en) Processing method and device of simulation model file and electronic equipment
CN105260184B (en) A kind of adjustment method and device for restoring image file
CN111399829B (en) Waveform modeling method and terminal based on model driving
CN111611008A (en) Software code packaging and deploying method, device, equipment and storage medium
CN108228185B (en) Embedded software modularization generation method and device
KR20210039714A (en) Method and apparatus for constructing test environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination