JP2018163432A - Automatic correction device - Google Patents

Automatic correction device Download PDF

Info

Publication number
JP2018163432A
JP2018163432A JP2017059060A JP2017059060A JP2018163432A JP 2018163432 A JP2018163432 A JP 2018163432A JP 2017059060 A JP2017059060 A JP 2017059060A JP 2017059060 A JP2017059060 A JP 2017059060A JP 2018163432 A JP2018163432 A JP 2018163432A
Authority
JP
Japan
Prior art keywords
model
block
dead code
pattern
processing unit
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.)
Granted
Application number
JP2017059060A
Other languages
Japanese (ja)
Other versions
JP6305598B1 (en
Inventor
恵夢 林田
Megumu Hayashida
恵夢 林田
大久保 陽一
Yoichi Okubo
陽一 大久保
恒毅 中村
Nobutaka Nakamura
恒毅 中村
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2017059060A priority Critical patent/JP6305598B1/en
Application granted granted Critical
Publication of JP6305598B1 publication Critical patent/JP6305598B1/en
Publication of JP2018163432A publication Critical patent/JP2018163432A/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide an automatic correction device that automatically corrects a model so that a dead code is not generated in model base development.SOLUTION: An automatic correction device of a model in model base development comprises a dead code detection processing unit and a model automatic correction processing unit. The dead code detection processing unit detects a point that generates a dead code from an uncorrected model before correction based on a dead code pattern which is a description pattern of a model that generates a dead code. The model automatic correction processing unit corrects a point that generates the dead code detected by the dead code detection processing unit, and generates a model after correction. The model includes a plurality of blocks which perform signal processing, and connections which couple between blocks. The model automatic correction processing unit deletes a block of a point that generates a dead code from a model before correction, and generates a model after correction by reconnecting between blocks of a disconnection point occurred by deletion.SELECTED DRAWING: Figure 1

Description

本発明はモデルベース開発におけるモデルの自動修正装置に関する。   The present invention relates to a model automatic correction apparatus in model-based development.

近年、プログラム開発においては、開発者がそのプログラムのソースコードを記述するのではなく、作成が容易で視覚的に表現される「モデル」を用いてプログラムを開発する「モデルベース開発」の手法が採られている。開発者は、このモデルに対応したプログラム開発環境を有するワークステーション、パーソナルコンピュータ等を使用することでソースコードを生成する。モデルに基づいてソースコードを生成する機能を有するプログラムはコード生成ツールと呼称され、モデル開発環境に組み込まれている。   In recent years, in program development, there is a “model-based development” method in which a developer develops a program using a “model” that is easy to create and visually expressed, rather than describing the source code of the program. It is taken. A developer generates a source code by using a workstation, a personal computer, or the like having a program development environment corresponding to this model. A program having a function of generating source code based on a model is called a code generation tool, and is incorporated in a model development environment.

モデルベース開発においては、開発過程でモデルおよびソースコードが、プログラムの製品としてどのような品質を有しているかを、所定の基準に基づいて評価する品質評価を行う。この品質評価の基準としては、例えばカバレッジが挙げられる。   In model-based development, quality evaluation is performed to evaluate the quality of a model and source code as a program product in a development process based on a predetermined standard. An example of the quality evaluation standard is coverage.

カバレッジとは、モデルおよびソースコードの条件分岐における複数の分岐先のうち、実行されないもの(未到達)がどの程度あるかを示す指標である。モデルおよびソースコードのカバレッジは、テスト入力パターンを用いて、モデルおよびソースの実行シミュレーションを行い、実行された分岐先と実行されなかった分岐先とを調査することで特定する。カバレッジの特定のための処理をカバレッジテストと呼称する。カバレッジテストの結果、実行されない分岐先を有する条件分岐は、実行されないコード、すなわちデッドコードとして抽出される。   Coverage is an index indicating how many of the branch destinations in the conditional branch of the model and source code are not executed (not reached). The coverage of the model and the source code is specified by performing an execution simulation of the model and the source using the test input pattern and investigating the branch destination that has been executed and the branch destination that has not been executed. A process for specifying the coverage is called a coverage test. As a result of the coverage test, a conditional branch having a branch destination that is not executed is extracted as a code that is not executed, that is, a dead code.

特許文献1には、モデルから生成されたソースコードに対するカバレッジ調査の結果、実行されないコード(デッドコード)を抽出し、デッドコードとなる箇所のモデルとソースコードの対応関係をディスプレイに表示する技術が開示されている。   Patent Document 1 discloses a technique for extracting a code (dead code) that is not executed as a result of a coverage investigation on a source code generated from a model, and displaying a correspondence relationship between the model of the portion that becomes the dead code and the source code on a display. It is disclosed.

特開2005−301568号公報JP 2005-301568 A

特許文献1では、デッドコードとなる箇所のモデルの修正を開発者が手動で行うこととなるため時間を要する。また、ヒューマンエラーが発生するリスクもある。   In Patent Document 1, it takes time because a developer manually corrects a model of a portion that becomes a dead code. There is also the risk of human error.

また、デッドコードとしては、例えば、絶対に成立しない条件における実行文などが挙げられるが、このようなデッドコードがソースコードに含まれているとプログラムの行数が増え、プログラムの実行の際に、プログラムを一時的に保存するためのメモリの記憶容量を大きくする必要が生じる。また、プログラムの行数が増えることで可読性が低下するといった課題がある。   In addition, examples of dead code include executable statements under conditions that do not hold, but if such dead code is included in the source code, the number of lines in the program increases, and the program is executed. Therefore, it is necessary to increase the storage capacity of the memory for temporarily storing the program. In addition, there is a problem that readability is reduced as the number of program lines increases.

さらに、デッドコードを含むソースコードは、ソースコードに入力されるパラメータの値によってはソフトウェアが想定外の動作をする可能性を含むため、規格またはガイドラインで制限または禁止される事例もある。例えば、自動車の機能安全規格ISO26262においてハザードを評価する指標であるASIL(Automotive Safety Integrity Level)における「ASIL D」に準拠させる場合には、デッドコードを含むソースコードは禁止されている。このように、ソースコードにデッドコードを含む場合には、当該ソースコードが規格に準拠していることを示す際の障害となる。   Furthermore, since the source code including dead code includes a possibility that the software operates unexpectedly depending on the value of a parameter input to the source code, there are cases where the code is restricted or prohibited by standards or guidelines. For example, in the case of conforming to “ASIL D” in ASIL (Automotive Safety Integrity Level), which is an index for evaluating hazards in automotive functional safety standard ISO26262, source code including dead code is prohibited. Thus, when a dead code is included in a source code, it becomes an obstacle at the time of showing that the said source code is based on a standard.

本発明は上記のような課題を解決するためになされたものであり、モデルベース開発において、デッドコードが生成されないように自動でモデルを修正する自動修正装置を提供することを目的とする。   The present invention has been made to solve the above-described problems, and an object thereof is to provide an automatic correction device that automatically corrects a model so that dead code is not generated in model-based development.

本発明に係る自動修正装置の態様は、モデルベース開発におけるモデルの自動修正装置であって、デッドコードを生成するモデルの記述パターンであるデッドコードパターンに基づいて未修正の修正前モデルからデッドコードを生成する箇所を検出するデッドコード検出処理部と、前記デッドコード検出処理部で検出された前記デッドコードを生成する箇所を修正して修正後モデルを生成するモデル自動修正処理部とを備え、前記モデルは、信号処理を行う複数のブロックと、ブロック間を繋ぐ結線とを有し、前記モデル自動修正処理部は、前記修正前モデルから前記デッドコードを生成する箇所の前記ブロックを削除し、削除によって発生した断線箇所のブロック間を再結線することで前記修正後モデルを生成する。   An aspect of an automatic correction device according to the present invention is a model automatic correction device in model-based development, in which a dead code is converted from an uncorrected model based on a dead code pattern which is a description pattern of a model for generating a dead code. A dead code detection processing unit for detecting a location for generating a model automatic correction processing unit for generating a corrected model by correcting the location for generating the dead code detected by the dead code detection processing unit, The model has a plurality of blocks for performing signal processing and a connection connecting the blocks, and the model automatic correction processing unit deletes the block at a location where the dead code is generated from the pre-correction model, The corrected model is generated by re-connecting between the blocks at the disconnection location generated by the deletion.

本発明に係る自動修正装置によれば、ソースコードを生成する前に、デッドコードが生成されないモデルを作成することが可能となる。   According to the automatic correction apparatus of the present invention, it is possible to create a model in which dead code is not generated before generating source code.

本発明に係る実施の形態の自動修正装置の構成を示す機能ブロック図である。It is a functional block diagram which shows the structure of the automatic correction apparatus of embodiment which concerns on this invention. 本発明に係る実施の形態の自動修正装置をパーソナルコンピュータで実現する場合の構成を示すブロック図である。It is a block diagram which shows the structure in the case of implement | achieving the automatic correction apparatus of embodiment which concerns on this invention with a personal computer. モデルエディタによって作成されたモデルの一例を示す図である。It is a figure which shows an example of the model produced by the model editor. デッドコードパターンと、修正後モデルのパターンを示す図である。It is a figure which shows the pattern of a dead code pattern and a model after correction. デッドコード検出処理部の動作を示すフローチャートである。It is a flowchart which shows operation | movement of a dead code detection process part. デッドコードパターン情報を示す図である。It is a figure which shows dead code pattern information. 検査対象ブロックを示す図である。It is a figure which shows a test object block. 検査対象ブロックを示す図である。It is a figure which shows a test object block. 検査対象ブロックを示す図である。It is a figure which shows a test object block. デッドコード検出結果の格納例を示す図である。It is a figure which shows the example of a storage of a dead code detection result. モデル自動修正処理部の動作を示すフローチャートである。It is a flowchart which shows operation | movement of a model automatic correction process part. 自動修正後モデルに出力されるコメント例を示す図である。It is a figure which shows the example of a comment output to a model after automatic correction.

<実施の形態>
<装置構成>
図1は、本発明に係る実施の形態の自動修正装置100の構成を示す機能ブロック図である。図1に示すように自動修正装置100は、処理部10と記憶部20とを備えている。なお、自動修正装置100には、ユーザが自動修正装置100を操作するためのキーボード、マウスなどの入力装置が接続されるが、図示は省略している。
<Embodiment>
<Device configuration>
FIG. 1 is a functional block diagram showing a configuration of an automatic correction apparatus 100 according to an embodiment of the present invention. As shown in FIG. 1, the automatic correction apparatus 100 includes a processing unit 10 and a storage unit 20. Note that an input device such as a keyboard and a mouse for operating the automatic correction device 100 by a user is connected to the automatic correction device 100, but the illustration is omitted.

処理部10は、デッドコード検出処理部101およびモデル自動修正処理部102を有し、記憶部20は、ソースコード生成時にデッドコードが生成されるモデルの記述パターンであるデッドコードパターンを格納するデッドコードパターン情報格納部201、デッドコードパターンが生成されないように修正する前の未修正の修正前モデルを格納する修正前モデル格納部202、デッドコード検出結果を格納するデッドコード検出結果格納部203およびデッドコードパターンが生成されないように修正された後の修正後モデルを格納する修正後モデル格納部204を有している。   The processing unit 10 includes a dead code detection processing unit 101 and a model automatic correction processing unit 102, and the storage unit 20 stores a dead code pattern that is a description pattern of a model in which dead code is generated when generating source code. A code pattern information storage unit 201; an uncorrected model storage unit 202 that stores an uncorrected model before correction so that a dead code pattern is not generated; a dead code detection result storage unit 203 that stores a dead code detection result; It has a corrected model storage unit 204 that stores a corrected model that has been corrected so that a dead code pattern is not generated.

デッドコード検出処理部101は、デッドコードパターン情報格納部201に格納されたデッドコードパターンと修正前モデル格納部202に格納された修正前モデルとを読み出し、読み出した修正前モデルにおいてデッドコードパターンに一致する箇所、すなわちデッドコードを生成するモデル記述箇所を検出する。検出したモデル記述箇所は、検出結果としてデッドコード検出結果格納部に保存される。   The dead code detection processing unit 101 reads the dead code pattern stored in the dead code pattern information storage unit 201 and the pre-correction model stored in the pre-correction model storage unit 202, and sets the dead code pattern in the read pre-correction model. A matching part, that is, a model description part that generates a dead code is detected. The detected model description location is stored in the dead code detection result storage unit as a detection result.

モデル自動修正処理部102は、修正前モデル格納部202から修正前モデルを読み出し、デッドコード検出結果格納部203から検出結果を読み出し、デッドコードを生成するモデル記述箇所をデッドコードが生成されないように修正前モデルを自動修正して修正後モデルを生成する。修正後モデルは修正後モデル格納部204に保存される。   The model automatic correction processing unit 102 reads out the pre-correction model from the pre-correction model storage unit 202, reads out the detection result from the dead code detection result storage unit 203, and prevents the dead code from being generated at the model description location where the dead code is generated. A model after correction is generated by automatically correcting the model before correction. The corrected model is stored in the corrected model storage unit 204.

モデルベース開発におけるモデルは、所定の規則に基づいて信号を出力することを表現する複数のブロック、およびブロック間の信号の入出力の繋がりを表現する結線等で構成される。このようなモデルは、モデルエディタを使用することによって作成される。   A model in model-based development is composed of a plurality of blocks expressing output of a signal based on a predetermined rule, a connection expressing a connection of signal input / output between the blocks, and the like. Such a model is created by using a model editor.

モデルエディタとしては、例えばMatlab(登録商標)上で動作するSimulink(登録商標)と呼称されるソフトウェアを用いることができる。なお、モデルエディタはこれに限定されないが、以下の説明においてはモデルエディタとして、Matlab(登録商標)上で動作するSimulink(登録商標)を例に採って説明する。   As the model editor, for example, software called Simulink (registered trademark) operating on Matlab (registered trademark) can be used. Although the model editor is not limited to this, in the following description, Simlink (registered trademark) operating on Matlab (registered trademark) will be described as an example of the model editor.

図2には、図1に示した自動修正装置100をパーソナルコンピュータ1で実現する場合の構成を示すブロック図である。図2に示すように、パーソナルコンピュータ1は、入力装置11、プロセッサ12、記憶装置13、第1メモリ14および第2メモリ15を備えている。パーソナルコンピュータ1には出力装置として液晶ディスプレイなどの表示装置が接続されるが図示は省略している。   FIG. 2 is a block diagram showing a configuration in the case where the automatic correction apparatus 100 shown in FIG. As shown in FIG. 2, the personal computer 1 includes an input device 11, a processor 12, a storage device 13, a first memory 14, and a second memory 15. Although a display device such as a liquid crystal display is connected to the personal computer 1 as an output device, illustration is omitted.

入力装置11は、キーボード、マウスなどで構成され、ユーザが操作することにより、その操作に応じた信号をプロセッサ12に出力する。   The input device 11 includes a keyboard, a mouse, and the like, and outputs a signal corresponding to the operation to the processor 12 when operated by the user.

第1メモリ14は、例えばRAM(Random Access Memory)などの読み出し、書き込みが可能な揮発性メモリであり、第2メモリ15は、例えばROM(Read Only Memory)などの読み出し専用の不揮発性メモリである。また、記憶装置13は、ハードディスク、磁気ディスク、フレキシブルディスク、光ディスク、コンパクトディスク、ミニディスクおよびDVD(Digital Versatile Disc)などのドライブ装置を必要とする記憶媒体である。なお、第1メモリ14としては、フラッシュメモリ、EPROM(Erasable Programmable Read Only Memory)、EEPROM(Electrically Erasable Programmable Read Only Memory)などを使用することもできる。   The first memory 14 is a volatile memory capable of reading and writing such as a RAM (Random Access Memory), and the second memory 15 is a read-only nonvolatile memory such as a ROM (Read Only Memory). . The storage device 13 is a storage medium that requires a drive device such as a hard disk, a magnetic disk, a flexible disk, an optical disk, a compact disk, a mini disk, and a DVD (Digital Versatile Disc). The first memory 14 may be a flash memory, an EPROM (Erasable Programmable Read Only Memory), an EEPROM (Electrically Erasable Programmable Read Only Memory), or the like.

記憶装置13および第2メモリ15には、プロセッサ12が読み出して実行するプログラム等のソフトウェアが予め記憶されている。また、記憶装置13には、モデル、モデルのデータ情報およびデッドコードを生成するモデル記述パターン情報が記憶されている。第1メモリ14は、プロセッサ12が記憶装置13および第2メモリ15に記憶されたプログラムを実行する際に、そのプログラムを一時的に保存するための記憶領域として用いられる。   In the storage device 13 and the second memory 15, software such as a program read and executed by the processor 12 is stored in advance. The storage device 13 stores a model, model data information, and model description pattern information for generating a dead code. The first memory 14 is used as a storage area for temporarily storing the program when the processor 12 executes the program stored in the storage device 13 and the second memory 15.

プロセッサ12は、パーソナルコンピュータ1に電源が投入されることによって起動すると、第2メモリ15から所定のブートプログラムを読み出して実行し、このブートプログラムに規定されるオペレーティングシステム(以下OSと略記)およびその他のプログラムを記憶装置13から読み出して実行することにより、パーソナルコンピュータ1の起動処理を行う。起動処理以後電源が遮断されるまで、プロセッサ12は、入力装置11からの信号、OSによって予め定められたスケジュール等に基づいて、記憶装置13に記憶されている各種プログラムをOS上のプロセスとして実行する。また、上記起動処理およびプロセスにおいて、プロセッサ12は必要に応じて入力装置11から信号の入力を受け付け、また第1メモリ14および記憶装置13に対してデータの読み出し、書き込みの制御を行う。   When the personal computer 1 is started by turning on the power, the processor 12 reads out and executes a predetermined boot program from the second memory 15, an operating system (hereinafter abbreviated as OS) defined by the boot program, and others Is read from the storage device 13 and executed to start the personal computer 1. The processor 12 executes various programs stored in the storage device 13 as processes on the OS based on a signal from the input device 11, a schedule predetermined by the OS, etc. until the power is turned off after the startup process. To do. In the activation process and process, the processor 12 receives a signal input from the input device 11 as necessary, and controls the reading and writing of data to the first memory 14 and the storage device 13.

図1に示した自動修正装置100の処理部10におけるデッドコード検出処理部101およびモデル自動修正処理部102はプロセッサ12によるプログラムの実行により実現し、ユーザが入力装置11に対して所定の操作をすることにより、または、他の方法で指示されることにより実行を開始する。   The dead code detection processing unit 101 and the model automatic correction processing unit 102 in the processing unit 10 of the automatic correction device 100 shown in FIG. 1 are realized by executing a program by the processor 12, and the user performs a predetermined operation on the input device 11. To begin execution, or as directed by other methods.

また、図1に示した自動修正装置100の記憶部20におけるデッドコードパターン情報格納部201、修正前モデル格納部202、デッドコード検出結果格納部203および修正後モデル格納部204は、それぞれ記憶装置13の記憶領域の一部である。   In addition, the dead code pattern information storage unit 201, the pre-correction model storage unit 202, the dead code detection result storage unit 203, and the post-correction model storage unit 204 in the storage unit 20 of the automatic correction device 100 illustrated in FIG. It is a part of 13 storage areas.

<モデルの例>
図3はモデルエディタによって作成されたモデルの一例を示す図である。図3に示されるように、符号301、302、303、304および305が付された、四角形または長円形の要素がモデルを構成するブロックである。ブロックは、入力端および出力端の何れかまたは両方を有し、所定の信号処理を行う。この信号処理は、ブロックが入力端を有していれば当該入力端で受けた信号に基づいた処理となる。また、ブロックが出力端を有していれば、当該ブロックで行った信号処理の結果が出力端から出力される。
<Example of model>
FIG. 3 is a diagram illustrating an example of a model created by the model editor. As shown in FIG. 3, rectangular or oval elements denoted by reference numerals 301, 302, 303, 304, and 305 are blocks constituting the model. The block has either or both of an input end and an output end, and performs predetermined signal processing. This signal processing is based on a signal received at the input end if the block has an input end. If the block has an output end, the result of signal processing performed in the block is output from the output end.

また、ブロック間を繋ぐ矢印線が結線(信号線)を表している。結線は、ブロックの出力端を始点とし、ブロックの入力端を終点とするように設定される。なお、結線の始点および終点とは、それぞれ結線を表す矢印線の矢印のない側の端点および矢印のある側の端点を指す。   Moreover, the arrow line which connects between blocks represents a connection (signal line). The connection is set so that the output end of the block is the start point and the input end of the block is the end point. The starting point and the ending point of the connection refer to an end point on the side without an arrow and an end point on the side with an arrow, respectively, representing the connection.

ここで、あるブロックAの出力端とあるブロックBの入力端との結線による繋がりは、ブロックAの出力端からの出力がブロックBの入力端において入力されることを表す。すなわち、結線はブロック間の信号の入出力の関係を表している。   Here, the connection by 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 of signals between blocks.

図3におけるブロック301は、時間的に変化しない定数(Param1)を出力する定数ブロックである。定数の具体的な値は、定数ブロックごとに開発者が設定することができる。図3ではParam1=50が設定された例を示している。   A block 301 in FIG. 3 is a constant block that outputs a constant (Param1) that does not change with time. The specific value of the constant can be set by the developer for each constant block. FIG. 3 shows an example in which Param1 = 50 is set.

また、図3におけるブロック302は、入力値が予め決められた範囲内であれば、入力値をそのままの値で出力し、予め決められた範囲外であれば、予め決められた上限値または下限値を出力する出力値制限ブロックである。図3ではブロック302の上限値は500、下限値は0に設定されているため、ブロック301が出力する定数(Param1=50)が入力されると、そのままの値で出力される。   Further, the block 302 in FIG. 3 outputs the input value as it is if the input value is within a predetermined range, and if it is outside the predetermined range, a predetermined upper limit value or lower limit value is output. This is an output value restriction block that outputs a value. In FIG. 3, since the upper limit value of the block 302 is set to 500 and the lower limit value is set to 0, when the constant (Param1 = 50) output from the block 301 is input, the value is output as it is.

また、図3におけるブロック303は、四則演算を行うブロックである。図3に示すブロック303は、2つの入力端で受けた入力値を加算し、その結果を出力する。   Also, a block 303 in FIG. 3 is a block that performs four arithmetic operations. A block 303 shown in FIG. 3 adds the input values received at the two input terminals and outputs the result.

また、図3におけるブロック304は、モデル外部からデータの入力を受け、当該データを出力する入力ブロックである。   A block 304 in FIG. 3 is an input block that receives data input from the outside of the model and outputs the data.

また、図3におけるブロック305は、結線を介して受けたブロック303からの入力データをモデル外部に出力する出力ブロックである。   A block 305 in FIG. 3 is an output block that outputs the input data from the block 303 received through the connection to the outside of the model.

ブロック301〜305および結線の組み合わせで構成される図3のモデルにおいては、ブロック301のデータとブロック304に入力されたデータの加算結果をブロック305に出力することとなる。その際、ブロック301の定数(Param1)がブロック302の制限範囲内であれば、入力値をそのままの値で出力し、定数(Param1)が上限値以上であれば上限値(500)を出力し、下限値以下であれば下限値(0)を出力し、ブロック303においてブロック304に入力されたデータと加算することとなる。   In the model of FIG. 3 configured by combining blocks 301 to 305 and connection, the addition result of the data of block 301 and the data input to block 304 is output to block 305. At this time, if the constant (Param1) of the block 301 is within the limit range of the block 302, the input value is output as it is, and if the constant (Param1) is equal to or greater than the upper limit, the upper limit (500) is output. If the value is less than or equal to the lower limit value, the lower limit value (0) is output and added to the data input to the block 304 in the block 303.

このように、モデルは、複数のブロックが結線によって繋ぎ合わされることで構成され、その繋ぎ合わせの構造によって、外部とのデータ入出力を表現するようになっている。しかし、図3に示すモデルにおいても、条件によってはデッドコードが生成されることとなる。本実施の形態の自動修正装置100では、モデル自動修正処理部102が、デッドコード検出結果格納部203から検出結果を読み出し、デッドコードとなるモデル記述箇所をデッドコードが生成されないように自動修正して修正後モデルを生成するので、デッドコードを含まないソースコードを得ることができる。   In this manner, the model is configured by connecting a plurality of blocks by connection, and expresses data input / output with the outside by the connection structure. However, even in the model shown in FIG. 3, a dead code is generated depending on conditions. In the automatic correction device 100 according to the present embodiment, the model automatic correction processing unit 102 reads out the detection result from the dead code detection result storage unit 203 and automatically corrects the model description portion that becomes the dead code so that the dead code is not generated. Since the model after correction is generated, source code that does not include dead code can be obtained.

<デッドコードの検出と修正>
図4は、ソースコード生成時にデッドコードが生成されるモデルのパターン(デッドコードパターン)と、デッドコードが生成されないように修正された修正後モデルのパターンを示す図である。図4は、3行6列のテーブルとして表されている。
<Detection and correction of dead code>
FIG. 4 is a diagram illustrating a model pattern (dead code pattern) in which a dead code is generated at the time of generating a source code and a corrected model pattern corrected so that a dead code is not generated. FIG. 4 is represented as a 3 × 6 table.

図4において、左端の第1列はパターン番号を示し、項目名は「No.」となっている。第2列はデッドコードが生成されるデッドコードパターンを説明しており、項目名は「パターン」となっている。第3列はデッドコードが生成されるデッドコードパターンのブロックの種類を示しており、項目名は「検査対象ブロック」となっている。これが一致することがパターン判定の第1条件となる。第4列はデッドコードが生成されるデッドコードパターンに該当するモデルを図示しており、項目名は「修正前モデル」となっている。第5列は、実際に生成される可能性があるソースコードを図示しており、項目名は「生成コード」となっている。右端の第6列は自動修正後のモデルの図示と修正方法を説明しており、項目名は「修正案」となっている。   In FIG. 4, the first column at the left end indicates the pattern number, and the item name is “No.”. The second column describes a dead code pattern in which a dead code is generated, and the item name is “pattern”. The third column shows the block type of the dead code pattern in which the dead code is generated, and the item name is “block to be inspected”. It is the first condition for pattern determination that these match. The fourth column shows a model corresponding to a dead code pattern in which a dead code is generated, and the item name is “pre-correction model”. The fifth column shows the source code that may be actually generated, and the item name is “generated code”. The sixth column at the right end illustrates the model after automatic correction and the correction method, and the item name is “correction proposal”.

ここで、図4におけるNo.1−1およびNo.1−2のパターンは、出力範囲制限処理の入力値が固定値であることと、当該入力値が下限値と上限値の範囲内(出力制限範囲内)であることの2条件を満たしているパターンである。そのため、何れのパターンも検査対象ブロックは、出力値を制限するブロックとなる。   Here, in the patterns of No. 1-1 and No. 1-2 in FIG. 4, the input value of the output range restriction process is a fixed value, and the input value is within the range between the lower limit value and the upper limit value (output It is a pattern that satisfies the two conditions of being within the limit range. Therefore, in any pattern, the inspection target block is a block that limits the output value.

また、図4におけるNo.2のパターンは、判断条件となる制御入力値に基づいて2つの入力の一方からの入力値を出力値とする判断処理の記述パターンであり、制御入力値が固定値であることと、2つの入力のうち絶対に条件が成立しない(選択されない)側に入力ブロックが存在しないことの2条件を満たしているパターンである。そのため、検査対象ブロックは、条件により出力値を判断するブロックとなる。   The pattern of No. 2 in FIG. 4 is a description pattern of determination processing in which an input value from one of two inputs is an output value based on a control input value as a determination condition, and the control input value is a fixed value. It is a pattern that satisfies the two conditions that the input block does not exist on the side where the condition is not satisfied (not selected) of the two inputs. Therefore, the inspection target block is a block for determining an output value according to a condition.

<No.1−1のパターンのモデル>
図4におけるNo.1−1のパターンのモデルは、図3に示したモデルと同じであり、同一の構成については同一の符号を付し、重複する説明は省略する。図4におけるNo.1−1のパターンのモデルでは、ブロック302の入力値がブロック301が出力する定数(Param1=50)であるので、必ず、予め決められた範囲内(0〜500)の値となる。従って、ブロック302において入力値が予め決められた範囲内にあるか否かを判断し、予め決められた範囲外であれば、予め決められた上限値または下限値を出力する出力範囲制限処理は実行されず、このようなモデルから生成されたソースコードにはデッドコードが含まれることとなる。具体的には、「生成コード」の項目に示されているソースコードの破線で囲まれた第4行〜第10行がデッドコードとなる。
<No. 1-1 Pattern Model>
The model of the pattern No. 1-1 in FIG. 4 is the same as the model shown in FIG. 3, and the same components are denoted by the same reference numerals and redundant description is omitted. In the No. 1-1 pattern model in FIG. 4, since the input value of the block 302 is a constant (Param1 = 50) output by the block 301, the value is always within a predetermined range (0 to 500). It becomes. Therefore, in block 302, it is determined whether or not the input value is within the predetermined range. If the input value is outside the predetermined range, the output range limiting process for outputting the predetermined upper limit value or lower limit value is performed. The source code that is not executed and is generated from such a model includes dead code. Specifically, the 4th to 10th lines surrounded by a broken line of the source code shown in the item “generated code” are dead codes.

上述したように、図4のNo.1−1のパターンのモデルでは、ブロック302において出力範囲を制限する必要はなく、出力値を制限するブロック302を削除しても問題はない。そこで、自動修正により、出力値を制限するブロックを削除し、削除によって断線した箇所を再結線することで、図4の「修正案」の項目に示されるように、ブロック302が削除され、ブロック303の一方の入力端にブロック301の出力端が結線された自動修正後のモデルを得る。   As described above, in the model of the pattern No. 1-1 in FIG. 4, it is not necessary to limit the output range in the block 302, and there is no problem even if the block 302 that limits the output value is deleted. Therefore, by deleting the block that limits the output value by automatic correction, and reconnecting the part that was disconnected by the deletion, the block 302 is deleted as shown in the item “correction proposal” in FIG. An automatically corrected model in which the output end of the block 301 is connected to one input end of 303 is obtained.

出力範囲を制限する処理を削除することで、デッドコードは生成されなくなるので、カバレッジ評価の結果では、デッドコードが抽出されずカバレッジが向上する。   Since the dead code is not generated by deleting the process for limiting the output range, the dead code is not extracted from the coverage evaluation result, and the coverage is improved.

<No.1−2のパターンのモデル>
図4におけるNo.1−2のパターンのモデルのブロック401は、時間的に変化しない定数(Param1)を出力する定数ブロックであり、図4ではParam1=50が設定された例を示している。
<No. 1-2 pattern model>
4 is a constant block that outputs a constant (Param1) that does not change with time, and FIG. 4 shows an example in which Param1 = 50 is set.

また、ブロック403は、時間的に変化しない定数(Param2)を出力する定数ブロックであり、図4ではParam2=200が設定された例を示している。   A block 403 is a constant block that outputs a constant (Param2) that does not change with time. FIG. 4 shows an example in which Param2 = 200 is set.

また、ブロック405は、モデル外部からデータの入力を受け、当該データを出力する入力ブロックである。   A block 405 is an input block that receives data input from outside the model and outputs the data.

また、ブロック402は、ブロック401の出力およびブロック403の出力をデータ入力として受け、制御入力となるブロック405の出力値に応じて、2つのデータ入力の一方を出力するスイッチブロックである。   The block 402 is a switch block that receives the output of the block 401 and the output of the block 403 as data inputs, and outputs one of the two data inputs according to the output value of the block 405 serving as a control input.

また、ブロック404は、入力値が予め決められた範囲内であれば、入力値をそのままの値で出力し、予め決められた範囲外であれば、予め決められた上限値または下限値を出力する出力値制限ブロックである。図4ではブロック402の上限値は500、下限値は0に設定されている。   The block 404 outputs the input value as it is if the input value is within a predetermined range, and outputs a predetermined upper limit value or lower limit value if the input value is outside the predetermined range. This is an output value limiting block. In FIG. 4, the upper limit value of the block 402 is set to 500, and the lower limit value is set to 0.

また、ブロック406は、結線を介して受けたブロック404からの入力データをモデル外部に出力する出力ブロックである。   A block 406 is an output block that outputs the input data from the block 404 received through the connection to the outside of the model.

図4におけるNo.1−2のパターンのモデルでは、ブロック402への制御入力が0以外の場合は、ブロック401から入力される定数(Param1=50)を出力し、ブロック402への制御入力が0の場合はブロック403から入力される定数(Param1=200)を出力する。このため、ブロック402から出力される値は50または200となるので、ブロック404の入力値は、必ず、予め決められた範囲内(0〜500)の値となる。従って、ブロック404において入力値が予め決められた範囲内にあるか否かを判断し、予め決められた範囲外であれば、予め決められた上限値または下限値を出力する出力範囲制限処理は実行されず、このようなモデルから生成されたソースコードにはデッドコードが含まれることとなる。具体的には、「生成コード」の項目に示されているソースコードの破線で囲まれた第10行〜第16行がデッドコードとなる。   In the model of the pattern No. 1-2 in FIG. 4, when the control input to the block 402 is other than 0, a constant (Param1 = 50) input from the block 401 is output, and the control input to the block 402 is In the case of 0, the constant (Param1 = 200) input from the block 403 is output. Therefore, since the value output from the block 402 is 50 or 200, the input value of the block 404 is always a value within a predetermined range (0 to 500). Therefore, in block 404, it is determined whether or not the input value is within the predetermined range. If the input value is outside the predetermined range, the output range limiting process for outputting the predetermined upper limit value or lower limit value is performed. The source code that is not executed and is generated from such a model includes dead code. Specifically, the 10th to 16th lines surrounded by a broken line of the source code shown in the item “generated code” are dead codes.

上述したように、図4のNo.1−2のパターンのモデルでは、ブロック404において出力範囲を制限する必要はなく、出力値を制限するブロック404を削除しても問題はない。そこで、自動修正により、出力値を制限するブロックを削除し、削除によって断線した箇所を再結線することで、図4の「修正案」の項目に示されるように、ブロック403が削除され、ブロック402の出力端にブロック406の入力端が結線された自動修正後のモデルを得る。   As described above, in the model of the pattern No. 1-2 in FIG. 4, it is not necessary to limit the output range in the block 404, and there is no problem even if the block 404 that limits the output value is deleted. Therefore, the block that restricts the output value is deleted by automatic correction, and the part disconnected by the deletion is reconnected, so that the block 403 is deleted and the block 403 is deleted as shown in the item “correction proposal” in FIG. A model after automatic correction in which the input end of the block 406 is connected to the output end of 402 is obtained.

出力範囲を制限する処理を削除することで、デッドコードは生成されなくなるので、カバレッジ評価の結果では、デッドコードが抽出されずカバレッジが向上する。   Since the dead code is not generated by deleting the process for limiting the output range, the dead code is not extracted from the coverage evaluation result, and the coverage is improved.

<No.2のパターンのモデル>
図4におけるNo.2のパターンのモデルのブロック501は、モデル外部からデータの入力を受け、当該データを出力する入力ブロックである。
<No.2 pattern model>
The model block 501 of the pattern No. 2 in FIG. 4 is an input block that receives data input from the outside of the model and outputs the data.

また、ブロック502は、時間的に変化しない定数(Param1)を出力する定数ブロックであり、図4ではParam1=50が設定された例を示している。   A block 502 is a constant block that outputs a constant (Param1) that does not change with time. FIG. 4 shows an example in which Param1 = 50 is set.

また、ブロック503は、時間的に変化しない定数(Param0)を出力する定数ブロックであり、図4ではParam0=0が設定された例を示している。   The block 503 is a constant block that outputs a constant (Param0) that does not change with time. FIG. 4 shows an example in which Param0 = 0 is set.

また、ブロック504は、入力の絶対値を出力する絶対値ブロックである。   A block 504 is an absolute value block that outputs the absolute value of the input.

また、ブロック505は、ブロック504の出力およびブロック503の出力をデータ入力として受け、制御入力となるブロック502の出力値に基づいて、2つのデータ入力の一方を出力するスイッチブロックである。   The block 505 is a switch block that receives the output of the block 504 and the output of the block 503 as data inputs, and outputs one of the two data inputs based on the output value of the block 502 serving as a control input.

また、ブロック506は、結線を介して受けたデータをモデル外部に出力する出力ブロックである。   A block 506 is an output block that outputs data received through the connection to the outside of the model.

図4におけるNo.2のパターンのモデルでは、ブロック505の制御入力はブロック502の出力であり、ブロック502は定数(Param1=50)を出力するので、ブロック505の制御入力にはParam1=50、すなわち0以外が与えられるので、ブロック505はブロック504からの入力を必ず出力する。このため、ブロック505への制御入力が0の場合に、ブロック503から入力される定数(Param0=0)を出力する処理は実行されず、このようなモデルから生成されたソースコードにはデッドコードが含まれることとなる。具体的には、「生成コード」の項目に示されているソースコードの破線で囲まれた第7行〜第9行がデッドコードとなる。   In the model of the pattern No. 2 in FIG. 4, the control input of the block 505 is the output of the block 502, and the block 502 outputs a constant (Param1 = 50). Therefore, the control input of the block 505 has Param1 = 50, That is, since a value other than 0 is given, the block 505 always outputs the input from the block 504. For this reason, when the control input to the block 505 is 0, the process of outputting the constant (Param0 = 0) input from the block 503 is not executed, and the dead code is included in the source code generated from such a model. Will be included. Specifically, the 7th to 9th lines surrounded by a broken line of the source code shown in the item “generated code” are dead codes.

上述したように、図4のNo.2のパターンのモデルでは、ブロック505において条件により出力値を判断する必要はなく、また、ブロック503にはモデル外部からデータの入力を受ける入力ブロックに接続されていない。従って、出力値を判断するブロック505および判断条件を出力するブロック502および絶対に条件が成立しない側のデータ入力を出力するブロック503を削除しても問題はない。そこで、自動修正により、条件により出力値を判断するブロック、判断条件を出力するブロックおよび条件が成立しない側のデータ入力を出力するブロックを削除し、削除によって断線した箇所を再結線することで、図4の「修正案」の項目に示されるように、ブロック502、503および505が削除され、ブロック504の出力端にブロック506の入力端が結線された自動修正後のモデルを得る。   As described above, in the model of the pattern No. 2 in FIG. 4, it is not necessary to determine the output value according to the condition in the block 505, and the block 503 is connected to an input block that receives data input from outside the model. Not. Accordingly, there is no problem even if the block 505 for determining the output value, the block 502 for outputting the determination condition, and the block 503 for outputting the data input on which the condition is not satisfied are deleted. Therefore, by automatic correction, by deleting the block that determines the output value according to the condition, the block that outputs the determination condition, and the block that outputs the data input on the side where the condition is not satisfied, and reconnecting the location disconnected by the deletion, As shown in the item “Correction proposal” in FIG. 4, the blocks 502, 503, and 505 are deleted, and an automatically corrected model in which the input end of the block 506 is connected to the output end of the block 504 is obtained.

出力値を判断する処理を削除することで、デッドコードは生成されなくなるため、カバレッジ評価の結果では、デッドコードが抽出されずカバレッジが向上する。   Since the dead code is not generated by deleting the process for determining the output value, the dead code is not extracted from the coverage evaluation result, and the coverage is improved.

<デッドコード検出処理>
次に、図1、図2を参照しつつ図5に示すフローチャートを用いてデッドコード検出処理部101の動作について説明する。ユーザが図示されない入力装置を操作することによりデッドコード検出処理が開始されると、まず、デッドコードパターン情報格納部201に記憶されたデッドコードパターン情報を読み出す(ステップS1)。デッドコードパターン情報は、デッドコードを生成するパターンの情報であり、その一例を図6に示す。
<Dead code detection processing>
Next, the operation of the dead code detection processing unit 101 will be described with reference to FIGS. 1 and 2 and the flowchart shown in FIG. When the dead code detection process is started by operating the input device (not shown), first, the dead code pattern information stored in the dead code pattern information storage unit 201 is read (step S1). The dead code pattern information is information on a pattern for generating a dead code, and an example thereof is shown in FIG.

図6に示すデッドコードパターン情報は、2種類のデッドコードパターンについて設定されており、2行5列のテーブルとして表されている。   The dead code pattern information shown in FIG. 6 is set for two types of dead code patterns, and is represented as a 2 × 5 table.

図6において、左端の第1列は検査対象ブロックの分類を示し、図6ではType1およびType2として分類されており、項目名は「検査対象ブロックの種類」である。第2列は、検査対象ブロックが接続される接続元のブロックを規定しており、図6ではType3のみが規定され、項目名は「接続元ブロックの種類」である。第3列は、接続元のブロックを取得する際のポート番号を示しており、項目名は「接続元ポート」である。第4列は、デッドコードパターンとなる第1の条件を規定しており、項目名は「条件1」である。第5列は、デッドコードパターンとなる第2の条件を規定しており、項目名は「条件2」である。   In FIG. 6, the first column at the left end indicates the classification of the inspection target block. In FIG. 6, the first column is classified as Type 1 and Type 2, and the item name is “Type of inspection target block”. The second column defines the connection source block to which the inspection target block is connected. In FIG. 6, only Type 3 is defined, and the item name is “type of connection source block”. The third column shows the port number when acquiring the connection source block, and the item name is “connection source port”. The fourth column defines a first condition for a dead code pattern, and the item name is “condition 1”. The fifth column defines the second condition for the dead code pattern, and the item name is “condition 2”.

ここで、図7および図8には、それぞれType1およびType2に該当する検査対象ブロックを示しており、Type1は出力値を制限するブロック、Type2は出力値を判断するブロックである。また、図9にはType3の接続元のブロックを示しており、Type3の接続元のブロックは、時間的に変化しない定数を出力する定数ブロックである。   Here, FIGS. 7 and 8 show blocks to be inspected corresponding to Type 1 and Type 2, respectively, where Type 1 is a block for limiting the output value, and Type 2 is a block for determining the output value. FIG. 9 shows Type 3 connection source blocks. The Type 3 connection source blocks are constant blocks that output constants that do not change with time.

次に、デッドコード検出処理部101は、修正前モデル格納部202に記憶された修正前モデルを読み出す(ステップS2)。修正前モデルは、例えば、図4における「修正前モデル」の項目に記載されているようなモデルである。   Next, the dead code detection processing unit 101 reads out the pre-correction model stored in the pre-correction model storage unit 202 (step S2). The pre-correction model is, for example, a model described in the item “Pre-correction model” in FIG.

次に、デッドコード検出処理部101は、検査対象ブロックの種類がTypeXに対応するブロックを修正前モデルから検出する(ステップS3)。例えば、検査対象ブロックがType1である場合、修正前モデルに同じブロックが含まれていればそれを検出する。Type1の検査対象ブロックは出力値を制限するブロックであるので、修正前モデルに含まれる出力値を制限するブロックを全て検出する。ここで、検出されたブロックを被検出ブロックと呼称する。なお、修正前モデルに検査対象ブロックに対応するブロックが含まれていない場合は一連の処理を終了する。   Next, the dead code detection processing unit 101 detects, from the pre-correction model, a block whose type of the inspection target block corresponds to TypeX (step S3). For example, when the inspection target block is Type 1, if the same block is included in the pre-correction model, it is detected. Since the inspection target block of Type 1 is a block that limits the output value, all blocks that limit the output value included in the pre-correction model are detected. Here, the detected block is referred to as a detected block. If the pre-correction model does not include a block corresponding to the inspection target block, the series of processing ends.

検査対象ブロックは、例えば、図4における「検査対象ブロック」の項目に記載されているようなブロックであり、本実施の形態では2種類を想定している。   The inspection target block is, for example, a block described in the item “inspection target block” in FIG. 4, and two types are assumed in the present embodiment.

ここで、検査対象ブロックは、図6の「検査対象ブロックの種類」の項目でType1およびType2として分類されており、Type1およびType2の両方についてステップS3以下の処理を繰り返す。   Here, the block to be inspected is classified as Type 1 and Type 2 in the item “Type of block to be inspected” in FIG. 6, and the processes in and after step S3 are repeated for both Type 1 and Type 2.

次に、デッドコード検出処理部101は、ステップS3で検出した被検出ブロックがデッドコードパターンとなる第1の条件(条件1)を満たすか否かを判定する(ステップS4)。ここで、条件1は図6の「条件1」の項目で規定されており、Type1の検査対象ブロックに対しては、検査対象ブロックが接続されている「接続元のブロックの種類がType3と一致する」という条件である。   Next, the dead code detection processing unit 101 determines whether or not the detected block detected in step S3 satisfies the first condition (condition 1) that becomes a dead code pattern (step S4). Here, Condition 1 is defined in the item of “Condition 1” in FIG. 6. For the inspection target block of Type 1, the inspection target block is connected to “the type of the connection source block matches Type 3. The condition is “Yes”.

そして、条件1を満たさないと判定される場合(No)は、他の被検出ブロックに対してステップS4の処理を実行する。なお、ステップS3で検出した被検出ブロックが1つだけの場合は、ステップS3で次の検査対象ブロックに対応するブロックが検出されるまで待機する。一方、条件1を満たす(Yes)と判定される場合はステップS5に移行する。なお、条件1を満たす場合とは、検査対象ブロックが時間的に変化しない定数を出力する定数ブロックに接続されている場合であり、検査対象ブロックに固定値(定数)が入力される場合である。   And when it determines with not satisfy | filling the conditions 1 (No), the process of step S4 is performed with respect to another detected block. If only one detected block is detected in step S3, the process waits until a block corresponding to the next inspection target block is detected in step S3. On the other hand, when it determines with satisfy | filling the conditions 1 (Yes), it transfers to step S5. The case where the condition 1 is satisfied is a case where the inspection target block is connected to a constant block that outputs a constant that does not change with time, and a case where a fixed value (constant) is input to the inspection target block. .

ステップS5では、ステップS3で検出した被検出ブロックがデッドコードパターンとなる第2の条件(条件2)を満たすか否かを判定する。   In step S5, it is determined whether or not the detected block detected in step S3 satisfies a second condition (condition 2) that becomes a dead code pattern.

ここで、条件2は図6の「条件2」の項目で規定されており、Type1の検査対象ブロックに対しては、検査対象ブロックの入力値が、下限値と上限値の範囲内であることが成立するという条件である。なお、当該条件は図6では「下限値<接続元からの出力値<上限値が成立する」と表されている。また、条件2はType2の検査対象ブロックに対しては、「条件が成立しない側の接続元ブロックがType3と一致する」という条件である。   Here, condition 2 is defined by the item “condition 2” in FIG. 6, and for the type 1 inspection target block, the input value of the inspection target block is within the range between the lower limit value and the upper limit value. Is a condition that holds. In FIG. 6, the condition is expressed as “lower limit value <output value from connection source <upper limit value is satisfied”. Condition 2 is a condition that “the connection source block on the side where the condition is not satisfied matches Type 3” for the Type 2 inspection target block.

そして、条件2を満たさないと判定される場合(No)は、他の被検出ブロックに対してステップS4以下の処理を実行する。なお、ステップS3で検出した被検出ブロックが1つだけの場合は、ステップS3で次の検査対象ブロックに対応するブロックが検出されるまで待機する。一方、条件2を満たす(Yes)と判定される場合はステップS6に移行する。なお、条件2を満たす場合とは、Type1の検査対象ブロックに対しては、検査対象ブロックが出力値制限ブロックであり、接続元ブロックからの出力値が、検査対象ブロックの出力の制限範囲内の値となる場合である。また、Type2の検査対象ブロックに対しては、検査対象ブロックが条件により出力値を判断するブロックであり、条件が成立しない側の接続元ブロックが、時間的に変化しない定数を出力する定数ブロックの場合である。   And when it determines with not satisfy | filling the conditions 2 (No), the process below step S4 is performed with respect to another detected block. If only one detected block is detected in step S3, the process waits until a block corresponding to the next inspection target block is detected in step S3. On the other hand, when it determines with satisfy | filling the conditions 2 (Yes), it transfers to step S6. In the case where the condition 2 is satisfied, for the Type 1 inspection target block, the inspection target block is an output value restriction block, and the output value from the connection source block is within the output restriction range of the inspection target block. This is the case. In addition, for the Type 2 inspection target block, the inspection target block is a block that determines an output value according to a condition, and the connection source block on which the condition is not satisfied outputs a constant that does not change with time. Is the case.

ステップS4およびS5の判定の結果、ステップS3で検出した被検出ブロックがデッドコードパターンとなる条件1および条件2を満たすとなった場合、当該ブロックはデッドコードパターンを生成するブロックであると判断することができ、当該ブロックをデッドコード検出結果としてデッドコード検出結果格納部203に格納する(ステップS6)。   As a result of the determination in steps S4 and S5, when the detected block detected in step S3 satisfies the condition 1 and the condition 2 that become a dead code pattern, it is determined that the block is a block that generates a dead code pattern. The block is stored in the dead code detection result storage unit 203 as a dead code detection result (step S6).

図10は、デッドコード検出結果の格納例を示す図である。図10においては3種類のパターンについて格納例を示しており、3行5列のテーブルとして表されている。   FIG. 10 is a diagram illustrating a storage example of the dead code detection result. FIG. 10 shows a storage example for three types of patterns, which are represented as a table of 3 rows and 5 columns.

図10において、左端の第1列は、デッドコードが生成されるブロックを含んだ修正前モデルのパターン番号を示し、図10ではNo.1−1、No.1−2およびNo.2が示されており、項目名は「No.」である。この修正前モデルが、図5のステップS2で読み出したモデルに相当し、No.1−1、No.1−2およびNo.2のパターンからデッドコードを検出したことを表している。   10, the first column at the left end shows the pattern number of the pre-correction model including the block in which the dead code is generated, and in FIG. 10, No. 1-1, No. 1-2, and No. 2 are shown. The item name is “No.”. This pre-correction model corresponds to the model read in step S2 in FIG. 5 and represents that a dead code is detected from the patterns of No. 1-1, No. 1-2, and No. 2.

第2列は検査対象ブロックの分類を示し、図10ではNo.1−1およびNo.1−2が、共にType1とされ、No.2がType2として分類されており、項目名は「検査対象ブロックの種類」である。第3列はモデルの最上層ブロックから削除対象ブロックまでのパス(絶対パス)が示されており、項目名は「削除対象ブロックパス」である。第4列は再結線する入力側と出力側それぞれのブロックまでのパスが上下段に分けて示されており、項目名は「再結線対象ブロックパス」である。なお、上段が入力側のブロックまでのパスであり、下段が出力側のブロックまでのパスである。第5列は検査対象ブロックを削除して断線箇所を再結線するパターンと、検査対象ブロックの他に、デッドコードとなるブロックも削除して断線箇所を再結線するパターンを規定しており、項目名は「削除対象オプション」である。なお、検査対象ブロックのみを削除するパターンを「0」とし、検査対象ブロックを含めて複数を削除するパターンを「1」で表している。   The second column shows the classification of the blocks to be inspected. In FIG. 10, No. 1-1 and No. 1-2 are both Type 1 and No. 2 is classified as Type 2. Block type ". The third column shows the path (absolute path) from the uppermost block of the model to the deletion target block, and the item name is “deletion target block path”. In the fourth column, the paths to the respective blocks on the input side and output side to be reconnected are shown in upper and lower stages, and the item name is “reconnection target block path”. The upper stage is a path to the input side block, and the lower stage is a path to the output side block. The fifth column specifies the pattern for deleting the inspection target block and reconnecting the disconnection location, and the pattern for deleting the block that becomes a dead code and reconnecting the disconnection location in addition to the inspection target block. The name is “deletion target option”. Note that a pattern for deleting only the inspection target block is “0”, and a pattern for deleting a plurality including the inspection target block is expressed by “1”.

ここで図5のフローチャートの説明に戻る。ステップS6でデッドコード検出結果をデッドコード検出結果格納部203に格納した後は、ステップS3で検出した全ての被検出ブロックに対してステップS4〜S6のデッドコード検出処理を実行したか否かを判定する(ステップS7)。   Returning to the flowchart of FIG. After the dead code detection result is stored in the dead code detection result storage unit 203 in step S6, it is determined whether or not the dead code detection processing in steps S4 to S6 has been executed for all the detected blocks detected in step S3. Determination is made (step S7).

そして、全ての被検出ブロックに対してデッドコード検出処理を実行した(Yes)と判定される場合はステップS8に移行し、処理すべき被検出ブロックが残っている(No)と判定される場合は残っている被検出ブロックに対してステップS4以下の処理を実行する。   If it is determined that dead code detection processing has been executed for all detected blocks (Yes), the process proceeds to step S8, and it is determined that there are remaining detected blocks to be processed (No). Step S4 and subsequent steps are executed for the remaining detected blocks.

ステップS8では、ステップS2で読み出した修正前モデルに対して、全ての検査対象ブロックを適用したか否かを判定する。すなわち、図6に示したように、検査対象ブロックの種類がType1およびType2の2種類である場合、ステップS2で読み出した修正前モデルについて、Type1およびType2の検査対象ブロックを適用して、対応するブロックが含まれているか否かを判定したかを確認する。   In step S8, it is determined whether or not all inspection target blocks have been applied to the pre-correction model read in step S2. That is, as shown in FIG. 6, when there are two types of inspection target blocks, Type 1 and Type 2, the inspection target blocks of Type 1 and Type 2 are applied to the pre-correction model read in step S2. Check if it is determined whether the block is included or not.

そして、修正前モデルに対して全ての検査対象ブロックを適用した(Yes)と判定される場合は一連の処理を終了し、適用すべき検査対象ブロックが残っている(No)と判定される場合はステップS3以下の処理を繰り返す。   When it is determined that all the inspection target blocks have been applied to the pre-correction model (Yes), a series of processing ends, and when it is determined that the inspection target blocks to be applied remain (No) Repeats the processing from step S3.

<モデル自動修正処理>
次に、図1、図2を参照しつつ図11に示すフローチャートを用いてモデル自動修正処理部102の動作について説明する。ユーザが図示されない入力装置を操作することによりモデル自動修正処理が開始されると、まず、デッドコード検出結果格納部203に記憶されたデッドコード検出結果を読み出す(ステップS11)。
<Automatic model correction processing>
Next, the operation of the model automatic correction processing unit 102 will be described using the flowchart shown in FIG. 11 with reference to FIGS. When the model automatic correction process is started by the user operating an input device (not shown), first, the dead code detection result stored in the dead code detection result storage unit 203 is read (step S11).

次に、モデル自動修正処理部102は、修正前モデル格納部202に記憶された修正前モデルを読み出す(ステップS12)。   Next, the model automatic correction processing unit 102 reads the pre-correction model stored in the pre-correction model storage unit 202 (step S12).

次に、モデル自動修正処理部102は、削除対象ブロックを特定する(ステップS13)。削除対象ブロックは、図10に示されるデッドコード検出結果の格納例においては、「削除対象ブロックパス」の項目に記載されている情報で規定される。すなわち、「削除対象ブロックパス」の項目では、例えばNo.1−1のパターンの場合、「Sample1/Target1」のように削除対象が規定されており、このうち「Sample1」を参照して、削除対象ブロックとする。また、「Target1」はモデルの最上層ブロックから削除対象ブロックまでのパスを規定している。   Next, the model automatic correction processing unit 102 specifies a deletion target block (step S13). In the storage example of the dead code detection result shown in FIG. 10, the deletion target block is defined by information described in the item “deletion target block path”. That is, in the item “deletion target block path”, for example, in the case of the pattern No. 1-1, the deletion target is defined as “Sample1 / Target1”. The target block. “Target 1” defines a path from the top layer block of the model to the deletion target block.

次に、モデル自動修正処理部102は、修正方法の判定を行う(ステップS14)。具体的には、図10に示されるデッドコード検出結果の「削除対象オプション」の項目を参照し、削除対象オプションが「0」であるか否かを判定し、「0」の場合(Yes)はステップS15に移行し、「1」の場合(No)はステップS20に移行する。例えばNo.1−1のパターンの場合、削除対象オプションは「0」であるので、ステップS15において検査対象ブロックのみを削除する。   Next, the model automatic correction processing unit 102 determines a correction method (step S14). Specifically, it is determined whether or not the deletion target option is “0” by referring to the item “deletion target option” of the dead code detection result shown in FIG. 10, and in the case of “0” (Yes) Shifts to step S15, and if “1” (No), shifts to step S20. For example, in the case of the pattern No. 1-1, since the deletion target option is “0”, only the inspection target block is deleted in step S15.

次に、モデル自動修正処理部102は、削除対象ブロックの削除により断線している箇所を再結線する(ステップS16)。再結線の箇所は、図10に示されるデッドコード検出結果の「再結線対象ブロックパス」の項目に記載されている情報で規定されている。すなわち、「再結線対象ブロックパス」の項目では、例えばNo.1−1のパターンの場合、「Sample1/Block1」、「Sample1/Block2」のように再結線対象が規定されており、「Target1」は削除されたブロックであり、「Block1」は「Target1」の入力側にあるブロックまでのパスを示し、「Block2」は「Target1」の出力側にあるブロックまでのパスを示している。モデル自動修正処理部102は、この情報に基づいて「Block1」と「Block2」との間を再結線する。No.1−1のパターンの場合、図4の「修正案」の項目に示されるように、ブロック302が削除され、ブロック303の一方の入力端にブロック301の出力端が結線されたモデルとなる。   Next, the model automatic correction processing unit 102 reconnects a portion that is disconnected due to deletion of the deletion target block (step S16). The location of reconnection is defined by the information described in the item “reconnection target block path” of the dead code detection result shown in FIG. That is, in the item “reconnection target block path”, for example, in the case of the pattern No. 1-1, reconnection targets are defined as “Sample1 / Block1”, “Sample1 / Block2”, and “Target1”. Is a deleted block, “Block 1” indicates a path to a block on the input side of “Target 1”, and “Block 2” indicates a path to a block on the output side of “Target 1”. The model automatic correction processing unit 102 reconnects “Block 1” and “Block 2” based on this information. In the case of the pattern of No. 1-1, a model in which the block 302 is deleted and the output end of the block 301 is connected to one input end of the block 303 as shown in the item “Proposed amendment” in FIG. Become.

その後、モデル自動修正処理部102は、モデルを修正したことを、修正後モデル内にコメントとして出力し、履歴を残す(ステップS17)。図12にはモデル内に出力されるコメントの例を示す。図12に示されるように、コメントには、修正日、修正者、修正内容が記載される。これにより、ユーザの便宜を図ることができる。   Thereafter, the model automatic correction processing unit 102 outputs the fact that the model has been corrected as a comment in the corrected model, and leaves a history (step S17). FIG. 12 shows an example of a comment output in the model. As shown in FIG. 12, the comment describes the correction date, the corrector, and the details of the correction. Thereby, a user's convenience can be aimed at.

その後、モデル自動修正処理部102は、ステップS18において、デッドコード検出結果に含まれる全ての削除対象ブロックを修正したか否かを判定し、全ての削除対象ブロックを修正した場合(Yes)には、ステップS19において修正後モデルを修正後モデル格納部204に格納して一連の処理を終了し、未修正の削除対象ブロックがある場合(No)には、ステップS13以下の処理を繰り返す。   Thereafter, in step S18, the model automatic correction processing unit 102 determines whether or not all deletion target blocks included in the dead code detection result have been corrected, and when all deletion target blocks have been corrected (Yes). In step S19, the corrected model is stored in the corrected model storage unit 204, and the series of processing ends. If there is an uncorrected deletion target block (No), the processing in step S13 and subsequent steps is repeated.

ここで、ステップS14で修正方法の判定を行った結果、削除対象オプションが「1」の場合は、削除対象ブロックが検査対象ブロック以外にも複数存在するため、その全てを削除する。例えばNo.2のパターンの場合、「削除対象ブロックパス」の項目には、「Sample3/Target3」、「Sample3/Target4」および「Sample3/Target5」のように削除対象が規定されており、このうち「Sample3」を参照して、削除対象ブロックとする。また、「Target3」、「Target4」および「Target5」のように、削除対象ブロックまでの絶対パスが3系統あるので、削除対象ブロックが検査対象ブロック以外にもあることを示している。   If the deletion target option is “1” as a result of determining the correction method in step S14, since there are a plurality of deletion target blocks other than the inspection target block, all of them are deleted. For example, in the case of the pattern of No. 2, the “deletion target block path” item specifies deletion targets such as “Sample3 / Target3”, “Sample3 / Target4”, and “Sample3 / Target5”. With reference to “Sample3”, the block is a deletion target block. Further, since there are three absolute paths to the deletion target block such as “Target3”, “Target4”, and “Target5”, it indicates that the deletion target block is other than the inspection target block.

ステップS20では、まず削除対象ブロックである「Target3」を削除し、次に、ステップS21において、「削除対象ブロックパス」の項目にある全ての削除対象ブロックを削除したか否かを判定し、全ての削除対象ブロックを削除した場合(Yes)には、ステップS22において削除対象ブロックの削除により断線している箇所を再結線する。図10の「再結線対象ブロックパス」の項目では、例えばNo.2のパターンの場合、「Sample3/Block5」、「Sample3/Block6」のように再結線対象が規定されており、「Target3」は削除されたブロックであり、「Block5」は「Target3」の入力側にあるブロックまでのパスを示し、「Block6」は「Target3」の出力側にあるブロックまでのパスを示している。モデル自動修正処理部102は、この情報に基づいて「Block5」と「Block6」との間を再結線する。   In step S20, first, “Target3” that is a deletion target block is deleted. Next, in step S21, it is determined whether all deletion target blocks in the “deletion target block path” item have been deleted. When the deletion target block is deleted (Yes), the disconnection portion is deleted by deleting the deletion target block in step S22. In the item “block path for reconnection” in FIG. 10, for example, in the case of the pattern No. 2, reconnection targets are defined as “Sample3 / Block5” and “Sample3 / Block6”, and “Target3” In the deleted block, “Block 5” indicates a path to the block on the input side of “Target 3”, and “Block 6” indicates a path to the block on the output side of “Target 3”. The model automatic correction processing unit 102 reconnects between “Block 5” and “Block 6” based on this information.

一方、ステップS21において、未削除の削除対象ブロックがある(No)と判定される場合には、ステップS20以下の処理を繰り返す。ここで、「削除対象ブロックパス」の項目にある「Target4」および「Target5」は、「Target3」以外にもブロックが含まれることを示しているが、これらのブロックは、「再結線対象ブロックパス」の項目では、再結線の対象となるブロックとして挙げられていないので、ステップS20で削除の対象となる。No.2のパターンの場合、図4の「修正案」の項目に示されるように、ブロック502、503および505が削除され、ブロック504の出力端にブロック506の入力端が結線されたモデルとなる。   On the other hand, if it is determined in step S21 that there is an undeleted block to be deleted (No), the processing in step S20 and subsequent steps is repeated. Here, “Target4” and “Target5” in the “deletion target block path” field indicate that blocks other than “Target3” are included, but these blocks are “reconnection target block paths”. In the item “”, since it is not listed as a block to be reconnected, it is a deletion target in step S20. In the case of the pattern No. 2, as shown in the item “Proposed amendment” in FIG. Become.

なお、本発明は、その発明の範囲内において、実施の形態を適宜、変形、省略することが可能である。   In the present invention, the embodiments can be appropriately modified and omitted within the scope of the invention.

101 デッドコード検出処理部、102 モデル自動修正処理部。   101 dead code detection processing unit, 102 model automatic correction processing unit.

Claims (4)

モデルベース開発におけるモデルの自動修正装置であって、
デッドコードを生成するモデルの記述パターンであるデッドコードパターンに基づいて未修正の修正前モデルからデッドコードを生成する箇所を検出するデッドコード検出処理部と、
前記デッドコード検出処理部で検出された前記デッドコードを生成する箇所を修正して修正後モデルを生成するモデル自動修正処理部と、を備え、
前記モデルは、信号処理を行う複数のブロックと、ブロック間を繋ぐ結線とを有し、
前記モデル自動修正処理部は、
前記修正前モデルから前記デッドコードを生成する箇所の前記ブロックを削除し、削除によって発生した断線箇所のブロック間を再結線することで前記修正後モデルを生成する、自動修正装置。
An automatic model correction device in model-based development,
A dead code detection processing unit that detects a location where a dead code is generated from an uncorrected pre-correction model based on a dead code pattern that is a description pattern of a model that generates a dead code;
A model automatic correction processing unit that generates a corrected model by correcting the location for generating the dead code detected by the dead code detection processing unit, and
The model includes a plurality of blocks that perform signal processing and a connection that connects the blocks.
The model automatic correction processing unit
An automatic correction device that generates the post-correction model by deleting the block at a location where the dead code is generated from the pre-correction model, and reconnecting between the blocks at the disconnection location generated by the deletion.
前記デッドコードパターンは、
出力範囲制限処理の記述パターンを含み、入力が固定値であり、該入力が下限値と上限値の範囲内にある条件を満たすパターンである、請求項1記載の自動修正装置。
The dead code pattern is:
The automatic correction device according to claim 1, wherein the automatic correction apparatus includes a description pattern of output range restriction processing, wherein the input is a fixed value, and the input satisfies a condition that is within a range between a lower limit value and an upper limit value.
前記デッドコードパターンは、
判断条件となる制御入力に基づいて2つの入力の一方からの入力値を出力値とする判断処理の記述パターンを含み、前記制御入力値が固定値であり、前記2つの入力のうち、条件が成立しない側には前記モデルの外部からデータが入力がない条件を満たすパターンである、請求項1または請求項2記載の自動修正装置。
The dead code pattern is:
Including a description pattern of a determination process in which an input value from one of two inputs is an output value based on a control input serving as a determination condition, the control input value is a fixed value, and the condition of the two inputs is The automatic correction device according to claim 1 or 2, wherein a pattern that satisfies a condition that no data is input from the outside of the model is provided on the side that is not established.
前記モデル自動修正処理部は、
前記修正後モデル内に、修正内容を示すコメントを出力し、履歴を残す、請求項1記載の自動修正装置。
The model automatic correction processing unit
The automatic correction device according to claim 1, wherein a comment indicating the correction content is output and a history is left in the corrected model.
JP2017059060A 2017-03-24 2017-03-24 Automatic correction device Active JP6305598B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2017059060A JP6305598B1 (en) 2017-03-24 2017-03-24 Automatic correction device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2017059060A JP6305598B1 (en) 2017-03-24 2017-03-24 Automatic correction device

Publications (2)

Publication Number Publication Date
JP6305598B1 JP6305598B1 (en) 2018-04-04
JP2018163432A true JP2018163432A (en) 2018-10-18

Family

ID=61828591

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2017059060A Active JP6305598B1 (en) 2017-03-24 2017-03-24 Automatic correction device

Country Status (1)

Country Link
JP (1) JP6305598B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102630168B1 (en) * 2023-06-01 2024-01-29 쿠팡 주식회사 Electronic device and method for managing codes

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008176639A (en) * 2007-01-19 2008-07-31 Mitsubishi Heavy Ind Ltd Control logic correction device and program
JP2008269281A (en) * 2007-04-20 2008-11-06 Meidensha Corp Software development support system, development support method and program
JP2013161219A (en) * 2012-02-03 2013-08-19 Denso Corp Code generation device and code generation program
US20130247019A1 (en) * 2012-03-19 2013-09-19 Lan Xu Specifying Memory Resource Implementations for Deployment of a Graphical Program to Programmable Hardware
JP2016177666A (en) * 2015-03-20 2016-10-06 キャッツ株式会社 Model inspection device, model inspection method, and program

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008176639A (en) * 2007-01-19 2008-07-31 Mitsubishi Heavy Ind Ltd Control logic correction device and program
JP2008269281A (en) * 2007-04-20 2008-11-06 Meidensha Corp Software development support system, development support method and program
JP2013161219A (en) * 2012-02-03 2013-08-19 Denso Corp Code generation device and code generation program
US20130247019A1 (en) * 2012-03-19 2013-09-19 Lan Xu Specifying Memory Resource Implementations for Deployment of a Graphical Program to Programmable Hardware
JP2016177666A (en) * 2015-03-20 2016-10-06 キャッツ株式会社 Model inspection device, model inspection method, and program

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102630168B1 (en) * 2023-06-01 2024-01-29 쿠팡 주식회사 Electronic device and method for managing codes

Also Published As

Publication number Publication date
JP6305598B1 (en) 2018-04-04

Similar Documents

Publication Publication Date Title
CN106776334B (en) Comment-based test case generation method and device
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
CN113434328B (en) Logic configuration compiling error correction method and system for distributed control system
JP6440895B2 (en) Software analysis apparatus and software analysis method
CN112328305B (en) Eye pattern testing method and device, electronic equipment and readable storage medium
KR101110241B1 (en) Program test device and program
KR101882759B1 (en) Method and apparatus for stabilized binary differencing
JP2009169828A (en) Test case creation device and creation program
US8255581B2 (en) Electronic device having physical switch to select functionality exposed to host computing device
JP6305598B1 (en) Automatic correction device
JP6275009B2 (en) Test apparatus and test program
WO2020230241A1 (en) Testing device, testing method, and program
JP2016128941A (en) Output determination device, output determination method, output determination program, and static analysis device
JP6447111B2 (en) Common information providing program, common information providing method, and common information providing apparatus
JP6579022B2 (en) Generating program, generating method, and generating apparatus
JP5958655B2 (en) Test program, test apparatus and test method
JP2010218452A (en) Terminal device which performs test of application, and test method of application
JP7228374B2 (en) Simulation system and simulation method
WO2024127583A1 (en) Operation assistance device, operation assistance method, and operation assistance program
JP5343840B2 (en) Program analysis apparatus and analysis method
JP6584724B1 (en) Program verification device, program verification method, and program verification program
JP2008262473A (en) Equipment maintenance management system
KR101956719B1 (en) Method for producing package software
US20130007528A1 (en) Using reverse time for coverage analysis
JP2018005321A (en) Test specification generation device, test specification generation method and test specification generation program

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20180117

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20180206

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20180306

R150 Certificate of patent or registration of utility model

Ref document number: 6305598

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111