Logic simulation method and system for embedded protection device
The relative offset address and base address are obtained through the memory mapped file, and the actual memory address is calculated, which solves the memory address acquisition problem in the logic simulation of multi-module protection devices, realizes accurate acquisition and real-time update of logic diagram data, and meets the needs of multi-module logic simulation.
Patent Information
- Application Number
- CN202311210197.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-19
- Publication Date
- 2025-03-21
AI Technical Summary
The multi-module protection device cannot accurately obtain the memory address of the logic diagram data during logic simulation, resulting in the inability to display the logic diagram correctly, causing trouble for the user's logic diagram modification and debugging.
The relative offset address is obtained through the memory mapped file, combined with the acquired base address, calculate the actual memory address, read the data of the protection device and update the logic diagram in real time, and complete the logical simulation of the multi-module protection device.
It realizes accurate acquisition and real-time update of the logic diagram data of multi-module protection devices, solves the problem of memory address acquisition during logical simulation, and meets the needs of multi-module logic simulation.
Smart Images

Figure CN119670313A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a logic simulation method and system for an embedded protection device, belonging to the field of embedded protection systems. Background Art
[0002] With the development of embedded technology and the promotion of digital substation technology, the protection logic of embedded relay protection devices is becoming more and more complex, and the demand for data perspective and logic display inside the device is becoming increasingly prominent. At present, embedded devices use remote process call (RPC) technology to read and display internal data of the device. The specific operation mode of the simulation tool is as follows Figure 1 As shown, first, the logic design tool edits the logic diagram and finally generates the device target code and memory mapping file (map file); then, the logic simulation tool loads the logic diagram and memory mapping file and establishes an RPC connection with the device; finally, the logic simulation tool reads the internal data of the device according to the memory address of the logic diagram parsed by the memory mapping file, and displays it graphically. However, when the single-module protection device is compiled to generate the target code at compile time, the memory mapping file generated is static and can correspond one-to-one with the running address of the single-module device. This implementation method is only valid for single-module embedded devices.
[0003] For multi-module protection devices, since each module is dynamically loaded and the running address of each module is dynamic, the address in the memory mapping file compiled by the logic design tool does not represent its actual address in the device. In this case, the logic simulation tool cannot obtain the memory address of the valid logic diagram data, and therefore cannot correctly display the logic diagram data on the graphical interface, which brings great trouble to the user's logic diagram modification and debugging. Summary of the invention
[0004] The purpose of the present invention is to provide an embedded protection device logic simulation method and system to solve the problem that the memory address of logic diagram data cannot be accurately obtained when a multi-module protection device performs logic simulation.
[0005] To achieve the above object, the solution of the present invention includes:
[0006] A logic simulation method for an embedded protection device of the present invention comprises the following steps:
[0007] 1) Compile the logic diagram to generate the module target code and memory mapping file loaded by the protection device, obtain the offset address according to the memory mapping file, and establish the connection relationship between the logic simulation tool and the protection device;
[0008] 2) After the logic simulation tool is successfully connected to the protection device, the base address of the loading module in the protection device is obtained, and the actual memory address of the loading module is obtained according to the base address and the offset address;
[0009] 3) Reading the data of the protection device according to the actual memory address, and then updating the data of the logic diagram in real time to obtain an updated logic diagram, and completing the logic simulation of the loading module in the protection device.
[0010] Beneficial effect: The embedded protection device logic simulation method of the present invention obtains the relative offset address through the memory mapping file, obtains the base address of the module to be simulated, obtains the actual address according to the base address and the corresponding relative offset address, performs logic simulation according to the actual address, and obtains accurate real-time value of logic diagram data. This method is aimed at multi-module protection devices, can effectively obtain the memory address of the logic diagram, and then can obtain accurate simulation results, meeting the needs of multi-module logic simulation.
[0011] Furthermore, the relative offset address of the loaded module is determined according to the MAP file in the corresponding memory mapping file.
[0012] Beneficial effect: The relative offset address of each module can be accurately obtained through the MAP file in the memory mapping file.
[0013] Furthermore, the logic simulation tool and the protection device are connected by using remote procedure call technology.
[0014] Furthermore, the base address acquisition step is as follows: the logic simulation tool sends a base address acquisition request command to the protection device, and the protection device returns the base address of each loaded module and the serial number corresponding to the module after receiving the request command.
[0015] Furthermore, after the updated logic diagram is graphically displayed for a set time, the logic simulation tool enters a dormant state until the logic diagram data of the protection device is read again after a set period.
[0016] An embedded protection device logic simulation system of the present invention includes a logic design tool and a logic simulation tool, and is characterized in that the logic design tool is used to compile a logic diagram and generate a module target code and a memory mapping file loaded by the protection device; the logic simulation tool is used to connect the protection device and to obtain the base address of the loaded module in the protection device, obtain the actual memory address of the loaded module according to the base address and the offset address, read the data of the protection device according to the actual memory address, and then update the data of the logic diagram in real time to obtain an updated logic diagram.
[0017] Beneficial effect: The embedded protection device logic simulation system of the present invention has a simple structure and mainly includes a logic design tool and a logic simulation tool. The logic design tool obtains the relative offset address through the memory mapping file, obtains the base address of the module to be simulated, obtains the actual address according to the base address and the corresponding relative offset address, performs logic simulation according to the actual address, and obtains accurate real-time value of logic diagram data. This system is aimed at multi-module protection devices, can effectively obtain the memory address of the logic diagram, and then can obtain accurate simulation results, meeting the needs of multi-module logic simulation.
[0018] Furthermore, the logic simulation tool and the protection device are connected by using remote procedure call technology.
[0019] Furthermore, the relative offset address of the loaded module is determined according to the MAP file in the corresponding memory mapping file.
[0020] Beneficial effect: The relative offset address of each module can be accurately obtained through the MAP file in the memory mapping file.
[0021] Furthermore, the base address acquisition step is as follows: the logic simulation tool sends a base address acquisition request command to the protection device, and the protection device returns the base address of each loaded module and the serial number corresponding to the module after receiving the request command. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic diagram of the specific operation flow of a logic simulation tool in the prior art under the condition of a single module;
[0023] Figure 2 It is a schematic diagram of the specific operation flow of the logic simulation tool in the method embodiment of the present invention. DETAILED DESCRIPTION
[0024] The present invention will be further described in detail below in conjunction with the accompanying drawings.
[0025] Embedded protection device logic simulation method embodiment:
[0026] Each module in the multi-module protection device is dynamically loaded, and the actual running address of each module can only be determined during operation. Based on this concept, the method in this embodiment is formed to form a mechanism that can automatically obtain the memory address in a multi-module environment to meet the needs of multi-module logic simulation.
[0027] like Figure 2The embedded protection device logic simulation method shown in the figure, during the operation of the multi-module protection device, obtains the base address of each module and the relative offset address obtained from the memory mapping file to obtain the actual address, reads the logic diagram data of the protection device according to the actual address, and then obtains the real-time value of the logic diagram data. The specific implementation method is as follows:
[0028] The method in this embodiment is implemented based on a logic simulation tool. The program in the logic simulation tool only performs logic simulation on a certain module of the protection device.
[0029] 1) Compile the logic diagram to generate the module target code and memory mapping file loaded by the protection device, obtain the offset address according to the memory mapping file, and establish the connection relationship between the logic simulation tool and the protection device.
[0030] In a multi-module protection device, after each module is loaded, the relative relationship of its internal logical data address is the same as the relative relationship of the logical data address in a single-module environment.
[0031] In this embodiment, the logic diagram is compiled by a logic design tool, and the target code and memory mapping file of the loading module in the protection device are obtained. According to the MAP file in the memory mapping file, the corresponding relative offset address is obtained. After obtaining the relative offset address, a connection relationship between the logic simulation tool and the protection device is established, and the connection relationship is an RPC (remote procedure call technology) connection. The MAP file internally describes the mapping relationship between the variables required by the logic simulation tool and the memory offset address. In the existing single-module device, the memory offset address is the actual running address of the device, and in the multi-module device in this embodiment, the actual running address is the sum of the base address and the memory offset address.
[0032] 2) After the logic simulation tool is successfully connected to the protection device, the base address of the loading module in the protection device is obtained, and the actual memory address of the loading module is obtained according to the base address and the offset address.
[0033] The connection method between the logic simulation tool and the protection device is to adopt the remote procedure call technology.
[0034] When the logic simulation tool is successfully connected to the protection device, the logic simulation tool obtains the base address of the module in the protection device in real time. After obtaining the base address, when reading the module data of the protection device, the actual address of the module is obtained according to the base address and relative offset address of the module. Specifically, after each power-on, the base address of each module will be changed according to the data change in the secondary boot process, while the base address will not change during the logic simulation process. Therefore, when performing logic simulation, it is necessary to obtain the base address of the simulated module and obtain the actual address of the module according to the obtained base address, where the actual address is the composite address of the base address of the module and the corresponding relative offset address. The base address of each module during operation is dynamically obtained, and the message format of RPC (remote procedure call technology) is expanded, that is, on the basis of the command for reading and writing data, a subcommand for obtaining the module base address is added. During the operation of the protection device, the logic simulation tool sends "obtain module base address" and "module serial number" to the protection device, and the protection device replies the module base address to the logic simulation tool.
[0035] In this embodiment, in a multi-module device, the base address is the first address of each module address space, which is dynamically loaded by the boot program and each sub-module is booted into a different address space. The relative offset address is an address generated by moving the distance relative to the first address. Inside each module, there are multiple variables of the module, and each variable is arranged in sequence. The order of arrangement determines the relative offset address of the variable.
[0036] For example, the relative offset address of the first variable is 1, and the relative offset address of the sixth variable is 6. If the base address at which the module is loaded is 0x8000, then the absolute address of the first variable of the module is the base address plus the relative offset address, which corresponds to 0x8000+1=0x8001; the absolute address of the sixth variable is 0x8000+6=0x8006.
[0037] Because the absolute address of each variable (that is, the actual memory address) must be obtained when simulating multiple modules online, it is necessary to first obtain the relative offset address from the MAP file, then dynamically obtain the base address, and finally add the base address to the offset address to obtain the absolute address (that is, the actual memory address).
[0038] The base address is dynamic and is dynamically deployed by the device boot program after power-on to each submodule, so it cannot be obtained statically.
[0039] 3) Read the data of the protection device according to the actual memory address, and then update the data of the logic diagram in real time to obtain the updated logic diagram, and complete the logic simulation of the loading module in the protection device.
[0040] After reading the logic diagram data of the protection device, this embodiment will display the logic diagram data graphically, that is, display and refresh the logic diagram in real time. After the logic diagram data is displayed for a set time, the logic simulation tool enters a dormant state until the logic diagram data of the protection device is read again after a set period.
[0041] Embedded protection device logic simulation system embodiment:
[0042] The embedded protection device logic simulation system in this embodiment includes a logic design tool and a logic simulation tool, characterized in that the logic design tool is used to compile the logic diagram and generate the module target code and memory mapping file loaded by the protection device; the logic simulation tool is used to connect the protection device and obtain the base address of the loaded module in the protection device, obtain the actual memory address of the loaded module according to the base address and the offset address, read the data of the protection device according to the actual memory address, and then update the data of the logic diagram in real time to obtain the updated logic diagram. The specific implementation principle has been specifically described in the embodiment of the embedded protection device logic simulation method, and will not be repeated here.
Claims
1. A logic simulation method for an embedded protection device, characterized in that: The following steps are involved: 1) Compile the logic diagram to generate the module target code and memory mapping file loaded by the protection device, obtain the relative offset address according to the memory mapping file, and establish the connection relationship between the logic simulation tool and the protection device; 2) After the logic simulation tool is successfully connected to the protection device, the base address of the loading module in the protection device is obtained, and the actual memory address of the loading module is obtained according to the base address and the relative offset address; 3) Reading the data of the protection device according to the actual memory address, and then updating the data of the logic diagram in real time to obtain an updated logic diagram, and completing the logic simulation of the loading module in the protection device.
2. The embedded protection device logic simulation method according to claim 1, characterized in that: The relative offset address of the loaded module is determined according to the MAP file in the corresponding memory mapping file.
3. The embedded protection device logic simulation method according to claim 1, characterized in that: The connection method between the logic simulation tool and the protection device is to adopt the remote procedure call technology.
4. The embedded protection device logic simulation method according to claim 1, characterized in that: The base address acquisition step is as follows: the logic simulation tool sends a base address acquisition request command to the protection device, and the protection device returns the base address of each loaded module and the serial number corresponding to the module after receiving the request command.
5. The embedded protection device logic simulation method according to claim 2, characterized in that: After the updated logic diagram is graphically displayed for a set time, the logic simulation tool enters a dormant state until the logic diagram data of the protection device is read again after a set period.
6. An embedded protection device logic simulation system, comprising a logic design tool and a logic simulation tool, characterized in that: The logic design tool is used to compile the logic diagram and generate the module target code and memory mapping file loaded by the protection device; the logic simulation tool is used to connect the protection device and obtain the base address of the loaded module in the protection device, obtain the actual memory address of the loaded module according to the base address and the offset address, read the data of the protection device according to the actual memory address, and then update the data of the logic diagram in real time to obtain the updated logic diagram.
7. The embedded protection device logic simulation system according to claim 6, characterized in that: The connection method between the logic simulation tool and the protection device is to adopt the remote procedure call technology.
8. The embedded protection device logic simulation system according to claim 7, characterized in that: The relative offset address of the loaded module is determined according to the MAP file in the corresponding memory mapping file.
9. The embedded protection device logic simulation system according to claim 7, characterized in that: The base address acquisition step is as follows: the logic simulation tool sends a base address acquisition request command to the protection device, and the protection device returns the base address of each loaded module and the serial number corresponding to the module after receiving the request command.