JP2021174426A - Source code automatic generation system - Google Patents
Source code automatic generation system Download PDFInfo
- 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
Links
Images
Abstract
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
しかしながら、特許文献1に記載された方法では、コントローラを変更した場合や、コントローラに内蔵されるデバイスが変更になると、対応するドライバも変更する必要があり、これに伴い、補助ブロックに設けられたドライバインターフェース部の変更も必要になるため、これらの変更への修正に手間がかかっていた。
However, in the method described in
これに対しては、例えば、ライブラリにアクセスするドライバインターフェース部を補助ブロックから独立させるラッパーを設けることが考えられる。その場合、補助ブロックには、ドライバインターフェース部に代えて、ラッパーにアクセスするラッパーインターフェース部を設けるとともに、ラッパー側にドライバインターフェース部を設けておく。 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.
図1は、本発明のソースコード自動生成システム11の一形態例を示すブロック図である。図1に示されるように、ソースコード自動生成システム11は、コンピュータ上で動作し、ユーザーの操作を受けて、制御の設計及び制御内容の検証が可能なソフトウェアである制御設計部12を備えている。
FIG. 1 is a block diagram showing an example of one form of the source code
制御設計部12は、コントローラの制御ロジックがブロック線図によって記述されたコントローラ・モデル13aや、制御対象の状態がブロック線図によって記述されたプラント・モデル13bを含むシミュレーション用のモデル13を読み込むことができ、モデル13の実装時にコントローラや制御対象を相互に接続するために必要な各種のIOデバイスをそれぞれモデル化した各種のIOブロック14が登録されている。
The
各種のIOブロック14には、検索・解析用のメタデータであるデバイス情報タグ14aがそれぞれ設定されており、デバイス情報タグ14aを読み取ることでIOブロック14に対応するIOデバイスの種類を外部から判別可能である。
A
また、制御設計部12には、モデル編集部15と、シミュレーション処理部17と、自動コード生成部18とが設けられている。
Further, the
モデル編集部15は、ユーザーの操作によって、読み込んだモデル13及び登録されているIOブロック14同士の接続や、IOブロック14の設定変更等の編集操作が可能なGUI(グラフィカルユーザーインターフェース)である。
The
また、モデル編集部15は、コントローラ・モデル13a、プラント・モデル13b、及び、IOブロック14が相互に接続されたクローズドループを組むことで、フィードバック制御のシミュレーションが実行可能な実装モデル16を作成可能に構成されている。
Further, the
さらに、モデル編集部15では、ターゲットとなるCPU(マイコン)、すなわち実装されるCPUの種類を、型番等の情報で具体的に指定することが可能であり、その旨の情報は、実装モデル16に含まれる、CPUをモデル化したブロックに対して、外部から判別可能なCPU情報タグ16aとして設定される。
Further, in the
シミュレーション処理部17は、モデル編集部15で作成された実装モデル16の動作をシミュレーションによって検証することができ、ユーザーに対してシミュレーションの結果を表示可能に構成されている。
The
自動コード生成部18は、シミュレーション処理部17によって動作の検証がされた実装モデル16のコントローラ・モデル13a又はプラント・モデル13bを、それぞれ、制御アプリケーションとして実行可能にする制御アプリケーションソースコード19を自動生成可能に構成されている。
The automatic code generation unit 18 automatically generates the control
また、ソースコード自動生成システム11は、制御設計部12から情報を取得可能なデバイス解析部20を備えている。デバイス解析部20は、制御設計部12からモデル編集部15によって構築された、デバイス情報タグ14aとCPU情報タグ16aとを含む実装モデル16を読み込んで、実装モデル16の構成を解析し、実装モデル16のIOデバイスの種類、数、設定等の情報を含むデバイス情報21aと、実装されるCPUの情報であるターゲット情報21bとを出力する。
Further, the source code
さらに、ソースコード自動生成システム11は、ドライバのコードを生成するデバイスドライバ生成部22と、デバイスドライバ生成部22との通信が可能な所定の記録媒体に記録され、任意のIOデバイスに対応するドライバコードのテンプレートが格納されたデータベースであるデバイスドライバライブラリ23とを備えている。
Further, the source code
デバイスドライバ生成部22は、デバイス解析部20から出力されたデバイス情報21aとターゲット情報21bとを読み込み、デバイスドライバライブラリ23から、ターゲットとなる特定のCPUに対応したIOデバイスに関するドライバコードを取得して、実装モデル16に組み込まれた特定のCPUに対応したIOデバイスの実装に必要なデバイスドライバソースコード24のみを生成可能に構成されている。
The device
そして、ソースコード自動生成システム11は、制御設計部12と、デバイスドライバ生成部22とから情報を受信可能なコード結合部25を備えている。
The source code
コード結合部25は、自動コード生成部18によって生成された制御アプリケーションソースコード19と、デバイスドライバ生成部22によって生成されたデバイスドライバソースコード24とを結合させた統合ソースコード26を生成可能に構成されている。
The
以下、ソースコード自動生成システム11について、自動車のパワーウィンドウを動作させるECU(Electric Control Unit)の開発を例に挙げて説明する。
Hereinafter, the source code
図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
ECU34は、モータ32を駆動させるモータ駆動回路35と、モータ駆動回路35に信号を出力するための制御アプリケーションを搭載可能なターゲットCPU36とを備えている。
The
スイッチ37は、自動車のドア窓を開け閉めするものである。スイッチ37からは、それぞれオンオフのデジタル入力信号であるDI信号38が発信され、パワーウィンドウ31のエンコーダ33からは、モータ32の回転角度に応じたパルス信号等を含むENC信号39が発信される。
The
ターゲットCPU36からは、モータ駆動回路35に対して、モータ32を駆動する出力信号であるPWM信号40と、モータ32の回転の正転・逆転を指定するデジタル出力信号であるDO信号41とを送信可能に構成されている。
The
また、ターゲットCPU36には、DI信号38を受信可能にするIOデバイスであるDI42と、ENC信号39を受信可能にするIOデバイスであるENC43と、PWM信号40を送信可能にするIOデバイスであるPWMOut44と、DO信号41を送信可能にするIOデバイスであるDO45とが内蔵されている。
Further, the
図3は、図1の制御設計部12において、図2のECU34中のターゲットCPU36及び各IOデバイスをモデル化したアプリケーションモデル(コントローラ・モデル)46を示すブロック図である。
FIG. 3 is a block diagram showing an application model (controller model) 46 in which the
図3に示されるように、アプリケーションモデル46は、スイッチ部37からターゲットCPU36に送られる入力信号に応じてモータ32をどのように駆動させるのかを定めるアルゴリズムが記述された制御ロジック記述ブロック47(本発明の制御の処理動作を記述するブロック)を備えている。
As shown in FIG. 3, the
また、制御ロジック記述ブロック47には、IOブロック14の一種であるDIブロック48a,48bと、ENCブロック49とが入力側に、PWMOutブロック50と、DOブロック51とが出力側に、それぞれ接続されている。
Further, in the control
ここで、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
図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
図4に示されるように、ECU実装モデル52は、図2のパワーウィンドウ31とECU34とスイッチ37とをモデル化し、図1のモデル編集部15で組み合わせて作られた、実装モデル16の一形態である。
As shown in FIG. 4, the
デバイス解析部20は、ECU実装モデル52の構成を解析し、アプリケーションモデル46に付属しているCPU情報タグ16aとIOブロック14に付属しているデバイス情報タグ14aとに基づいて、ターゲットCPU36の種類とターゲットCPU36に接続しているIOデバイスの数及び種類とを特定する。
The
そして、特定したターゲットCPU36の種類をターゲット情報21bとして出力するとともに、特定したIOデバイスの設定内容をデバイス情報21aとして出力する。
Then, the type of the specified
すなわち、デバイス解析部20は、アプリケーションモデル46のうち、DIブロック48からDI42の情報を取得し、ENCブロック49からENC43の情報を取得し、PWMOutブロック50からPWM44の情報を取得し、DOブロック51からDO45の情報を取得してデバイス情報21aに含めることができる。
That is, the
また、デバイスドライバ生成部22は、デバイス情報21aとターゲット情報21bとに基づいてデバイスドライバライブラリ23から、ターゲットCPU36に対応する各デバイスドライバ(DIドライバ、ENCドライバ、PWMOutドライバ、DOドライバ)のソースコード(テンプレート)を取得し、デバイス情報21a及びターゲット情報21bに基づいた修正を加えた上で、生成するデバイスドライバソースコード24に含めることができる。
Further, the device
例えば、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
図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
デバイス解析部20は、デバイス情報21a及びターゲット情報21bを取得すると、取得したデバイス情報21a及びターゲット情報21bをデバイスドライバ生成部22に送る。デバイスドライバ生成部22は、デバイス解析部20からデバイス情報21a及びターゲット情報21bを受け取ると、ターゲット情報21bに基づくCPUに対応するデバイスドライバのテンプレートをデバイスドライバライブラリ23から取得する(ステップS4)とともに、デバイス情報21aに含まれる各デバイスの設定内容に基づいて、取得したデバイスドライバを修正し(ステップS5)、適切なデバイスドライバソースコード24を構築する(ステップS6)。
When the
デバイスドライバ生成部22は、デバイスドライバソースコード24を構築すると、構築したデバイスドライバソースコード24をコード結合部25に送る。コード結合部25は、デバイスドライバ生成部22からデバイスドライバソースコード24を受け取ると、自動コード生成部18によって制御アプリケーションソースコード19が既に生成されているかを確認し、生成されていなければ生成されるまで待機する(ステップS7)。
When the device
制御アプリケーションソースコード19が生成されていれば、コード結合部25は、自動コード生成部18から制御アプリケーションソースコード19を受け取って、受け取った制御アプリケーションソースコード19とデバイスドライバソースコード24とを結合し、統合ソースコード26を構築する。
If the control
なお、この形態例では、図1の、制御の処理動作を記述するコントローラ・モデル13aを、ECUの中にあるCPUに実装しているが、本発明は、図1の、制御対象の動特性を記述するプラント・モデル13bを、HILS(Hardware in the Loop Simulation)におけるハードウェアの中にあるCPUに実装する場合にも適用できるものである。
In this embodiment, the
このように、本発明のソースコード自動生成システム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
なお、本発明は、以上の形態例に限定されることなく、発明の範囲内において種々の変更が可能である。例えば、本形態例では、デバイス解析部による実装モデルのデバイス解析は、自動コード生成部による制御アプリケーションソースコード生成の開始に応じて行われているが、同一の実装モデルについてデバイス解析と自動コード生成とが行われて、その結果生成されたデバイスドライバソースコードと制御アプリケーションソースコードとが結合されるのであれば、必ずしもデバイス解析の実行を制御アプリケーションソースコード生成の開始に合わせる必要はなく、デバイス解析の実行タイミングをユーザーが手動で決定してもよい。 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)
前記制御の処理動作を記述するブロックに基づく制御アプリケーションソースコードを生成する自動コード生成部と、
前記コントローラ・モデルに含まれる、実装される前記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.
前記制御の処理動作を記述するブロックに基づく制御アプリケーションソースコードを自動コード生成プログラムにより生成し、
前記コントローラ・モデルに含まれる、実装される前記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.
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) |
-
2020
- 2020-04-30 JP JP2020080034A patent/JP2021174426A/en active Pending
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 |