Simulation method for microcomputer control program and simulation system therefor

By converting microcomputer-specific object code into general-purpose functions during simulation, the method addresses the complexity and tampering risks of existing methods, enabling efficient execution and management of microcomputer operations on general-purpose computers.

JP7798331B2Active Publication Date: 2026-01-14APPLY LIMITED
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2021164664
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2021-10-06
Publication Date
2026-01-14
Estimated Expiration
2041-10-06

AI Technical Summary

Technical Problem

Existing methods for simulating microcomputer control programs on general-purpose computers require complex code conversions and risk tampering with source code due to the addition of register operation codes.

Method used

The method involves reading object code into memory and converting microcomputer-specific functions into general-purpose computer functions, allowing execution without changing the source code, using dynamic link libraries (DLLs) and APIs generated from debug symbol files to access variables, and managing infinite loops.

Benefits of technology

Enables execution of microcomputer-specific operations on general-purpose computers without modifying source code, simplifying the process, improving reliability, and facilitating easy maintenance and management of object code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007798331000001
    Figure 0007798331000001
  • Figure 0007798331000002
    Figure 0007798331000002
  • Figure 0007798331000003
    Figure 0007798331000003
Patent Text Reader

Abstract

To provide a method for easily simulating a control object code 33 generated from a source code 31 by a general-purpose computer having an instruction set different from that of a microcomputer without changing the source code 31 of a control program executed by the microcomputer.SOLUTION: An object code 33 of a control program is read into a memory 92 provided in a general-purpose computer at the time of simulation execution. In the memory 92, an object code of a microcomputer dedicated function is changed to an object code of a general-purpose computer function so that the general-purpose computer can execute an operation described by the microcomputer dedicated function. The general-purpose computer executes the object code of the control program in which the object code of the microcomputer dedicated function is changed to the object code of the general-purpose computer function.SELECTED DRAWING: Figure 6
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to a method for simulating a microcomputer control program, and more particularly to a method for executing object code generated from source code of a control program executed on a target microcomputer on a general-purpose computer having an instruction set different from that of the microcomputer. [Background technology]

[0002] Conventionally, systems have been known that perform simulations by converting the object code of a microcomputer control program into source code and then converting the source code into object code for a general-purpose computer having an instruction set different from that of the microcomputer, in order to confirm the operation of a microcomputer installed in a specific product (target) such as an electrical appliance or an automobile. For example, the system disclosed in Patent Document 1 first disassembles the object code of the vehicle-mounted microcomputer control program to extract register operation codes. Next, the assembler code is decompiled and converted into source code for the control program. The extracted register operation codes are automatically added to the source code. Finally, the source code with the register operation codes added is cross-compiled into object code for the general-purpose computer. This makes it possible to simulate the entire simulated vehicle, including the vehicle-mounted microcomputer, on the general-purpose computer. [Prior art documents] [Patent documents]

[0003] [Patent Document 1] Japanese Patent Application Laid-Open No. 2010-244377 Summary of the Invention [Problem to be solved by the invention]

[0004] However, in Patent Document 1, since "addition of register operation code" is performed to the source code, there is a risk of tampering with the source code. Also, since changing the source code requires a series of code conversions such as "object code → assembly code → compiler code (source code) → object code," the code conversion procedure is complicated.

[0005] The present invention has been made in view of the above points, and its object is to provide a method for easily executing object code generated from source code on a general-purpose computer having an instruction set different from that of a microcomputer installed in a specified product, without changing the source code of the control program executed on the microcomputer. [Means for solving the problem]

[0006] In order to achieve the above object, the present invention relates to a method for simulating a microcomputer control program, and is characterized in that, when the simulation is executed, object code generated from the source code of the microcomputer is read into a memory, and object code of functions dedicated to the microcomputer is converted into object code of functions for a general-purpose computer, thereby enabling operations described in functions dedicated to the microcomputer to be executed by a general-purpose computer.

[0007] Specifically, the present invention addresses a method for simulating object code generated from the source code of a control program executed by a microcomputer using a general-purpose computer that has a memory and an instruction set different from that of the microcomputer, and the following solution has been implemented.

[0008] That is, the first invention is characterized by including the steps of reading the object code of the control program into the memory when executing the simulation, converting the object code of the microcomputer-specific functions into object code of functions for a general-purpose computer within the memory so that operations described in functions for a microcomputer can be executed by the general-purpose computer, and executing the object code of the control program in which the object code of the microcomputer-specific functions has been converted into the object code of functions for the general-purpose computer by the general-purpose computer.

[0009] In the second invention, in the first invention, the change is characterized in that when the microcomputer-specific function is executed, a jump is made to the address of the object code of the general-purpose computer function and the object code of the general-purpose computer function is executed.

[0010] A third invention is characterized in that in any one of the first and second inventions, the object code includes a dynamic link library (DLL).

[0011] A fourth invention is characterized in that, in the third invention, it further includes generating an API (Application Program Interface) that acquires pointer information of a specified symbol name for accessing variables of the object code based on a debug symbol (PDB) file generated together with the generation of the object code.

[0012] A fifth invention is characterized in that, in any one of the first to fourth inventions, the object code is further configured so that, when there is no function to be executed, control is returned to the operating system of the general-purpose computer.

[0013] The present invention also targets a simulation system that enables operations described in microcomputer-specific functions to be executed on a general-purpose computer by converting object code of microcomputer-specific functions into object code of general-purpose computer functions in the loaded memory space when executing object code generated from source code, and the following solution has been taken.

[0014] That is, the sixth invention is characterized by comprising a general-purpose computer capable of executing the method according to any one of the first to fifth inventions. [Effects of the Invention]

[0015] In the first and sixth aspects of the present invention, object code generated from the source code of a control program is loaded into memory provided in a general-purpose computer during simulation execution. Within the loaded memory, the object code of microcomputer-specific functions is converted into object code of general-purpose computer functions so that the operations described in the microcomputer-specific functions can be executed on the general-purpose computer. The object code of the control program, in which the object code of microcomputer-specific functions has been converted into object code of general-purpose computer functions, is executed by the general-purpose computer. By changing the microcomputer-specific functions in the object code in memory during simulation execution, the operations described in the microcomputer-specific functions are executed on the general-purpose computer. Therefore, there is no need to change the source code of the control program when the object code is executed, eliminating the risk of tampering with the source code. Furthermore, there is no need for complex code conversion, so the object code can be easily executed on a general-purpose computer having an instruction set different from that of the microcomputer.

[0016] In the second invention, the object code of the microcomputer-dedicated function is changed so that when the microcomputer-dedicated function is executed, a jump to the address of the object code of the general-purpose computer function is performed to execute the general-purpose computer function. In other words, the object code of the microcomputer-dedicated function and the object code of the general-purpose computer function are implemented as separate functions. Therefore, the object code of the microcomputer-dedicated function and the object code of the general-purpose computer function can be separated, making the object code easy to maintain and manage.

[0017] In a third aspect of the present invention, the object code includes a dynamic link library (DLL). Since the internal variables of a DLL are initialized each time the DLL is loaded into memory, the initialization of the target microcomputer in the simulation can be easily realized by loading the DLL into memory.

[0018] In the fourth invention, an API is generated based on a debug symbol (PDB) file generated together with the object code, to obtain pointer information of a specified symbol name for accessing variables in the object code. Therefore, in order to access variables and functions in the object code, it is not necessary to define the variables and functions as input / output variables in the object code in advance, and therefore variables in the object code can be easily accessed during simulation.

[0019] In the fifth aspect of the present invention, the object code is configured so that control is returned to the operating system of the general-purpose computer when there are no functions to be executed. This object code allows control to be returned to the operating system of the general-purpose computer when there are no functions to be executed during simulation execution, preventing the simulation from falling into an infinite loop and running out of control when the object code is executed, thereby improving operational reliability. [Brief explanation of the drawings]

[0020] [Figure 1] FIG. 1 is a diagram illustrating a hardware configuration of a simulation method according to an embodiment of the present invention. [Figure 2] FIG. 2 is a diagram illustrating the software configuration of the simulation method according to one embodiment of the present invention. [Figure 3] FIG. 3 is a diagram illustrating the management unit of FIG. [Figure 4] FIG. 4 is a schematic diagram showing an execution flow of a simulation method according to one embodiment of the present invention. [Figure 5] FIG. 5 is a diagram illustrating the code injection function in the simulation method according to one embodiment of the present invention. [Figure 6] FIG. 6 is a flowchart illustrating the operation of the code injection function in the simulation method according to one embodiment of the present invention. [Figure 7] FIG. 7 is a diagram illustrating a variable name resolution function in a simulation method according to one embodiment of the present invention. [Figure 8] FIG. 8 is a diagram illustrating a managed notification function in a simulation method according to an embodiment of the present invention. [Figure 9] FIG. 9 is a diagram illustrating the operation of the managed notification function in the simulation method according to one embodiment of the present invention. [Figure 10] FIG. 10 is a flowchart illustrating a simulation method according to one embodiment of the present invention. [Figure 11] FIG. 11 is a schematic diagram showing the execution flow corresponding to FIG. DETAILED DESCRIPTION OF THE INVENTION

[0021] Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. In each embodiment, the same or corresponding parts will be designated by the same reference numerals, and the description thereof may be omitted as appropriate. Furthermore, the drawings are used to explain the present embodiment, and may differ from the actual dimensions. Note that the following description of the preferred embodiment is essentially merely an example.

[0022] FIG. 1 shows a hardware configuration 90 for a simulation method according to one embodiment of the present invention. The hardware configuration 90 is a general-purpose computer, and may be, for example, a commercially available personal computer (PC). Accordingly, the hardware configuration 90 includes an arithmetic unit 91, a main memory 92, a display unit 93, an auxiliary memory 94, an input device 95, and a bus 96 interconnecting these components. The instruction set of the arithmetic unit 91 is generally different from that of a target microcomputer installed in a given product. The input device 95 is, for example, a keyboard and a mouse. In this embodiment, a software configuration 10 for implementing the simulation method described below is stored in the auxiliary memory 94, and the arithmetic unit 91 reads it into the main memory 92 and executes it.

[0023] FIG. 2 shows a software configuration 10 of a simulation method according to one embodiment of the present invention. This embodiment describes a simulation method for a microcomputer system composed of multiple subsystems. The software configuration 10 includes a system construction unit 11, which has functions for constructing, executing, and testing the entire system, and an A module unit 12, a B module unit 13, and a C module unit 14, which are executable files launched for each process to simulate subsystems A, B, and C that make up the system. Each module unit includes a manage unit 15, which configures a window screen for each module unit, the execution order operations of a native unit 16 (described later), and communication functions between the module units. The native unit 16 includes an object file 33 of microcomputer code for device control software, a driver, and simulator code 35 that simulates the microcomputer. Each of the module units 12, 13, and 14 is an executable file with a UI (User Interface) that runs on, for example, Microsoft's .NET Framework.

[0024] Referring to Figure 3, the management unit 15 is developed, for example, using Microsoft Visual Studio (registered trademark) 2019, and includes SymbolLoader 37, which is a C# version of DbgHelp.dll 36, a C / C++ version API provided by Microsoft (registered trademark), and PdbHelp 40.

[0025] PdbHelp 40 reads object files 33 and analyzes PDB files 34 using SymbolLoader 37. PdbHelp 40 also stores symbol information of variables and functions targeted by the read object files 33 in cache memory, and generates an API library 42 for acquiring a pointer to a specified symbol name (specified symbol name pointer acquisition API) so that the variables and functions can be accessed from other files in the object files 33 without incurring overhead or restrictions during simulation operation. The PDB file 34 is a file (32 in FIG. 4) that is generated when generating (building) object files, which will be described later.

[0026] Next, the execution flow of the microcomputer system simulation method according to one embodiment of the present invention will be described with reference to FIG.

[0027] First, the simulation user grasps the operation of the microcomputer-specific functions in the source code 31 of the target microcomputer, and creates simulator code 35 for describing the simulation specifications. In the simulator code 35, the operation described in the microcomputer-specific functions in the source code 31 is written so that it is executed by a general-purpose computer function.

[0028] From the simulator code 35 and the source code 31, a DLL 33 and a PDB file 34, which are object files for a simulation PC, which is a general-purpose computer, are generated (32).

[0029] Next, the DLL 33 and the PDB file 34 are loaded into the simulation PC (39).

[0030] Next, the code injection function described below in the simulator code 35 is executed to simulate the DLL 33 (43, 44).

[0031] <Code injection function> As shown in Figure 5, the code injection function changes microcomputer (microcontroller) dedicated function A in DLL 33 to a jump to the address of PC function B described in simulator code 35. When a simulation is executed, after DLL 33 is loaded into memory, the call destination of the object code of microcomputer dedicated function A in memory is changed to the address of the object code of PC function B, which executes the operation described in microcomputer dedicated function A. In other words, the object code of microcomputer dedicated function A in memory is changed so that the object code of PC function B is executed.

[0032] An example of the operation of the code injection function is shown in Figure 6. In step S61, a simulation is started. In step S62, DLL 33 is loaded into memory 92 of the simulation PC. In step S63, the object code of microcomputer-dedicated function A in memory 92 is changed to a jump to the address of the object code of PC function B described in simulator code 35. In step S64, the changed DLL 33 is executed. In step S65, if it is determined that the call of microcomputer-dedicated function A is YES (present) while the changed DLL 33 is being executed, a jump is made to the address of the object code of PC function B in step S67. In step S68, the object code of PC function B is executed. In step S69, the process returns to the caller address of microcomputer-dedicated function A in step S65, and execution of step S64 is continued.

[0033] In this way, with the code injection function, the object code of the control program in which the object code of the microcomputer-specific function A in memory 92 is changed to the object code of the PC function B in the simulation execution memory 92 is executed by the general-purpose computer. Without changing the source code 31 of the control program executed by the microcomputer, the object code generated from the source code 31 can be executed by a general-purpose computer having an instruction set different from that of the microcomputer.

[0034] Furthermore, when the execution (S64) of the DLL33, which is an object code, involves accessing variables or functions in other files of the DLL33, the variable name resolution function described below can also be used.

[0035] <Variable name resolution function> As shown in FIG. 7, the variable name resolution function is a function that eliminates the need for defining structures and publishing externally the variables and functions of the DLL 33 in order to describe access to the variables and functions in the simulator code 35.

[0036] 7, by using the specified symbol name pointer acquisition function API library 42, for example, it is possible to access the "tagInfo" variable in DLL 33 without preparing a "structure definition" that is the basis of the "tagInfo" variable in DLL 33 and without "exposing" the variable using extern or the like. In other words, there is no need to modify the source code 31 of the microcomputer that generates DLL 33 in order to describe access to any variable or function in DLL 33 in simulator code 35.

[0037] Furthermore, in the object file (DLL) generation 32, the managed notification function described below can be used to prevent the DLL 33 from falling into an infinite loop when executed.

[0038] <Managed notification function> The managed notification function is a function that returns control to the operating system of the simulation PC when there is no function to be executed in the DLL 33. As shown in Fig. 8, this function replaces a specific keyword with the original processing of the DLL 33 to be generated and processing that transfers control to the managed unit 15 that performs the operation in the execution order of the DLL 33. In Fig. 8, a managed notification function API is used when transferring control from the native unit 16 including the DLL 33 to the managed unit 15.

[0039] For example, if the DLL 33 of the microcomputer contains a while statement, if it is executed as is, control will not be returned to the managed unit 15. In contrast, in the example of FIG. 8, #define while(X) while(managed notification function) and generates DLL33. As a result, as shown in Fig. 9, after the "module body" is started, when the while statement in DLL33 is executed, control is transferred to the managed unit 15, so that the managed unit 15 can determine whether or not there is a function to be executed. If there is no function to be executed, control can be returned to the operating system of the simulation PC, so the execution of DLL33 does not fall into an infinite loop.

[0040] Next, a simulation method based on the above configuration, including a code injection function, a variable name resolution function, and a managed notification function, will be described with reference to FIGS.

[0041] In step S11, a preprocessing process is performed on the microcomputer source code 31 to add a managed notification function, and an object file (DLL) is generated (32 in FIG. 11). As a result, a DLL 33 is generated that has the managed notification function added and can be executed on the simulation PC.

[0042] In step S12, a simulation of the simulation PC is started. In step S13, the generated DLL 33 is read into memory 92 of the simulation PC (39 in FIG. 11). In step S14, the object code of the microcomputer-dedicated function in memory 92 is changed to a jump to the address of the object code of the PC function written in simulator code 35. That is, in memory 92, the object code of the microcomputer-dedicated function written in simulator code 35 is changed so as to execute the object code of the PC function. In step S15, the changed DLL 33 is executed (43 in FIG. 11).

[0043] In steps S16 and S17, the code injection function is executed for the microcomputer-specific function (44 in FIG. 11). In steps S18 and S19, if an access process to a variable or function in another file of the modified DLL 33 occurs, the specified symbol name pointer acquisition function API library 42 is used to access the information in the DLL 33 (45 in FIG. 11). The processes from steps S15 to S19 are repeated until the simulation is completed.

[0044] Thus, according to one embodiment of the present invention, object code (DLL) 33 generated from control program source code 31 is loaded into memory 92 of a general-purpose computer during simulation. Inside memory 92, the object code for microcomputer-specific functions is converted into object code for general-purpose computer functions so that the operations described in the microcomputer-specific functions can be executed on the general-purpose computer. The object code of the control program, in which the object code for microcomputer-specific functions has been converted into object code for general-purpose computer functions, is executed by the general-purpose computer. By converting the microcomputer-specific functions in object code 33 in memory 92 during simulation, the operations described in the microcomputer-specific functions are executed on the general-purpose computer. Therefore, there is no need to modify control program source code 31 during execution of object code 33, eliminating the risk of tampering with source code 31. Furthermore, because there is no need for complex code conversion, object code 33 can be easily executed on a general-purpose computer having an instruction set different from that of the microcomputer.

[0045] Furthermore, the object code for the microcomputer-dedicated function is modified so that when the microcomputer-dedicated function is executed, a jump to the address of the object code for the general-purpose computer function is made and the general-purpose computer function is executed. In other words, the object code for the microcomputer-dedicated function and the object code for the general-purpose computer function are implemented as separate functions. This allows the object code for the microcomputer-dedicated function and the object code for the general-purpose computer function to be placed separately, making the object code 33 easy to maintain and manage.

[0046] The object code 33 is a dynamic link library (DLL). Since the internal variables of the DLL 33 are initialized each time the DLL 33 is loaded into memory, the initialization of the target microcomputer in the simulation can be easily realized by loading the DLL 33 into memory 92.

[0047] Furthermore, an API library 42 is generated based on a debug symbol (PDB) file 34 generated together with the generation of the object code 33, to acquire pointer information of a specified symbol name for accessing variables of the object code 33. Therefore, in order to access variables and functions of the object code 33, it is not necessary to define the variables and functions in advance as input / output variables in the object code 33, and therefore variables of the object code 33 can be easily accessed when a simulation is executed.

[0048] Furthermore, the object code 33 is generated so that control is returned to the operating system of the general-purpose computer when there are no functions to be executed. This object code 33 allows control to be returned to the operating system of the general-purpose computer when there are no functions to be executed during simulation execution, so the simulation will not enter an infinite loop and run out of control when the object code 33 is executed, thereby improving operational reliability. [Explanation of symbols]

[0049] 10 Software Configuration 15 Management Department 16 Native Section 31 Microcomputer control program source code 33 Object code, object files (DLL) 34 PDB files 35 Simulator Code 36 DbgHelp.dll 37 SymbolLoader 40 PdbHelp 42 Specified symbol name pointer acquisition function API library 90 Hardware Configuration 91 Arithmetic unit 92 Main memory 93 Display Device 94 Auxiliary storage device 95 Input Devices 96 Bus

Claims

1. A method for simulating object code generated from source code of a control program executed by a microcomputer, using a general-purpose computer having a memory and an instruction set different from that of the microcomputer, comprising: reading an object code of the control program into the memory when executing the simulation; converting, within said memory, object code of the microcomputer-dedicated functions into object code of general-purpose computer functions so that operations described in the microcomputer-dedicated functions can be executed by said general-purpose computer; executing, by the general-purpose computer, the object code of the control program in which the object code of the microcomputer-specific functions has been converted into the object code of the general-purpose computer functions; The method further comprising: modifying the object code of the control program such that if no function is executed, control is returned to the operating system of the general purpose computer.

2. 2. The method of claim 1, wherein the modification comprises: When the microcomputer-specific function is executed, a jump is made to the address of the object code of the general-purpose computer function, and the object code of the general-purpose computer function is executed.

3. 3. The method according to claim 1, wherein the object code of the control program includes a dynamic link library (DLL).

4. 4. The method of claim 3, further comprising generating an API for obtaining pointer information of a specified symbol name for accessing a variable in the object code of the control program based on a debug symbol (PDB) file generated together with the object code of the control program.

5. A simulation system comprising a general-purpose computer capable of executing the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Software development supporting device

    JP1989273144A

  • Method and device for pseudo-executing different kind computer instruction

    JP1993346872A

  • Apparatus and method for creating simulation program, and simulation system

    JP2010244377A

  • Method for converting subject program code into target program code, computer program, and computer

    JP2011123917A

  • Real-time quality of service monitoring apparatus and method

    US20170257287A1