WO2018163304A1 - Source code improvement device, source code improvement method, and source code improvement program - Google Patents

Source code improvement device, source code improvement method, and source code improvement program Download PDF

Info

Publication number
WO2018163304A1
WO2018163304A1 PCT/JP2017/009088 JP2017009088W WO2018163304A1 WO 2018163304 A1 WO2018163304 A1 WO 2018163304A1 JP 2017009088 W JP2017009088 W JP 2017009088W WO 2018163304 A1 WO2018163304 A1 WO 2018163304A1
Authority
WO
WIPO (PCT)
Prior art keywords
source code
improvement
execution result
information
code
Prior art date
Application number
PCT/JP2017/009088
Other languages
French (fr)
Japanese (ja)
Inventor
功也 三浦
努 元濱
真一 落合
Original Assignee
三菱電機株式会社
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 三菱電機株式会社 filed Critical 三菱電機株式会社
Priority to PCT/JP2017/009088 priority Critical patent/WO2018163304A1/en
Publication of WO2018163304A1 publication Critical patent/WO2018163304A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the present invention relates to a source code improvement device, a source code improvement method, and a source code improvement program for improving source code.
  • model-based development using a method in which source code is automatically generated from a control model a developer does not describe source code directly, but abstractly describes the function of a target program in the form of a model.
  • the developer confirms the operation of the model by performing a model simulation using a computer in which a program development environment corresponding to the model is installed.
  • the source code is automatically generated from the model to obtain a program that behaves the same as the operation confirmed by the simulation.
  • the hardware that can be used when the microcomputer is different, for example, the presence or absence of a floating point arithmetic unit or a cache is different, the instructions that can be used for the microcomputer are different. Therefore, in order to generate the optimum source code for the microcomputer, it is necessary to recognize the hardware that can be used by the microcomputer and modify the source code to use each hardware as necessary. This also increases the software development period.
  • Patent documents 1 and 2 exist as prior art which solves the above-mentioned subject.
  • Japanese Patent Application Laid-Open No. 2004-151561 discloses a technique for performing a simulation using a control parameter designated by a developer and assisting in adjusting an optimal control parameter.
  • Patent Document 2 discloses a technique for automatically determining optimal control parameters based on simulation results.
  • the techniques disclosed in Patent Document 1 and Patent Document 2 are techniques that support control parameter adjustment on a model, and the optimization target is a model. Therefore, since the operation when the generated program is operated on an actual machine is not guaranteed, the problem that the above-described restrictions on the actual machine may not be satisfied remains.
  • Patent Document 3 is a technique showing a method of reducing ROM (Read Only Memory) capacity to be used for source code automatically generated from a model.
  • ROM Read Only Memory
  • the object of the present invention is to provide an apparatus and a method capable of generating an optimum source code regardless of dynamic constraints or static constraints when automatically generating source code from a model in model-based development.
  • the source code improvement device of the present invention is: A code generator for generating source code from the control model; A simulation unit that performs a simulation in which the microcomputer identified by the specified identification information operates with the source code, and generates an execution result that is a simulation result; and A target value for the execution result is compared with a value indicated by the execution result, and it is determined whether the execution result satisfies the target value. When it is determined that the execution result does not satisfy the target value, related information related to the execution result is obtained. Improvement information for improving the source code by searching using the related information for operation type information acquired from the source code and associated with a plurality of attributes of the operation for each operation type A code improvement unit that extracts the calculation type information and uses the improvement information to improve the source code.
  • the source code improvement device of the present invention includes a code improvement unit. Therefore, the source code improvement device can generate optimal source code regardless of dynamic constraints or static constraints when automatically generating source code from a model in model-based development.
  • FIG. 3 is a diagram of the first embodiment, showing an outline of a hardware configuration of a source code improvement device 1.
  • FIG. 3 is a diagram illustrating the hardware configuration of the source code improvement device 1 according to the first embodiment.
  • FIG. 3 is a diagram illustrating the functional configuration of the source code improvement device 1 according to the first embodiment.
  • the figure of Embodiment 1 the figure which shows the microcomputer information 23A.
  • the figure of Embodiment 1 is a figure which shows the calculation method information 24A.
  • FIG. 3 is a flowchart of the operation of the source code improvement device 1 in the diagram of the first embodiment.
  • FIG. 7 is a diagram of the first embodiment, in which FIG. 6 is sequenced.
  • FIG. *** Explanation of configuration *** FIG. 1 shows an outline of the hardware configuration of the source code improvement device 1.
  • FIG. 2 shows a hardware configuration of the source code improving apparatus 1.
  • FIG. 3 shows a functional configuration of the source code improving apparatus 1.
  • the source code improvement device 1 is a computer.
  • the source code improvement device 1 includes a processor 10, a storage 20, a memory 30, an I / O interface 40, an input device 50, and a display device 60 as hardware.
  • the processor 10 is connected to other hardware via a signal line, and controls these other hardware.
  • the processor 10 is an IC (Integrated Circuit) that performs arithmetic processing.
  • Specific examples of the processor 10 are a CPU (Central Processing Unit), a DSP (Digital Signal Processor), and a GPU (Graphics Processing Unit).
  • Storage 20 is an auxiliary storage device.
  • the storage 20 is a readable / writable storage device.
  • a specific example of the storage 20 is a magnetic disk device (Magnetic Disk Drive).
  • the storage 20 may be a storage device using a portable storage medium such as an optical disk, a compact disk, a Blu-ray (registered trademark) disk, or a DVD (Digital Versatile Disk).
  • the memory 30 is a main storage device.
  • the memory 30 is a readable / writable storage device. Specific examples of the memory 30 are SRAM (Static Random Access Memory) and DRAM (Dynamic Random Access Memory).
  • the I / O (INPUT OUTPUT) interface 40 is an interface device for the processor 10 to communicate with the input device 50 and the display device 60.
  • the input device 50 is a device for inputting data to the source code improvement device 1.
  • the input device 50 is, for example, a keyboard or a mouse.
  • the display device 60 is a device that displays information.
  • the display device 60 is a liquid crystal display, for example.
  • the source code improvement device 1 includes a code generation unit 11, a simulation unit 12, and a code improvement unit 13 as functional elements.
  • the functions of the code generation unit 11, the simulation unit 12, and the code improvement unit 13 are realized by software.
  • the storage 20 stores programs that realize the functions of the code generation unit 11, the simulation unit 12, and the code improvement unit 13. This program is read and executed by the processor 10. Thereby, the functions of the code generation unit 11, the simulation unit 12, and the code improvement unit 13 are realized.
  • the source code improving apparatus 1 may include a plurality of processors that replace the processor 10.
  • the plurality of processors share execution of programs of the code generation unit 11, the simulation unit 12, and the code improvement unit 13.
  • Each processor is an IC that performs arithmetic processing in the same manner as the processor 10.
  • the storage 20 implements a storage unit including a control model storage unit 21, a generated code storage unit 22, a microcomputer information storage unit 23, a calculation method storage unit 24, and an improved code storage unit 25.
  • the control model storage unit 21 stores a control model to be optimized. The control model is described using a development environment for creating a block diagram such as, for example, MATLAB / Simulink (registered trademark).
  • the generated code storage unit 22 stores the source code 21B generated by the code generation unit 11.
  • the microcomputer information storage unit 23 stores microcomputer information 23A.
  • FIG. 4 shows the microcomputer information 23A.
  • the microcomputer information 23A describes information related to the microcomputer, such as the price, ROM size, operating frequency, and cache presence.
  • the calculation method information 24A is stored in the calculation method storage unit 24.
  • FIG. 5 shows calculation method information 24A.
  • FIG. 5 shows an operation type column, an operation content column, an operation method column, an execution time column, and a ROM size column.
  • Calculation contents, calculation method, execution time, and ROM size are attributes of calculation contents.
  • the calculation method information 24A describes patterns of a plurality of existing calculation methods. For example, when performing a trigonometric function operation, an operation method using a floating-point operation library, an operation method using a fixed-point operation table, and the like are described in the operation method information 24A.
  • Regarding the influence on the target value due to the selection of each calculation method since a specific numerical value may change depending on the microcomputer, abstract relations such as large, medium and small are entered.
  • the influence on the target value includes the execution time and the ROM size.
  • the information in the microcomputer information storage unit 23 and the calculation method storage unit 24 is stored in the storage 20 of the source code improvement device 1.
  • the information stored in the microcomputer information storage unit 23 and the calculation method storage unit 24 may be stored in an external device such as a server device.
  • the target value the target value is directly input to the source code improving apparatus 1 by the input device 50 in the first embodiment.
  • the target value may be arranged as a database.
  • FIG. 6 is a flowchart showing the operation of the source code improving apparatus 1.
  • FIG. 7 is a sequence diagram of FIG.
  • step S11 the code generation unit 11 generates a source code 21B from the control model 21A. Specifically, the code generation unit 11 automatically generates source code 21B from the control model 21A based on the control model 21A stored in the control model storage unit 21. For the automatic generation of the source code 21B, for example, MATLAB / Simulink can be used. The code generation unit 11 automatically generates a source code 21 ⁇ / b> B having the function of the control model 21 ⁇ / b> A stored in the control model storage unit 21 and stores it in the generated code storage unit 22.
  • step S12 the simulation unit 12 operates.
  • the simulation unit 12 performs a simulation in which the microcomputer identified by the specified identification information operates with the source code 21B, and generates an execution result 21D that is a simulation result.
  • the user designates a microcomputer name.
  • the user selects one microcomputer name to be mounted from the microcomputer information 23 ⁇ / b> A registered in the microcomputer information storage unit 23 using the input device 50.
  • the microcomputer name is identification information for identifying the microcomputer.
  • the simulation unit 12 builds the source code 21B stored in the generated code storage unit 22 so as to operate with the selected microcomputer.
  • the simulation unit 12 generates an execution file 21C of the source code 21B that is executed by the selected microcomputer.
  • the simulation unit 12 acquires information on the selected microcomputer, such as ROM size to be used and RAM (Random Access Memory) size, and information on the selected microcomputer from the microcomputer information 23A.
  • step S13 the simulation unit 12 executes the generated execution file 21C and performs a simulation. At this time, the simulation unit 12 acquires information, such as an execution time, for which the result is not statically known as a simulation result. The simulation unit 12 transmits an execution result 21 ⁇ / b> D that is a simulation result to the code improvement unit 13.
  • step S14 The code improvement unit 13 compares the target value for the execution result 21D with the value indicated by the execution result 21D, and determines whether the execution result 21D satisfies the target value.
  • the code improving unit 13 determines whether the execution result 21D transmitted from the simulation unit 12 has achieved all target values. Specifically, the code improving unit 13 compares the target value input from the input device 50 with the value of the item of the execution result 21D corresponding to the target value item. When the target value is the execution time target value, the code improving unit 13 compares the execution time value of the execution result 21D with the target value.
  • the code improvement unit 13 performs a comparison according to the input target value, for example, (A) Whether the output result when operated by a microcomputer is within the allowable error range which is a target value, (B) Whether the ROM size and execution time are within target values, Determine.
  • step S14 If the optimization has been achieved for all the optimization items, the code improvement unit 13 stores the source code 21B as the optimized code in the improved code storage unit 25 in step S21 and ends the process. To do.
  • step S14 If the target value has not been reached in any item, the code improvement unit 13 optimizes the source code 21B.
  • the optimization by the code improvement unit 13 will be described as an example in which the execution time is optimized for simplicity. Note that the code improvement unit 13 also performs optimization for the other optimization target items by the same process as the optimization of the execution time. That is, the optimization target by the code improvement unit 13 is not limited to the calculation time.
  • step S15 the code improvement unit 13 extracts items that need to be optimized (hereinafter referred to as optimization items) based on the comparison result in step S14.
  • the code improvement unit 13 extracts the execution time as an optimization item.
  • the code improvement unit 13 optimizes each optimization item one by one. For example, when there are two optimization items of calculation accuracy and execution time, the code improvement unit 13 first optimizes the calculation accuracy and then optimizes the execution time.
  • step S16 if the code improvement unit 13 determines in step S14 that the value of the execution result 21D does not satisfy the target value, the code improvement unit 13 acquires related information 71 related to the execution result 21D from the source code 21B. Specifically, it is as follows.
  • the code improvement unit 13 analyzes the source code 21B. Based on the analysis of the source code 21B, the code improvement unit 13 uses information for optimization, such as information regarding the calculation method and accuracy performed in the source code 21B, and the ROM size (large, medium, small) used by the variables And related information 71, which is information related to the execution result, is acquired from the source code 21B.
  • the information that the code improving unit 13 acquires from the source code 21B as the related information 71 is set in advance according to the optimization item.
  • the code improvement unit 13 acquires the related information 71 from the source code 21B according to the setting.
  • step S17 the code improvement unit 13 searches the operation type information 924A in which a plurality of attributes of operations for each operation type are associated with each other using the related information 71 to improve the source code 21B.
  • the improvement information 72 is extracted from the calculation type information 924. Specifically, it is as follows.
  • the code improvement unit 13 searches the calculation method information 24A in the calculation method storage unit 24 using the item extracted in step S15 and the related information 71 obtained as the analysis result of the source code 21B acquired in step S16. .
  • the calculation method information 24A is calculation type information 924A.
  • the item extracted in step S15 is the execution time in this example.
  • the code improvement unit 13 extracts the improvement information 72 of the source code 21B necessary to shorten the execution time by searching the calculation method information 24A using the related information 71 as a search key. For example, if the microcomputer specified in step S12 does not have a floating point arithmetic unit and uses a library function, the execution time is “large” in the current arithmetic method as shown in FIG. is there. Therefore, the code improvement unit 13 extracts a calculation method having an execution time of “small” as improvement information 72 from the calculation method information 24A. In the calculation method information 24A, the execution time of the single-precision floating-point calculation that is the record in the third row is “small”.
  • the code improvement unit 13 extracts the calculation method using the floating-point calculation table in the third line as the improvement information 72 from the calculation method information 24A. When there are a plurality of implementation method candidates that can be implemented, the code improvement unit 13 selects the computation method that is the improvement information 72 according to a certain rule, such as selecting the computation method in order from the list listed as candidates. select.
  • step S18 the code improvement unit 13 uses the improvement information 72 to improve the source code 21B. Specifically, it is as follows.
  • the code improvement unit 13 applies the improvement method extracted in step S17 to the source code 21B stored in the generated code storage unit 22.
  • the output may change with the change. In that case, there is a possibility that the target value for optimization cannot be cleared.
  • the code improvement unit 13 extracts the parameter dependency relationship related to the optimization item from the control model 21A stored in the control model storage unit 21 related to the optimization item simultaneously with the optimization of the optimization item, The parameter affected by the optimization item is acquired from the control model 21A.
  • the code improvement unit 13 appropriately changes the value of the acquired parameter simultaneously with optimization of the optimization item. Adjustments are made so that they fall within the target values by appropriately changing the parameter values and then evaluating the simulation execution results. In this way, the source code 21B is sequentially improved so that the source code 21B in the generated code storage unit 22 can achieve the target. That is, regarding the parameters, the code improvement unit 13 acquires a parameter related to the execution result 21D determined that the value does not satisfy the target value from the control model 21A, and changes the value of the parameter included in the source code 21B. Including the source code 21B.
  • step S19 the code improvement unit 13 determines whether all possible combinations of calculation methods have been confirmed. If all possible combinations of calculation methods have not been confirmed, the code improvement unit 13 inputs the source code 21B of the generated code storage unit 22 to which the improvement is applied and operates the simulation unit 12 again in step S13. Then, the optimization is performed in the same procedure. That is, the code improvement unit 13 causes the simulation unit 12 to perform a simulation in which the microcomputer identified by the identification information operates with the improved source code 21B, thereby obtaining the execution result after the improvement by the improved source code 21B. The simulation unit 12 generates the target value, compares the target value with the value indicated by the improved execution result, and determines whether the improved execution result satisfies the target value. That is, when the improvement from step S15 to step S18 is performed to the source code 21B, the process returns to step S13, and a simulation using the source code 21B to which the improvement is applied is performed in step S13.
  • step S20 If the target value cannot be achieved even after checking all possible combinations of calculation methods, in step S20, the code improving unit 13 displays a screen for prompting selection of another microcomputer on the display device 60, and processing Returns to step S12. The code improvement unit 13 displays this screen because the designated microcomputer cannot achieve the target if the target value cannot be achieved even after checking all possible combinations of calculation methods.
  • the source code improving apparatus 1 performs a simulation for the changed microcomputer in the same procedure, finds a combination of operations that fall within the target value, and changes it. An optimal source code generation process is performed for the microcomputer.
  • the source code improving apparatus depends on the description method of the control model and the hardware information of the microcomputer by performing simulation on the source code automatically generated from the control model. And the source code can be improved. Therefore, the software development period can be shortened.
  • the source code improvement device is a code improvement unit, when generating source code automatically from a model in model-based development, an optimal source code can be generated regardless of dynamic constraints and static constraints.
  • 1 source code improvement device 10 processor, 11 code generation unit, 12 simulation unit, 13 code improvement unit, 20 storage, 21 control model storage unit, 21A control model, 21B source code, 21C execution file, 21D execution result, 22 generation Code storage unit, 23 microcomputer information storage unit, 23A microcomputer information, 24 calculation method storage unit, 24A calculation method information, 25 improved code storage unit, 30 memory, 40 I / O interface, 50 input device, 60 display device 71 related information, 72 improvement information.

Abstract

A code generation unit (11) generates a source code (21B) from a control model (21A). A simulation unit (12) executes a simulation in which a specified microcomputer operates in accordance with the source code (21B), thereby generating execution results (21D). A code improvement unit (13) compares the execution results (21D) with target value conditions, and extracts related information relating to the execution results (21D) from the source code (21B) if the execution results (21D) do not satisfy the target value conditions. The code improvement unit (13) then searches calculation method information (24A) using the extracted related information, extracts improvement information for improving the source code (21B) from the calculation method information (24A), and improves the source code (21B) using the improvement information.

Description

ソースコード改善装置、ソースコード改善方法及びソースコード改善プログラムSource code improvement apparatus, source code improvement method, and source code improvement program
 この発明は、ソースコードを改善する、ソースコード改善装置、ソースコード改善方法及びソースコード改善プログラムに関する。 The present invention relates to a source code improvement device, a source code improvement method, and a source code improvement program for improving source code.
 制御モデルからソースコードが自動生成される手法を用いるモデルベース開発においては、開発者は、直接ソースコードを記述せず、目的とするプログラムの機能をモデルという形で抽象的に記述する。
 開発者は、モデルに対応したプログラム開発環境がインストールされたコンピュータを用いて、モデルのシミュレーションを実施することにより、モデルの動作を確認する。
 動作確認が完了したモデルを入力データとして、モデルからソースコードを自動生成することにより、シミュレーションで確認した動作と同じ振る舞いをするプログラムを入手する。
In model-based development using a method in which source code is automatically generated from a control model, a developer does not describe source code directly, but abstractly describes the function of a target program in the form of a model.
The developer confirms the operation of the model by performing a model simulation using a computer in which a program development environment corresponding to the model is installed.
By using the model for which the operation check has been completed as input data, the source code is automatically generated from the model to obtain a program that behaves the same as the operation confirmed by the simulation.
 モデルベース開発を用いることで、シミュレーション時に確認した動作と同じ振る舞いをする、マイクロコンピュータ用のプログラムを入手可能である。しかし、自動生成されるソースコードはモデルの記述方法に依存してその記述内容が変化する。このために、ソースコードの記述方法が変更されると、実行時間または演算精度に影響を与えるため、システムに要求される時間制約または演算精度が満たせなくなる。よって、実際のマイクロコンピュータの出力を確認しながら、制約を満たすように人手によってソースコードを調整する必要があった。よって、ソフトウェア開発の属人化による、ソフトウェア開発期間の増加が課題となっていた。 ∙ By using model-based development, it is possible to obtain a program for a microcomputer that behaves the same as the operation confirmed during simulation. However, the description of the automatically generated source code changes depending on the model description method. For this reason, if the description method of the source code is changed, the execution time or calculation accuracy is affected, so that the time constraint or calculation accuracy required for the system cannot be satisfied. Therefore, it was necessary to manually adjust the source code so as to satisfy the constraints while checking the output of the actual microcomputer. Therefore, an increase in the software development period due to the belonging of software development has become an issue.
 また、マイクロコンピュータが異なる場合には使用できるハードウェア、例えば、浮動小数点演算ユニットまたはキャッシュの有無などが異なるため、マイクロコンピュータに対して使用できる命令が異なる。このため、そのマイクロコンピュータにとって最適なソースコードを生成するためには、マイクロコンピュータで使用可能なハードウェアを認識し、必要に応じて各ハードウェアを使用するようにソースコードを修正する必要があり、こうした面でもソフトウェア開発期間が増大する。 In addition, since the hardware that can be used when the microcomputer is different, for example, the presence or absence of a floating point arithmetic unit or a cache is different, the instructions that can be used for the microcomputer are different. Therefore, in order to generate the optimum source code for the microcomputer, it is necessary to recognize the hardware that can be used by the microcomputer and modify the source code to use each hardware as necessary. This also increases the software development period.
 上記の課題を解決する先行技術として、特許文献1および特許文献2が存在する。特許文献1では、開発者が指定した制御パラメータを用いてシミュレーションを実施し、最適な制御パラメータを調整する支援を行う技術が公開されている。また、特許文献2では、シミュレーション結果を基にして最適な制御パラメータを自動的に決定する技術が公開されている。
 しかし、特許文献1および特許文献2で公開されている技術は、モデル上での制御パラメータ調整を支援する技術であり、最適化対象はモデルとなっている。よって生成したプログラムを実機で動作させる場合の動作を保証するものではないため、先に述べた実機上での制約を満たすことができない可能性があるという課題は残ったままである。
Patent documents 1 and 2 exist as prior art which solves the above-mentioned subject. Japanese Patent Application Laid-Open No. 2004-151561 discloses a technique for performing a simulation using a control parameter designated by a developer and assisting in adjusting an optimal control parameter. Patent Document 2 discloses a technique for automatically determining optimal control parameters based on simulation results.
However, the techniques disclosed in Patent Document 1 and Patent Document 2 are techniques that support control parameter adjustment on a model, and the optimization target is a model. Therefore, since the operation when the generated program is operated on an actual machine is not guaranteed, the problem that the above-described restrictions on the actual machine may not be satisfied remains.
 また、特許文献3は、モデルから自動生成されたソースコードを対象として、使用するROM(Read Only Memory)容量を削減する方法を示した技術である。しかし、この技術はROM容量のみを対象としており、実行時間など、動的にしか確認できない制約事項は検討できない。 Patent Document 3 is a technique showing a method of reducing ROM (Read Only Memory) capacity to be used for source code automatically generated from a model. However, this technology targets only the ROM capacity, and restrictions such as execution time that can only be confirmed dynamically cannot be considered.
特開2004-38428号公報JP 2004-38428 A 特開2009-116515号公報JP 2009-116515 A 特開2013-161220号公報JP 2013-161220 A
 本発明は、モデルベース開発において、モデルからソースコードを自動生成する際に、動的な制約、静的な制約に関わらず、最適なソースコードを生成できる装置及び方法の提供を目的とする。 The object of the present invention is to provide an apparatus and a method capable of generating an optimum source code regardless of dynamic constraints or static constraints when automatically generating source code from a model in model-based development.
 本発明のソースコード改善装置は、
 制御モデルからソースコードを生成するコード生成部と、
 指定された識別情報で識別されるマイクロコンピュータが前記ソースコードで動作するシミュレーションを行い、シミュレーション結果である実行結果を生成するシミュレーション部と、
 前記実行結果に対する目標値と前記実行結果の示す値とを比較し、前記実行結果が前記目標値を満たしているか判定し、満たしていないと判定した場合に、前記実行結果に関連する関連情報を前記ソースコードから取得し、演算種別ごとに前記演算の有する複数の属性が対応付けられた演算種別情報を対象に前記関連情報を用いて検索することにより前記ソースコードを改善するための改善情報を前記演算種別情報から抽出し、前記改善情報を用いて前記ソースコードを改善するコード改善部と
を備える。
The source code improvement device of the present invention is:
A code generator for generating source code from the control model;
A simulation unit that performs a simulation in which the microcomputer identified by the specified identification information operates with the source code, and generates an execution result that is a simulation result; and
A target value for the execution result is compared with a value indicated by the execution result, and it is determined whether the execution result satisfies the target value. When it is determined that the execution result does not satisfy the target value, related information related to the execution result is obtained. Improvement information for improving the source code by searching using the related information for operation type information acquired from the source code and associated with a plurality of attributes of the operation for each operation type A code improvement unit that extracts the calculation type information and uses the improvement information to improve the source code.
 本発明のソースコード改善装置はコード改善部を備えている。よってソースコード改善装置は、モデルベース開発において、モデルからソースコードを自動生成する際に、動的な制約、静的な制約に関わらず、最適なソースコードを生成できる。 The source code improvement device of the present invention includes a code improvement unit. Therefore, the source code improvement device can generate optimal source code regardless of dynamic constraints or static constraints when automatically generating source code from a model in model-based development.
実施の形態1の図で、ソースコード改善装置1のハードウェア構成の概要を示す図。FIG. 3 is a diagram of the first embodiment, showing an outline of a hardware configuration of a source code improvement device 1. 実施の形態1の図で、ソースコード改善装置1のハードウェア構成を示す図。FIG. 3 is a diagram illustrating the hardware configuration of the source code improvement device 1 according to the first embodiment. 実施の形態1の図で、ソースコード改善装置1の機能構成を示す図。FIG. 3 is a diagram illustrating the functional configuration of the source code improvement device 1 according to the first embodiment. 実施の形態1の図で、マイクロコンピュータ情報23Aを示す図。The figure of Embodiment 1, the figure which shows the microcomputer information 23A. 実施の形態1の図で、演算方法情報24Aを示す図。The figure of Embodiment 1 is a figure which shows the calculation method information 24A. 実施の形態1の図で、ソースコード改善装置1の動作を示すフローチャート。FIG. 3 is a flowchart of the operation of the source code improvement device 1 in the diagram of the first embodiment. 実施の形態1の図で、図6をシーケンス化した図。FIG. 7 is a diagram of the first embodiment, in which FIG. 6 is sequenced.
実施の形態1.
***構成の説明***
 図1は、ソースコード改善装置1のハードウェア構成の概要を示す。
 図2は、ソースコード改善装置1のハードウェア構成を示す。
 図3は、ソースコード改善装置1の機能構成を示す。
Embodiment 1 FIG.
*** Explanation of configuration ***
FIG. 1 shows an outline of the hardware configuration of the source code improvement device 1.
FIG. 2 shows a hardware configuration of the source code improving apparatus 1.
FIG. 3 shows a functional configuration of the source code improving apparatus 1.
 ソースコード改善装置1はコンピュータである。ソースコード改善装置1は、ハードウェアとして、プロセッサ10、ストレージ20、メモリ30、I/Oインタフェース40、入力装置50及び表示装置60を備えている。プロセッサ10は、信号線を介して他のハードウェアと接続され、これら他のハードウェアを制御する。 The source code improvement device 1 is a computer. The source code improvement device 1 includes a processor 10, a storage 20, a memory 30, an I / O interface 40, an input device 50, and a display device 60 as hardware. The processor 10 is connected to other hardware via a signal line, and controls these other hardware.
 プロセッサ10は、演算処理を行うIC(Integrated Circuit)である。プロセッサ10は、具体例としては、CPU(Central Processing Unit)、DSP(Digital Signal Processor)、GPU(Graphics Processing Unit)である。 The processor 10 is an IC (Integrated Circuit) that performs arithmetic processing. Specific examples of the processor 10 are a CPU (Central Processing Unit), a DSP (Digital Signal Processor), and a GPU (Graphics Processing Unit).
 ストレージ20は補助記憶装置である。ストレージ20は読み書きが可能な記憶装置である。ストレージ20の具体例としては、磁気ディスク装置(Magnetic Disk Drive)である。また、ストレージ20は、光ディスク、コンパクトディスク、ブルーレイ(登録商標)ディスク、DVD(Digital Versatile Disk)といった可搬記憶媒体を使用する記憶装置であってもよい。 Storage 20 is an auxiliary storage device. The storage 20 is a readable / writable storage device. A specific example of the storage 20 is a magnetic disk device (Magnetic Disk Drive). The storage 20 may be a storage device using a portable storage medium such as an optical disk, a compact disk, a Blu-ray (registered trademark) disk, or a DVD (Digital Versatile Disk).
 メモリ30は主記憶装置である。メモリ30は読み書きが可能な記憶装置である。メモリ30の具体例としては、SRAM(Static Random Access Memory)、DRAM(Dynamic Random Access Memory)である。 The memory 30 is a main storage device. The memory 30 is a readable / writable storage device. Specific examples of the memory 30 are SRAM (Static Random Access Memory) and DRAM (Dynamic Random Access Memory).
 I/O(INPUT OUTPUT)インタフェース40は、プロセッサ10が入力装置50及び表示装置60と通信するためのインタフェース装置である。 The I / O (INPUT OUTPUT) interface 40 is an interface device for the processor 10 to communicate with the input device 50 and the display device 60.
 入力装置50はソースコード改善装置1にデータを入力する装置である。入力装置50は、例えばキーボードまたはマウスである。 The input device 50 is a device for inputting data to the source code improvement device 1. The input device 50 is, for example, a keyboard or a mouse.
 表示装置60は情報を表示する装置である。表示装置60は例えば液晶ディスプレイである。 The display device 60 is a device that displays information. The display device 60 is a liquid crystal display, for example.
 図2のように、ソースコード改善装置1は、機能要素として、コード生成部11、シミュレーション部12及びコード改善部13を備えている。コード生成部11、シミュレーション部12及びコード改善部13の機能は、ソフトウェアにより実現される。ストレージ20には、コード生成部11、シミュレーション部12及びコード改善部13の機能を実現するプログラムが記憶されている。このプログラムは、プロセッサ10により読み込まれ実行される。これにより、コード生成部11、シミュレーション部12及びコード改善部13の機能が実現される。 As shown in FIG. 2, the source code improvement device 1 includes a code generation unit 11, a simulation unit 12, and a code improvement unit 13 as functional elements. The functions of the code generation unit 11, the simulation unit 12, and the code improvement unit 13 are realized by software. The storage 20 stores programs that realize the functions of the code generation unit 11, the simulation unit 12, and the code improvement unit 13. This program is read and executed by the processor 10. Thereby, the functions of the code generation unit 11, the simulation unit 12, and the code improvement unit 13 are realized.
 図2では、プロセッサ10は、1つだけ示されている。しかし、ソースコード改善装置1は、プロセッサ10を代替する複数のプロセッサを備えていてもよい。これら複数のプロセッサは、コード生成部11、シミュレーション部12及びコード改善部13のプログラムの実行を分担する。それぞれのプロセッサは、プロセッサ10と同じように、演算処理を行うICである。 In FIG. 2, only one processor 10 is shown. However, the source code improving apparatus 1 may include a plurality of processors that replace the processor 10. The plurality of processors share execution of programs of the code generation unit 11, the simulation unit 12, and the code improvement unit 13. Each processor is an IC that performs arithmetic processing in the same manner as the processor 10.
 ストレージ20は、制御モデル格納部21、生成コード格納部22、マイクロコンピュータ情報格納部23、演算方法格納部24及び改善後コード格納部25の各格納部を実現する。
(1)制御モデル格納部21には、最適化対象となる制御モデルが格納される。制御モデルは、例えば、MATLAB/Simulink(登録商標)に代表されるような、ブロック図を作成するための開発環境を用いて記述される。
(2)生成コード格納部22には、コード生成部11によって生成されたソースコード21Bが格納される。
(3)マイクロコンピュータ情報格納部23は、マイクロコンピュータ情報23Aが格納される。
 図4は、マイクロコンピュータ情報23Aを示す。マイクロコンピュータ情報23Aには、価格、ROMサイズ、動作周波数、キャッシュ有無など、マイクロコンピュータに関する情報が記載されている。
(4)演算方法格納部24には、演算方法情報24Aが格納される。
 図5は演算方法情報24Aを示す。
 図5では、演算種別の列、演算内容の列、演算方法の列、実行時間の列及びROMサイズの列を示している。演算内容、演算方法、実行時間及びROMサイズは、演算内容の属性である。演算方法情報24Aは、既存の複数の演算方法のパターンが記載される。例えば、三角関数演算を実施する場合に、浮動小数点演算ライブラリを用いた場合の演算方法、及び固定小数点演算のテーブルを用いた場合の演算方法などが、演算方法情報24Aに記述される。各演算方法を選択したことによる目標値への影響については、マイクロコンピュータによって具体的な数値が変化することがあるので、大、中、小のような抽象的な関係が記入される。目標値への影響とは、実行時間及びROMサイズなどである。
The storage 20 implements a storage unit including a control model storage unit 21, a generated code storage unit 22, a microcomputer information storage unit 23, a calculation method storage unit 24, and an improved code storage unit 25.
(1) The control model storage unit 21 stores a control model to be optimized. The control model is described using a development environment for creating a block diagram such as, for example, MATLAB / Simulink (registered trademark).
(2) The generated code storage unit 22 stores the source code 21B generated by the code generation unit 11.
(3) The microcomputer information storage unit 23 stores microcomputer information 23A.
FIG. 4 shows the microcomputer information 23A. The microcomputer information 23A describes information related to the microcomputer, such as the price, ROM size, operating frequency, and cache presence.
(4) The calculation method information 24A is stored in the calculation method storage unit 24.
FIG. 5 shows calculation method information 24A.
FIG. 5 shows an operation type column, an operation content column, an operation method column, an execution time column, and a ROM size column. Calculation contents, calculation method, execution time, and ROM size are attributes of calculation contents. The calculation method information 24A describes patterns of a plurality of existing calculation methods. For example, when performing a trigonometric function operation, an operation method using a floating-point operation library, an operation method using a fixed-point operation table, and the like are described in the operation method information 24A. Regarding the influence on the target value due to the selection of each calculation method, since a specific numerical value may change depending on the microcomputer, abstract relations such as large, medium and small are entered. The influence on the target value includes the execution time and the ROM size.
 なお、図2では、マイクロコンピュータ情報格納部23及び演算方法格納部24の情報は、ソースコード改善装置1の有するストレージ20に保存される構成である。しかし、マイクロコンピュータ情報格納部23及び演算方法格納部24に格納される情報は、サーバ装置などの外部の装置に格納してもよい。
 また、目標値についても、実施の形態1では目標値は、入力装置50によってソースコード改善装置1に直接入力される。しかし、目標値は、データベースとして配置されてもよい。
In FIG. 2, the information in the microcomputer information storage unit 23 and the calculation method storage unit 24 is stored in the storage 20 of the source code improvement device 1. However, the information stored in the microcomputer information storage unit 23 and the calculation method storage unit 24 may be stored in an external device such as a server device.
As for the target value, the target value is directly input to the source code improving apparatus 1 by the input device 50 in the first embodiment. However, the target value may be arranged as a database.
***動作の説明***
<ステップS11>
 図3、図6及び図7を参照してソースコード改善装置1の動作を説明する。
 図6はソースコード改善装置1の動作を示すフローチャートである。
 図7は図6をシーケンス化した図である。
*** Explanation of operation ***
<Step S11>
The operation of the source code improving apparatus 1 will be described with reference to FIGS.
FIG. 6 is a flowchart showing the operation of the source code improving apparatus 1.
FIG. 7 is a sequence diagram of FIG.
<ステップS11>
 ステップS11において、コード生成部11は、制御モデル21Aからソースコード21Bを生成する。具体的には、コード生成部11は、制御モデル格納部21に格納された制御モデル21Aを基にして、制御モデル21Aからソースコード21Bを自動生成する。ソースコード21Bの自動生成には、例えば、既存技術であるMATLAB/Simulinkを用いることができる。コード生成部11は、制御モデル格納部21に格納された制御モデル21Aの機能を有するソースコード21Bを自動生成し、生成コード格納部22へ格納する。
<Step S11>
In step S11, the code generation unit 11 generates a source code 21B from the control model 21A. Specifically, the code generation unit 11 automatically generates source code 21B from the control model 21A based on the control model 21A stored in the control model storage unit 21. For the automatic generation of the source code 21B, for example, MATLAB / Simulink can be used. The code generation unit 11 automatically generates a source code 21 </ b> B having the function of the control model 21 </ b> A stored in the control model storage unit 21 and stores it in the generated code storage unit 22.
<ステップS12>
 ステップS12では、シミュレーション部12が動作する。
シミュレーション部12は、指定された識別情報で識別されるマイクロコンピュータがソースコード21Bで動作するシミュレーションを行い、シミュレーション結果である実行結果21Dを生成する。
 具体的には以下のようである。
 ステップS12において、ユーザがマイクロコンピュータ名を指定する。ユーザは、マイクロコンピュータ情報格納部23に登録されているマイクロコンピュータ情報23Aの中から、実装対象であるマイクロコンピュータ名を、入力装置50を用いて一つ選択する。マイクロコンピュータ名はこの場合、マイクロコンピュータを識別する識別情報である。
 シミュレーション部12は、選択されたマイクロコンピュータで動作するように、生成コード格納部22に格納されているソースコード21Bをビルドする。これにより、選択されたマイクロコンピュータによって実行される、ソースコード21Bの実行ファイル21Cがシミュレーション部12によって生成される。このとき、シミュレーション部12は、使用するROMサイズ及びRAM(Random Access Memory)サイズなど、静的にわかる情報を、選択されたマイクロコンピュータの情報をマイクロコンピュータ情報23Aから取得する。
<Step S12>
In step S12, the simulation unit 12 operates.
The simulation unit 12 performs a simulation in which the microcomputer identified by the specified identification information operates with the source code 21B, and generates an execution result 21D that is a simulation result.
Specifically, it is as follows.
In step S12, the user designates a microcomputer name. The user selects one microcomputer name to be mounted from the microcomputer information 23 </ b> A registered in the microcomputer information storage unit 23 using the input device 50. In this case, the microcomputer name is identification information for identifying the microcomputer.
The simulation unit 12 builds the source code 21B stored in the generated code storage unit 22 so as to operate with the selected microcomputer. As a result, the simulation unit 12 generates an execution file 21C of the source code 21B that is executed by the selected microcomputer. At this time, the simulation unit 12 acquires information on the selected microcomputer, such as ROM size to be used and RAM (Random Access Memory) size, and information on the selected microcomputer from the microcomputer information 23A.
<ステップS13>
 ステップS13では、シミュレーション部12は、生成された実行ファイル21Cを実行し、シミュレーションを行う。この時、シミュレーション部12は、実行時間など、静的には結果がわからない情報を、シミュレーション結果として取得する。シミュレーション部12は、シミュレーション結果である実行結果21Dを、コード改善部13に送信する。
<Step S13>
In step S13, the simulation unit 12 executes the generated execution file 21C and performs a simulation. At this time, the simulation unit 12 acquires information, such as an execution time, for which the result is not statically known as a simulation result. The simulation unit 12 transmits an execution result 21 </ b> D that is a simulation result to the code improvement unit 13.
<ステップS14>
 ステップS14において、
 コード改善部13は、実行結果21Dに対する目標値と実行結果21Dの示す値とを比較し、実行結果21Dが目標値を満たしているか判定する。コード改善部13は、シミュレーション部12から送信された実行結果21Dが、すべての目標値を達成しているかを判定する。具体的には、コード改善部13は、入力装置50から入力された目標値と、目標値の項目に対応する実行結果21Dの項目の値とを比較する。目標値が実行時間の目標値の場合、コード改善部13は、実行結果21Dの実行時間の値と目標値とを比較する。コード改善部13は、入力された目標値に従った比較を行うことによって、例えば、
(a)マイクロコンピュータで動作させた場合の出力結果が、目標値である許容誤差範囲内に収まっているか、
(b)ROMサイズ及び実行時間が、目標値に収まっているか、
を判定する。
<Step S14>
In step S14
The code improvement unit 13 compares the target value for the execution result 21D with the value indicated by the execution result 21D, and determines whether the execution result 21D satisfies the target value. The code improving unit 13 determines whether the execution result 21D transmitted from the simulation unit 12 has achieved all target values. Specifically, the code improving unit 13 compares the target value input from the input device 50 with the value of the item of the execution result 21D corresponding to the target value item. When the target value is the execution time target value, the code improving unit 13 compares the execution time value of the execution result 21D with the target value. The code improvement unit 13 performs a comparison according to the input target value, for example,
(A) Whether the output result when operated by a microcomputer is within the allowable error range which is a target value,
(B) Whether the ROM size and execution time are within target values,
Determine.
<ステップS14でYES>
 コード改善部13は、全ての最適化項目において目標を達成していた場合には、ステップS21にて、そのソースコード21Bを最適化後コードとして改善後コード格納部25に格納し、処理を終了する。
<YES in step S14>
If the optimization has been achieved for all the optimization items, the code improvement unit 13 stores the source code 21B as the optimized code in the improved code storage unit 25 in step S21 and ends the process. To do.
<ステップS14でNO>
 いずれかの項目において目標値に達していなかった場合は、コード改善部13は、そのソースコード21Bの最適化を実施する。
<NO in step S14>
If the target value has not been reached in any item, the code improvement unit 13 optimizes the source code 21B.
 コード改善部13による最適化は、簡単のために、実行時間を最適化する場合を例として説明する。なお、コード改善部13は、他の最適化の対象になる項目に関しても、実行時間の最適化と同様の処理で最適化を実施する。つまり、コード改善部13による最適化の対象は演算時間に限定されない。 The optimization by the code improvement unit 13 will be described as an example in which the execution time is optimized for simplicity. Note that the code improvement unit 13 also performs optimization for the other optimization target items by the same process as the optimization of the execution time. That is, the optimization target by the code improvement unit 13 is not limited to the calculation time.
<ステップS15>
 ステップS15において、コード改善部13は、ステップS14の比較結果に基づき、最適化が必要な項目(以下、最適化項目という)を抽出する。この例では、コード改善部13は、実行時間を最適化項目として抽出する。最適化項目が複数存在する場合は、コード改善部13は、各最適化項目を一つずつ最適化する。例えば、演算精度と実行時間との2つの最適化項目がある場合には、コード改善部13は、まず演算精度を最適化し、次に実行時間を最適化する。
<Step S15>
In step S15, the code improvement unit 13 extracts items that need to be optimized (hereinafter referred to as optimization items) based on the comparison result in step S14. In this example, the code improvement unit 13 extracts the execution time as an optimization item. When there are a plurality of optimization items, the code improvement unit 13 optimizes each optimization item one by one. For example, when there are two optimization items of calculation accuracy and execution time, the code improvement unit 13 first optimizes the calculation accuracy and then optimizes the execution time.
<ステップS16>
 ステップS16において、コード改善部13は、ステップS14において、実行結果21Dの値が目標値を満たしていないと判定した場合に、実行結果21Dに関連する関連情報71をソースコード21Bから取得する。具体的には以下のようである。コード改善部13は、ソースコード21Bを解析する。ソースコード21Bの解析により、コード改善部13は、ソースコード21Bで実施している演算方法及び演算精度に関する情報、変数の使用するROMサイズ(大、中、小)など、最適化に使用する情報であり実行結果に関連する情報である関連情報71を、ソースコード21Bから取得する。コード改善部13が、どのような情報を関連情報71としてソースコード21Bから取得するかについては、最適化項目に応じて、予め設定されている。コード改善部13は、その設定に従って、ソースコード21Bから関連情報71を取得する。
<Step S16>
In step S16, if the code improvement unit 13 determines in step S14 that the value of the execution result 21D does not satisfy the target value, the code improvement unit 13 acquires related information 71 related to the execution result 21D from the source code 21B. Specifically, it is as follows. The code improvement unit 13 analyzes the source code 21B. Based on the analysis of the source code 21B, the code improvement unit 13 uses information for optimization, such as information regarding the calculation method and accuracy performed in the source code 21B, and the ROM size (large, medium, small) used by the variables And related information 71, which is information related to the execution result, is acquired from the source code 21B. The information that the code improving unit 13 acquires from the source code 21B as the related information 71 is set in advance according to the optimization item. The code improvement unit 13 acquires the related information 71 from the source code 21B according to the setting.
<ステップS17>
 ステップS17において、コード改善部13は、演算種別ごとに演算の有する複数の属性が対応付けられた演算種別情報924Aを対象に関連情報71を用いて検索することにより、ソースコード21Bを改善するための改善情報72を演算種別情報924から抽出する。具体的には以下のようである。コード改善部13は、ステップS15で抽出した項目と、ステップS16にて取得した、ソースコード21Bの解析結果である関連情報71とを用いて、演算方法格納部24の演算方法情報24Aを検索する。演算方法情報24Aは演算種別情報924Aである。ステップS15で抽出した項目は、この例では実行時間である。コード改善部13は、実行時間を短縮するために必要なソースコード21Bの改善情報72を、関連情報71を検索キーとして演算方法情報24Aを検索することにより抽出する。
 例えば、ステップS12で指定されたマイクロコンピュータが、浮動小数点演算ユニットを持っておらず、ライブラリ関数を使用している場合は、図5のように、現在の演算方法では実行時間が「大」である。よって、コード改善部13は、実行時間が「小」となる演算方法を、演算方法情報24Aから改善情報72として抽出する。演算方法情報24Aでは、3行目のレコードである単精度浮動少数点演算の実行時間が「小」である。コード改善部13は、3行目の、浮動小数点演算テーブルを使用した演算方法を改善情報72として、演算方法情報24Aから抽出する。コード改善部13は、実装可能な演算方法の候補が複数存在する場合は、候補として挙がったリストの上から順に演算方法として選択するなど、一定のルールに則って改善情報72である演算方法を選択する。
<Step S17>
In step S17, the code improvement unit 13 searches the operation type information 924A in which a plurality of attributes of operations for each operation type are associated with each other using the related information 71 to improve the source code 21B. The improvement information 72 is extracted from the calculation type information 924. Specifically, it is as follows. The code improvement unit 13 searches the calculation method information 24A in the calculation method storage unit 24 using the item extracted in step S15 and the related information 71 obtained as the analysis result of the source code 21B acquired in step S16. . The calculation method information 24A is calculation type information 924A. The item extracted in step S15 is the execution time in this example. The code improvement unit 13 extracts the improvement information 72 of the source code 21B necessary to shorten the execution time by searching the calculation method information 24A using the related information 71 as a search key.
For example, if the microcomputer specified in step S12 does not have a floating point arithmetic unit and uses a library function, the execution time is “large” in the current arithmetic method as shown in FIG. is there. Therefore, the code improvement unit 13 extracts a calculation method having an execution time of “small” as improvement information 72 from the calculation method information 24A. In the calculation method information 24A, the execution time of the single-precision floating-point calculation that is the record in the third row is “small”. The code improvement unit 13 extracts the calculation method using the floating-point calculation table in the third line as the improvement information 72 from the calculation method information 24A. When there are a plurality of implementation method candidates that can be implemented, the code improvement unit 13 selects the computation method that is the improvement information 72 according to a certain rule, such as selecting the computation method in order from the list listed as candidates. select.
<ステップS18>
 ステップS18において、コード改善部13は、改善情報72を用いてソースコード21Bを改善する。具体的には以下のようである。
 コード改善部13は、ステップS17で抽出した改善方法を生成コード格納部22に格納されているソースコード21Bに適用する。最適化により演算精度と実行時間との少なくともいずれかが変化する場合には、その変化に伴い出力が変化する場合がある。その場合、最適化のための目標値をクリアできない可能性がある。
 このため、コード改善部13は、最適化項目の最適化と同時に、最適化項目に関連する制御モデル格納部21に格納された制御モデル21Aから最適化項目に関連するパラメータ依存関係を抽出し、最適化項目が影響を与えるパラメータを制御モデル21Aから取得する。コード改善部13は、最適化項目の最適化と同時に、取得したパラメータの値を適宜変更する。パラメータの値を適宜変更し、その後にシミュレーションの実行結果を評価することで、目標値に収まるように調整を実施する。このようにして、生成コード格納部22にあるソースコード21Bが目標を達成できるように、ソースコード21Bを順次改善する。
 つまり、パラメータに関し、コード改善部13は、値が目標値を満たしていないと判定された実行結果21Dに関連するパラメータを制御モデル21Aから取得し、ソースコード21Bに含まれるパラメータの値の変更を含めてソースコード21Bを改善する。
<Step S18>
In step S18, the code improvement unit 13 uses the improvement information 72 to improve the source code 21B. Specifically, it is as follows.
The code improvement unit 13 applies the improvement method extracted in step S17 to the source code 21B stored in the generated code storage unit 22. When at least one of calculation accuracy and execution time changes due to optimization, the output may change with the change. In that case, there is a possibility that the target value for optimization cannot be cleared.
For this reason, the code improvement unit 13 extracts the parameter dependency relationship related to the optimization item from the control model 21A stored in the control model storage unit 21 related to the optimization item simultaneously with the optimization of the optimization item, The parameter affected by the optimization item is acquired from the control model 21A. The code improvement unit 13 appropriately changes the value of the acquired parameter simultaneously with optimization of the optimization item. Adjustments are made so that they fall within the target values by appropriately changing the parameter values and then evaluating the simulation execution results. In this way, the source code 21B is sequentially improved so that the source code 21B in the generated code storage unit 22 can achieve the target.
That is, regarding the parameters, the code improvement unit 13 acquires a parameter related to the execution result 21D determined that the value does not satisfy the target value from the control model 21A, and changes the value of the parameter included in the source code 21B. Including the source code 21B.
<ステップS19>
 ステップS19において、コード改善部13は、可能なすべての演算方法の組み合わせを確認したか判定する。コード改善部13は、可能なすべての演算方法の組み合わせが確認されていない場合は、改善が適用された生成コード格納部22のソースコード21Bを入力として再度ステップS13にてシミュレーション部12を動作させて、同様の手順で最適化を実施する。
 つまり、コード改善部13は、識別情報で識別されるマイクロコンピュータが改善されたソースコード21Bで動作するシミュレーションをシミュレーション部12に行わせることで、改善されたソースコード21Bによる改善後の実行結果をシミュレーション部12に生成させ、目標値と改善後の実行結果の示す値とを比較し、改善後の実行結果が目標値を満たしているか判定する。すなわち、ステップS15からステップS18でソースコード21Bへの改善が実施された場合には、処理はステップS13に戻り、ステップS13で、改善が適用されたソースコード21Bを用いたシミュレーションが行われる。
<Step S19>
In step S19, the code improvement unit 13 determines whether all possible combinations of calculation methods have been confirmed. If all possible combinations of calculation methods have not been confirmed, the code improvement unit 13 inputs the source code 21B of the generated code storage unit 22 to which the improvement is applied and operates the simulation unit 12 again in step S13. Then, the optimization is performed in the same procedure.
That is, the code improvement unit 13 causes the simulation unit 12 to perform a simulation in which the microcomputer identified by the identification information operates with the improved source code 21B, thereby obtaining the execution result after the improvement by the improved source code 21B. The simulation unit 12 generates the target value, compares the target value with the value indicated by the improved execution result, and determines whether the improved execution result satisfies the target value. That is, when the improvement from step S15 to step S18 is performed to the source code 21B, the process returns to step S13, and a simulation using the source code 21B to which the improvement is applied is performed in step S13.
<ステップS20>
 可能なすべての演算方法の組み合わせを確認しても目標値が達成できない場合には、コード改善部13は、ステップS20において、他のマイクロコンピュータの選択を促す画面を表示装置60に表示し、処理はステップS12に戻る。コード改善部13がこの画面を表示するのは、可能なすべての演算方法の組み合わせを確認しても目標値が達成できない場合は、指定されたマイクロコンピュータは目標を達成できないからである。
 ユーザによって再度マイクロコンピュータが選択されることにより、ソースコード改善装置1は、変更されたマイクロコンピュータに対して、同様の手順でシミュレーションを実施し、目標値内に収まる演算の組み合わせを発見し、変更されたマイクロコンピュータに対する最適なソースコードの生成処理を実施する。
<Step S20>
If the target value cannot be achieved even after checking all possible combinations of calculation methods, in step S20, the code improving unit 13 displays a screen for prompting selection of another microcomputer on the display device 60, and processing Returns to step S12. The code improvement unit 13 displays this screen because the designated microcomputer cannot achieve the target if the target value cannot be achieved even after checking all possible combinations of calculation methods.
When the microcomputer is selected again by the user, the source code improving apparatus 1 performs a simulation for the changed microcomputer in the same procedure, finds a combination of operations that fall within the target value, and changes it. An optimal source code generation process is performed for the microcomputer.
***実施の形態1の効果***
 以上のように、実施の形態1のソースコード改善装置は、制御モデルから自動生成したソースコードに対してシミュレーションを実施することにより、制御モデルの記述方法及びマイクロコンピュータのハードウェア情報に依存することなく、ソースコードを改善できる。よって、ソフトウェアの開発期間を短縮することができる。
 また、ソースコード改善装置はコード改善部ので、モデルベース開発において、モデルからソースコードを自動生成する際に、動的な制約、静的な制約に関わらず、最適なソースコードを生成できる。
*** Effects of Embodiment 1 ***
As described above, the source code improving apparatus according to Embodiment 1 depends on the description method of the control model and the hardware information of the microcomputer by performing simulation on the source code automatically generated from the control model. And the source code can be improved. Therefore, the software development period can be shortened.
In addition, since the source code improvement device is a code improvement unit, when generating source code automatically from a model in model-based development, an optimal source code can be generated regardless of dynamic constraints and static constraints.
 1 ソースコード改善装置、10 プロセッサ、11 コード生成部、12 シミュレーション部、13 コード改善部、20 ストレージ、21 制御モデル格納部、21A 制御モデル、21B ソースコード、21C 実行ファイル、21D 実行結果、22 生成コード格納部、23 マイクロコンピュータ情報格納部、23A マイクロコンピュータ情報、24 演算方法格納部、24A 演算方法情報、25 改善後コード格納部、30 メモリ、40 I/Oインタフェース、50 入力装置、60 表示装置、71 関連情報、72 改善情報。 1 source code improvement device, 10 processor, 11 code generation unit, 12 simulation unit, 13 code improvement unit, 20 storage, 21 control model storage unit, 21A control model, 21B source code, 21C execution file, 21D execution result, 22 generation Code storage unit, 23 microcomputer information storage unit, 23A microcomputer information, 24 calculation method storage unit, 24A calculation method information, 25 improved code storage unit, 30 memory, 40 I / O interface, 50 input device, 60 display device 71 related information, 72 improvement information.

Claims (5)

  1.  制御モデルからソースコードを生成するコード生成部と、
     指定された識別情報で識別されるマイクロコンピュータが前記ソースコードで動作するシミュレーションを行い、シミュレーション結果である実行結果を生成するシミュレーション部と、
     前記実行結果に対する目標値と前記実行結果の示す値とを比較し、前記実行結果が前記目標値を満たしているか判定し、満たしていないと判定した場合に、前記実行結果に関連する関連情報を前記ソースコードから取得し、演算種別ごとに前記演算の有する複数の属性が対応付けられた演算種別情報を対象に前記関連情報を用いて検索することにより前記ソースコードを改善するための改善情報を前記演算種別情報から抽出し、前記改善情報を用いて前記ソースコードを改善するコード改善部と
    を備えるソースコード改善装置。
    A code generator for generating source code from the control model;
    A simulation unit that performs a simulation in which the microcomputer identified by the specified identification information operates with the source code, and generates an execution result that is a simulation result; and
    A target value for the execution result is compared with a value indicated by the execution result, and it is determined whether the execution result satisfies the target value. When it is determined that the execution result does not satisfy the target value, related information related to the execution result is obtained. Improvement information for improving the source code by searching using the related information for operation type information acquired from the source code and associated with a plurality of attributes of the operation for each operation type A source code improvement device comprising: a code improvement unit that extracts from the operation type information and improves the source code using the improvement information.
  2.  前記コード改善部は、
     前記値が前記目標値を満たしていないと判定された前記実行結果に関連するパラメータを前記制御モデルから取得し、前記ソースコードに含まれる前記パラメータの値の変更を含めて前記ソースコードを改善する請求項1に記載のソースコード改善装置。
    The code improvement unit
    A parameter related to the execution result determined that the value does not satisfy the target value is acquired from the control model, and the source code is improved by including a change in the value of the parameter included in the source code The source code improvement device according to claim 1.
  3.  前記コード改善部は、
     前記識別情報で識別される前記マイクロコンピュータが改善された前記ソースコードで動作するシミュレーションを前記シミュレーション部に行わせることで、改善された前記ソースコードによる改善後の実行結果を前記シミュレーション部に生成させ、前記目標値と改善後の実行結果の示す値とを比較し、改善後の実行結果が前記目標値を満たしているか判定する請求項1または請求項2に記載のソースコード改善装置。
    The code improvement unit
    By causing the simulation unit to perform a simulation in which the microcomputer identified by the identification information operates with the improved source code, the simulation unit generates an improved execution result with the improved source code. 3. The source code improving apparatus according to claim 1, wherein the target value is compared with a value indicated by the improved execution result to determine whether the improved execution result satisfies the target value.
  4.  コンピュータが行うソースコード改善方法であって、
     制御モデルからソースコードを生成し、
     指定された識別情報で識別されるマイクロコンピュータが前記ソースコードで動作するシミュレーションを行い、シミュレーション結果である実行結果を生成し、
     前記実行結果に対する目標値と前記実行結果の示す値とを比較し、前記実行結果が前記目標値を満たしているか判定し、満たしていないと判定した場合に、前記実行結果に関連する関連情報を前記ソースコードから取得し、演算種別ごとに前記演算の有する複数の属性が対応付けられた演算種別情報を対象に前記関連情報を用いて検索することにより前記ソースコードを改善するための改善情報を前記演算種別情報から抽出し、前記改善情報を用いて前記ソースコードを改善する、
    ソースコード改善方法。
    A source code improvement method performed by a computer,
    Generate source code from the control model,
    The microcomputer identified by the specified identification information performs a simulation that operates on the source code, generates an execution result that is a simulation result,
    A target value for the execution result is compared with a value indicated by the execution result, and it is determined whether the execution result satisfies the target value. When it is determined that the execution result does not satisfy the target value, related information related to the execution result is obtained. Improvement information for improving the source code by searching using the related information for operation type information acquired from the source code and associated with a plurality of attributes of the operation for each operation type Extracting from the operation type information and improving the source code using the improvement information;
    Source code improvement method.
  5.  コンピュータに、
     制御モデルからソースコードを生成する処理と、
     指定された識別情報で識別されるマイクロコンピュータが前記ソースコードで動作するシミュレーションを行い、シミュレーション結果である実行結果を生成する処理と、
     前記実行結果の目標値と前記実行結果の示す値とを比較し、前記実行結果が前記目標値を満たしているか判定し、満たしていないと判定した場合に、前記実行結果に関連する関連情報を前記ソースコードから取得し、演算種別ごとに前記演算の有する複数の属性が対応付けられた演算種別情報を対象に前記関連情報を用いて検索することにより前記ソースコードを改善するための改善情報を前記演算種別情報から抽出し、前記改善情報を用いて前記ソースコードを改善する処理と
    を実行させるためのソースコード改善プログラム。
    On the computer,
    Processing to generate source code from the control model;
    A process in which a microcomputer identified by the specified identification information operates with the source code and generates an execution result which is a simulation result;
    The target value of the execution result is compared with the value indicated by the execution result, and it is determined whether the execution result satisfies the target value, and when it is determined that the execution result does not satisfy, the related information related to the execution result is Improvement information for improving the source code by searching using the related information for operation type information acquired from the source code and associated with a plurality of attributes of the operation for each operation type A source code improvement program for executing processing for extracting from the operation type information and improving the source code using the improvement information.
PCT/JP2017/009088 2017-03-07 2017-03-07 Source code improvement device, source code improvement method, and source code improvement program WO2018163304A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2017/009088 WO2018163304A1 (en) 2017-03-07 2017-03-07 Source code improvement device, source code improvement method, and source code improvement program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2017/009088 WO2018163304A1 (en) 2017-03-07 2017-03-07 Source code improvement device, source code improvement method, and source code improvement program

Publications (1)

Publication Number Publication Date
WO2018163304A1 true WO2018163304A1 (en) 2018-09-13

Family

ID=63448169

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2017/009088 WO2018163304A1 (en) 2017-03-07 2017-03-07 Source code improvement device, source code improvement method, and source code improvement program

Country Status (1)

Country Link
WO (1) WO2018163304A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021047480A (en) * 2019-09-17 2021-03-25 富士通株式会社 Information processing method and optimization program
CN116724276A (en) * 2021-03-18 2023-09-08 三菱电机株式会社 Operation improvement support program, operation improvement support device, and operation improvement support method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004280786A (en) * 2003-02-28 2004-10-07 Denso Corp Control program inspection method, inspection device and inspection program
JP2005301568A (en) * 2004-04-09 2005-10-27 Denso Corp Display information storage controller, and program thereof
WO2010131758A1 (en) * 2009-05-12 2010-11-18 日本電気株式会社 Model verification system, model verification method and recording medium
JP2014059805A (en) * 2012-09-19 2014-04-03 Denso Corp Test case generation device and test case generation method for model-based control device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004280786A (en) * 2003-02-28 2004-10-07 Denso Corp Control program inspection method, inspection device and inspection program
JP2005301568A (en) * 2004-04-09 2005-10-27 Denso Corp Display information storage controller, and program thereof
WO2010131758A1 (en) * 2009-05-12 2010-11-18 日本電気株式会社 Model verification system, model verification method and recording medium
JP2014059805A (en) * 2012-09-19 2014-04-03 Denso Corp Test case generation device and test case generation method for model-based control device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021047480A (en) * 2019-09-17 2021-03-25 富士通株式会社 Information processing method and optimization program
JP7263994B2 (en) 2019-09-17 2023-04-25 富士通株式会社 Information processing method and optimization program
CN116724276A (en) * 2021-03-18 2023-09-08 三菱电机株式会社 Operation improvement support program, operation improvement support device, and operation improvement support method

Similar Documents

Publication Publication Date Title
US11157385B2 (en) Time-weighted risky code prediction
US10175975B2 (en) Self-mending software builder
CN113641701B (en) Data query method, system, heterogeneous acceleration platform and storage medium
US9141344B2 (en) Hover help support for application source code
WO2018163304A1 (en) Source code improvement device, source code improvement method, and source code improvement program
US11120602B2 (en) Acceleration of shader programs by compiler precision selection
KR20140050323A (en) Method and apparatus for license verification of binary file
US11782813B2 (en) Methods and apparatus to determine refined context for software bug detection and correction
JPWO2009011057A1 (en) Application analysis program, application analysis method, and application analysis apparatus
AU2017227739B2 (en) Automated testing method for application program user interface, electronic device, system, and storage medium
JP5758311B2 (en) Test code generation device, test code generation method, test code generation program
JP5826099B2 (en) Software evaluation support apparatus and program
JP2023183447A (en) Rewriting program, rewriting method, and information processing apparatus
US20210049008A1 (en) Identifying implicit dependencies between code artifacts
JP2021103354A (en) Program testing method
US20140372982A1 (en) Standardization of variable names in an integrated development environment
KR20200073700A (en) Apparatus and method for generating and managing document
JP5190899B2 (en) Information processing apparatus, setting file generation method, and setting file generation program
Garnaik et al. Reliability enhancement of software programs by minimizing the overflow errors
US20150310134A1 (en) Interference detection in a three-dimensional data model
JP2023031614A (en) Change degree measuring device, method, and program
JP6877150B2 (en) Project management support device, project management support method and project management support program
WO2019171425A1 (en) Software development assistance device, software development assistance method, and software development assistance program
JP2013029920A (en) Information processing apparatus, information processing method and program
JP5458956B2 (en) COBOL variable definition automatic generation system and COBOL variable definition automatic generation method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17900004

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17900004

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP