Device behavior simulation method and device, electronic device, and readable storage medium

By obtaining the target program counter value sequence and label relationship, the target function is directly executed to realize device behavior simulation, which solves the problem of low simulation efficiency in the existing technology and realizes efficient device behavior simulation.

CN120805809BActive Publication Date: 2025-11-28BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511292712.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-10
Publication Date
2025-11-28
Estimated Expiration
2045-09-10

AI Technical Summary

Technical Problem

Existing equipment behavior simulation methods are inefficient, require complex modeling work, and have long simulation times.

Method used

By obtaining the target program counter value sequence of the program to be executed, and based on the correspondence between the program counter value sequence and the label, the target label is obtained, and the target function is extracted from the target label. The target function is then executed directly to achieve device behavior simulation, thus avoiding the modeling of the preset device and the direct execution of the target machine code.

Benefits of technology

It improves simulation efficiency, reduces processing workload, and solves the problems of high workload and low simulation efficiency in equipment behavior simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120805809B_ABST
    Figure CN120805809B_ABST
Patent Text Reader

Abstract

The application provides a device behavior simulation method and device, electronic equipment and readable storage medium, and relates to the technical field of processors. The method comprises the following steps: obtaining a target program counter value sequence of a to-be-executed project program; the to-be-executed project program is used for device behavior simulation of a preset device; the target program counter value sequence is used for indicating the address of at least one to-be-executed instruction in the to-be-executed project program; obtaining a target label corresponding to the target program counter value sequence according to the correspondence between the program counter value sequence and the label; the target program counter value sequence is used for indicating the address of at least one preset instruction; the label comprises a function function, the function function is used for realizing the function of an instruction sequence corresponding to the label, a target function function is extracted from the target label, and a simulation result of the device behavior of the preset device is obtained according to the target function function. The device behavior simulation method has the advantage of high simulation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of processors, and in particular to a device behavior simulation method and device, an electronic device, and a readable storage medium. BACKGROUND

[0002] In the field of chip design technology, by performing behavior simulation on an external device, it can be verified whether the interaction between the chip and the external device is correct.

[0003] In related technologies, a language such as SystemC can be used to model the external device to simulate the hardware structure, timing interface, and behavior function of the external device, and directly run the target machine code corresponding to the modeling program to perform device behavior simulation.

[0004] However, the device modeling process is usually complex, and the internal structures of different devices differ greatly, which will result in long modeling time and large amount of work to be processed. In addition, directly running the target machine code corresponding to the modeling program requires processing a large amount of code data and a long simulation time. Therefore, the device behavior simulation method in related technologies has the problem of low simulation efficiency. SUMMARY

[0005] Embodiments of the present application provide a device behavior simulation method, device, electronic device, and readable storage medium to solve the problem of low simulation efficiency of the device behavior simulation method in the prior art.

[0006] In a first aspect, the embodiments of the present application provide a device behavior simulation method, comprising: obtaining a target program counter value sequence of a to-be-executed project program; the to-be-executed project program is used to perform device behavior simulation on a preset device; the target program counter value sequence is used to indicate the address of at least one to-be-executed instruction in the to-be-executed project program; obtaining a target label corresponding to the target program counter value sequence according to the correspondence between the program counter value sequence and the label; the program counter value sequence is used to indicate the address of at least one instruction sample in a project program sample; the label includes a function function, and the function function is used to implement the function of the project program sample; extracting a target function function from the target label to obtain a simulation result of the device behavior of the preset device according to the target function function.

[0007] In a second aspect, an embodiment of the present application provides a device behavior simulation apparatus, the apparatus comprising: a first obtaining module configured to obtain a target program counter value sequence of a to-be-executed project program, the to-be-executed project program being configured to perform device behavior simulation on a preset device, the target program counter value sequence being configured to indicate an address of at least one to-be-executed instruction in the to-be-executed project program; a second obtaining module configured to obtain a target label corresponding to the target program counter value sequence according to a correspondence between a program counter value sequence and a label, the program counter value sequence being configured to indicate an address of at least one instruction sample in a project program sample, the label comprising a function function, the function function being configured to implement a function of the project program sample; and a third obtaining module configured to extract a target function function from the target label, so as to obtain a simulation result of device behavior of the preset device according to the target function function.

[0008] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor, and a memory configured to store instructions executable by the processor, wherein the processor is configured to execute the instructions to implement the method of the first aspect.

[0009] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method of the first aspect.

[0010] In the embodiment of the present application, the target program counter value sequence of the to-be-executed project program is obtained, the target label corresponding to the target program counter value sequence is obtained according to the correspondence between the program counter value sequence and the label, and the target function function is extracted from the target label, so that the simulation result of the device behavior of the preset device can be obtained by executing the target function function. The embodiment does not need to model the preset device, nor does it need to directly run the target machine code corresponding to the modeling program, but obtains the target label corresponding to the target program counter value sequence of the to-be-executed project program, and then obtains the target function in the target label and directly executes it. The embodiment needs to process less workload and has high simulation efficiency, and solves the problems of large workload and low simulation efficiency caused by the need for device modeling and the need for directly running the target machine code corresponding to the modeling program in the related art.

[0011] The above description is only a summary of the technical solutions of the present application. In order to more clearly understand the technical means of the present application, the following detailed description can be implemented according to the content of the description, and in order to make the above and other purposes, characteristics and advantages of the present application more obvious and easy to understand, the following detailed description of the specific embodiments of the present application is provided. BRIEF DESCRIPTION OF DRAWINGS

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiments description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0013] Figure 1 is a device behavior simulation method application scenario provided by an embodiment of the present application;

[0014] Figure 2 is a device behavior simulation method step flowchart provided by an embodiment of the present application;

[0015] Figure 3 is a simulation effect schematic diagram provided by an embodiment of the present application;

[0016] Figure 4 is a device behavior simulation method step flowchart provided by an embodiment of the present application;

[0017] Figure 5 is a device behavior simulation method step flowchart provided by an embodiment of the present application;

[0018] Figure 6 is an external device display interface schematic diagram provided by an embodiment of the present application;

[0019] Figure 7 is an external device simulation display result schematic diagram provided by an embodiment of the present application;

[0020] Figure 8 is a device behavior simulation device block diagram provided by an embodiment of the present application;

[0021] Figure 9 is an electronic device block diagram provided by an embodiment of the present application;

[0022] Figure 10 is another electronic device block diagram provided by another embodiment of the present application. DETAILED DESCRIPTION

[0023] The technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.

[0024] The terms "first", "second", and the like in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally a class and do not limit the number of objects, for example, the first object can be one or more. In addition, the term "and / or" in this application is used to describe the relationship between the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents an "or" relationship between the associated objects. The term "multiple" in the embodiments of the present application means two or more, and other quantifiers are similar.

[0025] Figure 1 is a schematic diagram of an application scenario of a device behavior simulation method provided by an embodiment of the present application, referring to Figure 1 , the application scenario at least includes a microcontroller unit (MCU) 10 and a state sequence monitor 20.

[0026] The microcontroller unit 10 acquires a to-be-executed project program, and the to-be-executed project program is used for device behavior simulation on a preset device; the state sequence monitor 20 acquires a target program counter value sequence of the to-be-executed project program, and obtains a target function function used for realizing a function of the to-be-executed project program according to the target program counter value sequence, so as to obtain a simulation result of device behavior of the preset device according to the target function function.

[0027] In the related art, an external device can be modeled by using a language such as SystemC, to obtain a VP of the external device, and the hardware structure, timing interface and behavior function of the external device are simulated by using the modeling language. Although this method can simulate the control flow and data flow of the external device, and can realize the internal logic of the external device. However, this method needs to model the external device, and the modeling and development of the external device has a large workload, and the structures of different external devices are quite different, so a special analysis needs to be made on the specific internal structure of the external device, which further increases the workload of modeling and development of the external device.

[0028] In addition, the method in the related art needs to be implemented through a virtualized electronic control unit (vECU). The ECU can simulate an actual electronic control device through a computer host, and the processing mode includes four levels of Level 11, Level 12, level 13, and Level 14. Among them, Level 14 is the model closest to the actual ECU. Based on the Level 14 model, the binary file (i.e., the target machine code) of the program can be run on the actual board card, in other words, the binary file of the program can be directly run on the vECU without modification, and the running condition of the hardware can be obtained by directly running the binary file of the program. The Level 14 level simulation needs to simulate the actual hardware structure and directly run the target machine code, and the simulation speed is relatively slow.

[0029] To solve the problems in the related art, the embodiments of the present application can obtain a target program counter value sequence of a to-be-executed project program; the to-be-executed project program is used to perform device behavior simulation on a preset device; the target program counter value sequence is used to indicate the address of at least one to-be-executed instruction in the to-be-executed project program; a target label corresponding to the target program counter value sequence is obtained according to the correspondence between the program counter value sequence and the label; the program counter value sequence is used to indicate the address of at least one instruction sample in a project program sample; the label includes a function function, and the function function is used to implement the function of the project program sample; a target function function is extracted from the target label, so as to obtain a simulation result of the device behavior of the preset device according to the target function function. The embodiments of the present application obtain the target function function of the to-be-executed project program, and can implement the device behavior simulation on the external device according to the target function function, without the need to perform device modeling on the external device and without the need to execute all the codes in the to-be-executed project program, so that the workload is small, the simulation efficiency is high, and the disadvantages of the related art, i.e., the large workload and the low simulation efficiency, are solved.

[0030] It should be noted that the above application scenarios are only exemplary descriptions of the embodiments of the present application, and the device behavior simulation method of the present application can be implemented by the cooperation of the MCU and the sequence monitor, or can be implemented by a processor, and the embodiments of the present application do not limit the execution subject.

[0031] The device behavior simulation method provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0032] Figure 2 is a step flowchart of a device behavior simulation method provided by the embodiments of the present application, as shown in the figure, the method can include: Figure 2 ​

[0033] Step 101, obtaining a target program counter value sequence of a to-be-executed project program.

[0034] The to-be-executed project program is used for device behavior simulation on a preset device, and the target program counter value sequence is used for indicating an address of at least one to-be-executed instruction in the to-be-executed project program.

[0035] For example, the to-be-executed project program includes at least one to-be-executed instruction, a target program counter (PC) value of each to-be-executed instruction is obtained respectively, and a target PC sequence of the to-be-executed project program is obtained according to the target PC value corresponding to each to-be-executed instruction.

[0036] The preset device can be an external device of a network on a chip. The external device can generally include various intellectual property (IP) cores of the network on a chip, and the IP can be a universal asynchronous receiver or transmitter (UART), a serial peripheral interface (SPI), or pulse width modulation (PWM), etc. The external device can also include a board-level external device, which can be a liquid crystal display, an external sensor, etc. The preset device in the embodiment can be a board-level device in the external device.

[0037] Step 102, obtaining a target label corresponding to the target program counter value sequence according to a correspondence between the program counter value sequence and the label.

[0038] The program counter value sequence is used for indicating an address of at least one instruction sample in a project program sample, and the label includes a function function used for implementing a function of the project program sample.

[0039] For example, a project program sample is obtained, a PC value of an instruction sample in the project program sample is obtained, and a PC value sequence is obtained according to the PC value of the instruction sample and an execution order of the instruction sample.

[0040] Further, a label including a function function used for implementing a function of the project program sample is obtained, and the label includes the function function used for implementing the function of the project program sample. Then, a correspondence between the PC value sequence and the label is constructed according to the PC value sequence and the label.

[0041] In an example, the PC value sequence corresponding to the target PC value sequence is obtained by comparing the target PC value sequence and the PC value sequence, and the target label corresponding to the PC value sequence is obtained according to the correspondence between the PC value sequence and the label, and the target label is determined as the target label corresponding to the target PC value sequence.

[0042] In step 103, the target function is extracted from the target label to obtain the simulation result of the device behavior of the preset device according to the target function.

[0043] In the correspondence between the program counter value sequence and the label, the label includes a function, and the target function in the target label is the target function in this step according to the correspondence.

[0044] After the target function is extracted from the target label, the target function is executed to obtain the simulation result of the device behavior of the preset device.

[0045] In an example, the execution subject of the embodiment can be a sequence monitor, a microcontroller unit (MCU) obtains a project program to be executed, the sequence monitor obtains a target PC value sequence of the project program to be executed, a target label corresponding to the target program counter value sequence is obtained according to the correspondence between the program counter value sequence and the label, a target function in the target label is determined, the MCU executes the target function, and a simulation result of the device behavior of the preset device is obtained.

[0046] In an example, the execution subject of the embodiment can be a processor, the processor obtains a target PC value sequence of a project program to be executed, a target label corresponding to the target program counter value sequence is obtained according to the correspondence between the program counter value sequence and the label, a target function in the target label is determined and executed, and a simulation result of the device behavior of the preset device is obtained.

[0047] In the related art, a virtual prototype responds to the data read-write operation of the MCU on the address range of the external device through a modeling language, and then simulates and emulates the device behavior of the external device. When the external device is accessed, the external device will have a corresponding response, and the modeling of the response to the external device is relatively complex, for example, the response of the external device needs to be simulated on the bottom layer.

[0048] In the embodiment, the address of the preset device (such as an external device) can be determined as a common random access memory (RAM) interval without modeling the preset device. After regarding the address of the preset device as a common RAM address interval, when performing read and write operations on the interval, only data read and write are implemented, and the preset device will not give a response, that is, when performing read and write operations on the interval, the response of the preset device does not need to be considered, and the read and write operations will not have actual behavioral effects on the preset device. Therefore, based on the method of the embodiment, the MCU performs read and write access according to the preset device, but has no actual effect on the preset device.

[0049] For example, a state sequence monitor running in parallel with the MCU can be used to detect a target state sequence of the to-be-executed program executed by the MCU, wherein the target state sequence includes a target program counter value sequence. When the state sequence monitor detects that the target program counter value sequence in the target state sequence matches a pre-stored program counter value sequence, a target function function in a target label corresponding to the matched program counter value sequence is triggered, and the behavioral simulation of the preset device is implemented. The target function function is a behavioral level simulation interface function, and is used to implement the behavioral level simulation of the preset device.

[0050] For example, the preset device can be a display screen, and by executing the target function function, the operation of drawing points and pictures on a virtual screen can be implemented. For another example, the preset device can be a sensor, and by executing the target function function, the value of a virtual sensor can be read.

[0051] With reference to Figure 3 By using the method of the related art, the function of a cycle-accurate instruction set simulator can be implemented based on a cycle-accurate external device simulation model, or the function of a behavioral level instruction set simulator can be implemented based on a behavioral level external device simulation model. Based on the embodiment, the function of a cycle-accurate instruction set simulator can be implemented, and the function of a behavioral level instruction set simulator can also be implemented.

[0052] In the embodiment of the present application, the target program counter value sequence of the to-be-executed project program is obtained, the target label corresponding to the target program counter value sequence is obtained according to the correspondence between the program counter value sequence and the label, and the target function function in the target label is extracted. By executing the target function function, the simulation result of the device behavior of the preset device can be obtained. The embodiment does not need to model the preset device, and does not need to directly run the target machine code corresponding to the modeling program, but obtains the target label corresponding to the target program counter value sequence of the to-be-executed project program, and then obtains the target function in the target label and directly executes it. The embodiment needs to process less workload, has high simulation efficiency, and solves the problems of large workload and low simulation efficiency caused by the need to model the device and directly run the target machine code corresponding to the modeling program in the related art.

[0053] Figure 4 A device behavior simulation method provided by an embodiment of the present application is shown, and the method can include the following steps: Figure 4 , the method can include the following steps:

[0054] Step 201, obtaining a target program counter value sequence of a to-be-executed project program.

[0055] The to-be-executed project program is used for device behavior simulation of a preset device, and the target program counter value sequence is used for indicating the address of at least one to-be-executed instruction in the to-be-executed project program.

[0056] In the case where the to-be-executed project program includes at least one program block, the correspondence between the program counter value sequence and the label includes at least one program counter value sequence set, and a label set corresponding to each program counter value sequence set, respectively, the method further includes:

[0057] Step 202, obtaining a program counter value sequence corresponding to each program block, respectively.

[0058] For example, the preset device is a display screen, and the to-be-executed project program for realizing the circle drawing and rectangle drawing functions of the display screen is as follows:

[0059] Void main()

[0060] {

[0061] if (button_press()){

[0062] DrawCircle(50,50,100)

[0063] }

[0064] else{

[0065] DrawRectangle(10, 10, 30, 40)

[0066] }

[0067] }

[0068] The to-be-executed item program includes two program blocks, and the first program block is taken as an example for description below:

[0069] The first program block includes {DrawCircle(50, 50, 100)}, and the to-be-executed instruction corresponding to the program block includes X5 = 50, X6 = 60, and X7 = 100, where X5, X6, and X7 are registers for writing the X coordinate, Y coordinate, and radius of the circle center, respectively.

[0070] The target PC values corresponding to X5 = 50, X6 = 60, and X7 = 100 are PC = 1234, PC = 1235, and PC = 1236, respectively. The target PC value sequence in this embodiment is {1234, 1235, 1236}.

[0071] In step 203, the target program register value sequence set of the to-be-executed item program is obtained according to the program counter value sequence corresponding to each program block.

[0072] The target PC value sequence set includes multiple target PC value sequences arranged in sequence, and the arrangement sequence number of the target PC value sequence in the target PC value sequence set is the same as the arrangement sequence number of the program block in the item program.

[0073] In step 204, the target label set matching the target program counter value sequence set is obtained according to the correspondence between the program counter value sequence set and the label set.

[0074] The target PC value sequence set and the PC value sequence set are compared to obtain the PC value sequence set matching the target PC value sequence set. In the correspondence between the program counter value sequence set and the label set, the label set corresponding to the PC value sequence set matching the target PC value sequence set is determined as the target label set matching the target program counter value sequence set.

[0075] Further, the target PC value sequence set includes multiple target PC value sequences arranged in sequence, and the PC value sequence set includes multiple PC value sequences arranged in sequence. If the nth target PC value sequence in the target PC value sequence set is the same as the nth PC value sequence in the PC value sequence set, it is determined that the target PC value sequence and the PC value sequence set match. Wherein, n ∈ [1, N], and N is an integer greater than or equal to 2.

[0076] For example, the correspondence between the set of program counter value sequences and the set of labels in step 204 is obtained according to the following sub-steps:

[0077] Sub-step Al, obtaining a program sample of the project.

[0078] The program sample of the project includes at least one program block sample, the program block sample has a corresponding label, a first keyword and a second keyword, the first keyword and the second keyword are used to identify the start position and the end position of the program block respectively.

[0079] For example, the program sample of the project is as follows:

[0080] Void main()

[0081] {

[0082] if (button_press()){

[0083] START(“DrawCircle 50 50 100”);

[0084] DrawCircle(50,50,100);

[0085] END();

[0086] }

[0087] else{

[0088] START(“DrawRectangle 10 10 30 40”);

[0089] DrawRectangle(10,10,30,40)

[0090] END()

[0091] }

[0092] }

[0093] The program sample of the project includes two program segments, the label of the first program segment is: DrawCircle 50 50 100, the first keyword and the second keyword are START and END respectively; the label of the second program segment is: DrawRectangle 10 10 30 40, the first keyword and the second keyword are START and END respectively.

[0094] Sub-step A2, obtaining an instruction sample between the first keyword and the second keyword, and a program register value sample corresponding to the instruction sample between the first keyword and the second keyword;

[0095] Sub-step A3, obtaining the program register value sequence corresponding to the program block sample according to the program register value sample corresponding to the instruction sample between the first keyword and the second keyword.

[0096] For example, in the embodiment shown in sub-step A1, the project program sample includes two program segment samples, the first program segment sample is:

[0097] {

[0098] START(“DrawCircle 60 50 100”);

[0099] DrawCircle(60,50,100);

[0100] END();

[0101] }

[0102] The instruction sample corresponding to the first program segment sample includes X5=60, X6=60, and X7=100, wherein X5, X6, and X7 are registers for writing the X coordinate, Y coordinate, and radius of the circle respectively. The PC values corresponding to X5=60, X6=60, and X7=100 are PC=1234, PC=1235, and PC=1236 respectively. The program register value sequence corresponding to the program block sample in this embodiment is {1234, 1235, 1236}.

[0103] It should be noted that in the case of the same compilation optimization mode, the PC values of the instructions with the same arrangement sequence number in the instruction sequence of the same project program are the same, and the registers for storing the parameters in the instructions correspond to each other. The project program to be executed in this embodiment and step 202 is the same, the instruction sequence corresponding to the program segment is the same, even if the parameters in the instructions are different, the PC values of the instructions with the same arrangement sequence number in the instruction sequence are the same (all are PC=1234, PC=1235, and PC=1236), and the registers for storing the parameters in the instructions also correspond to each other (all are X5, X6, and X7).

[0104] Sub-step A4, constructing a program register value sequence set according to the program register value sequence corresponding to each program block sample.

[0105] The PC value sequence set includes the PC sequence corresponding to each program block sample, the arrangement sequence number of the PC value sequence in the PC value sequence set, and the arrangement sequence number of the program block sample corresponding to the PC value sequence in at least one program block sample of the project program sample are the same.

[0106] Sub-step A5, constructing a label set according to the label corresponding to each program block sample.

[0107] For example, the function function sample and the corresponding parameter of the function function sample are obtained from the instruction sample of the program block sample, and the function function sample and the corresponding parameter of the function function sample are determined as the label corresponding to the program block sample.

[0108] For example, in the embodiment shown in sub-step A1, the label set is {DrawCircle 50 50 100; DrawRectangle 10 10 30 40}.

[0109] In sub-step A6, the correspondence between the program counter value sequence set and the label set is constructed according to the program register sequence set and the label set.

[0110] Specifically, for each program block sample, a set of program register value sequence set and label set with corresponding relationship is obtained according to the program register value sequence set and the label set corresponding to the program block sample. Therefore, according to the program register value sequence set and the label set corresponding to each program block, the correspondence between the program counter value sequence set and the label set can be constructed.

[0111] For example, the program register value sequence and the label set corresponding to the program block 1 are A1 and B1 respectively, and the program register value sequence and the label set corresponding to the program block 2 are A2 and B2 respectively. In the correspondence between the program counter value sequence set and the label set constructed, the program register value sequence A1 corresponds to the label set B1, and the program register value sequence A2 corresponds to the label set B2.

[0112] In step 205, the target label in the target label set is determined as the target label corresponding to the target program counter value sequence.

[0113] In step 206, the target function function is extracted from the target label, and the simulation result of the device behavior of the preset device is obtained according to the target function function.

[0114] For example, the target label in the target label set has at least one, and each target label has a corresponding target function function, then the target function function obtained based on the embodiment has at least one. Each target function function is executed to obtain the simulation result of the device behavior of the preset device.

[0115] For example, the target label set includes a target label with a target function function DrawCircle, and a target label with a target function function DrawRectangle, then the target function function DrawCircle and the target function function DrawRectangle are executed respectively to obtain the simulation result of the device behavior of the preset device.

[0116] For example, the method further comprises:

[0117] In step 207, according to the correspondence between the register sequence and the label, a target register sequence corresponding to the target label is obtained.

[0118] The register sequence is used to store parameters of a function corresponding to the label.

[0119] In an example, the register sequence is at least one, and the register sequence and the preset compiler optimization mode correspond to each other.

[0120] The register used to store the same parameter in the same instruction can be different due to different preset compiler optimization modes. For example, the preset compiler optimization modes of the GNU Compiler Collection (GCC) compiler can include O1 mode, O2 mode, and O3 mode in which the optimization program is sequentially increased. A project program sample is obtained, and the project program sample is run under each preset compiler optimization mode to obtain a register sequence corresponding to each preset compiler optimization mode.

[0121] For example, in an embodiment of sub-step A2, in the O1 mode, the register sequence used to store the X coordinate, Y coordinate, and radius of the center of the circle is {X3, X4, X5}, and in the O2 mode, the register sequence used to store the X coordinate, Y coordinate, and radius of the center of the circle can be {X4, X5, X6}.

[0122] Correspondingly, step 207 can include the following sub-steps:

[0123] In sub-step B1, a target compiler optimization mode used to compile a to-be-executed project program is obtained.

[0124] The target compiler optimization mode is set according to the user's requirement for the optimization degree, for example, if the requirement for the optimization degree is high, the target compiler optimization mode can be set to the O3 mode, and if the requirement for the optimization degree is low, the target compiler optimization mode can be set to the O1 mode.

[0125] In sub-step B2, according to the correspondence between the register sequence and the label, at least one register sequence corresponding to the target label is obtained.

[0126] The register sequence corresponding to the label is at least one, and by comparing the target label and the label in the correspondence, at least one register sequence corresponding to the same label as the target label is determined as at least one register sequence corresponding to the target label.

[0127] In sub-step B3, at least one register sequence corresponding to the target label is determined, and the register sequence corresponding to the target compiler optimization mode is determined as the target register sequence corresponding to the target label.

[0128] For example, the at least one register sequence corresponding to the target label includes a register sequence corresponding to the O1 mode and a register sequence corresponding to the O3 mode; the target compiler optimization mode is the O3 mode, and the register sequence corresponding to the O3 mode is determined as the register sequence corresponding to the target label.

[0129] In step 208, the target parameter of the target function is extracted from the target register sequence.

[0130] In the same instruction sequence of the same project program under the same compiler optimization mode, the parameters of the instructions with the same arrangement number exist in the same register.

[0131] For example, the register used to store the X coordinate of the center of the circle in step 202 is X5, and the register used to store the X coordinate of the center of the circle in the project program sample in sub-step A2 is also X5. When the project program sample is executed, the value written in the register X5 is the X coordinate of the center of the circle 60, and after the execution of the project program sample, the value written in the register X5 is the X coordinate of the center of the circle 50 when the to-be-executed project program is executed.

[0132] The target parameter is used to pass into the target function to obtain the simulation result of the device behavior of the preset device according to the target function passed in the target parameter.

[0133] Specifically, the target function passed in the target parameter is executed to obtain the simulation result of the device behavior of the preset device.

[0134] For example, before step 207, the method further includes:

[0135] In step 209, the label added in the project program sample is obtained.

[0136] The label includes at least one parameter sample of the function, and the parameter sample is obtained from the instruction sample included in the project program sample.

[0137] For example, the parameter sample is obtained from the instruction sample. For example, in the embodiment shown in sub-step A2, the label is DrawCircle 60 50 100, wherein the function is DrawCircle, and the parameter samples 60, 50 and 100 of the function are obtained from the instruction DrawCircle(60, 50, 100).

[0138] In step 210, a plurality of preset registers are determined, and for each parameter sample of the function, the parameter write value written in each preset register after the execution of the instruction sample corresponding to the parameter sample is obtained, and the register corresponding to the parameter sample is obtained according to the matching result of the parameter write value and the parameter sample.

[0139] For example, if the parameter write value written in the preset register is the same as the value of the parameter sample of the function function, it is determined that the parameter write value in the preset register matches the parameter sample, and the preset register is determined as the register corresponding to the parameter of the function function; otherwise, it is determined that the parameter write value in the preset register does not match the parameter sample, and the preset register is not the register corresponding to the function function.

[0140] For example, the function function is DrawCircle 60 50 100, after executing the instruction sample corresponding to the parameter sample of the function function, the values of the parameter write values written in the register X3, the register X4 and the register X5 are 60, 50 and 100 respectively, and then the register X3, the register X4 and the register X5 are determined as the registers corresponding to the three parameter samples of the function function DrawCircle in turn.

[0141] For example, step 210 can include the following sub-steps:

[0142] Sub-step C1, the project program sample is executed multiple times, and for each parameter sample of the function function, the parameter write value written in each preset register after each execution of the instruction sample corresponding to the parameter sample is obtained.

[0143] Sub-step C2, for each parameter sample of the function function, the difference degree value between the multiple parameter write values is obtained.

[0144] The parameter write value and the operation of executing the instruction sample corresponding to the parameter sample are one-to-one corresponding. Specifically, each execution of the instruction sample corresponding to the parameter sample obtains a parameter write value corresponding to the parameter sample.

[0145] The difference degree value is used to reflect the difference degree between the multiple parameter write values. For example, the difference value, mean square error, or standard deviation between the multiple parameter write values can be determined as the difference degree value between the multiple parameter write values.

[0146] Sub-step C3, according to the difference degree value and the matching result between the parameter write value and the parameter sample, the register corresponding to the parameter sample is obtained.

[0147] For example, the register corresponding to the parameter write value with small difference degree value and small difference value between the parameter write value and the parameter sample can be determined as the register corresponding to the parameter sample.

[0148] During the program running process, each register has different weights respectively, for example, for the temporary register used for parameter passing, its weight is relatively large, and the other temporary registers have less influence on the identification of the state sequence, so their weights are relatively small.

[0149] The processing procedure of the embodiment is a training procedure of the corresponding relationship between the project program sample and the label. In the training procedure, the trainer dynamically adjusts the weight of each register of the state sequence corresponding to each label according to the label type, the parameter list, and the parameter value and the like.

[0150] For example, the project program sample corresponding to the same label is trained for multiple rounds. In one round of training, the project program sample is run to complete one round of training of the project program sample. The project program sample includes k instruction samples, and one cycle corresponds to one instruction sample. Therefore, one round of training needs to be executed for k cycles.

[0151] If the value of the register Xk corresponding to the kth cycle of the same label changes constantly in multiple rounds of training, the weight of the register Xk in the kth cycle corresponding to the label is gradually reduced, and vice versa. The register Xk corresponding to the preset weight value is determined as the register for storing the parameters of the instruction sample of the kth cycle. For example, in the embodiment shown in sub-step A2, the instruction sample of the second cycle corresponding to the label DrawCircle is used to write the X-axis coordinate of the center of the circle in the register. If the values of the parameters written in the preset register X3 are all 60 in multiple rounds of training, the weight of the preset register X3 in the second cycle is increased. If the values of the parameters written in the preset register X5 are 50, 60, 70, and the like, respectively, it indicates that the difference degree value between the multiple parameters written in the preset register X5 is large in multiple rounds of training, and the weight of the preset register X5 in the second cycle is reduced. By dynamically adjusting the register weight, the accuracy of subsequent register sequence matching can be improved.

[0152] Further, in the training procedure, different situations of different labels also need to be considered. For example, if the values of a certain register in the state sequence of different labels are the same, it indicates that the register has a small role in distinguishing the label type, and the weight of the register needs to be reduced.

[0153] Step 211: obtaining the register sequence corresponding to the function function according to the preset register corresponding to each parameter sample.

[0154] Step 212: constructing the corresponding relationship between the register sequence and the label according to the register sequence corresponding to the function function and the label to which the function function belongs.

[0155] For example, in the embodiment shown in sub-step A2, the register sequence corresponding to the label DrawCircle is {X3, X4, X5}.

[0156] The embodiment automatically generates a virtual prototype framework according to a small amount of artificial marking information, and automatically adds related external devices in all user programs, and engineers only need to implement a user-level simulation effect function of each external device, without modeling each external device from the bottom using a modeling language.

[0157] The embodiment supports progressive development of a virtual prototype. For example, a preset device is a screen external device, and the screen external device is introduced in an application program at the beginning. When the simulation of the screen is completed, other external devices are introduced. The virtual prototype framework can add a new external device to an existing automatically generated virtual prototype framework, to realize progressive development and improvement.

[0158] The embodiment is based on an artificial intelligence machine learning method. A large amount of running data is collected as a standard sample, combined with artificial label marking, processed by a special machine learning algorithm, to complete mapping of a state sequence and a label. The entire processing process can be automatically run, and the framework of the entire virtual prototype can be generated by one key.

[0159] To realize one-key automatic training data and export, the embodiment directly develops a virtual prototype based on a program to be simulated. Specifically, an actual project sample is artificially marked at a source code level, to obtain a label of the project program sample. External device access is marked, and then a corresponding relationship between a state sequence (i.e., a PC sequence) and the label is obtained. According to the mapping relationship between the state sequence and the label, a target function function of the project program to be executed is obtained.

[0160] Referring to Figure 5 , the device behavior simulation method of the embodiment can include the following steps:

[0161] Step S1, obtaining a project program sample.

[0162] The project program sample is an application program created by a user and running on a virtual platform. The application program includes at least one code block, and each code block has a respective first keyword and second keyword. The first keyword and the second keyword are respectively used to identify the start position and the end position of the code block to which the keyword belongs.

[0163] For example, part of the code in the project program sample is as follows:

[0164] Void main()

[0165] {

[0166] if (button_press()){

[0167] DrawCircle(50,50,100)

[0168] }

[0169] else{

[0170] DrawRectangle(10,10,30,40)

[0171] }

[0172] }

[0173] The project program sample is used to display a circle on the screen when the button is pressed, and display a rectangle when the button is released.

[0174] The embodiment is used to simulate the drawing operation of the display screen. As shown in the example, the result of drawing a circle in the display screen is as shown in Figure 6 , and the simulation result obtained through simulation is as shown in Figure 7 . According to the results shown in Figure 6 and Figure 7 , the device behavior simulation result obtained through the embodiment is highly consistent with the actual operation result of the device.

[0175] In step S2, keywords for identifying the starting position and the ending position of the instruction sample are added in the project program sample, and instruction labels are added. The labels include parameters in the instruction sample.

[0176] The project program sample includes at least one program block sample, the program block sample includes at least one instruction sample, and the starting position and the ending position of the instruction sample are the starting position and the ending position of the program block sample where the instruction sample is located.

[0177] The labels are added in the above project program, and the labels include a first keyword and a second keyword. The first keyword is START, and the second keyword is END. The project program sample after the first keyword is:

[0178] Void main()

[0179] {

[0180] if (button_press()){

[0181] START(“DrawCircle 50 50 100”);

[0182] DrawCircle(50,50,100);

[0183] END();

[0184] }

[0185] else{

[0186] START ("DrawRectangle 10 10 30 40");

[0187] DrawRectangle(10,10,30,40)

[0188] END()

[0189] }

[0190] }

[0191] The construction process of the virtual prototype of the embodiment is illustrated by taking a screen as an example in the above embodiment, which is only for describing the device behavior simulation method of the embodiment, and the method of the embodiment is not limited to the above application scenario. For example, the method of the embodiment can be applied to input, output, communication and other device behavior simulation of other external devices.

[0192] Based on the embodiment, a general virtual prototype can be quickly constructed, and development cost and time can be greatly reduced. Meanwhile, based on the behavior-level device behavior simulation method, the processing speed of the simulator can be improved, and project development and verification can be accelerated.

[0193] In step S3, the project program sample is run on the virtual platform, the sequence monitor detects the keywords in the label, and acquires the state sequence corresponding to the instruction sample between the keywords and the corresponding relationship between the state sequence and the label, and the state sequence includes a program counter sequence and a register sequence.

[0194] For example, in the embodiment of step S1, there are two code blocks, and the first keyword and the second keyword of the two code blocks are START and END respectively, and the labels of the two code blocks are DrawCircle and DrawRectangle respectively.

[0195] The state sequence between the keywords of the code block includes all processor information of the processor during the processing period corresponding to the label. For example, it can include the values of the registers (such as register X1 to register X31) and the value of the program counter (PC) of each clock cycle.

[0196] The sequence monitor can automatically extract the parameters in the code block. For example, in the embodiment shown in step S1, the draw circle function (DrawCircle) has three parameters, which are the center coordinates (x1, y1) and the radius r; the draw rectangle function (DrawRectangle) has four parameters, which are the center coordinates (x2, y2), the width w and the height h.

[0197] No matter the user program runs in the compile optimization mode o1, o2 or o3, there is a corresponding register to store the arguments of the function call. Through the sequence monitor, it can be determined which register the parameters in each label are extracted from.

[0198] Steps S1 to S3 are the training process. After running for a long time, the trainer can identify the state sequence of each label.

[0199] In step S4, the sequence monitor analyzes the to-be-executed project program to obtain the target program counter sequence of the to-be-executed project program.

[0200] In step S5, the program counter sequence matching the target program counter sequence is obtained, and the target label corresponding to the state sequence to which the program counter sequence belongs is obtained.

[0201] When the to-be-executed project program is identified, the label corresponding to the state sequence is triggered.

[0202] After the training is completed, in the actual running state, the sequence monitor analyzes the processor running state in real time, obtains the state sequence of the to-be-executed project program, and triggers the function function corresponding to the state sequence.

[0203] Combined with the weight information of each register of the state sequence of the to-be-executed project program and the state sequence and the label corresponding to the state sequence obtained through the training, the label of the state sequence of the to-be-executed project program and the function function corresponding to the label can be obtained.

[0204] In step S6, the target register is determined from the state sequence corresponding to the target label, and the parameters are extracted from the target register. The parameters are transmitted to the target function function in the target label to obtain the device behavior simulation result of the preset device.

[0205] After the label corresponding to the state sequence is identified, the parameters extracted from the register can be transmitted through the callback function. Based on this, the user interface (User Interface, UI) engineer for constructing a virtual prototype only needs to implement the function function corresponding to the label, so as to realize the device behavior simulation of the external device. For example, a circle and a rectangle can be drawn on a specified position on a virtual screen using parameters.

[0206] Based on the embodiment, when the user program runs on the virtual prototype, the sequence monitor can obtain the label corresponding to the to-be-executed target project instruction, and the UI system completes the running of the virtual prototype according to the function function corresponding to the label.

[0207] In the related art, when developing a virtual prototype, if an external device (for example, a screen external device) is to be added, the hardware design architecture layer of a screen driver chip is started from, and the functions of a communication interface and a large number of hardware registers are simulated from the bottom, and a behavior level simulation is performed based on this.

[0208] Taking drawing a figure in a screen external device as an example, based on the method of the related art, operations such as drawing a point and clearing a screen need to be performed, and the workload is large. According to the method of the embodiment, a user level function function can be directly written, thereby directly bypassing the simulation process of the entire screen hardware structure, reducing the development workload, and improving the simulation speed. The user level function function directly written can be, for example, the DrawCircle function, the DrawRectangle function, and the like in the foregoing embodiment. Based on the embodiment, without making any modification to the machine code file running on a real object, the machine code file can be directly run on a virtual prototype software instance, and a presentation effect completely consistent with the real object is obtained, and the method has the advantages of high simulation result accuracy and high simulation efficiency.

[0209] Reference Figure 8 which shows a device behavior simulation apparatus provided by the embodiment of the application, the device behavior simulation apparatus 30 comprises:

[0210] A first obtaining module 301 is configured to obtain a target program counter value sequence of a to-be-executed project program; the to-be-executed project program is used to perform device behavior simulation on a preset device; and the target program counter value sequence is used to indicate the address of at least one to-be-executed instruction in the to-be-executed project program. A second obtaining module 302 is configured to obtain a target label corresponding to the target program counter value sequence according to a corresponding relationship between the program counter value sequence and the label; the program counter value sequence is used to indicate the address of at least one instruction sample in a project program sample; and the label comprises a function function, and the function function is used to implement the function of the project program sample. A third obtaining module 303 is configured to extract a target function function from the target label, so as to obtain a simulation result of the device behavior of the preset device according to the target function function.

[0211] Optionally, the apparatus 30 further comprises a fourth obtaining module configured to obtain a target register sequence corresponding to the target label according to a corresponding relationship between a register sequence and the label; the register sequence is used to store the parameters of the function function corresponding to the label; and a fifth obtaining module is configured to extract a target parameter of the target function function from the target register sequence; wherein the target parameter is used to be transmitted into the target function function, so as to obtain the simulation result of the device behavior of the preset device according to the target function function to which the target parameter is transmitted.

[0212] Optionally, in the case that the register sequence corresponding to the label has at least one register sequence corresponding to the preset compiler optimization mode one by one, the fourth obtaining module is further configured to: obtain a target compiler optimization mode used for compiling the program to be executed; obtain at least one register sequence corresponding to the target label according to the correspondence between the register sequence and the label; and determine the register sequence corresponding to the target compiler optimization mode in the at least one register sequence corresponding to the target label as a target register sequence corresponding to the target label.

[0213] Optionally, before the fourth obtaining module obtains the target register sequence corresponding to the target label according to the correspondence between the register sequence and the label, the fourth obtaining module is further configured to: obtain a label added in the program sample; the label comprises at least one parameter sample of a function function, and the parameter sample is extracted from an instruction sample included in the program sample; determine a plurality of preset registers, and for each parameter sample of the function function, obtain a parameter write value respectively written in each preset register after executing the instruction sample corresponding to the parameter sample, and obtain a preset register corresponding to the parameter sample according to a matching result of the parameter write value and the parameter sample; obtain a register sequence corresponding to the function function according to the preset register corresponding to each parameter sample; and construct the correspondence between the register sequence and the label according to the register sequence corresponding to the function function and the label to which the function function belongs.

[0214] Optionally, the fourth obtaining module is further configured to: execute the program sample for multiple times, and for each parameter sample of the function function, obtain a parameter write value respectively written in each preset register after executing the instruction sample corresponding to the parameter sample each time; and obtain a register corresponding to the parameter sample according to a matching result of the parameter write value and the parameter sample, comprising: for each parameter sample of the function function, obtaining a difference degree value between a plurality of parameter write values; the parameter write value and an operation of executing the instruction sample corresponding to the parameter sample correspond to each other; and obtaining the register corresponding to the parameter sample according to the difference degree value and the matching result of the parameter write value and the parameter sample.

[0215] Optionally, in the case that the to-be-executed project program comprises at least one program block, the correspondence between the program counter value sequence and the label comprises at least one program counter value sequence set and at least one label set corresponding to each program counter value sequence set respectively, the second obtaining module 302 is further configured to: obtain a program counter value sequence corresponding to each program block respectively; obtain a target program register value sequence set of the to-be-executed project program according to the program counter value sequence corresponding to each program block respectively; obtain a target label set matched with the target program counter value sequence set according to the correspondence between the program counter value sequence set and the label set; and determine a target label in the target label set as a target label corresponding to the target program counter value sequence.

[0216] Optionally, the second obtaining module 302 is further configured to: obtain a project program sample; the project program sample comprises at least one program block sample, the program block sample has a corresponding label, a first keyword and a second keyword, and the first keyword and the second keyword are used to identify the start position and the end position of the program block respectively; obtain an instruction sample between the first keyword and the second keyword and a program register value sample corresponding to the instruction sample between the first keyword and the second keyword; obtain a program register value sequence corresponding to the program block sample according to the program register value sample corresponding to the instruction sample between the first keyword and the second keyword; construct a program register value sequence set according to the program register value sequence corresponding to each program block sample respectively; construct a label set according to the label corresponding to each program block sample respectively; and construct the correspondence between the program counter value sequence set and the label set according to the program register sequence set and the label set.

[0217] In summary, the target program counter value sequence of the to-be-executed project program is obtained, the target label corresponding to the target program counter value sequence is obtained according to the correspondence between the program counter value sequence and the label, and the target function is extracted from the target label, so that the simulation result of the device behavior of the preset device can be obtained by executing the target function. The embodiment does not need to model the preset device, nor directly run the target machine code corresponding to the modeling program, but obtains the target label corresponding to the target program counter value sequence of the to-be-executed project program, and then obtains the target function in the target label and directly executes it. The embodiment needs to process less workload and has high simulation efficiency, and solves the problems of large workload and low simulation efficiency caused by the need for device modeling and the need for directly running the target machine code corresponding to the modeling program in the related art.

[0218] Figure 9is a block diagram of an electronic device 400 according to an exemplary embodiment. The electronic device 400 can be, for example, a mobile phone, a computer, a digital broadcasting terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like.

[0219] Referring to Figure 9 The electronic device 400 can include one or more of the following components: a processing component 402, a memory 404, a power supply component 406, a multimedia component 408, an audio component 410, an input / output (I / O) interface 412, a sensor component 414, and a communication component 416.

[0220] The processing component 402 usually controls overall operations of the electronic device 400, such as operations associated with displaying, making phone calls, data communications, camera operations, and recording operations. The processing component 402 can include one or more processors 420 to execute instructions to complete all or part of steps of the above-described methods. In addition, the processing component 402 can include one or more modules to facilitate interaction between the processing component 402 and other components. For example, the processing component 402 can include a multimedia module to facilitate the interaction between the multimedia component 408 and the processing component 402.

[0221] The memory 404 is used to store various types of data to support operations of the electronic device 400. Examples of these data include instructions for any application or method operating on the electronic device 400, contact data, phonebook data, messages, pictures, multimedia, and the like. The memory 404 can be implemented by any type of volatile or non-volatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0222] The power supply component 406 supplies power for various components of the electronic device 400. The power supply component 406 can include a power supply management system, one or more power supplies, and other components associated with generating, managing and distributing power for the electronic device 400.

[0223] The multimedia component 408 includes a screen providing an output interface between the electronic device 400 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide and gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or sliding action, but also detect duration and pressure related to the touching or sliding action. In some embodiments, the multimedia component 408 includes a front camera and / or a rear camera. When the electronic device 400 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0224] The audio component 410 is configured to output and / or input audio signals. For example, the audio component 410 includes a microphone (MIC) to receive an external audio signal when the electronic device 400 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 404 or transmitted via the communication component 416. In some embodiments, the audio component 410 also includes a speaker to output audio signals.

[0225] The I / O interface 412 provides an interface between the processing component 402 and peripheral interface modules, which can be a keypad, a click wheel, buttons, and the like. The buttons can include, but are not limited to, a home button, a volume button, a start button, and a lock button.

[0226] The sensor component 414 includes one or more sensors to provide various state assessments for the electronic device 400. For example, the sensor component 414 can detect an open / closed state of the electronic device 400, relative positioning of components, such as a display and a keypad of the electronic device 400, a change in position of the electronic device 400 or a component of the electronic device 400, presence or absence of user contact with the electronic device 400, orientation or acceleration / deceleration of the electronic device 400, and a temperature change of the electronic device 400. The sensor component 414 can include a proximity sensor configured to detect presence of a nearby object without any physical touch. The sensor component 414 can further include a light sensor, such as a CMOS or CCD image sensor, for use in an imaging application.

[0227] The communication component 416 is configured to facilitate wired or wireless communication between the electronic device 400 and other devices. The electronic device 400 can access a wireless network based on a communication standard. In an exemplary embodiment, the communication component 416 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 further includes a Near Field Communication (NFC) module to facilitate short-range communication.

[0228] In an exemplary embodiment, the electronic device 400 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic elements, for implementing a device behavior simulation method provided by embodiments of the present application.

[0229] In an exemplary embodiment, a non-transitory computer readable storage medium including instructions, such as the memory 404 including instructions, is also provided, which can be executed by the processor 420 of the electronic device 400 to complete the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0230] Figure 10 is a block diagram of an electronic device 500 according to an exemplary embodiment. For example, the electronic device 500 can be provided as a server. Referring to Figure 10 , the electronic device 500 includes a processing component 522, which further includes one or more processors, and a memory resource represented by a memory 532, for storing instructions executable by the processing component 522, such as an application program. The application program stored in the memory 532 can include one or more than one module each corresponding to a set of instructions. In addition, the processing component 522 is configured to execute the instructions to perform a device behavior simulation method provided by embodiments of the present application.

[0231] The electronic device 500 can also include a power supply component 526 configured to perform power management of the electronic device 500, a wired or wireless network interface 550 configured to connect the electronic device 500 to a network, and an input / output (I / O) interface 558.

[0232] Embodiments of the present application also provide a computer program product including a computer program, which, when executed by a processor, implements a device behavior simulation method.

[0233] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the specification and examples be considered as exemplary only, with a true scope of the application being indicated by the following claims.

[0234] It should be understood that the application is not limited to the precise construction and will vary in the details of practice without departing from the scope of the application.

[0235] The above merely provides the preferred embodiments of the present application, and is not intended to limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0236] The above describes in detail a device behavior simulation method and device, electronic equipment and computer readable storage medium provided by the present application, the principle and implementation mode of the present application are described in this paper, the above embodiment is only used to help understand the method and core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description should not be understood as limiting the present application.

Claims

1. A method of simulating device behavior, characterized by, The method comprises: obtaining a target program counter value sequence of a to-be-executed project program; the to-be-executed project program is used for device behavior simulation of a preset device; the target program counter value sequence is used for indicating the address of at least one to-be-executed instruction in the to-be-executed project program; obtaining a target label corresponding to the target program counter value sequence according to the correspondence between the program counter value sequence and the label; the program counter value sequence is used for indicating the address of at least one instruction sample in a project program sample; the label comprises a function function, and the function function is used for realizing the function of the project program sample; extracting a target function function from the target label to obtain a simulation result of the device behavior of the preset device according to the target function function.

2. The method of claim 1, wherein, The method further comprises: obtaining a target register sequence corresponding to the target label according to the correspondence between the register sequence and the label; the register sequence is used for storing the parameters of the function function corresponding to the label; extracting a target parameter of the target function function from the target register sequence; wherein the target parameter is used for inputting into the target function function to obtain the simulation result of the device behavior of the preset device according to the target function function inputting the target parameter.

3. The method of claim 2, wherein, In the case that there is at least one register sequence corresponding to the label, and the register sequence and the preset compiler optimization mode correspond to each other, the obtaining of the target register sequence corresponding to the target label according to the correspondence between the register sequence and the label comprises: obtaining a target compiler optimization mode used for compiling the to-be-executed project program; obtaining at least one register sequence corresponding to the target label according to the correspondence between the register sequence and the label; determining the register sequence corresponding to the target compiler optimization mode in the at least one register sequence corresponding to the target label as the target register sequence corresponding to the target label.

4. The method of claim 2, wherein, Before the obtaining of the target register sequence corresponding to the target label according to the correspondence between the register sequence and the label, the method further comprises: obtaining a label added in the project program sample; the label comprises at least one parameter sample of the function function, and the parameter sample is obtained by extracting from the instruction sample included in the project program sample; determining a plurality of preset registers, and for each parameter sample of the function function, obtaining a parameter write value respectively written in each preset register after executing the instruction sample corresponding to the parameter sample, and obtaining a preset register corresponding to the parameter sample according to the matching result of the parameter write value and the parameter sample; obtaining a register sequence corresponding to the function function according to the preset register corresponding to each parameter sample; constructing the correspondence between the register sequence and the label according to the register sequence corresponding to the function function and the label to which the function function belongs.

5. The method of claim 4, wherein, For each parameter sample of the function, after obtaining the instruction sample corresponding to the parameter sample, the parameter write value is written into each of the preset registers, including: The project program sample is executed multiple times, and for each parameter sample of the function, the parameter write value is obtained after each execution of the instruction sample corresponding to the parameter sample and written into each preset register. The step of obtaining the register corresponding to the parameter sample based on the matching result of the parameter write value and the parameter sample includes: For each parameter sample of the function, the degree of difference between multiple parameter write values ​​is obtained; the parameter write values ​​correspond one-to-one with the operation of executing the instruction sample corresponding to the parameter sample. Based on the degree of difference value and the matching result between the parameter write value and the parameter sample, the register corresponding to the parameter sample is obtained.

6. The method of claim 1, wherein, In the case where the program to be executed includes at least one program block, and the correspondence between the program counter value sequence and the label includes at least one set of program counter value sequences, and a set of labels corresponding to each set of program counter value sequences, obtaining the target label corresponding to the target program counter value sequence based on the correspondence between the program counter value sequence and the label includes: Obtain the sequence of program counter values ​​corresponding to each of the program blocks; Based on the program counter value sequence corresponding to each of the program blocks, the set of target program register value sequences of the program to be executed is obtained; Based on the correspondence between the program counter value sequence set and the label set, obtain the target label set that matches the target program counter value sequence set; The target labels in the target label set are determined as the target labels corresponding to the target program counter value sequence.

7. The method of claim 6, wherein, The method further includes: Obtain a project program sample; the project program sample includes at least one program block sample, the program block sample has a corresponding tag, a first keyword and a second keyword, the first keyword and the second keyword are used to identify the start position and end position of the program block, respectively; Obtain the instruction sample between the first keyword and the second keyword, and the program register value sample corresponding to the instruction sample between the first keyword and the second keyword; Based on the program register value sample corresponding to the instruction sample between the first keyword and the second keyword, a sequence of program register values ​​corresponding to the program block sample is obtained; Construct the set of program register value sequences based on the program register value sequence corresponding to each program block sample; Construct the tag set based on the tag corresponding to each of the program block samples; Based on the program register value sequence set and the tag set, construct the correspondence between the program counter value sequence set and the tag set.

8. An apparatus behavior emulation device, comprising: The device includes: A first obtaining module is configured to obtain a target program counter value sequence of a to-be-executed project program; the to-be-executed project program is used to perform device behavior simulation on a preset device; and the target program counter value sequence is used to indicate an address of at least one to-be-executed instruction in the to-be-executed project program. A second obtaining module is configured to obtain a target label corresponding to the target program counter value sequence according to a correspondence between a program counter value sequence and a label; the program counter value sequence is used to indicate an address of at least one instruction sample in a project program sample; and the label includes a function function, which is used to implement a function of the project program sample. A third obtaining module is configured to extract a target function function from the target label, so as to obtain a simulation result of a device behavior of the preset device according to the target function function.

9. An electronic device, comprising: comprise: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method of any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can perform the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Software simulation test system, method and equipment of target chip and medium

    CN116932141A

  • Chip verification method and device, electronic equipment and storage medium

    CN117131821A