JP2021174426A - Source code automatic generation system - Google Patents

Source code automatic generation system Download PDF

Info

Publication number
JP2021174426A
JP2021174426A JP2020080034A JP2020080034A JP2021174426A JP 2021174426 A JP2021174426 A JP 2021174426A JP 2020080034 A JP2020080034 A JP 2020080034A JP 2020080034 A JP2020080034 A JP 2020080034A JP 2021174426 A JP2021174426 A JP 2021174426A
Authority
JP
Japan
Prior art keywords
source code
information
cpu
code
driver
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
JP2020080034A
Other languages
Japanese (ja)
Inventor
智大 川本
Tomohiro Kawamoto
正一 近藤
Shoichi Kondo
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.)
Model Solution Tech Co Ltd
Original Assignee
Model Solution Tech 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 Model Solution Tech Co Ltd filed Critical Model Solution Tech Co Ltd
Priority to JP2020080034A priority Critical patent/JP2021174426A/en
Publication of JP2021174426A publication Critical patent/JP2021174426A/en
Pending legal-status Critical Current

Links

Images

Abstract

To provide a source code automatic generation system and a method which can generate a source code of a mounting model including a code in a part depending on a device at a high execution rate while suppressing consumption of a storage capacity.SOLUTION: A source code automatic generation system 11 includes: an automatic code generation part 18 for generating a control application source code 19 on the basis of a block describing control processing operation; a device analysis part 20 for analyzing target information 21b related to a CPU to be mounted and device information 21a related to an IO device, which are included in a controller model; a device driver generation part 22 for generating only a device driver source code 24 required for mounting the IO device corresponding to the CPU from a device driver library 23 on the basis of the information analyzed by the device analysis part; and a code coupling part 25 for outputting the control application source code and the device source code as an integral source code 26.SELECTED DRAWING: Figure 1

Description

本発明は、ソースコード自動生成システム及び方法に関し、詳しくは、モデルベース開発における、ソースコードを自動生成するプログラムを用いて、コントローラ(マイコン)に内蔵されるデバイスに依存する部分のコードを含んだ実装モデルのソースコードを自動生成するシステム及び方法に関する。 The present invention relates to an automatic source code generation system and method, and more specifically, includes a device-dependent part code built in a controller (microcomputer) by using a program for automatically generating source code in model-based development. The system and method for automatically generating the source code of the implementation model.

自動車、航空機、ロボット等の高度な制御を必要とする電子機器開発の分野では、電子機器の制御内容や制御対象を数式によってモデル化し、これらのモデルを用いてシミュレーションをしながら制御装置や制御プログラムの開発・検証をしていくモデルベース開発という手法がある。 In the field of electronic device development that requires advanced control of automobiles, aircraft, robots, etc., the control contents and control targets of electronic devices are modeled by mathematical formulas, and control devices and control programs are simulated using these models. There is a method called model-based development that develops and verifies.

モデルベース開発におけるモデルの記述やシミュレーションは、例えば、Mathworks(登録商標)社が提供する、シミュレーションに必要な行列計算が容易に行えるMATLAB(登録商標)や、コントローラ・モデルをブロック線図でグラフィカルに記述可能なSimulink(登録商標)といったソフトウェアによって行われる。 For model description and simulation in model-based development, for example, MATLAB (registered trademark) provided by MathWorks (registered trademark) that can easily calculate the matrix required for simulation, and the controller model graphically in a block diagram. It is done by software such as descriptive Simulation®.

開発者は、MATLAB(登録商標)/Simulink(登録商標)を用いることで、設計したコントローラ・モデルをコンピュータ上でシミュレーションし、実現したい処理動作の妥当性を検証することができ、しかも、検証したコントローラ・モデルについては、例えば、dSPACE社の提供するTargetLink(登録商標)といった自動コード生成ツールを適用することで、実物のコントローラによる制御を実行可能なソースコードを自動生成可能である。 By using MATLAB (registered trademark) / Simulink (registered trademark), the developer can simulate the designed controller model on a computer and verify the validity of the processing operation to be realized, and also verified it. For the controller model, for example, by applying an automatic code generation tool such as TargetLink (registered trademark) provided by dSPACE, it is possible to automatically generate source code that can be controlled by an actual controller.

ただし、現実にコントローラ・モデル通りの制御を実行するには、センサ、アクチュエータ等の周辺機器や、それらの信号をやりとりするためのIOデバイスといった各種のデバイスの存在が必須となるので、制御を実行するソースコードには、アプリケーション(制御ソフトウェア)をデバイスに適合させるための専用の処理ルーチンであるデバイスドライバのコードも必要となる。 However, in order to actually execute control according to the controller model, the existence of various devices such as peripheral devices such as sensors and actuators and IO devices for exchanging those signals is essential, so control is executed. The source code to be executed also requires the code of the device driver, which is a dedicated processing routine for adapting the application (control software) to the device.

ところが、自動コード生成ツールは、デバイスごとに異なる仕様を持つデバイスドライバの自動生成にまでは対応しておらず、デバイスドライバの実装に関しては手動でコーディングする必要があった。そこで、そのようなデバイス依存な部分についてもソースコードを自動生成可能な技術が提案されている(例えば、特許文献1参照。)。 However, the automatic code generation tool does not support the automatic generation of device drivers with different specifications for each device, and it was necessary to manually code the device driver implementation. Therefore, a technique capable of automatically generating source code for such a device-dependent part has been proposed (see, for example, Patent Document 1).

例えば、自動車の各機能について制御を行うECUの開発において、ECUに搭載されるコントローラ(マイコン)には、外部と連携する機能を実現するため、各種のIOデバイス(ADC、DAC、DIO、PWM等)が内蔵されている。 For example, in the development of an ECU that controls each function of an automobile, various IO devices (ADC, DAC, DIO, PWM, etc.) are used in the controller (microcomputer) mounted on the ECU in order to realize a function of cooperating with the outside. ) Is built-in.

この場合、特許文献1に記載された方法によれば、各デバイスを補助ブロックとしてモデル化するとともに、各ドライバが登録されたライブラリを用意する。さらに、補助ブロックには、ライブラリからドライバを取り出すドライバインターフェース部を設け、ドライバインターフェース部を自動コード生成の対象とすることで、補助ブロックが接続されたコントローラ・モデルに対して、各補助ブロックに対応するデバイスのドライバと結合したソースコードを自動生成可能にしている。 In this case, according to the method described in Patent Document 1, each device is modeled as an auxiliary block, and a library in which each driver is registered is prepared. Furthermore, the auxiliary block is provided with a driver interface section that extracts the driver from the library, and by targeting the driver interface section for automatic code generation, each auxiliary block corresponds to the controller model to which the auxiliary block is connected. The source code combined with the driver of the device to be used can be automatically generated.

特許第5137367号公報Japanese Patent No. 5137367

しかしながら、特許文献1に記載された方法では、コントローラを変更した場合や、コントローラに内蔵されるデバイスが変更になると、対応するドライバも変更する必要があり、これに伴い、補助ブロックに設けられたドライバインターフェース部の変更も必要になるため、これらの変更への修正に手間がかかっていた。 However, in the method described in Patent Document 1, when the controller is changed or the device built in the controller is changed, it is necessary to change the corresponding driver as well, and the auxiliary block is provided accordingly. Since it is also necessary to change the driver interface part, it took time and effort to correct these changes.

これに対しては、例えば、ライブラリにアクセスするドライバインターフェース部を補助ブロックから独立させるラッパーを設けることが考えられる。その場合、補助ブロックには、ドライバインターフェース部に代えて、ラッパーにアクセスするラッパーインターフェース部を設けるとともに、ラッパー側にドライバインターフェース部を設けておく。 For this, for example, it is conceivable to provide a wrapper that makes the driver interface part that accesses the library independent from the auxiliary block. In that case, the auxiliary block is provided with a wrapper interface section for accessing the wrapper instead of the driver interface section, and a driver interface section is provided on the wrapper side.

また、ラッパーがドライバインターフェース部を介してライブラリからドライバを取り出せるようにし、補助ブロックが入出力の処理を行う際に用いるドライバを、ラッパーインターフェース部がラッパーから読み取るように構成する。そして、ラッパーインターフェース部を自動コード生成の対象とする。 Further, the wrapper can be fetched from the library via the driver interface section, and the driver used when the auxiliary block performs input / output processing is configured so that the wrapper interface section reads from the wrapper. Then, the wrapper interface part is targeted for automatic code generation.

このように、補助ブロックとライブラリとの関係を構築し直すことで、補助ブロック自体のデバイス依存性をなくせるので、デバイス変更時に必要な修正の手間を軽減することができる。しかしながら、ラッパーがドライバを取り出しているので、実行速度が悪化するという問題がある。 By reconstructing the relationship between the auxiliary block and the library in this way, the device dependence of the auxiliary block itself can be eliminated, and the time and effort required for modification when changing the device can be reduced. However, since the wrapper takes out the driver, there is a problem that the execution speed is deteriorated.

さらに、そのような対処を行ったとしても、使用する可能性のある様々なデバイスに対応するためには、それら全てのデバイスのドライバが登録されたライブラリが必要である。 Furthermore, even if such measures are taken, in order to support various devices that may be used, a library in which drivers for all of these devices are registered is required.

このため、CPUを内蔵するマイコン等の電子演算機器には、コントローラの構成やデバイスの種類を変更する場合に備えて、各種のデバイスに対応するデバイスドライバを、実際に使用することながなくても記憶しておかねばならず、モデルの実装時に無駄なリソース(記憶容量)が要求されるという問題があった。 For this reason, electronic computing devices such as microcomputers with a built-in CPU do not actually use device drivers corresponding to various devices in case the controller configuration or device type is changed. There was a problem that wasted resources (storage capacity) were required when implementing the model.

そこで本発明は、デバイスに依存する部分のコードを含んだ実装モデルのソースコードを、記憶容量の消費を抑え、早い実行速度によって、自動生成可能なソースコード自動生成システム及び方法を提供することを目的としている。 Therefore, the present invention provides an automatic source code generation system and method capable of automatically generating the source code of an implementation model including the code of a device-dependent part by suppressing the consumption of storage capacity and at a high execution speed. I am aiming.

上記目的を達成するため、本発明のソースコード自動生成システムは、ECU(Electric Control Unit)内部のマイコンに内蔵されるCPUに実装するためのソースコードを、前記CPUに関する制御の処理動作を記述するブロックと、前記CPUを他の機器と接続可能にするIOデバイスに対応するIOブロックとを有するコントローラ・モデルに基づいて自動生成するソースコード自動生成システムであって、前記制御の処理動作を記述するブロックに基づく制御アプリケーションソースコードを生成する自動コード生成部と、前記コントローラ・モデルに含まれる、実装される前記CPUに関する情報であるターゲット情報と、前記IOデバイスに関する情報であるデバイス情報を解析するデバイス解析部と、前記デバイス解析部で解析された前記ターゲット情報と前記デバイス情報とに基づいて、ドライバコードのテンプレートが格納されたデータベースであるデバイスドライバライブラリのテンプレートから、前記CPUに対応したIOデバイスの実装に必要なデバイスドライバソースコードのみを生成するデバイスドライバ生成部と、前記制御アプリケーションソースコードと前記デバイスドライブソースコードとを結合して、統合ソースコードとして出力するコード結合部と、を備えていることを特徴としている。 In order to achieve the above object, the source code automatic generation system of the present invention describes the control processing operation related to the CPU by mounting the source code to be mounted on the CPU built in the microcomputer inside the ECU (Electric Control Unit). A source code automatic generation system that is automatically generated based on a controller model having a block and an IO block corresponding to an IO device that enables the CPU to be connected to other devices, and describes the processing operation of the control. An automatic code generator that generates control application source code based on blocks, a device that analyzes target information that is included in the controller model and is information about the CPU to be implemented, and device information that is information about the IO device. From the template of the device driver library, which is a database in which the template of the driver code is stored, based on the analysis unit, the target information analyzed by the device analysis unit, and the device information, the IO device corresponding to the CPU can be used. It includes a device driver generator that generates only the device driver source code required for implementation, and a code coupling unit that combines the control application source code and the device drive source code and outputs it as an integrated source code. It is characterized by that.

また、上記目的を達成するため、本発明のソースコード自動生成方法は、ECU(Electric Control Unit)内部のマイコンに内蔵されるCPUに実装するためのソースコードを、前記CPUに関する制御の処理動作を記述するブロックと、前記CPUを他の機器と接続可能にするIOデバイスに対応するIOブロックとを有するコントローラ・モデルに基づいて自動生成するソースコード生成方法であって、前記制御の処理動作を記述するブロックに基づく制御アプリケーションソースコードを自動コード生成プログラムにより生成し、前記コントローラ・モデルに含まれる、実装される前記CPUに関する情報であるターゲット情報と、前記IOデバイスに関する情報であるデバイス情報を解析し、解析された前記ターゲット情報と前記デバイス情報に基づいて、ドライバコードのテンプレートが格納されたデータベースであるデバイスドライバライブラリのテンプレートから、前記CPUに対応したIOデバイスの実装に必要なデバイスドライバソースコードのみを生成し、前記制御アプリケーションソースコードと前記デバイスドライブソースコードとを結合することにより、統合ソースコードとして出力することを特徴としている。 Further, in order to achieve the above object, in the source code automatic generation method of the present invention, the source code for mounting the source code to be mounted on the CPU built in the microcomputer inside the ECU (Electric Control Unit) is subjected to the control processing operation related to the CPU. A source code generation method that automatically generates a source code based on a controller model having a block to be described and an IO block corresponding to an IO device that enables the CPU to be connected to other devices, and describes the processing operation of the control. The control application source code based on the block is generated by the automatic code generation program, and the target information which is the information about the CPU to be implemented and the device information which is the information about the IO device included in the controller model are analyzed. , Only the device driver source code required to implement the IO device corresponding to the CPU from the device driver library template, which is a database in which the driver code template is stored, based on the analyzed target information and the device information. Is generated, and the control application source code and the device drive source code are combined to output as an integrated source code.

本発明のソースコード自動生成システム及び方法によれば、デバイス解析部が、デバイス情報及びターゲット情報に基づいて、必要なデバイスドライバのソースコードのみを構成し、制御アプリケーションのソースコードと結合して統合ソースコードとして出力することができるので、ライブラリの記憶容量も少なく、実行速度も早い。 According to the source code automatic generation system and method of the present invention, the device analysis unit configures only the necessary device driver source code based on the device information and the target information, and integrates it by combining with the source code of the control application. Since it can be output as source code, the storage capacity of the library is small and the execution speed is fast.

ソースコード自動生成システムの一形態例を示すブロック図。The block diagram which shows one form example of the source code automatic generation system. ECUを含む制御システムを模式的に示すブロック図。The block diagram which shows typically the control system including an ECU. 図2のECU中のCPU及びIOデバイスをモデル化したアプリケーションモデルを示すブロック図。The block diagram which shows the application model which modeled the CPU and IO device in the ECU of FIG. 図3のアプリケーションモデルを含む制御システムの実装モデルにおける、各デバイスドライバが生成される流れを模式的に示すブロック図。FIG. 6 is a block diagram schematically showing a flow in which each device driver is generated in an implementation model of a control system including the application model of FIG. 統合ソースコードの生成プロセスを示すフローチャート。A flowchart showing the integrated source code generation process.

図1は、本発明のソースコード自動生成システム11の一形態例を示すブロック図である。図1に示されるように、ソースコード自動生成システム11は、コンピュータ上で動作し、ユーザーの操作を受けて、制御の設計及び制御内容の検証が可能なソフトウェアである制御設計部12を備えている。 FIG. 1 is a block diagram showing an example of one form of the source code automatic generation system 11 of the present invention. As shown in FIG. 1, the source code automatic generation system 11 includes a control design unit 12 which is software that operates on a computer and can be operated by a user to design a control and verify the control contents. There is.

制御設計部12は、コントローラの制御ロジックがブロック線図によって記述されたコントローラ・モデル13aや、制御対象の状態がブロック線図によって記述されたプラント・モデル13bを含むシミュレーション用のモデル13を読み込むことができ、モデル13の実装時にコントローラや制御対象を相互に接続するために必要な各種のIOデバイスをそれぞれモデル化した各種のIOブロック14が登録されている。 The control design unit 12 reads the model 13 for simulation including the controller model 13a in which the control logic of the controller is described by the block diagram and the plant model 13b in which the state of the controlled object is described by the block diagram. The various IO blocks 14 that model the various IO devices necessary for connecting the controller and the controlled object to each other at the time of mounting the model 13 are registered.

各種のIOブロック14には、検索・解析用のメタデータであるデバイス情報タグ14aがそれぞれ設定されており、デバイス情報タグ14aを読み取ることでIOブロック14に対応するIOデバイスの種類を外部から判別可能である。 A device information tag 14a, which is metadata for search / analysis, is set in each of the various IO blocks 14, and the type of IO device corresponding to the IO block 14 can be determined from the outside by reading the device information tag 14a. It is possible.

また、制御設計部12には、モデル編集部15と、シミュレーション処理部17と、自動コード生成部18とが設けられている。 Further, the control design unit 12 is provided with a model editing unit 15, a simulation processing unit 17, and an automatic code generation unit 18.

モデル編集部15は、ユーザーの操作によって、読み込んだモデル13及び登録されているIOブロック14同士の接続や、IOブロック14の設定変更等の編集操作が可能なGUI(グラフィカルユーザーインターフェース)である。 The model editing unit 15 is a GUI (graphical user interface) capable of performing editing operations such as connecting the read model 13 and the registered IO blocks 14 and changing the settings of the IO blocks 14 by the user's operation.

また、モデル編集部15は、コントローラ・モデル13a、プラント・モデル13b、及び、IOブロック14が相互に接続されたクローズドループを組むことで、フィードバック制御のシミュレーションが実行可能な実装モデル16を作成可能に構成されている。 Further, the model editing unit 15 can create an implementation model 16 capable of executing feedback control simulation by forming a closed loop in which the controller model 13a, the plant model 13b, and the IO block 14 are interconnected. It is configured in.

さらに、モデル編集部15では、ターゲットとなるCPU(マイコン)、すなわち実装されるCPUの種類を、型番等の情報で具体的に指定することが可能であり、その旨の情報は、実装モデル16に含まれる、CPUをモデル化したブロックに対して、外部から判別可能なCPU情報タグ16aとして設定される。 Further, in the model editing unit 15, the target CPU (microcomputer), that is, the type of CPU to be mounted can be specifically specified by information such as a model number, and the information to that effect is the mounting model 16. The block that models the CPU included in the above is set as a CPU information tag 16a that can be discriminated from the outside.

シミュレーション処理部17は、モデル編集部15で作成された実装モデル16の動作をシミュレーションによって検証することができ、ユーザーに対してシミュレーションの結果を表示可能に構成されている。 The simulation processing unit 17 can verify the operation of the mounting model 16 created by the model editing unit 15 by simulation, and is configured to be able to display the simulation result to the user.

自動コード生成部18は、シミュレーション処理部17によって動作の検証がされた実装モデル16のコントローラ・モデル13a又はプラント・モデル13bを、それぞれ、制御アプリケーションとして実行可能にする制御アプリケーションソースコード19を自動生成可能に構成されている。 The automatic code generation unit 18 automatically generates the control application source code 19 that enables the controller model 13a or the plant model 13b of the mounting model 16 whose operation has been verified by the simulation processing unit 17 to be executed as a control application, respectively. It is configured to be possible.

また、ソースコード自動生成システム11は、制御設計部12から情報を取得可能なデバイス解析部20を備えている。デバイス解析部20は、制御設計部12からモデル編集部15によって構築された、デバイス情報タグ14aとCPU情報タグ16aとを含む実装モデル16を読み込んで、実装モデル16の構成を解析し、実装モデル16のIOデバイスの種類、数、設定等の情報を含むデバイス情報21aと、実装されるCPUの情報であるターゲット情報21bとを出力する。 Further, the source code automatic generation system 11 includes a device analysis unit 20 capable of acquiring information from the control design unit 12. The device analysis unit 20 reads the mounting model 16 including the device information tag 14a and the CPU information tag 16a constructed by the model editing unit 15 from the control design unit 12, analyzes the configuration of the mounting model 16, and analyzes the mounting model. It outputs device information 21a including information such as types, numbers, and settings of 16 IO devices, and target information 21b which is information of the CPU to be mounted.

さらに、ソースコード自動生成システム11は、ドライバのコードを生成するデバイスドライバ生成部22と、デバイスドライバ生成部22との通信が可能な所定の記録媒体に記録され、任意のIOデバイスに対応するドライバコードのテンプレートが格納されたデータベースであるデバイスドライバライブラリ23とを備えている。 Further, the source code automatic generation system 11 is recorded on a predetermined recording medium capable of communicating between the device driver generation unit 22 that generates the driver code and the device driver generation unit 22, and is a driver corresponding to an arbitrary IO device. It includes a device driver library 23, which is a database in which code templates are stored.

デバイスドライバ生成部22は、デバイス解析部20から出力されたデバイス情報21aとターゲット情報21bとを読み込み、デバイスドライバライブラリ23から、ターゲットとなる特定のCPUに対応したIOデバイスに関するドライバコードを取得して、実装モデル16に組み込まれた特定のCPUに対応したIOデバイスの実装に必要なデバイスドライバソースコード24のみを生成可能に構成されている。 The device driver generation unit 22 reads the device information 21a and the target information 21b output from the device analysis unit 20, and acquires the driver code related to the IO device corresponding to the specific CPU as the target from the device driver library 23. , Only the device driver source code 24 necessary for mounting the IO device corresponding to the specific CPU incorporated in the mounting model 16 can be generated.

そして、ソースコード自動生成システム11は、制御設計部12と、デバイスドライバ生成部22とから情報を受信可能なコード結合部25を備えている。 The source code automatic generation system 11 includes a control design unit 12 and a code coupling unit 25 capable of receiving information from the device driver generation unit 22.

コード結合部25は、自動コード生成部18によって生成された制御アプリケーションソースコード19と、デバイスドライバ生成部22によって生成されたデバイスドライバソースコード24とを結合させた統合ソースコード26を生成可能に構成されている。 The code coupling unit 25 is configured to be capable of generating integrated source code 26 in which the control application source code 19 generated by the automatic code generation unit 18 and the device driver source code 24 generated by the device driver generation unit 22 are combined. Has been done.

以下、ソースコード自動生成システム11について、自動車のパワーウィンドウを動作させるECU(Electric Control Unit)の開発を例に挙げて説明する。 Hereinafter, the source code automatic generation system 11 will be described by taking as an example the development of an ECU (Electronic Control Unit) that operates a power window of an automobile.

図2は、パワーウィンドウを動かすECUを含む制御システムを模式的に示すブロック図である。図2に示されるように、パワーウィンドウ31は、窓の開閉動作を行うモータ32と、モータ32の内部状態を信号として出力するエンコーダ33とを備えている。 FIG. 2 is a block diagram schematically showing a control system including an ECU that moves a power window. As shown in FIG. 2, the power window 31 includes a motor 32 that opens and closes the window, and an encoder 33 that outputs the internal state of the motor 32 as a signal.

ECU34は、モータ32を駆動させるモータ駆動回路35と、モータ駆動回路35に信号を出力するための制御アプリケーションを搭載可能なターゲットCPU36とを備えている。 The ECU 34 includes a motor drive circuit 35 that drives the motor 32, and a target CPU 36 that can mount a control application for outputting a signal to the motor drive circuit 35.

スイッチ37は、自動車のドア窓を開け閉めするものである。スイッチ37からは、それぞれオンオフのデジタル入力信号であるDI信号38が発信され、パワーウィンドウ31のエンコーダ33からは、モータ32の回転角度に応じたパルス信号等を含むENC信号39が発信される。 The switch 37 opens and closes the door window of the automobile. A DI signal 38, which is an on / off digital input signal, is transmitted from the switch 37, and an ENC signal 39 including a pulse signal or the like according to the rotation angle of the motor 32 is transmitted from the encoder 33 of the power window 31.

ターゲットCPU36からは、モータ駆動回路35に対して、モータ32を駆動する出力信号であるPWM信号40と、モータ32の回転の正転・逆転を指定するデジタル出力信号であるDO信号41とを送信可能に構成されている。 The target CPU 36 transmits a PWM signal 40, which is an output signal for driving the motor 32, and a DO signal 41, which is a digital output signal for designating forward / reverse rotation of the motor 32, to the motor drive circuit 35. It is configured to be possible.

また、ターゲットCPU36には、DI信号38を受信可能にするIOデバイスであるDI42と、ENC信号39を受信可能にするIOデバイスであるENC43と、PWM信号40を送信可能にするIOデバイスであるPWMOut44と、DO信号41を送信可能にするIOデバイスであるDO45とが内蔵されている。 Further, the target CPU 36 includes DI 42, which is an IO device that enables reception of the DI signal 38, ENC 43, which is an IO device that enables reception of the ENC signal 39, and PWM Out 44, which is an IO device that enables transmission of the PWM signal 40. And DO45, which is an IO device that enables transmission of the DO signal 41, are built-in.

図3は、図1の制御設計部12において、図2のECU34中のターゲットCPU36及び各IOデバイスをモデル化したアプリケーションモデル(コントローラ・モデル)46を示すブロック図である。 FIG. 3 is a block diagram showing an application model (controller model) 46 in which the target CPU 36 and each IO device in the ECU 34 of FIG. 2 are modeled in the control design unit 12 of FIG.

図3に示されるように、アプリケーションモデル46は、スイッチ部37からターゲットCPU36に送られる入力信号に応じてモータ32をどのように駆動させるのかを定めるアルゴリズムが記述された制御ロジック記述ブロック47(本発明の制御の処理動作を記述するブロック)を備えている。 As shown in FIG. 3, the application model 46 describes a control logic description block 47 (present) in which an algorithm for determining how to drive the motor 32 in response to an input signal sent from the switch unit 37 to the target CPU 36 is described. A block that describes the processing operation of the control of the invention) is provided.

また、制御ロジック記述ブロック47には、IOブロック14の一種であるDIブロック48a,48bと、ENCブロック49とが入力側に、PWMOutブロック50と、DOブロック51とが出力側に、それぞれ接続されている。 Further, in the control logic description block 47, DI blocks 48a and 48b, which are a type of IO block 14, and ENC block 49 are connected to the input side, and PWMOut block 50 and DO block 51 are connected to the output side, respectively. ing.

ここで、DIブロック48a,48bは、DI42をモデル化したものであり、DIブロック48aはスイッチ37のUPに、DIブロック48bはスイッチ37のDOWNに対応している。また、ENCブロック49は、ENC43をモデル化したものである。また、PWMOutブロック50は、PWM44をモデル化したものであり、DOブロック51は、DO45をモデル化したものである。 Here, the DI blocks 48a and 48b are models of the DI 42, the DI block 48a corresponds to the UP of the switch 37, and the DI block 48b corresponds to the DOWN of the switch 37. The ENC block 49 is a model of the ENC 43. Further, the PWM Out block 50 is a model of the PWM 44, and the DO block 51 is a model of the DO 45.

図4は、図1の制御設計部12で設計された、図3のアプリケーションモデル46を含むECU実装モデル52における、各デバイスドライバが生成される流れを模式的に示すブロック図である。 FIG. 4 is a block diagram schematically showing a flow in which each device driver is generated in the ECU mounting model 52 including the application model 46 of FIG. 3 designed by the control design unit 12 of FIG.

図4に示されるように、ECU実装モデル52は、図2のパワーウィンドウ31とECU34とスイッチ37とをモデル化し、図1のモデル編集部15で組み合わせて作られた、実装モデル16の一形態である。 As shown in FIG. 4, the ECU mounting model 52 is a form of the mounting model 16 formed by modeling the power window 31 of FIG. 2, the ECU 34, and the switch 37 and combining them with the model editing unit 15 of FIG. Is.

デバイス解析部20は、ECU実装モデル52の構成を解析し、アプリケーションモデル46に付属しているCPU情報タグ16aとIOブロック14に付属しているデバイス情報タグ14aとに基づいて、ターゲットCPU36の種類とターゲットCPU36に接続しているIOデバイスの数及び種類とを特定する。 The device analysis unit 20 analyzes the configuration of the ECU mounting model 52, and based on the CPU information tag 16a attached to the application model 46 and the device information tag 14a attached to the IO block 14, the type of the target CPU 36 And the number and type of IO devices connected to the target CPU 36.

そして、特定したターゲットCPU36の種類をターゲット情報21bとして出力するとともに、特定したIOデバイスの設定内容をデバイス情報21aとして出力する。 Then, the type of the specified target CPU 36 is output as the target information 21b, and the setting contents of the specified IO device are output as the device information 21a.

すなわち、デバイス解析部20は、アプリケーションモデル46のうち、DIブロック48からDI42の情報を取得し、ENCブロック49からENC43の情報を取得し、PWMOutブロック50からPWM44の情報を取得し、DOブロック51からDO45の情報を取得してデバイス情報21aに含めることができる。 That is, the device analysis unit 20 acquires the information of the DI 42 from the DI block 48, the information of the ENC 43 from the ENC block 49, the information of the PWM 44 from the PWM Out block 50, and the DO block 51 in the application model 46. The DO45 information can be obtained from the device information 21a and included in the device information 21a.

また、デバイスドライバ生成部22は、デバイス情報21aとターゲット情報21bとに基づいてデバイスドライバライブラリ23から、ターゲットCPU36に対応する各デバイスドライバ(DIドライバ、ENCドライバ、PWMOutドライバ、DOドライバ)のソースコード(テンプレート)を取得し、デバイス情報21a及びターゲット情報21bに基づいた修正を加えた上で、生成するデバイスドライバソースコード24に含めることができる。 Further, the device driver generation unit 22 obtains the source code of each device driver (DI driver, ENC driver, PWMOut driver, DO driver) corresponding to the target CPU 36 from the device driver library 23 based on the device information 21a and the target information 21b. (Template) can be acquired, modified based on the device information 21a and the target information 21b, and then included in the generated device driver source code 24.

例えば、DOドライバであれば、DOドライバのテンプレートが取得された後、そのテンプレートのソースコードに対して、あらかじめユーザーによって指定された終了時の出力状態に応じた修正が行われる。また、ADCドライバであれば、ADCドライバのテンプレートが取得された後、そのテンプレートのソースコードに対して、あらかじめユーザーによって指定されたA/D(アナログ/デジタル)変換方法に応じたソースコードの修正が行われる。 For example, in the case of a DO driver, after the DO driver template is acquired, the source code of the template is modified according to the output state at the end specified by the user in advance. In the case of an ADC driver, after the template of the ADC driver is acquired, the source code of the template is modified according to the A / D (analog / digital) conversion method specified in advance by the user. Is done.

以下、ECU実装モデル52に関し、ソースコード自動生成システム11によって、デバイス依存の統合ソースコード26の生成プロセスを説明する。 Hereinafter, the process of generating the device-dependent integrated source code 26 by the source code automatic generation system 11 will be described with respect to the ECU mounting model 52.

図5は、統合ソースコード26の生成プロセスを示すフローチャートである。デバイス解析部20は、制御設計部12を監視しており、図5に示されるように、制御設計部12において、実装モデル16(ECU実装モデル52)を対象として、自動コード生成部18によって制御アプリケーションソースコード19(制御ロジック記述ブロック47のコード)の生成が開始されると(ステップS1)、実装モデル16(ECU実装モデル52)のデバイス解析を行い(ステップS2)、ターゲット情報とデバイス情報21aを取得する(ステップS3)。 FIG. 5 is a flowchart showing the generation process of the integrated source code 26. The device analysis unit 20 monitors the control design unit 12, and as shown in FIG. 5, the control design unit 12 controls the mounting model 16 (ECU mounting model 52) by the automatic code generation unit 18. When the generation of the application source code 19 (code of the control logic description block 47) is started (step S1), the device analysis of the mounting model 16 (ECU mounting model 52) is performed (step S2), and the target information and the device information 21a are performed. (Step S3).

デバイス解析部20は、デバイス情報21a及びターゲット情報21bを取得すると、取得したデバイス情報21a及びターゲット情報21bをデバイスドライバ生成部22に送る。デバイスドライバ生成部22は、デバイス解析部20からデバイス情報21a及びターゲット情報21bを受け取ると、ターゲット情報21bに基づくCPUに対応するデバイスドライバのテンプレートをデバイスドライバライブラリ23から取得する(ステップS4)とともに、デバイス情報21aに含まれる各デバイスの設定内容に基づいて、取得したデバイスドライバを修正し(ステップS5)、適切なデバイスドライバソースコード24を構築する(ステップS6)。 When the device analysis unit 20 acquires the device information 21a and the target information 21b, the device analysis unit 20 sends the acquired device information 21a and the target information 21b to the device driver generation unit 22. When the device driver generation unit 22 receives the device information 21a and the target information 21b from the device analysis unit 20, the device driver generation unit 22 acquires a device driver template corresponding to the CPU based on the target information 21b from the device driver library 23 (step S4), and also obtains the device driver template. Based on the setting contents of each device included in the device information 21a, the acquired device driver is modified (step S5), and an appropriate device driver source code 24 is constructed (step S6).

デバイスドライバ生成部22は、デバイスドライバソースコード24を構築すると、構築したデバイスドライバソースコード24をコード結合部25に送る。コード結合部25は、デバイスドライバ生成部22からデバイスドライバソースコード24を受け取ると、自動コード生成部18によって制御アプリケーションソースコード19が既に生成されているかを確認し、生成されていなければ生成されるまで待機する(ステップS7)。 When the device driver source code 24 is constructed, the device driver generation unit 22 sends the constructed device driver source code 24 to the code coupling unit 25. When the code coupling unit 25 receives the device driver source code 24 from the device driver generation unit 22, the automatic code generation unit 18 confirms whether the control application source code 19 has already been generated, and if it has not been generated, the code coupling unit 25 is generated. Wait until (step S7).

制御アプリケーションソースコード19が生成されていれば、コード結合部25は、自動コード生成部18から制御アプリケーションソースコード19を受け取って、受け取った制御アプリケーションソースコード19とデバイスドライバソースコード24とを結合し、統合ソースコード26を構築する。 If the control application source code 19 is generated, the code coupling unit 25 receives the control application source code 19 from the automatic code generation unit 18 and combines the received control application source code 19 with the device driver source code 24. , Build integrated source code 26.

なお、この形態例では、図1の、制御の処理動作を記述するコントローラ・モデル13aを、ECUの中にあるCPUに実装しているが、本発明は、図1の、制御対象の動特性を記述するプラント・モデル13bを、HILS(Hardware in the Loop Simulation)におけるハードウェアの中にあるCPUに実装する場合にも適用できるものである。 In this embodiment, the controller model 13a, which describes the control processing operation shown in FIG. 1, is mounted on the CPU in the ECU. However, in the present invention, the dynamic characteristics of the controlled object shown in FIG. The plant model 13b that describes the above can also be applied to a CPU in hardware in HILS (Hardware in the Loop Simulation).

このように、本発明のソースコード自動生成システム11によれば、制御設計部12において、シミュレーション用のモデル13とIOブロック14とを組み合わせた実装モデル16のうち、コントローラ・モデル13a又はプラント・モデル13bに係る制御アプリケーションソースコード19を自動コード生成部18によって生成すると、デバイス解析部20が実装モデル16から、IOブロック14に関するデバイス情報21aと実装するCPUのターゲット情報21bとを取得し、デバイスドライバ生成部22がこのデバイス情報21a及びターゲット情報21bに基づいてデバイスドライバソースコード24を生成し、さらに、生成された制御アプリケーションソースコード19とデバイスドライバソースコード24とがコード結合部25によって結合されて統合ソースコード26として出力されるので、任意のデバイスが接続されたコントローラを動作させ、記憶容量の消費を抑えたデバイス依存ソースコードを実装モデルから自動生成することができる。 As described above, according to the source code automatic generation system 11 of the present invention, the control design unit 12 has the controller model 13a or the plant model among the mounting models 16 in which the simulation model 13 and the IO block 14 are combined. When the control application source code 19 according to 13b is generated by the automatic code generation unit 18, the device analysis unit 20 acquires the device information 21a related to the IO block 14 and the target information 21b of the CPU to be mounted from the mounting model 16, and the device driver. The generation unit 22 generates the device driver source code 24 based on the device information 21a and the target information 21b, and further, the generated control application source code 19 and the device driver source code 24 are combined by the code coupling unit 25. Since it is output as the integrated source code 26, it is possible to operate a controller to which an arbitrary device is connected and automatically generate a device-dependent source code that suppresses the consumption of storage capacity from the implementation model.

なお、本発明は、以上の形態例に限定されることなく、発明の範囲内において種々の変更が可能である。例えば、本形態例では、デバイス解析部による実装モデルのデバイス解析は、自動コード生成部による制御アプリケーションソースコード生成の開始に応じて行われているが、同一の実装モデルについてデバイス解析と自動コード生成とが行われて、その結果生成されたデバイスドライバソースコードと制御アプリケーションソースコードとが結合されるのであれば、必ずしもデバイス解析の実行を制御アプリケーションソースコード生成の開始に合わせる必要はなく、デバイス解析の実行タイミングをユーザーが手動で決定してもよい。 The present invention is not limited to the above embodiment, and various modifications can be made within the scope of the invention. For example, in this embodiment, device analysis of the implementation model by the device analysis unit is performed according to the start of control application source code generation by the automatic code generation unit, but device analysis and automatic code generation for the same implementation model. If the resulting device driver source code and control application source code are combined, the execution of device analysis does not necessarily have to coincide with the start of control application source code generation. The user may manually determine the execution timing of.

また、本形態例では、デバイスドライバソースコードの生成は、デバイスドライバ生成部によって行われるが、デバイス解析部から出力されたデバイス情報に基づく適切なデバイスドライバソースコードが作られるのであれば必ずしも自動生成しなくてもよく、デバイスドライバ生成部に代えてユーザーが作成してもよい。 Further, in this embodiment, the device driver source code is generated by the device driver generation unit, but it is not always automatically generated if an appropriate device driver source code is created based on the device information output from the device analysis unit. It does not have to be done, and it may be created by the user instead of the device driver generator.

11…ソースコード自動生成システム、12…制御設計部、13…モデル、13a…コントローラ・モデル、13b…プラント・モデル、14…IOブロック、14a…デバイス情報タグ、15…モデル編集部、16…実装モデル、17…シミュレーション処理部、18…自動コード生成部、19…制御アプリケーションソースコード、20…デバイス解析部、21a…デバイス情報、21b…ターゲット情報、22…デバイスドライバ生成部、23…デバイスドライバライブラリ、24…デバイスドライバソースコード、25…コード結合部、26…統合ソースコード、31…パワーウィンドウ、32…モータ、33…エンコーダ、34…ECU、35…モータ駆動回路、36…ターゲットCPU、37…スイッチ、38…DI信号、39…ENC信号、40…PWM信号、41…DO信号、42…DI、43…ENC、44…PWM、45…DO、46…アプリケーションモデル、47…制御ロジック記述ブロック、48a,48b…DIブロック、49…ENCブロック、50…PWMOutブロック、51…DOブロック、52…ECU実装モデル 11 ... Source code automatic generation system, 12 ... Control design department, 13 ... Model, 13a ... Controller model, 13b ... Plant model, 14 ... IO block, 14a ... Device information tag, 15 ... Model editorial department, 16 ... Implementation Model, 17 ... Simulation processing unit, 18 ... Automatic code generation unit, 19 ... Control application source code, 20 ... Device analysis unit, 21a ... Device information, 21b ... Target information, 22 ... Device driver generation unit, 23 ... Device driver library , 24 ... device driver source code, 25 ... code coupling, 26 ... integrated source code, 31 ... power window, 32 ... motor, 33 ... encoder, 34 ... ECU, 35 ... motor drive circuit, 36 ... target CPU, 37 ... Switch, 38 ... DI signal, 39 ... ENC signal, 40 ... PWM signal, 41 ... DO signal, 42 ... DI, 43 ... ENC, 44 ... PWM, 45 ... DO, 46 ... Application model, 47 ... Control logic description block, 48a, 48b ... DI block, 49 ... ENC block, 50 ... PWMOut block, 51 ... DO block, 52 ... ECU mounting model

Claims (2)

ECU(Electric Control Unit)内部のマイコンに内蔵されるCPUに実装するためのソースコードを、前記CPUに関する制御の処理動作を記述するブロックと、前記CPUを他の機器と接続可能にするIOデバイスに対応するIOブロックとを有するコントローラ・モデルに基づいて自動生成するソースコード自動生成システムであって、
前記制御の処理動作を記述するブロックに基づく制御アプリケーションソースコードを生成する自動コード生成部と、
前記コントローラ・モデルに含まれる、実装される前記CPUに関する情報であるターゲット情報と、前記IOデバイスに関する情報であるデバイス情報を解析するデバイス解析部と、
前記デバイス解析部で解析された前記ターゲット情報と前記デバイス情報とに基づいて、ドライバコードのテンプレートが格納されたデータベースであるデバイスドライバライブラリのテンプレートから、前記CPUに対応したIOデバイスの実装に必要なデバイスドライバソースコードのみを生成するデバイスドライバ生成部と、
前記制御アプリケーションソースコードと前記デバイスドライブソースコードとを結合して、統合ソースコードとして出力するコード結合部と、
を備えたソースコード自動生成システム。
The source code for mounting on the CPU built in the microcomputer inside the ECU (Electronic Controller Unit) is attached to the block that describes the control processing operation related to the CPU and the IO device that enables the CPU to be connected to other devices. A source code automatic generation system that automatically generates based on a controller model that has a corresponding IO block.
An automatic code generator that generates control application source code based on a block that describes the processing operation of the control,
A device analysis unit that analyzes target information, which is information about the CPU to be mounted, and device information, which is information about the IO device, included in the controller model.
Based on the target information analyzed by the device analysis unit and the device information, it is necessary to implement an IO device corresponding to the CPU from the template of the device driver library which is a database in which the template of the driver code is stored. A device driver generator that generates only the device driver source code,
A code coupling unit that combines the control application source code and the device drive source code and outputs it as an integrated source code.
Source code automatic generation system with.
ECU(Electric Control Unit)内部のマイコンに内蔵されるCPUに実装するためのソースコードを、前記CPUに関する制御の処理動作を記述するブロックと、前記CPUを他の機器と接続可能にするIOデバイスに対応するIOブロックとを有するコントローラ・モデルに基づいて自動生成するソースコード生成方法であって、
前記制御の処理動作を記述するブロックに基づく制御アプリケーションソースコードを自動コード生成プログラムにより生成し、
前記コントローラ・モデルに含まれる、実装される前記CPUに関する情報であるターゲット情報と、前記IOデバイスに関する情報であるデバイス情報を解析し、
解析された前記ターゲット情報と前記デバイス情報に基づいて、ドライバコードのテンプレートが格納されたデータベースであるデバイスドライバライブラリのテンプレートから、前記CPUに対応したIOデバイスの実装に必要なデバイスドライバソースコードのみを生成し、
前記制御アプリケーションソースコードと前記デバイスドライブソースコードとを結合することにより、統合ソースコードとして出力するソースコード生成方法。
The source code for mounting on the CPU built in the microcomputer inside the ECU (Electronic Controller Unit) is attached to the block that describes the control processing operation related to the CPU and the IO device that enables the CPU to be connected to other devices. A source code generation method that automatically generates based on a controller model that has a corresponding IO block.
A control application source code based on a block that describes the processing operation of the control is generated by an automatic code generation program.
The target information, which is information about the CPU to be mounted, and the device information, which is information about the IO device, included in the controller model are analyzed.
Based on the analyzed target information and the device information, only the device driver source code necessary for implementing the IO device corresponding to the CPU is extracted from the device driver library template, which is a database in which the driver code template is stored. Generate and
A source code generation method that outputs as integrated source code by combining the control application source code and the device drive source code.
JP2020080034A 2020-04-30 2020-04-30 Source code automatic generation system Pending JP2021174426A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2020080034A JP2021174426A (en) 2020-04-30 2020-04-30 Source code automatic generation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2020080034A JP2021174426A (en) 2020-04-30 2020-04-30 Source code automatic generation system

Publications (1)

Publication Number Publication Date
JP2021174426A true JP2021174426A (en) 2021-11-01

Family

ID=78279728

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2020080034A Pending JP2021174426A (en) 2020-04-30 2020-04-30 Source code automatic generation system

Country Status (1)

Country Link
JP (1) JP2021174426A (en)

Similar Documents

Publication Publication Date Title
US6442441B1 (en) Method of automatically generating and verifying programmable logic controller code
US20050102054A1 (en) Method and system for simulating processing of a workpiece with a machine tool
Muller-Glaser et al. Multiparadigm modeling in embedded systems design
US20160085567A1 (en) Method for executing an application program of an electronic control unit on a computer
US20140324408A1 (en) Flexible allocation of i/o channels of a hardware component
JP2012208843A (en) Development support device
JP2014199635A (en) Calculation device and simulation system
JP4885639B2 (en) HILS equipment
JP2007518152A (en) Simulation system and computer-implemented method for simulating and verifying a control system
JP2021174426A (en) Source code automatic generation system
JP5137367B2 (en) Model-based development auxiliary block, simulation system, and automatic code generation method
Erkkinen et al. Automatic code generation-technology adoption lessons learned from commercial vehicle case studies
Wozniak et al. A guidance framework for the generation of implementation models in the automotive domain
US20210141710A1 (en) Development support device
Rafique et al. Generating hardware specific code at different abstraction levels using Averest
JP2005250793A (en) Physical model creation apparatus, simulation system having the physical model creation apparatus, and physical model creation method
JP2008159058A (en) Method and device for dynamically processing object
JP2016071883A (en) Determining signals for readback from fpga
Neudorfer et al. FMI for Physics-Based Models on AUTOSAR Platforms
Geng et al. Embedded C code generation platform for electric vehicle controller
Heininger et al. Testing power electronics according to ISO 26262
Rafique et al. Learning various aspects of a distributed real-time automotive embedded system
Hosoai et al. System product line engineering for small appliances with driver derivation
Vasiliu et al. Hardware-in-the-loop simulation for electric powertrains
JP4549077B2 (en) Simulation apparatus and program for the apparatus