JP2005332333A - Grouping program and source code generator - Google Patents

Grouping program and source code generator Download PDF

Info

Publication number
JP2005332333A
JP2005332333A JP2004152172A JP2004152172A JP2005332333A JP 2005332333 A JP2005332333 A JP 2005332333A JP 2004152172 A JP2004152172 A JP 2004152172A JP 2004152172 A JP2004152172 A JP 2004152172A JP 2005332333 A JP2005332333 A JP 2005332333A
Authority
JP
Japan
Prior art keywords
grouping
block
complexity
model
source code
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
JP2004152172A
Other languages
Japanese (ja)
Inventor
Katsuyoshi Fukuda
勝吉 福田
Yoshitaka Uematsu
義貴 植松
Hirotaka Ito
寛隆 伊藤
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.)
Denso Corp
Original Assignee
Denso Corp
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 Denso Corp filed Critical Denso Corp
Priority to JP2004152172A priority Critical patent/JP2005332333A/en
Publication of JP2005332333A publication Critical patent/JP2005332333A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To reduce variation of complexity of functions of source codes to be generated from a model in a model base development environment. <P>SOLUTION: A personal computer 1 reads block groups continued by connection from a storage medium as grouping candidate parts from a specified model (a step 105) and cumulatively calculates the complexity of the read grouping candidate parts based on connection relation by kinds of the block groups and the connection of the block groups (a step 110). Then, when the calculated complexity is within a predetermined complexity reference range (steps 115, 130), the grouping candidate parts after blocks are newly included are made into subsystems (a step 135). Then, a C source code using the subsystems as one function is generated. <P>COPYRIGHT: (C)2006,JPO&NCIPI

Description

本発明は、モデルによって表現される処理を実現するソースコードを生成し、その生成の際に当該モデルの構成部分がグループ化されている旨のグループ化情報を読み出すと、当該構成部分を当該ソースコード中の1つの関数とするソースコード生成装置、および当該ソースコード生成装置に読み出させるためのグループ化情報を生成するグループ化プログラムに関する。   The present invention generates a source code that realizes processing represented by a model, reads grouping information indicating that the constituent parts of the model are grouped at the time of generation, and converts the constituent parts into the source The present invention relates to a source code generation device as one function in code and a grouping program for generating grouping information to be read by the source code generation device.

従来より、例えば車両のエンジンECUの作動のためのプログラムにおいては、開発者が直接そのプログラムのソースコードを記述せず、目的とするプログラムの機能を、より作成が簡易で視認性の良い「モデル」という形態で記述する場合がある(例えば特許文献1参照)。   Conventionally, for example, in a program for operating an engine ECU of a vehicle, the developer does not directly describe the source code of the program, and the function of the target program is easier to create and has a better visibility In some cases (for example, see Patent Document 1).

開発者は、このモデルに対応したプログラム開発環境がインストールされたワークステーション、パーソナルコンピュータ等を用い、モデルから自動的にソースコードを生成する。モデルからソースコードを生成する機能を実現するためのプログラムは、コード生成ツールと呼ばれる。コード生成ツールは、モデル開発環境に組み込まれている場合が多い。モデルからソースコードを生成するようなプログラム開発は、モデルベース開発と呼ばれる。   A developer uses a workstation, personal computer, or the like in which a program development environment corresponding to this model is installed, to automatically generate source code from the model. A program for realizing the function of generating source code from a model is called a code generation tool. Code generation tools are often built into model development environments. Program development that generates source code from a model is called model-based development.

モデルベース開発に対応したプログラム開発環境としては、例えば、Mothworks(登録商標)社のMatlab(登録商標)がある。Matlab(登録商標)においては、開発者はMatlab(登録商標)の一機能であるSimulink(登録商標)を用いて、目的とするプログラムのモデルを記述する。   As a program development environment corresponding to model-based development, for example, there is Matlab (registered trademark) of Mothworks (registered trademark). In Matlab (registered trademark), a developer describes a model of a target program using Simulink (registered trademark) which is one function of Matlab (registered trademark).

モデルは、ブロックと呼ばれる機能単位および機能単位間の入出力関係を示す結線の組み合わせとして記述される。すなわち、複数のブロックが結線によって繋ぎ合わされた集合体がモデルである。   The model is described as a combination of functional units called blocks and connection lines indicating input / output relationships between the functional units. That is, an aggregate in which a plurality of blocks are connected by connection is a model.

ブロックの具体例としては、信号の入力(インポート)および出力の一方または両方を表現する。信号の入力や出力の内容は、そのブロックに割り当てられた所定の規則に基づいたものとなっている。ブロックとしては、例えば入力された信号を変数とするサイン関数の値を出力することを表現するブロック、ファイルからデータを読み出すことを表現するブロック、入力されたデータに対する特定の四則演算を行った結果を出力することを表現するブロック、複数のブロックおよび結線がグループ化された上位のブロックとしてのサブシステム等がある。   As a specific example of the block, one or both of input (import) and output of a signal are expressed. The contents of signal input and output are based on a predetermined rule assigned to the block. As a block, for example, a block that expresses the output of a sine function with the input signal as a variable, a block that expresses reading data from a file, and the result of performing specific four arithmetic operations on the input data There are a block expressing the output of a signal, a plurality of blocks, a subsystem as an upper block in which connections are grouped, and the like.

結線は、あるブロックの出力と他のブロックの入力との繋がりを表現する。具体的には、サイン関数を表現するブロックの出力および階段関数を表現するブロックの出力のそれぞれから、積演算ブロックのそれぞれの入力へリングが繋がっている場合、サイン関数と階段関数とが積演算の対象の項となることが表されている。   The connection represents the connection between the output of one block and the input of another block. Specifically, if a ring is connected from the output of the block that represents the sine function and the output of the block that represents the staircase function to each input of the product operation block, the sine function and the staircase function are multiplied. It is expressed that it becomes a target item.

このようなモデルベース開発では、開発者がモデルを作成し、その後、モデルからコード生成ツールを用いてソースコードを自動生成する。この際、コード生成ツールは、モデル中に含まれるサブシステムのそれぞれを、ソースコード中の1つの関数に変換する。
特開平2000−20291号公報
In such model-based development, a developer creates a model, and then automatically generates source code from the model using a code generation tool. At this time, the code generation tool converts each subsystem included in the model into one function in the source code.
Japanese Patent Laid-Open No. 2000-20291

このような従来技術におけるコード生成ツールは、そのサブシステムの内部のブロックの構成に関わらず、サブシステムを関数に変換する。したがって、生成されるソースコード中にある関数の複雑度は、サブシステムの大小に応じて非常に大きくなる場合もあれば非常に小さくなる場合もある。   Such a conventional code generation tool converts a subsystem into a function regardless of the configuration of the internal blocks of the subsystem. Accordingly, the complexity of the function in the generated source code may be very large or very small depending on the size of the subsystem.

このような場合、ソースコードから生成されたオブジェクトコードの実行効率やソースコードの検査の効率が悪くなる。具体的には、複雑度が小さすぎる関数が多い場合には、オブジェクトコードの実行時に関数コールのオーバーヘッドに無駄な処理時間が費やされてしまう。また、複雑度が大きすぎる関数はソースコードの品質検査の際に検査シナリオが膨大になり時間が掛かると共に、そのソースコード中で実際には実行されない部分を特定するためのカバレッジテストが困難となる。   In such a case, the execution efficiency of the object code generated from the source code and the inspection efficiency of the source code are deteriorated. Specifically, if there are many functions with too low complexity, useless processing time is spent on the overhead of function calls when executing object code. In addition, functions that are too complex have a huge amount of inspection scenarios during the quality inspection of the source code, and it takes time, and it is difficult to perform a coverage test to identify portions that are not actually executed in the source code. .

本発明は上記点に鑑み、モデルベース開発環境において、モデルから生成されるソースコードの関数の複雑度のばらつきを低減することを目的とする。   In view of the above points, the present invention has an object to reduce the variation in the complexity of the function of the source code generated from the model in the model-based development environment.

このような目的を達成するための本発明の特徴は、「モデルによって表現される処理を実現するソースコードを生成し、その生成の際に当該モデルの構成部分がグループ化されている旨のグループ化情報を読み出すと、当該構成部分を当該ソースコード中の1つの関数とするソースコード生成装置」に読み出させるためのグループ化情報を生成するグループ化プログラムが、演算装置を、(1)モデルの構成部分を、グループ化候補部分として記憶媒体から読み出し、(2)その読み出した当該グループ化候補部分の複雑度を算出し、(3)その算出した複雑度が所定の複雑度基準範囲内にある場合、当該グループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込む装置として機能させることである。   The feature of the present invention for achieving such an object is that “a source code that realizes a process expressed by a model is generated, and the components of the model are grouped at the time of generation. When the grouping information is read out, the grouping program for generating grouping information for causing the source code generation apparatus that reads the component as one function in the source code to read out the arithmetic unit, the (1) model Are read from the storage medium as grouping candidate parts, (2) the complexity of the read grouping candidate parts is calculated, and (3) the calculated complexity falls within a predetermined complexity reference range In some cases, the grouping information is made to function as a device that writes grouping information for grouping the grouping candidate portions to a storage medium.

このようになっているので、モデルの、複雑度が所定の複雑度基準範囲内にある構成部分についてのグループ化情報をソースコード生成装置が読み出し、当該グループ化された構成部分をソースコード中の1つの関数とする。したがって、ソースコード中の関数は、上述した所定の複雑度基準範囲内に対応した複雑度となるので、モデルから生成されるソースコードの関数の複雑度を低減することができる。   Since this is the case, the source code generation device reads out the grouping information for the constituent parts of the model whose complexity is within the predetermined complexity reference range, and the grouped constituent parts are read in the source code. Let it be one function. Therefore, the function in the source code has a complexity corresponding to the above-described predetermined complexity reference range, so that the complexity of the function of the source code generated from the model can be reduced.

なお、本発明における関数は、クラス、サブルーチンを含む概念である。   The function in the present invention is a concept including a class and a subroutine.

また、『「所定の規則に基づいて信号を出力することを表現するブロックおよびそれらブロック間の信号の入出力の繋がりを表現する結線を有するモデル」によって表現される信号処理を実現するソースコードを生成し、その生成の際に、当該モデルの構成部分がグループ化されている旨のグループ化情報を読み出すと、当該構成部分を当該ソースコード中の1つの関数とするソースコード生成装置』に読み出させるためのグループ化情報を生成するグループ化プログラムが、演算装置を、(1)当該結線によって連なったブロック群をグループ化候補部分として記憶媒体から読み出し、(2)その読み出したグループ化候補部分の複雑度を、前記ブロック群の結線による接続関係に基づいて算出し、(3)算出した複雑度が所定の複雑度基準範囲内にある場合、当該グループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込む装置として機能させることによっても本発明の目的は達成される。   In addition, source code that realizes signal processing expressed by “a model having a block that expresses output of a signal based on a predetermined rule and a connection that expresses a signal input / output connection between the blocks” When the grouping information indicating that the constituent parts of the model are grouped is read out at the time of the generation, the constituent parts are read into a source code generation device that functions as one function in the source code. A grouping program for generating grouping information to be output causes the computing device to read out (1) a block group connected by the connection from the storage medium as a grouping candidate part, and (2) the read grouping candidate part And (3) the calculated complexity is a predetermined complexity base. If within the range, the object of the invention is achieved also by function as an apparatus for writing grouping information indicating grouping the grouping candidate portions in the storage medium.

なお、結線によって連なったブロック群とは、「そのブロック群に含まれる異なる任意の2個のブロックが、1個以上の結線およびそのブロック群に含まれる0個以上のブロックだけを経て繋がっているようなブロック群」をいう。   In addition, the block group connected by the connection is that “any two different blocks included in the block group are connected via only one or more connections and zero or more blocks included in the block group. Such a block group.

また、グループ化プログラムによって、演算装置は、読み出したグループ化候補部分の複雑度を、当該グループ化候補部分に含まれるブロックの種類に基づいた重みづけで算出するように機能してもよい。   Further, the arithmetic unit may function by the grouping program so as to calculate the complexity of the read grouping candidate portion by weighting based on the type of block included in the grouping candidate portion.

また、グループ化プログラムによって、演算装置は、グループ化候補部分に含まれる1つのブロックから1つの結線を経た出力先のブロックを新たに記憶媒体から読み出して当該グループ化候補部分に含めることで、順次グループ化候補部分を更新し、また、算出した複雑度が、新たに含められたブロックの存在によって所定の複雑度の閾値を超えた場合、当該ブロックが新たに含められた後または含められる前のグループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込むように機能してもよい。   Further, according to the grouping program, the arithmetic unit sequentially reads out an output destination block that has undergone one connection from one block included in the grouping candidate portion from the storage medium and includes it in the grouping candidate portion. The grouping candidate part is updated, and when the calculated complexity exceeds a predetermined complexity threshold due to the presence of a newly included block, the block is newly included or before it is included The grouping information for grouping the grouping candidate portions may be written to the storage medium.

また、グループ化プログラムによって、演算装置は、算出した複雑度が、新たに含められたブロックの存在によって所定の複雑度の閾値を超え、かつ当該グループ化候補部分が1つのループを形成するブロック群のうち一部のみと当該ループ外のブロックを含む場合、当該ループを形成するブロック群の当該一部を当該グループ化候補部分から除いた残りの部分をグループ化する旨のグループ化情報を記憶媒体に書き込むように機能してもよい。   In addition, the grouping program causes the arithmetic unit to cause the calculated complexity to exceed a predetermined complexity threshold due to the presence of a newly included block, and the grouping candidate portion forms one loop. Grouping information indicating that the remaining part of the group of blocks forming the loop is excluded from the grouping candidate part is grouped when only a part of the block and a block outside the loop are included It may function to write to.

また、上記した発明は、モデルが記憶された記憶媒体と、モデルの構成部分を、グループ化候補部分として記憶媒体から読み出す読み出し手段と、読み出し手段が読み出した当該グループ化候補部分の複雑度を算出する算出手段と、算出手段が算出した複雑度が所定の複雑度基準範囲内にある場合、当該グループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込む書き込み手段と、書き込み手段が書き込んだモデルのグループ化情報に基づいて、当該モデルのグループ化情報に係る構成部分1つの関数として有する、当該モデルによって表現される処理を実現するソースコードを生成するソースコード生成手段と、を備えたソースコード生成装置としても実現可能である。   Further, the above-described invention calculates the complexity of the storage medium storing the model, the reading unit that reads the constituent parts of the model from the storage medium as the grouping candidate part, and the grouping candidate part read by the reading unit. A calculating unit that writes the grouping information for grouping the grouping candidate parts to the storage medium when the complexity calculated by the calculating unit is within a predetermined complexity reference range; Source code generation means for generating a source code that realizes the processing expressed by the model, based on the written grouping information of the model, as a function of one component part related to the grouping information of the model It can also be realized as a source code generator.

以下、本発明の一実施形態について説明する。図1に、本実施形態に係るソースコード生成装置としてのパーソナルコンピュータ1の構成を示す。このパーソナルコンピュータ1は、ディスプレイ11、入力装置12、RAM13、ROM14、HDD(ハードディスクドライブ)15、CPU(演算装置に相当する)16等から構成される。   Hereinafter, an embodiment of the present invention will be described. FIG. 1 shows a configuration of a personal computer 1 as a source code generation device according to the present embodiment. The personal computer 1 includes a display 11, an input device 12, a RAM 13, a ROM 14, an HDD (hard disk drive) 15, a CPU (corresponding to a computing device) 16, and the like.

ディスプレイ11は、CPU16から入力された映像信号を、ユーザ(開発者)に対して映像として表示する。   The display 11 displays the video signal input from the CPU 16 as a video to the user (developer).

入力装置12は、キーボード、マウス等から構成され、ユーザが操作することにより、その操作に応じた信号をCPU16に出力する。   The input device 12 includes a keyboard, a mouse, and the like, and outputs a signal corresponding to the operation to the CPU 16 when operated by the user.

RAM13は読み出し、書き込み可能な揮発性メモリであり、ROM14は読み出し専用の不揮発性メモリであり、HDD15は読み出し、書き込み可能な不揮発性メモリである。ROM14、HDD15には、CPU16が読み出して実行するプログラム等があらかじめ記憶されている。またHDD15には、後述するモデルが記憶されている。  The RAM 13 is a readable / writable volatile memory, the ROM 14 is a read-only nonvolatile memory, and the HDD 15 is a readable / writable nonvolatile memory. In the ROM 14 and the HDD 15, programs that are read and executed by the CPU 16 are stored in advance. The HDD 15 stores a model to be described later.

RAM13は、CPU16がROM14、HDD15に記憶されたプログラムを実行する際に、そのプログラムを一時的に保存するための記憶領域、および作業用のデータを一時的に保存するための記憶領域として用いられる。   The RAM 13 is used as a storage area for temporarily storing the program when the CPU 16 executes the program stored in the ROM 14 and the HDD 15 and a storage area for temporarily storing work data. .

CPU16は、パーソナルコンピュータ1に電源が投入されることによって起動すると、ROM14から所定のブートプログラムを読み出して実行し、このブートプログラムに規定されるオペレーティングシステム(以下OSと記す)その他のプログラムをHDD15から読み出して実行することにより、起動処理を行う。起動処理以後、電源が遮断されるまで、CPU16は、入力装置12からの信号、OSによって予め定められたスケジュール等に基づいて、HDD15に記録されている各種プログラムを当該OS上のプロセスとして実行する。また、上記した起動処理およびプロセスにおいて、CPU16は必要に応じて入力装置12から信号の入力を受け付け、またディスプレイ11に映像信号を出力し、またRAM13、HDD15に対してデータの読み出し/書き込みの制御を行う。   When the CPU 16 is started by turning on the power of the personal computer 1, the CPU 16 reads and executes a predetermined boot program from the ROM 14, and loads an operating system (hereinafter referred to as OS) and other programs defined in the boot program from the HDD 15. The activation process is performed by reading and executing. After the startup process, until the power is turned off, the CPU 16 executes various programs recorded in the HDD 15 as processes on the OS based on a signal from the input device 12, a schedule predetermined by the OS, and the like. . In the startup process and process described above, the CPU 16 receives a signal input from the input device 12 as necessary, outputs a video signal to the display 11, and controls data read / write to the RAM 13 and the HDD 15. I do.

パーソナルコンピュータ1のCPU16が実行するプログラムの構成を図2に示す。CPU16は、ソースコード生成プログラム21、サブシステム化プログラム22等を実行する。   The configuration of a program executed by the CPU 16 of the personal computer 1 is shown in FIG. The CPU 16 executes a source code generation program 21, a subsystemization program 22, and the like.

なお以降は、プログラムを実行することによるCPU16の動作を、その実行されるプログラム自体の動作であるとして説明する。   Hereinafter, the operation of the CPU 16 by executing the program will be described as the operation of the executed program itself.

ソースコード生成プログラム21は、HDD15に記憶されているモデルを読み出し、この読み出したモデルによって表現される信号処理を実現するソースコードを生成する。   The source code generation program 21 reads a model stored in the HDD 15 and generates source code for realizing signal processing expressed by the read model.

モデルは、所定の規則に基づいて信号を出力することを表現するブロックおよびそれらブロック間の信号の入出力の繋がりを表現する結線等から成る。このようなモデルは、図示しないモデルエディタ等の、CPU16が上記OS上で実行されるプログラムをユーザが利用することによって作成され、さらにHDD15に記憶されるようになっている。   The model includes a block that represents outputting a signal based on a predetermined rule, and a connection that represents a connection of input and output of signals between the blocks. Such a model is created when the user uses a program executed by the CPU 16 on the OS, such as a model editor (not shown), and further stored in the HDD 15.

モデルエディタとしては、例えばMatlab(登録商標)上で動作するSimulink(登録商標)と呼ばれるソフトウェアを用いることができる。   As the model editor, for example, software called Simulink (registered trademark) operating on Matlab (registered trademark) can be used.

図3に、このようなモデルエディタによって作成されたモデルの一例を示す。図中に長方形または円形で表されたものがブロックである。ブロックは、入力端および出力端のいずれかまたは両方を有し、所定の信号処理を行う。その信号処理は、当該ブロックが入力端を有していればその入力端から受けた信号に基づいたものとなる。また、当該ブロックが出力端を有していれば、当該信号処理の結果を出力端から出力する。   FIG. 3 shows an example of a model created by such a model editor. In the figure, a block is a rectangle or circle. The block has either or both of an input end and an output end, and performs predetermined signal processing. The signal processing is based on a signal received from the input terminal if the block has an input terminal. If the block has an output end, the signal processing result is output from the output end.

また、ブロック間を繋ぐ矢印線が結線を表している。結線は、ブロックの出力端を始点とし、ブロックの入力端を終点とするようになっている。なお、結線の始点および終点とは、それぞれ当該結線を表す矢印線の矢印のない端点および矢印のある端点をいう。   Moreover, the arrow line which connects between blocks represents a connection. The connection is such that the output end of the block is the starting point and the input end of the block is the end point. Note that the starting point and the ending point of the connection refer to an end point without an arrow and an end point with an arrow, respectively, representing the connection.

そして、あるブロックAの出力端とあるブロックBの入力端との結線による繋がりは、当該ブロックAの当該出力端からの出力が当該ブロックBの当該入力端において入力されることを表す。すなわち、結線は、ブロック間の入出力の関係を表すものである。   The connection between the output end of a certain block A and the input end of a certain block B indicates that the output from the output end of the block A is input at the input end of the block B. That is, the connection represents the input / output relationship between the blocks.

図3中、ブロック301、302、303、309は、条件分岐用のIFブロックである。IFブロックは、条件信号入力端(図中上から2番目の入力端)を含む3つの入力端を有し、条件信号入力端からの信号がオンであるかオフであるかに基づいて、他の2つの入力端から受けた信号のいずれかを出力する。   In FIG. 3, blocks 301, 302, 303, and 309 are IF blocks for conditional branching. The IF block has three input terminals including a condition signal input terminal (second input terminal from the top in the figure), and the other is based on whether the signal from the condition signal input terminal is on or off. One of the signals received from the two input terminals is output.

また、ブロック304〜308は、四則演算ブロックであり、複数の入力端から受けた信号を用いた所定の加算、減算、乗算、除算を行い、その結果を出力する。   Blocks 304 to 308 are four arithmetic operation blocks, which perform predetermined addition, subtraction, multiplication, and division using signals received from a plurality of input terminals, and output the results.

また、図3におけるブロック301〜309以外のブロックは、RAM13、HDD15等にあらかじめ記憶された所定のデータを出力するデータリードブロック、または入力があったデータをRAM13、HDD15等に記憶させるデータライトブロックである。   Further, blocks other than blocks 301 to 309 in FIG. 3 are a data read block for outputting predetermined data stored in advance in the RAM 13, HDD 15 or the like, or a data write block for storing input data in the RAM 13, HDD 15 or the like. It is.

図4に、ソースコード生成プログラム21が図3のブロックを元に生成したCソースコードを示す。   FIG. 4 shows C source code generated by the source code generation program 21 based on the block of FIG.

図5のソースコード中の最初のifブロックがブロック301およびそれに関連するデータリードブロックの機能を実現し、2番目のifブロックがブロック302およびそれに関連するデータリードブロックの機能を実現し、3番目のifブロックがブロック303およびそれに関連するデータリードブロックの機能を実現し、4番目のifブロックがブロック309およびそれに関連するデータリードブロック、データライトブロックの機能を実現する。   The first if block in the source code of FIG. 5 realizes the function of the block 301 and the related data read block, the second if block realizes the function of the block 302 and the related data read block, and the third The if block realizes the function of the block 303 and the data read block related thereto, and the fourth if block realizes the function of the block 309 and the data read block and data write block related thereto.

また、4番目のifブロック中において、最初の中括弧{}内の代入式の右辺がブロック304、305、306およびそれに関連するデータリードブロックの機能を実現し、2番目の中括弧{}内の代入式の右辺がブロック307、308、およびそれに関連するデータリードブロックの機能を実現する。   In the fourth if block, the right side of the assignment expression in the first brace {} implements the functions of the blocks 304, 305, 306 and the data read block related thereto, and the second brace {} The right side of the substitution formula realizes the functions of the blocks 307 and 308 and the data read block related thereto.

また、ソースコード生成プログラム21はこのソースコード生成の際、そのモデル中で1つのサブシステムとしてグループ化されているブロック群によって表現される信号処理を、当該ソースコード中の1つの関数とする。ここで、モデル中であるブロック群がサブシステムとしてまとめられていること自体が、当該ブロック群がグループ化されている旨の情報、すなわちグループ化情報に相当する。   In addition, when generating the source code, the source code generation program 21 uses signal processing expressed by a group of blocks grouped as one subsystem in the model as one function in the source code. Here, the fact that the block group in the model is grouped as a subsystem itself corresponds to information indicating that the block group is grouped, that is, grouping information.

以上のようなソースコード生成プログラム21としては、Matlab(登録商標)上で動作するReal Time Workshop(登録商標)と呼ばれる、Simulink(登録商標)で作成されたモデルに基づいたCソースコードを生成するソフトウェアを用いることができる。   As the source code generation program 21 as described above, C source code based on a model created by Simulink (registered trademark) called Real Time Workshop (registered trademark) that operates on Matlab (registered trademark) is generated. Software can be used.

サブシステム化プログラム22は、HDD15中に記憶されているモデルを読み出して、その一部をモデルの複雑度に関する所定の基準に基づいてサブシステム化し、その一部がサブシステム化されたモデルをHDD15に記憶させるためのプログラムである。サブシステム化とは、モデル中の複数のブロックを1つのサブシステムにグループ化することをいう。そして、このサブシステム化された構成部分を有するモデルをHDD15に記憶することが、グループ化情報を記憶させることに相当する。   The subsystemization program 22 reads a model stored in the HDD 15, converts a part of the model into a subsystem based on a predetermined standard related to the complexity of the model, and converts the part of the model into the HDD 15. It is a program for memorizing. Subsystemization refers to grouping a plurality of blocks in a model into one subsystem. Then, storing the model having the subsystemized components in the HDD 15 corresponds to storing the grouping information.

例えば、Real Time Workshop(登録商標)においては、ユーザがディスプレイ11に表示されているモデルの一部を入力装置12を用いて選択し、さらにそれらをサブシステム化する旨の操作を入力装置12を用いて行うことで、当該サブシステム化が実現される。本実施形態では、サブシステム化プログラム22が、このような処理を自動的に行うことで、サブシステム化を実現する。   For example, in Real Time Workshop (registered trademark), the user selects a part of the model displayed on the display 11 using the input device 12, and further performs an operation for substituting them into the subsystem. By using this, the subsystemization is realized. In the present embodiment, the subsystemization program 22 realizes subsystemization by automatically performing such processing.

図5に、このサブシステム化プログラム22のフローチャートを示す。ステップ105では、サブシステム化プログラム22は、HDD15に記憶されたモデルから、入力装置12等の操作によってユーザが指定したモデルの一部として1つのブロックを読み込み、それをグループ化候補部分のいずれか1つに含める。なお、グループ化候補部分に含めるとは、具体的にはRAM13中のグループ化候補リストにそのブロックを登録することをいう。グループ化候補リストとは、グループ化候補部分が含むブロックの名称、当該ブロック毎の後述する累積的な複雑度、および後述するForループ始点情報等を含むテーブルである。   FIG. 5 shows a flowchart of this subsystemization program 22. In step 105, the subsystemization program 22 reads one block from the model stored in the HDD 15 as a part of the model specified by the user by operating the input device 12 or the like, and reads it as one of the grouping candidate portions. Include in one. The inclusion in the grouping candidate portion specifically means that the block is registered in the grouping candidate list in the RAM 13. The grouping candidate list is a table including the names of blocks included in the grouping candidate portion, the cumulative complexity described later for each block, and For Loop starting point information described later.

ここで、読み出すブロックは、具体的には、以下の条件(1)、(2)のどちらかを満たすブロックのいずれか1つである。
条件(1): 入力端を有さない
条件(2): 自己の入力端と1つの結線を介して繋がっているブロックのそれぞれが既にサブシステム化されているまたはグループ化候補リストに登録されている
そして、この読み出したブロックを、どのグループ化候補リストに登録するかは、以下の基準(1)および基準(2)に基づいて決定する。
Here, the block to be read is specifically one of the blocks satisfying either of the following conditions (1) and (2).
Condition (1): Condition that does not have an input terminal (2): Each block that is connected to its own input terminal via one connection is already subsystemized or registered in the grouping candidate list Then, to which grouping candidate list the read block is registered is determined based on the following criteria (1) and criteria (2).

基準(1):読み出したブロックが、入力端を有さないものであるか、またはそのブロックの入力端と1つの結線を介して繋がっているブロックのすべてが既にサブシステム化されている場合、新たなグループ化候補リストを生成し、その生成したグループ化候補リストに読み出したブロックを登録する。   Criterion (1): If the read block does not have an input end, or all of the blocks connected to the input end of the block through one connection are already subsystemized, A new grouping candidate list is generated, and the read block is registered in the generated grouping candidate list.

基準(2):読み出したブロックが、「グループ化候補リストに登録されているブロックと1つの結線を介して繋がる入力端」を少なくとも1つ有している場合、それら1つ以上のグループ化候補リストを1つにまとめ、さらに読み出したブロックをその1つにまとめられたグループ化候補リストに登録する。なお、グループ化候補リストを1つにまとめる場合、まとめられたグループ化候補リストは、まとめられる前のグループ化候補リストがForループ始点情報を有していれば、その情報も含むようにする。   Criterion (2): When the read block has at least one “input end connected to the block registered in the grouping candidate list via one connection”, the one or more grouping candidates The lists are combined into one, and the read blocks are registered in the grouping candidate list combined into one. When grouping candidate lists are combined into one, the grouping candidate list that is grouped includes the information if the grouping candidate list before the grouping includes For loop start point information.

このように、サブシステム化プログラム22がグループ化候補リストを生成することで、グループ化候補部分は、それに含まれる1つのブロックから1つの結線を経た出力先のブロックが新たにグループ化候補部分に含められることで、順次更新される。その結果グループ化候補部分は、結線によって連なったブロック群となる。なお、結線によって連なったブロック群とは、「そのブロック群に含まれる異なる任意の2個のブロックが、1個以上の結線およびそのブロック群に含まれる0個以上のブロックのみを経て繋がっているようなブロック群」をいう。   In this way, the subsystemization program 22 generates the grouping candidate list, so that the grouping candidate part is a new grouping candidate part from one block included in the grouping candidate part to the output destination block. By being included, it is updated sequentially. As a result, the grouping candidate portion becomes a block group connected by connection. In addition, the block group connected by the connection is that “any two different blocks included in the block group are connected via only one or more connections and zero or more blocks included in the block group. Such a block group.

次にステップ110で、直前に読み込んだブロックが含まれたグループ化候補リストに対応するグループ化候補部分の複雑度を、グループ化候補リストに含まれるブロックの種類、および当該ブロック間の結線による接続関係に基づいて計算する。具体的には、当該ブロック間の結線に沿って、出力する側のブロックから入力する側のブロックへ、複雑度を累積的に順次継承させ、最も後段のブロックにおける複雑度を、そのグループ化候補部分の複雑度とする。そして、各ブロックにおける複雑度の累積的な継承の方法は、ブロックの種類毎にあらかじめ決められ、HDD15に記憶されている。   Next, in step 110, the complexity of the grouping candidate part corresponding to the grouping candidate list including the block read immediately before is determined by the type of block included in the grouping candidate list and the connection between the blocks. Calculate based on relationships. Specifically, along the connection between the blocks, the complexity is sequentially inherited from the output side block to the input side block, and the complexity in the last block is set as a grouping candidate. Let the complexity of the part. The method of cumulative inheritance of complexity in each block is determined in advance for each block type and stored in the HDD 15.

本実施形態においては、複雑度として、出力パターン数を用いる。そして、ifブロック、比較ブロック、スイッチブロックにおける累積的な継承の方法は、条件信号入力端以外の2つの入力端のそれぞれに1つの結線を介して繋がるブロックにおける累積的な出力パターン数の総和を取ることである。また、四則演算ブロックにおける累積的な継承の方法は、複数の入力端のそれぞれに1つの結線を介して繋がるブロックにおける累積的な出力パターン数の総積を取ることである。   In the present embodiment, the number of output patterns is used as the complexity. The cumulative inheritance method in the if block, comparison block, and switch block is the sum of the cumulative number of output patterns in the block connected to each of the two input terminals other than the condition signal input terminal via one connection. Is to take. Further, the cumulative inheritance method in the four arithmetic operation blocks is to take the total product of the cumulative number of output patterns in the block connected to each of the plurality of input terminals through one connection.

ステップ110では、この計算のために、直前に読み込んだブロックの種類を特定し、そのブロックの入力端に1つの結線を介して繋がるブロックにおける累積的な出力パターン数をブロック化候補リストから読み出し、そのブロックの種類の累積的な継承方法に基づいて、当該読み出した出力パターン数に対して当該継承方法によって規定された演算を行い、その演算結果を、当該ブロックにおける累積的な出力パターン数とし、さらに、この演算結果を、当該グループ化候補部分の複雑度としての出力パターン数とする。   In step 110, for this calculation, the type of the block read immediately before is specified, and the cumulative number of output patterns in the block connected to the input end of the block via one connection is read from the block candidate list, Based on the cumulative inheritance method of the type of the block, the operation specified by the inheritance method is performed on the read output pattern number, and the calculation result is set as the cumulative output pattern number in the block, Further, the calculation result is set as the number of output patterns as the complexity of the grouping candidate portion.

なお、本実施形態では、入力端を有さないブロックにおける出力パターン数は2であるとする。また、サブシステム化プログラム22によってサブシステム化されたサブシステムからの出力パターン数は1であるとする。   In the present embodiment, it is assumed that the number of output patterns in a block having no input terminal is 2. Further, it is assumed that the number of output patterns from the subsystems subsystemized by the subsystemization program 22 is one.

次にステップ112で、直前に読み込んだブロックが含まれたグループ化候補リストがForループ内に進入した場合、当該ブロックの位置をForループ開始位置とするForループ始点情報を当該グループ化候補リストに含める。なお、「直前に読み込んだブロックが含まれたグループ化候補リストがForループ内に進入した」ことは、当該直前に読み込んだブロックがForループを構成するサブシステム内部にあり、かつ、討議ブロックが含まれたグループ化候補リストには、他にそのForループを構成するサブシステム内部にあるブロックを含まないこと
によって特定できる。
Next, in step 112, when the grouping candidate list including the block read immediately before enters the For loop, the For loop start point information having the position of the block as the For loop start position is added to the grouping candidate list. include. Note that “the grouping candidate list including the block read immediately before has entered the For loop” means that the block read immediately before is in the subsystem constituting the For loop and the discussion block is The included grouping candidate list can be specified by not including any other block inside the subsystem constituting the For loop.

次にステップ115で、計算したグループ化候補部分の複雑度が、所定の閾値(例えば10)より小さいか否かを判定し、小さい場合、続いてステップ120を実行し、小さくない場合、続いてステップ130を実行する。   Next, in step 115, it is determined whether or not the calculated complexity of the grouping candidate portion is smaller than a predetermined threshold (for example, 10). If it is smaller, then step 120 is executed. Step 130 is executed.

ステップ120では、指定されたモデルのすべてのブロックの読み込みが終了したか否か、すなわち、直前に読み出したブロックが、そのモデル中で最後に読み出されたブロックであるか否か、を判定する。   In step 120, it is determined whether or not reading of all the blocks of the specified model is completed, that is, whether or not the block read immediately before is the block read last in the model. .

すべてのブロックの読み込みが終了した場合、続いてステップ125を実行し、終了していない場合、続いてステップ105を実行する。   If all blocks have been read, then step 125 is executed. If not, step 105 is executed.

ステップ125では、現グループ化候補部分、すなわち直前に読み込んだブロックが含まれるグループ化候補部分をサブシステム化する。ただし、グループ化候補部分に当該ブロックのみが含まれている場合は、サブシステム化を行わない。ステップ125の後、サブシステム化プログラム22の実行は終了する。   In step 125, the current grouping candidate portion, that is, the grouping candidate portion including the block read immediately before is formed into a subsystem. However, when only the relevant block is included in the grouping candidate portion, the subsystem is not formed. After step 125, execution of subsystemization program 22 ends.

ステップ130では、直前に読み出したブロックがForループ中のブロックであるか否かを判定する。Forループ中のブロックであれば続いてステップ135を実行し、Forループ中のブロックでなければ続いてステップ145を実行する。   In step 130, it is determined whether or not the block read immediately before is a block in the For loop. If it is a block in the For loop, step 135 is subsequently executed, and if it is not a block in the For loop, step 145 is subsequently executed.

ステップ135では、ステップ125と同様に、現グループ化候補部分をサブシステム化する。ステップ135の後、続いてステップ105の処理を実行する。   In step 135, as in step 125, the current grouping candidate portion is made into a subsystem. After step 135, the process of step 105 is subsequently executed.

ステップ145では、現グループ化候補部分のうち、Forループ開始位置の直前までのブロックをサブシステム化する。具体的には、現グループ化候補部分についてのブロック化候補リストから、ステップ112で記憶したForループ始点情報に基づいて、Forループ開始位置のブロックを特定し、この特定したブロックおよび当該ブロックの出力端以降に連なるブロックを、当該ブロック化候補リストから削除し、残ったブロックをサブシステム化する。なお、始点情報中にブロックの始点が2つ以上ある場合、当該残った部分を、結線によって連なったブロック毎にサブシステム化する。   In step 145, the blocks up to immediately before the For loop start position in the current grouping candidate portion are made into subsystems. Specifically, the block at the For loop start position is identified from the block candidate list for the current grouping candidate portion based on the For loop start point information stored in Step 112, and the identified block and the output of the block are identified. Blocks connected after the end are deleted from the block candidate list, and the remaining blocks are made into subsystems. When there are two or more start points of the block in the start point information, the remaining portion is made into a subsystem for each block connected by connection.

ステップ145の後、続いてステップ105の処理を実行する。   After step 145, the process of step 105 is subsequently executed.

以上のようなサブシステム化プログラム22を実行することによってCPU16は、指定されたモデルから、結線によって連なったブロック群をグループ化候補部分として記憶媒体から読み出し(ステップ105参照)、その読み出したグループ化候補部分の複雑度を、ブロック群の種類、ブロック群の結線による接続関係に基づいて累積的に算出する(ステップ110参照)。   By executing the subsystemization program 22 as described above, the CPU 16 reads from the storage medium a group of blocks connected by connection as a grouping candidate portion from the specified model (see step 105), and the grouping thus read out The complexity of the candidate part is cumulatively calculated based on the type of block group and the connection relationship by connection of the block group (see step 110).

そしてCPU16は、算出した複雑度が所定の複雑度基準範囲内にある場合、すなわち、新たなブロックがグループ化候補部分に含められることによって複雑度が所定の複雑度の閾値を超え(ステップ115参照)、かつ当該グループ化候補部分を独立した関数とするCソースコードを生成することが可能である場合(ステップ130参照)、当該ブロックが新たに含められた後グループ化候補部分をサブシステム化する(ステップ135参照)。   If the calculated complexity is within the predetermined complexity reference range, that is, the new block is included in the grouping candidate portion, the complexity exceeds the predetermined complexity threshold (see step 115). ), And if it is possible to generate C source code having the grouping candidate part as an independent function (see step 130), the grouping candidate part is sub-systemized after the block is newly included. (See step 135).

ここで、「当該グループ化候補部分を独立した関数とするCソースコードを生成することが可能である場合」とは、「当該グループ化候補部分がForループを形成するブロック群のうち一部のみを有しており、かつ当該Forループ外のブロックを含むようになっている場合」以外の場合に相当する。   Here, “when it is possible to generate C source code having the grouping candidate part as an independent function” means “only a part of a block group in which the grouping candidate part forms a For loop” This corresponds to a case other than the case where a block outside the For loop is included.

また、CPU16は、新たなブロックがグループ化候補部分に含められることによって複雑度が所定の複雑度の閾値を超え(ステップ115参照)、かつ当該グループ化候補部分を独立した関数とするCソースコードを生成することが不可能である場合(ステップ130参照)、当該Forループを形成するブロック群の当該一部を当該グループ化候補部分から除いた残りの部分をサブシステム化する(ステップ145参照)。   Further, the CPU 16 adds a new block to the grouping candidate part, so that the complexity exceeds a predetermined complexity threshold (see step 115), and the C source code uses the grouping candidate part as an independent function. When it is impossible to generate (see step 130), the remaining part of the group of blocks forming the For loop is removed from the grouping candidate part and the remaining part is made into a subsystem (see step 145). .

このような処理において、ステップ120、135、145からステップ105に戻ることによるループが繰り返されることで、指定されたモデルのすべてのブロックについてサブシステム化が行われる。   In such processing, the loop by returning from step 120, 135, 145 to step 105 is repeated, whereby subsystemization is performed for all blocks of the specified model.

なお、当該ブロックが新たに含められた後のグループ化候補部分ではなく、当該ブロックが新たに含められる前のグループ化候補部分をサブシステム化するようになっていてもよい。   Note that the grouping candidate portion before the block is newly included may be made into a subsystem instead of the grouping candidate portion after the block is newly included.

図6に、図3に示したモデルが指定されてサブシステム化プログラム22が実行された場合の、サブシステム化プログラム22がHDD15に出力するモデルを示す。ただし、この例においては、上記した出力パターン数の閾値は10である。   FIG. 6 shows a model that the subsystemization program 22 outputs to the HDD 15 when the model shown in FIG. 3 is specified and the subsystemization program 22 is executed. However, in this example, the threshold value for the number of output patterns described above is 10.

図6においては、ブロック303およびそれらの前段のブロックから成るブロック群が、サブシステム401としてサブシステム化されている。また、残りのブロック群のうち、最後端のブロック(すなわち出力端を有しないブロック)が、サブシステム402としてサブシステム化されている。   In FIG. 6, a block group including the block 303 and the preceding block is sub-systemized as a sub-system 401. In the remaining block group, the last block (that is, a block having no output end) is sub-systemized as a sub-system 402.

これは、サブシステム化プログラム22を実行することによる以下のような出力パターン数の算出によって実現される。すなわち、ifブロック301、302における出力パターン数は(2+2)=4となり、ifブロック303における出力パターン数は(4+4)=8となり、積演算ブロック304にける出力パターン数は(8×2)=16となる。したがって、積演算ブロック304を読み出した直後のステップ115で、複雑度が閾値を超え、ステップ135で当該積演算ブロック304および積演算ブロック304の前段のブロックから成るブロック群がサブシステム化される。   This is realized by calculating the number of output patterns by executing the subsystemized program 22 as follows. That is, the number of output patterns in the if blocks 301 and 302 is (2 + 2) = 4, the number of output patterns in the if block 303 is (4 + 4) = 8, and the number of output patterns in the product operation block 304 is (8 × 2) = 16 Therefore, in step 115 immediately after reading the product operation block 304, the complexity exceeds the threshold value, and in step 135, the block group including the product operation block 304 and the previous block of the product operation block 304 is made into a subsystem.

また、和演算ブロック305における出力パターン数は(2×1)=2となり、差演算ブロック306における出力パターン数は(2×2)=4となり、積演算ブロック307における出力パターン数は(2×2)=4となり、積演算ブロック308における出力パターン数は(2×4)=8となり、ifブロック309における出力パターン数は(4+8)=12となる。したがって、ifブロック309を読み出した直後のステップ115で、複雑度が閾値を超え、ステップ135で当該積演算ブロック309の前段のブロックから成るブロック群(ただしサブシステム401のブロック群は除く)がサブシステム化される。   The number of output patterns in the sum operation block 305 is (2 × 1) = 2, the number of output patterns in the difference operation block 306 is (2 × 2) = 4, and the number of output patterns in the product operation block 307 is (2 × 1). 2) = 4, the number of output patterns in the product operation block 308 is (2 × 4) = 8, and the number of output patterns in the if block 309 is (4 + 8) = 12. Therefore, in step 115 immediately after reading the if block 309, the complexity exceeds the threshold value, and in step 135, a block group consisting of blocks preceding the product operation block 309 (except for the block group of the subsystem 401) is sub Systematized.

このようにしてサブシステム化された後のモデルに基づいてソースコード生成プログラム21が生成するCソースコードを図7に示す。   FIG. 7 shows the C source code generated by the source code generation program 21 based on the model after being subsystemized in this manner.

図7の最も下にある関数sample1sub_cal()が、図6のモデル全体を示す部分であり、この関数内で呼び出される関数Subsystem1()およびSubsystem2()が、それぞれサブシステム401および402に対応する部分である。このように、ソースコード生成プログラム21は、サブシステムを1つの関数としたCソースコードを生成する。   The function sample1sub_cal () at the bottom of FIG. 7 is a part showing the entire model of FIG. 6, and the functions Subsystem1 () and Subsystem2 () called in this function are parts corresponding to the subsystems 401 and 402, respectively. It is. Thus, the source code generation program 21 generates C source code with the subsystem as one function.

このとき、サブシステムは所定の複雑度閾値に基づいて区切られているので、生成される関数においても、複雑度のばらつきが少ない。したがって、適切な複雑度を維持した関数を有するCソースコードが生成される。   At this time, since the subsystems are partitioned based on a predetermined complexity threshold value, the complexity of the generated function is small. Therefore, C source code having a function maintaining an appropriate complexity is generated.

次に、図8に、モデルの別の例として、Forループを示すサブシステム801を有するモデルを示す。   Next, FIG. 8 shows a model having a subsystem 801 indicating a For loop as another example of the model.

ブロック601は2つの入力のうち値が大きい方を出力する比較ブロックであり、ブロック602は2つの入力のうち値が小さい方を出力する比較ブロックである。また、ブロック609は、図中最上部の入力端から受けた条件信号が1、2、または3のいずれを示すかに基づいて、他の3つの入力端から受けた信号のいずれを出力するかを選択するスイッチブロックである。   A block 601 is a comparison block that outputs a larger value of two inputs, and a block 602 is a comparison block that outputs a smaller value of two inputs. Also, block 609 outputs which of the signals received from the other three input terminals based on whether the condition signal received from the uppermost input terminal in the figure indicates 1, 2, or 3. This is a switch block for selecting.

Forサブシステム801は、このサブシステムに含まれるブロックによる機能をある回数だけ繰り返し実行する機能を表すサブシステムである。図9に、図8のモデルに基づいてソースコード生成プログラム21が生成するCソースコードを示す。   The For sub-system 801 is a sub-system representing a function that repeatedly executes a function by a block included in the sub-system for a certain number of times. FIG. 9 shows C source code generated by the source code generation program 21 based on the model of FIG.

図9において、Forサブシステム801の機能を実現するための部分は、forソースブロック901である。   In FIG. 9, a part for realizing the function of the For subsystem 801 is a for source block 901.

このように、ソースコード生成プログラム21によって、図8のForサブシステム801の内部に表された処理が、forソースブロック901の内部のソースコードとして実現され、その結果、変数NUMの回数だけ、当該処理が繰り返される。   In this way, the processing shown in the For subsystem 801 in FIG. 8 is realized by the source code generation program 21 as the source code inside the for source block 901, and as a result, the number of times corresponding to the variable NUM The process is repeated.

このようなforソースブロックを、その一部のみが他のソースコードと共に関数化することはできない。したがって、Forサブシステム801の内部のブロック群のうち、その一部のみをForサブシステム801外のブロックと共にサブシステム化しても、正常に機能するソースコードは生成できない。   Only a part of such a for source block cannot be functionalized with other source code. Therefore, even if only a part of the block group inside the For subsystem 801 is made into a subsystem together with the block outside the For subsystem 801, a source code that functions normally cannot be generated.

サブシステム化プログラム22は、図8に示すようなモデルを指定された上で実行されると、上述したステップ112、130、145の処理によって、Forサブシステム801を構成するブロックのうち一部のみが他の外部のブロックと共にサブシステム化されないようなサブシステム化の処理を行うことができる。なお、この場合においても、複雑度の閾値は10であるとする。   When the subsystemized program 22 is executed after a model as shown in FIG. 8 is designated, only a part of the blocks constituting the For subsystem 801 is processed by the above-described steps 112, 130, and 145. Can be sub-systemized so that it is not sub-systemized with other external blocks. In this case, it is assumed that the complexity threshold is 10.

具体的には、サブシステム化プログラム22を実行することにより、CPU16が以下のような出力パターン数の算出を行う。すなわち、比較ブロック601における出力パターン数は(2+2)=4となり、比較ブロック602における出力パターン数は(2+4)=6となる。   Specifically, by executing the subsystemization program 22, the CPU 16 calculates the number of output patterns as follows. That is, the number of output patterns in the comparison block 601 is (2 + 2) = 4, and the number of output patterns in the comparison block 602 is (2 + 4) = 6.

そして、ステップ105でブロック603を読み出したとき、ステップ112で、このブロックの位置をForループ開始位置とするForループ始点情報が、グループ化候補リストに追加される。   Then, when the block 603 is read in step 105, For loop start point information having the position of this block as the For loop start position is added to the grouping candidate list in step 112.

そして、比較ブロック602における出力パターン数は(6×2)=12となる。このとき、出力パターン数が閾値を超え(ステップ115参照)、かつ現在のブロックがforループ内なので(ステップ130参照)、CPU16は、ステップ145によって、forループの開始位置の前まで、すなわちブロック602およびその前段をサブシステム化する。これが、図10のサブシステム701に相当する。   The number of output patterns in the comparison block 602 is (6 × 2) = 12. At this time, since the number of output patterns exceeds the threshold value (see step 115) and the current block is in the for loop (see step 130), the CPU 16 performs step 145 until the for loop start position, that is, block 602. And the previous stage is made into a subsystem. This corresponds to the subsystem 701 in FIG.

そして、積演算ブロック603における出力パターン数は(1×2)=2となり、積演算ブロック604における出力パターン数は(2×2)=4となり、積演算ブロック605における出力パターン数は(4×2)=8となり、積演算ブロック606における出力パターン数は(8×2)=16となる。ここで、出力パターン数が閾値を超えたので、ステップ135で当該積演算ブロック606の前段のブロックから成るブロック群(ただしサブシステム701のブロック群は除く)がサブシステム化される。これが、図10のサブシステム702に相当する。   The number of output patterns in the product operation block 603 is (1 × 2) = 2, the number of output patterns in the product operation block 604 is (2 × 2) = 4, and the number of output patterns in the product operation block 605 is (4 × 2) = 8, and the number of output patterns in the product calculation block 606 is (8 × 2) = 16. Here, since the number of output patterns exceeds the threshold value, a block group (except for the block group of the subsystem 701) consisting of the preceding block of the product operation block 606 is made into a subsystem in step 135. This corresponds to the subsystem 702 in FIG.

また、和演算ブロック607における出力パターン数は(2×2)=4となり、差演算ブロック608における出力パターン数は(2×1)=2となり、スイッチブロック609における出力パターン数は(1+4+2)=7となり最後のデータライトブロックにおける出力パターン数は7となる。従って、複雑度が閾値を超える前にすべてのブロックの読み込みが終了したので(ステップ120参照)、現在のグループ化リストに含まれるブロック、すなわち、サブシステム701、702に含まれないブロックがサブシステム化される。これが、図10のサブシステム703に相当する。   Further, the number of output patterns in the sum calculation block 607 is (2 × 2) = 4, the number of output patterns in the difference calculation block 608 is (2 × 1) = 2, and the number of output patterns in the switch block 609 is (1 + 4 + 2) = 7 and the number of output patterns in the last data write block is 7. Therefore, since all blocks have been read before the complexity exceeds the threshold value (see step 120), blocks included in the current grouping list, that is, blocks not included in the subsystems 701 and 702 are included in the subsystem. It becomes. This corresponds to the subsystem 703 in FIG.

このようにしてサブシステム化プログラム22の実行によりサブシステム化されたモデルに基づいてソースコード生成プログラム21が生成するCソースコードを図11に示す。   FIG. 11 shows the C source code generated by the source code generation program 21 based on the model that has been subsystemized by executing the subsystemization program 22 in this manner.

図11の最も下にある関数sample2_cal()が、図6のモデル全体を示す部分であり、この関数内で呼び出される関数Subsystem1()、Subsystem2()およびSubsystem3()が、それぞれサブシステム701、702および703に対応する部分である。   The function sample2_cal () at the bottom of FIG. 11 is a part showing the entire model of FIG. 6, and the functions Subsystem 1 (), Subsystem 2 () and Subsystem 3 () called in this function are subsystems 701 and 702, respectively. And 703.

このとき、サブシステムは所定の複雑度閾値に基づいて区切られているので、生成される関数においても、複雑度のばらつきが少ない。したがって、適切な複雑度を維持した関数を有するCソースコードが生成される。また、Forサブシステム801を構成するブロックのうち一部のみが他のブロックと共にサブシステム化されることがないので、実行可能な正常なソースコードが生成される。   At this time, since the subsystems are partitioned based on a predetermined complexity threshold value, the complexity of the generated function is small. Therefore, C source code having a function maintaining an appropriate complexity is generated. In addition, since only a part of the blocks constituting the For subsystem 801 is not subsystemized together with other blocks, a normal executable source code is generated.

なお、上記した実施形態においては、サブシステム化プログラム22がグループ化プログラムに相当し、パーソナルコンピュータ1がソースコード生成装置に相当し、RAMおよびHDDが記憶媒体に相当する。   In the above-described embodiment, the subsystemization program 22 corresponds to a grouping program, the personal computer 1 corresponds to a source code generation device, and the RAM and HDD correspond to storage media.

また、CPU16が、サブシステム化プログラム22のステップ105の処理を実行することで、読み出し手段として機能する。   Further, the CPU 16 functions as a reading unit by executing the processing of step 105 of the subsystemization program 22.

また、CPU16が、サブシステム化プログラム22のステップ110の処理を実行することで、算出手段として機能する。   Further, the CPU 16 functions as a calculation unit by executing the processing of step 110 of the subsystemization program 22.

また、CPU16が、サブシステム化プログラム22のステップ115、130、135、145の処理を実行することで、書き込み手段として機能する。   Further, the CPU 16 functions as a writing unit by executing the processing of steps 115, 130, 135, and 145 of the subsystemization program 22.

また、CPU16が、ソースコード生成プログラム21を実行することで、ソースコード生成手段として機能する。   Further, the CPU 16 functions as source code generation means by executing the source code generation program 21.

また、上記したサブシステム化プログラム22は、ステップ112、130、145の処理によって、Forループを構成するブロックのうち一部のみが他のブロックと共にサブシステム化されないようにしているが、このような、その構成部分の一部のみが他のブロックと共にサブシステム化されないようにする対象は、必ずしもForループのみである必要はない。例えば、whileループのサブシステム等の、Simulink(登録商標)のアトミックサブシステムのすべてを対象として、上記のような処理を行ってもよい。すなわち、Forループは、構成するブロックのうち一部のみが他の外部のブロックと共にサブシステム化されると、サブシステムを関数として生成するソースコード生成プログラム21が正常なプログラムを生成できなくなるようなモデルの構成部分として一般化できる。   In addition, the above-described subsystemization program 22 prevents only a part of the blocks constituting the For loop from being subsystemized together with other blocks by the processing of steps 112, 130, and 145. The target for preventing only a part of the component from being subsystemized together with other blocks is not necessarily limited to the For loop. For example, the above-described processing may be performed for all Simulink (registered trademark) atomic subsystems, such as a while loop subsystem. That is, in the For loop, when only a part of the constituting blocks is made into a subsystem together with other external blocks, the source code generation program 21 that generates the subsystem as a function cannot generate a normal program. Can be generalized as a component of the model.

また、上記した実施形態においては、ブロック群の複雑度として、出力パターン数を用いたが、これ以外にも、ブロック数、ディスプレイ11にモデルを表示させたときに当該ブロック群が占める表示面積等を用いてもよい。また、生成されるソースコード中の当該ブロック群に対応する部分のネスト数、コード行数、ループ数、代入変数数等を、当該ブロック群の複雑度としてもよい。   In the above-described embodiment, the number of output patterns is used as the complexity of the block group. In addition to this, the number of blocks, the display area occupied by the block group when the model is displayed on the display 11, etc. May be used. Further, the number of nesting, the number of code lines, the number of loops, the number of substitution variables, and the like corresponding to the block group in the generated source code may be used as the complexity of the block group.

ある指標が複雑度であるか否かは、あるグループ化されたブロック群についてのその指標の値と、そのブロック群の総ブロック数との間に強い相関関係があるか否かで特定することができる。   Whether or not an index is complexity is specified by whether or not there is a strong correlation between the value of the index for a group of blocks and the total number of blocks in the block group. Can do.

また、上記実施形態においてデータリードブロックとして説明したブロックは、任意に複雑度の値を設定してもよいブロックの例として示したものであり、必ずしもデータリードブロックとして実現されておらずともよい。   The block described as the data read block in the above embodiment is shown as an example of a block for which a complexity value may be arbitrarily set, and may not necessarily be realized as a data read block.

また、ブロックの種類毎の複雑度の累積的な継承の方法は、入力装置12を用いて入力するようになっていてもよい。   Also, the method of cumulative inheritance of complexity for each block type may be input using the input device 12.

また、ソースコード生成プログラム21が生成するソースコードは、プログラミング言語Cに限らない。Java(登録商標)やC++のソースコードであってもよい。   The source code generated by the source code generation program 21 is not limited to the programming language C. Java (registered trademark) or C ++ source code may be used.

パーソナルコンピュータ1の構成を示す図である。1 is a diagram illustrating a configuration of a personal computer 1. FIG. CPU16の実行するプログラムを示す図である。It is a figure which shows the program which CPU16 performs. モデルの一例を示す図である。It is a figure which shows an example of a model. 図3に示したモデルを元にソースコード生成プログラム21が生成したCソースコードを示す図である。It is a figure which shows the C source code which the source code generation program 21 produced | generated based on the model shown in FIG. サブシステム化プログラム22のフローチャートである。It is a flowchart of the subsystemization program 22. 図3に示したモデルに基づいてサブシステム化プログラム22が生成するモデルを示す図である。It is a figure which shows the model which the subsystem-ized program 22 produces | generates based on the model shown in FIG. 図6に示したモデルに基づいてソースコード生成プログラム21が生成したCソースコードを示す図である。It is a figure which shows the C source code which the source code generation program 21 produced | generated based on the model shown in FIG. Forループを有するモデルの一例を示す図である。It is a figure which shows an example of the model which has a For loop. 図8に示したモデルに基づいてソースコード生成プログラム21が生成したCソースコードを示す図である。It is a figure which shows the C source code which the source code generation program 21 produced | generated based on the model shown in FIG. 図8に示したモデルに基づいてサブシステム化プログラム22が生成するモデルを示す図である。It is a figure which shows the model which the subsystem-ized program 22 produces | generates based on the model shown in FIG. 図10に示したモデルに基づいてソースコード生成プログラム21が生成したCソースコードを示す図である。It is a figure which shows the C source code which the source code generation program 21 produced | generated based on the model shown in FIG.

符号の説明Explanation of symbols

1…パーソナルコンピュータ、11…ディスプレイ、12…入力装置、13…RAM、
14…ROM、15…HDD、16…CPU、21…ソースコード生成プログラム、
22…サブシステム化プログラム、301〜309…ブロック、
401、402…サブシステム、601〜609…ブロック、
701〜703…サブシステム、801…Forループサブシステム、
901…forソースブロック。
DESCRIPTION OF SYMBOLS 1 ... Personal computer, 11 ... Display, 12 ... Input device, 13 ... RAM,
14 ... ROM, 15 ... HDD, 16 ... CPU, 21 ... Source code generation program,
22 ... Subsystemization program, 301 to 309 ... block,
401, 402 ... subsystem, 601-609 ... block,
701 to 703 ... subsystem, 801 ... For loop subsystem,
901 ... for source block.

Claims (6)

モデルによって表現される処理を実現するソースコードを生成し、その生成の際に当該モデルの構成部分がグループ化されている旨のグループ化情報を読み出すと、当該構成部分を当該ソースコード中の1つの関数とするソースコード生成装置、に読み出させるためのグループ化情報を生成するグループ化プログラムであって、
モデルの構成部分を、グループ化候補部分として記憶媒体から読み出す読み出し手段、
前記読み出し手段が読み出した当該グループ化候補部分の複雑度を算出する算出手段、および
前記算出手段が算出した複雑度が所定の複雑度基準範囲内にある場合、当該グループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込む書き込み手段、として演算装置を機能させるグループ化プログラム。
When source code that realizes processing represented by a model is generated and grouping information indicating that the constituent parts of the model are grouped at the time of generation is generated, the constituent parts are represented as 1 in the source code. A grouping program for generating grouping information to be read by a source code generation device as one function,
Reading means for reading out the constituent parts of the model from the storage medium as grouping candidate parts,
A calculating unit that calculates the complexity of the grouping candidate portion read by the reading unit; and, when the complexity calculated by the calculating unit is within a predetermined complexity reference range, the grouping candidate portion is grouped A grouping program for causing an arithmetic unit to function as writing means for writing grouping information to a storage medium.
所定の規則に基づいて信号を出力することを表現するブロックおよびそれらブロック間の信号の入出力の繋がりを表現する結線を有するモデル、によって表現される信号処理を実現するソースコードを生成し、その生成の際に、当該モデルの構成部分がグループ化されている旨のグループ化情報を読み出すと、当該構成部分を当該ソースコード中の1つの関数とするソースコード生成装置、に読み出させるためのグループ化情報を生成するグループ化プログラムであって、
前記結線によって連なったブロック群をグループ化候補部分として記憶媒体から読み出す読み出し手段、
前記読み出し手段が読み出したグループ化候補部分の複雑度を、前記ブロック群の結線による接続関係に基づいて算出する算出手段、および
前記算出手段が算出した複雑度が所定の複雑度基準範囲内にある場合、当該グループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込む書き込み手段、として演算装置を機能させるグループ化プログラム。
Generating a source code that realizes signal processing expressed by a block that expresses output of a signal based on a predetermined rule and a model that has a connection that expresses a connection of input and output of signals between the blocks, and At the time of generation, when the grouping information indicating that the constituent parts of the model are grouped is read, the source code generating apparatus that reads the constituent parts as one function in the source code A grouping program for generating grouping information,
Reading means for reading from the storage medium the group of blocks connected by the connection as a grouping candidate part,
A calculation unit that calculates the complexity of the grouping candidate portion read by the reading unit based on a connection relationship by connection of the block group, and the complexity calculated by the calculation unit is within a predetermined complexity reference range A grouping program that causes the arithmetic unit to function as a writing unit that writes grouping information for grouping the grouping candidate portions to a storage medium.
前記算出手段は、前記読み出し手段が読み出したグループ化候補部分の複雑度を、当該グループ化候補部分に含まれるブロックの種類に基づいて算出することを特徴とする請求項2に記載のグループ化プログラム。 The grouping program according to claim 2, wherein the calculating unit calculates the complexity of the grouping candidate portion read by the reading unit based on a type of a block included in the grouping candidate portion. . 前記読み出し手段は、前記グループ化候補部分に含まれる1つのブロックから1つの結線を経た出力先のブロックを新たに記憶媒体から読み出して当該グループ化候補部分に含めることで、順次グループ化候補部分を更新し、
前記書き込み手段は、前記算出手段が算出した複雑度が、新たに含められたブロックの存在によって所定の複雑度の閾値を超えた場合、当該ブロックが新たに含められた後または含められる前のグループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込むことを特徴とする請求項2または3に記載のグループ化プログラム。
The reading means newly reads an output destination block from one block included in the grouping candidate portion from one storage medium and includes it in the grouping candidate portion so that the grouping candidate portions are sequentially added. Updated,
When the complexity calculated by the calculation unit exceeds a predetermined complexity threshold due to the presence of a newly included block, the writing unit is a group after or before the block is newly included 4. The grouping program according to claim 2, wherein grouping information for grouping candidate groups is written to a storage medium.
前記書き込み手段は、前記算出手段が算出した複雑度が、新たに含められたブロックの存在によって所定の複雑度の閾値を超え、かつ当該グループ化候補部分が1つのループを形成するブロック群のうち一部のみと当該ループ外のブロックを含む場合、当該ループを形成するブロック群の当該一部を当該グループ化候補部分から除いた残りの部分をグループ化する旨のグループ化情報を記憶媒体に書き込むことを特徴とする請求項4に記載のグループ化プログラム。 The writing means has a complexity calculated by the calculating means exceeding a predetermined complexity threshold due to the presence of a newly included block, and the grouping candidate portion is a block group that forms one loop. When only a part and a block outside the loop are included, grouping information indicating that the remaining part of the group of blocks forming the loop is excluded from the grouping candidate part is written to the storage medium. The grouping program according to claim 4, wherein: モデルが記憶された記憶媒体と、
モデルの構成部分を、グループ化候補部分として記憶媒体から読み出す読み出し手段と、
前記読み出し手段が読み出した当該グループ化候補部分の複雑度を算出する算出手段と、
前記算出手段が算出した複雑度が所定の複雑度基準範囲内にある場合、当該グループ化候補部分をグループ化する旨のグループ化情報を記憶媒体に書き込む書き込み手段と、
前記書き込み手段が書き込んだモデルのグループ化情報に基づいて、当該モデルのグループ化情報に係る構成部分1つの関数として有する、当該モデルによって表現される処理を実現するソースコードを生成するソースコード生成手段と、を備えたソースコード生成装置。
A storage medium storing the model;
Reading means for reading the constituent parts of the model from the storage medium as grouping candidate parts;
Calculating means for calculating the complexity of the grouping candidate portion read by the reading means;
A writing unit that writes grouping information for grouping the grouping candidate parts to a storage medium when the complexity calculated by the calculating unit is within a predetermined complexity reference range;
Based on the grouping information of the model written by the writing unit, the source code generating unit that generates the source code that realizes the processing expressed by the model, having as a function of one component part related to the grouping information of the model And a source code generation device.
JP2004152172A 2004-05-21 2004-05-21 Grouping program and source code generator Pending JP2005332333A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004152172A JP2005332333A (en) 2004-05-21 2004-05-21 Grouping program and source code generator

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2004152172A JP2005332333A (en) 2004-05-21 2004-05-21 Grouping program and source code generator

Publications (1)

Publication Number Publication Date
JP2005332333A true JP2005332333A (en) 2005-12-02

Family

ID=35486938

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004152172A Pending JP2005332333A (en) 2004-05-21 2004-05-21 Grouping program and source code generator

Country Status (1)

Country Link
JP (1) JP2005332333A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2148274A1 (en) 2008-06-30 2010-01-27 Hitachi, Ltd. Controller development tool and motor drive system developed by the tool

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2148274A1 (en) 2008-06-30 2010-01-27 Hitachi, Ltd. Controller development tool and motor drive system developed by the tool
EP3037959A1 (en) 2008-06-30 2016-06-29 Hitachi, Ltd. Controller development tool and motor drive system developed by the tool

Similar Documents

Publication Publication Date Title
JP2006024006A (en) Test case generation device, test case generation program, model base development program, device and program for diagnosing validity of source code generation, and method for developing model base
US20110145799A1 (en) Path-sensitive dataflow analysis including path refinement
CN106462405B (en) Interactive learning tool using arenas
JP2009265810A (en) Status transition test support device, status transition test support program and status transition test support method
US8527254B2 (en) Simulator engine development system and simulator engine development method
JP2009169828A (en) Test case creation device and creation program
JP2009294846A (en) Test case generator, and test case generation program and method
JP2005078243A (en) Microcomputer resource consumption estimating program, microcomputer resource consumption estimating device, and program generating method
JP2009104252A (en) Debugging support device and debugging support method
CN116663491B (en) Method, equipment and medium for covering group condition constraint statement based on BDD solving function
JP2004227500A (en) Code generation device, code generation program, simulator, simulation program, model generation device, and model generation program
JP4870956B2 (en) Embedded program generation method, embedded program development system, and information table section
JP2005332333A (en) Grouping program and source code generator
JP2016128941A (en) Output determination device, output determination method, output determination program, and static analysis device
US20070011440A1 (en) Processor and processing method
JP2013161219A (en) Code generation device and code generation program
JP2005301568A (en) Display information storage controller, and program thereof
JP2020144509A (en) Automatic code generation method and automatic code generating program
JP2017041196A (en) Stub object determination device, method, and program
JP2008299423A (en) Information processor and information processing program
Vasiliev et al. Integration of Business Process Definition, Analysis and Execution Tools Based on Block-structured Approach
JP6519530B2 (en) Verification apparatus, verification program, and verification method
JP2007018313A (en) Circuit design program, circuit design device and circuit design method
JP5067705B2 (en) Abnormal test support device, abnormal test support method, and program
JP7059827B2 (en) Source code generator

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20060630

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20080926

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20090908

A02 Decision of refusal

Effective date: 20100112

Free format text: JAPANESE INTERMEDIATE CODE: A02