The present disclosure relates to a design support apparatus and a design support method.
There is a disclosed technique listed below.
As an apparatus used in the model-based development, a virtual development environment apparatus as shown in Patent Document 1 is known. The virtual development environment apparatus includes an interface unit for enabling control of intentional fault injections, intentional response delays, and the like into a device model from the system test program.
Model-based development is known as a development method of various embedded systems representative of automobile applications and the like. The model-based development is a technique of previously creating a model such as a system model and a device model, and operating the model in a model execution environment, thereby advancing development of a target indicated by the model based on the model.
Here, in the model, functions, configurations, and operations of a target such as a system or a device are virtually implemented on software using a Computer Aided Engineering (CAE) tool. The model execution environment is an environment constructed by a CAE tool. CAE tools typically include MATLAB®, Simulink® and the like.
With such model-based development, for example, various problems that have been extracted by testing actual systems and devices in the past can be extracted without waiting for completion of the actual systems and devices, and can be fed back to the design of the systems and devices at an early stage.
On the other hand, for example, a device manufacturer has many source codes that can be mounted on a device such as a microcontroller as a design asset. Here, for example, a case is assumed in which the source code included in the design asset is effectively utilized and a new system including a device on which the source code is mounted as a component is developed by model-based development.
In this case, there may be a situation where the source code exists, but there is no system model that reflects the source code. For this reason, for example, a user such as a designer needs to create a new system model and verify that the created system model accurately reflects the source code. However, this verification operation may cause a great workload such as labor and work time.
Other objects and new features will be apparent from the description of this specification and the accompanying drawings.
Therefore, the design support apparatus according to one embodiment is an apparatus that supports a generation of a code block to verify a model created by referencing a source code, and includes a processor and a storage device. The model operates in a model execution environment in model-based development. The source code is registered in the code block. The storage device stores the source code and the model. The processor generates a terminal generation setting file in which a terminal of the code block is written, by searching a terminal block included in the model read from the storage device and defining the terminal of the code block based on the terminal block obtained from a search result of the terminal block. Further, the processor writes, in the code block, a terminal linking code indicating a correspondence relationship between the terminal written in the terminal generation setting file and the source code. Furthermore, the processor compiles, using the terminal generation setting file, the code block in which the terminal linking code is written into a format executable in the model execution environment.
The design support apparatus according to one embodiment can be used to reduce the workload of the user.
In the following embodiments, when required for convenience, the description will be made by dividing into a plurality of sections or embodiments, but except when specifically stated, they are not independent of each other, and one is related to the modified example, detail, supplementary description, or the like of part or all of the other. In the following embodiments, the number of elements, etc. (including the number of elements, numerical values, quantities, ranges, etc.) is not limited to the specific number, but may be not less than or equal to the specific number, except for cases where the number is specifically indicated and is clearly limited to the specific number in principle. Furthermore, in the following embodiments, it is needless to say that the constituent elements (including element steps and the like) are not necessarily essential except in the case where they are specifically specified and the case where they are considered to be obviously essential in principle. Similarly, in the following embodiments, when referring to the shapes, positional relationships, and the like of components and the like, it is assumed that the shapes and the like are substantially approximate to or similar to the shapes and the like, except for the case in which they are specifically specified and the case in which they are considered to be obvious in principle, and the like. The same applies to the above numerical values and ranges.
Hereinafter, embodiments will be described in detail with reference to the drawings. In all the drawings for explaining the embodiments, members having the same functions are denoted by the same reference numerals, and repetitive descriptions thereof are omitted. In the following embodiments, descriptions of the same or similar parts will not be repeated in principle except when particularly necessary.
Various Assumptions for Design Support Apparatus
In addition, the block is usually hierarchically constructed such that a plurality of lower-level blocks is included in an upper-level block. In this viewpoint, the model 10 can also be regarded as a single upper-level block. As a specific example, it is assumed that a microcontroller functions as a motor controller by, for example, implementing a source code in the microcontroller. The motor controller includes a Proportional Integral (PI) controller for speed control, and a PI controller for torque control. Furthermore, each PI controller includes a proportional calculator, an integral calculator, or the like.
In this case, the model 10, which is also the upper-level block, for example, indicates the function, configuration, operation of the motor controller. The middle-level block included in the upper-level block indicates the function, configuration, and operation of the PI controller or the like. Further, the lower-level block included in the middle-level block indicates the function, configuration, and operation of the integral calculator or the like. In the block diagram, the terminal of each block is also one of the blocks, for example, the input terminal IN1 is an input terminal block, the output terminal OT1 is an output terminal block.
In the source 21 of
Considering the function of “funcA” in
In
Specifically, in the CAE tool such as MATLAB and Simulink, any C code 20 can be generally registered, and a block such as an S-function block that can execute the registered C code 20 is provided in advance. The user creates the code block BKC using the blocks on the CAE tool.
In addition, the user uses the model execution environment 15 to create an input block 30 for inputting the same data to the created code block BKC and the verification target block BKM, and a comparison block 31 for comparing the outputs from the two blocks in accordance therewith. Then, the user compiles the four blocks thus created into a format executable in the model execution environment 15, and verifies the identity between the code block BKC and the verification target block BKM by operating the blocks in the model execution environment 15.
That is, the user verifies that the verification target block BKM has been created accurately reflecting the C code 20 based on the comparison result of the comparison block 31. Specifically, the user confirms that the difference between the output of the code block BKC and the output of the verification target block BKM is zero, or less than or equal to the threshold value. The threshold value at this time is determined on the basis of a difference in the method of handling decimal points in the two blocks. This difference in the handling method may occur due to the specification of the CAE tool.
The block type of two input terminals IN whose argument names are “a1” and “a2” is set to an argument block 45 on the CAE tool. The block type of the input terminal IN whose variable name is “g” is set in a global variable block 47. In this specification, the input terminal IN set in the global variable block 47 is referred to as a global variable input terminal as distinguished from the input terminal IN set in the argument block 45.
The block type of the output terminal OT whose return value name is “ret” is set to a return value block 46. The block type of the output terminal OT whose variable name is “g” is set in a global variable block 47. In this specification, the output terminal OT set in the global variable block 47 is referred to as a global variable output terminal as distinguished from the output terminal OT set in the return value block 46. The addition block ADD adds the values of “a1” and “a2” at the input terminals and the value of “g” at the global variable input terminal, and outputs the addition result as the value of “ret” at the output terminal.
When verifying such a verification target block BKM, the user registers the C code 20, which is the reflection source of the verification target block BKM, in the code block BKC. In this example, the function of “funcA” shown in
Next, as the second operation, the user creates a terminal generation setting file 36 describing the terminals of the code block BKC, in order to generate the input terminal reflecting the argument ARG of the C code 20, the output terminal reflecting the return value RV, and the input and output terminals reflecting the global variable GV. The description items in the terminal generation setting file 36 are an input/output attribute IC, a type name TYP, and a terminal name PN.
By the first and second operations, the C code 20 is registered in the code block BKC, and necessary terminals can be generated in the code block BKC. However, at this stage, each terminal is not linked to the C code 20. Therefore, as the third operation, the user describes a terminal linking code 41 indicating the correspondence relationship between the terminal described in the terminal generation setting file 36 and the C code 20 in the code block BKC in order to link each terminal and the C code 20. A declaration 40 of the global variable is also described in the code block BKC.
In the example of the terminal linking code 41 of
Next, as the fourth operation, the user compiles the code block BKC in which the terminal linking code 41 is described into the format executable in the model execution environment 15 using the code registration setting file 35 and the terminal generation setting file 36. As a result, as shown in
However, as the comparative example, in the generation method as described in
As the second problem, there is a high possibility of a description error associated with the generation of the code registration setting file 35, the terminal generation setting file 36, and the terminal linking code 41. When such a description error occurs, the code block BKC which originally should function as the expected value does not function as the expected value. The third problem is that the consistency between the terminals of the verification target block BKM and the parameters of the C code 20 cannot be verified. The parameters of the C code 20 include, for example, the arguments ARG, return value RV, global variable GV, and the like. That is, since it is desirable that the verification target block BKM is created by accurately reflecting the C code 20, it is desirable that the terminals of the verification target block BKM match the parameters of the C code 20.
This causes a mismatch in the comparison block 31 of
A description error 49b in
Configuration of Design Support Apparatus
The auxiliary storage device 52b stores a CAE tool 15a, the verification target block BKM, the C code 20, a search program 56, and a design support program 55a. The processor 50 copies the required programs and data from the auxiliary storage device 52b to the main storage device 52a via the bus 51. The processor 50 executes the programs stored in the main storage device 52a.
For example, the processor 50 executes the CAE tool 15a stored in the main storage device 52a to build the model execution environment 15 described above on the processor 50. By executing the search program 56 stored in the main storage device 52a, the processor 50 can acquire, for example, a file path FP of a predetermined file in the storage device. Further, the processor 50 executes the design support program 55a stored in the main storage device 52a so that the design support apparatus described later is implemented on the processor 50.
Based on the function name FN input by the user, the file registration device 60 searches the storage device for a file defining the function of the function name FN, and generates a code registration setting file 35 in which the file path FP obtained from the search result is written. The terminal generation device 61 reads the verification block BKM from the storage device based on the verification block BKM specified by the user. Then, the terminal generation device 61 searches for the terminal block included in the read-out verification target block BKM, and determines the terminal of the code block BKC based on the terminal block obtained from the search result, thereby generating a terminal generation setting file 36 in which the terminal of the code block BKC is written.
The terminal linking device 62 writes a terminal linking code 41 in the code block BKC based on the function name FN input by the user and the terminal generation setting file 36 generated by the terminal generation device 61. As shown in the
In the examples of
Details of File Registration Device
Next, in a step S13, the file registration device 60 determines a hit or miss hit of the search result of the step S12. In a step S14, if the search result of the step S13 is a hit, the file registration device 60 acquires the extension of the file name included in the file path FP.
Here, when the extension is “c” in a step S15, the file registration device 60 writes, in a step S16, the file identifier FID indicating the source 21, and the file path FP in the code registration setting file 35 generated in the step S11. Meanwhile, when the extension is “h” in the step S15, the file registration device 60 writes, in a step S17, the file identifier FID indicating the header 22 and the file path FP in the code registration setting file 35 generated in step S11.
When the search result in step S13 is a plurality of hits, the file registration device 60 performs the processing of the steps S14 to S17 on the plurality of file paths FP that serve as the search result. In addition, if the search result is a miss hit in the step S13, the file registration device 60 outputs, for example, an error in a step S18.
By providing the file registration device 60 for performing such processing, the correct C code 20, which is a reflection source of the verification target block BKM, can be automatically registered in the code block BKC. That is, it is possible to prevent the user from manually registering an incorrect C code 20 in the code block BKC.
Details of Terminal Generation Device
In a step S222, the terminal generation device 61 determines a hit or miss hit of the search result of the step S221. If the search result in the step S222 is a hit, the terminal generation device 61 repeatedly executes processing of steps S224 and S225 by the number of the argument blocks 45 obtained in the step S221 (Refer to steps S223a, S223b, S223c, and S223d). On the other hand, in a step S226, if the search result in the step S222 is a miss hit, the terminal generation device 61 outputs, for example, an error or warning.
In the step S224, the terminal generation device 61 acquires the [A]th argument block 45 from the argument block list generated in the step S221. Next, in the step S225, the terminal generation device 61 acquires the type name TYP and the argument name from the argument blocks 45 acquired in step S224, and writes “input type name argument name_in” in the terminal generation setting file 36 generated in the step S21 of
As a result, the terminal generation device 61 can write, in the terminal generation setting file 36, an input terminal based on the argument names of the argument blocks 45 searched from the verification target block BKM. As a specific example, in the cases of
Along with this difference, in the step S231, the terminal generation device 61 searches the return value block 46 from the verification target block BKM. In the step S234, the terminal generation device 61 acquires the [A]th return value block 46 from a return value block list. Then, in the step S235, the terminal generation device 61 acquires the type name TYP and the return value name from the return value block 46 acquired in the step S234, and writes “output type name return value name_out” in the terminal generation setting file 36.
As a result, the terminal generation device 61 can write, in the terminal generation setting file 36, the output terminal based on the return value name of the return value block 46 searched from the verification target block BKM. As a specific example, in the cases of
Along with this difference, in the step S241, the terminal generation device 61 searches the global variable block 47 from the verification target block BKM. In the step S244, the terminal generation device 61 acquires the [A]th global variable block 47 from a global variable block list. Then, in the step S245, the terminal generation device 61 acquires the type name TYP and the variable name from the global variable block 47 acquired in the step S244, and writes “input type name variable name_in_g” in the terminal generation setting file 36. In addition, the terminal generation device 61 also writes “output type name variable name_out_g” in the terminal generation setting file 36.
As a result, the terminal generation device 61 can write, in the terminal generation setting file 36, the global variable input terminal and the global variable output terminal based on the variable name of the global variable block 47 searched from the verification target block BKM. As a specific example, in the cases of
By providing the terminal generation device 61 for performing such processing, for example, in
Furthermore, since the terminal generation setting file 36 is generated based on the block type of the terminal included in the verification target block BKM rather than the parameter of the C code 20, the processing load of the terminal generation device 61 can be reduced. That is, the C code 20 differs from the verification target block BKM, and a variety of description formats may exist. Therefore, the processing can be simplified by searching the block type of the terminal from the verification target block BKM, rather than searching the parameter from the C code 20.
Details of Terminal Linking Device
Subsequently, the terminal linking device 62 repeatedly executes processing of steps S313 and S314 by the number of terminals obtained in the step S311 (Refer to steps S312a, S312b, S312c, and S312d). In the step S313, the terminal linking device 62 acquires the [A]th terminal from the terminal list generated in the step S311.
Then, in the step S314, the terminal linking device 62 acquires the terminal name PN of the terminal acquired in the step S313. The acquired terminal name PN is in the form of “xx_in_g”. Then, the terminal linking device 62 processes the portion “_in_g” included in the terminal name PN, thereby writing “xx=xx_in_g;” in the terminal linking code 41. The terminal linking device 62 repeats the processing of the steps S313 and S314 while incrementing [A].
As a result, the terminal linking device 62 can write, in the terminal linking code 41, the code indicating that the value of the global variable input terminal IN is substituted into the global variable GV, based on the terminal name PN of the global variable input terminal IN. As a specific example, in the cases of
Further, by using such processing, for example, it is possible to prevent the description error 49a in the terminal linking code 41 as shown in
In this case, “g2_in_g” is written in the terminal generation setting file 36, and “g2=g2_in_g” is written in the terminal linking code 41. In this state, when the code block BKC is compiled by the CAE tool 15a, the compiler of the CAE tool 15a attempts to search the global variable “g2” from the C code 20 of the corresponding
In this manner, it is possible to verify that the variable name of the global variable block 47 created in the verification target block BKM matches the variable name of the global variable in the C code 20. In other words, it is possible to verify that the variable name of the terminal block of the verification target block BKM is created by accurately reflecting the name of the parameter of the C code 20.
Along with this difference, in the step S321, the terminal linking device 62 searches the terminal generation setting file 36 for a terminal whose tail is “_in”. Further, in the step S323, the terminal linking device 62 acquires the [A]th terminal from the terminal list. Then, in the step S324, the terminal linking device 62 acquires the terminal name PN of the terminal acquired in the step S323. The acquired terminal name PN is in the form of “xx_in”. Then, the terminal linking device 62 writes “xx=xx_in;” in the terminal linking code 41 by processing the portion “_in” included in the terminal name PN.
Next, in a S332, the terminal linking device 62 writes the “function name (” in the terminal linking code 41 based on the function name FN input by the user. Then, the terminal linking device 62 repeatedly executes processing of steps S334 and S335 by the number obtained by subtracting 1 from the number of terminals obtained in the step S331 (Refer to steps S333a, S333b, S333c, and S333d). In the step S334, the terminal linking device 62 acquires the [A]th terminal from the terminal list generated in the step S331.
Subsequently, in the step S335, the terminal linking device 62 acquires the terminal name PN of the terminal acquired in the step S334. The acquired terminal name PN is in the form of “xx_in”. Then, by omitting the portion of “_in” included in the terminal name PN, the terminal linking device 62 writes “xx,” as a continuation of the “function name (” written in the S332 described above. The terminal linking device 62 repeats the processing of the steps S334 and S335 from the end of the terminal list to the first terminal of the terminal list while incrementing W. For the second and subsequent terminals, “xx,” is written as a continuation of the “function name (xx,” written in the step S335.
Thereafter, in a step S336, the terminal linking device 62 acquires the last terminal from the terminal list generated in the step S331. Subsequently, in a step S337, the terminal linking device 62 acquires the terminal name PN of the terminal acquired in the step S336, and by omitting the portion of “_in” included in the terminal name PN, writes “xx);” as a continuation of the “function name (xx, . . . ,” written in the above-described step S335.
As a result, the terminal linking device 62 can write, in the terminal linking code 41, a part of the code indicating that the value of the input terminal IN is substituted into the argument of the function represented by the function names FN, based on the terminal generation setting file 36 and the function name FN input by the user. As a specific example, in the cases of
By using such processing, it is possible to verify that the number of argument blocks 45 created in the verification target block BKM is correct. As a specific example, it is assumed that the user sets the number of argument blocks 45 in the verification target block BKM to 1 or 3 instead of 2. In this instance, “funcA(xx);” or “funcA(xx,xx,xx);” is written in the terminal linking cord 41. In this situation, when the code block BKC is compiled by the CAE tool 15a, the compiler generates a compilation error because there are two arguments of “funcA” in the C code 20 of
If the number of terminals in the step S342 is one, the terminal linking device 62 acquires the terminal name PN of the terminal. The acquired terminal name PN is in the form of “xx_out”. Then, in a step S343, the terminal linking device 62 writes “xx_out=” immediately before the function name FN written in the terminal linking code 41 by the processing of
As a result, the terminal linking device 62 can write, in the terminal linking code 41, a part of the code indicating that the return value of the function is substituted into the value of the output terminal OT based on the terminal generation setting file 36. As a specific example, in the cases of
By using such processing, the terminal linking device 62 can output an error when the number of output terminals OT written in the terminal generation setting file 36 is not one. That is, since the number of return values of the function in the C code 20 is usually 1, the number of return value blocks 46 created in the verification target block BKM should also be 1. On this assumption, it becomes possible to verify that the number of output terminals OT in the verification target block BKM, specifically, the number of return value blocks 46 is correct.
Along with this difference, in a step S351, the terminal linking device 62 searches the terminal generation setting file 36 for a terminal whose tail is “_out_g”. Further, in a step S353, the terminal linking device 62 acquires the [A]th terminal from the terminal list. Then, in a step S354, the terminal linking device 62 acquires the terminal name PN of the terminal acquired in the step S353. The acquired terminal name PN is the form of “xx_out_g”. The terminal association device 62 writes “xx_out_g=xx;” in the terminal linking code 41 by processing the portion of “_out_g” included in the terminal name PN.
Thus, the terminal linking device 62 can write, in the terminal linking code 41, the code indicating that the global variable GV is substituted into the value of the global variable output terminal OT based on the terminal name PN of the global variable output terminal OT. As a specific example, in the cases of
Further, by using such processing, as in the case of
As described above, by using the method of the embodiment, it is possible to reduce a workload such as a user's labor and work time. In addition, it is possible to prevent a description error associated with the generation of the code registration setting file 35, the terminal generation setting file 36, and the terminal linking code 41. Further, it becomes possible to verify the consistency between the terminals of the verification target block BKM and the argument ARG, the return value RV, the global variable GV, and the like which are the parameters of the C code 20. As a result, the design can be facilitated, and the design period can be shortened.
Here, it is assumed that the method of the embodiment is applied to a system model created by a device manufacturer. However, the method of the embodiment can be similarly applied to models created by higher-level system manufacturers such as Electronic Control Unit (ECU) manufacturers and automobile manufacturers, for example. However, in general, since the model created by the device manufacturer has a larger number of terminals than the model or the like created by the higher-level system manufacturer, the generation of the code block BKC can be more complicated. In this respect, it is useful to apply the method of the embodiment to the system model created by the device manufacturer.
Although the invention made by the present inventors has been specifically described based on the embodiment, the present invention is not limited to the embodiment described above, and it is needless to say that various modifications can be made without departing from the gist thereof.
Number | Name | Date | Kind |
---|---|---|---|
10474566 | Indurthivenkata | Nov 2019 | B2 |
20140380269 | Conrad | Dec 2014 | A1 |
20180137022 | Funabashi et al. | May 2018 | A1 |
20210124563 | Moors | Apr 2021 | A1 |
Number | Date | Country |
---|---|---|
2018-081400 | May 2018 | JP |
Entry |
---|
Thomas Weigert et al., Automated Code Generation for Industrial-Strength Systems, IEEE, 2008, retrieved online on Jan. 28, 2022, pp. 464-472. Retrieved from the Internet: <URL: https://ieeexplore.IEEE.org/stamp/stamp.jsp?tp=&arnumber=4591598>. (Year: 2008). |