Equipment behavior simulation method and device, electronic equipment 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 problems of complex modeling and low simulation efficiency in the existing technology and improves simulation efficiency.

CN120805809AActive Publication Date: 2025-10-17BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511292712.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-10
Publication Date
2025-10-17
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 problem of low simulation efficiency caused by equipment modeling and directly running target machine code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120805809A_ABST
    Figure CN120805809A_ABST
Patent Text Reader

Abstract

The invention provides an equipment behavior simulation method and device, electronic equipment and a 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 performing equipment behavior simulation on preset equipment; 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 item program; obtaining a target label corresponding to the target program counter value sequence according to a corresponding relation between the program counter value sequence and the label; the program counter value sequence is used for indicating the address of at least one preset instruction; the tag comprises a performance function, and the performance function is used for realizing the function of the instruction sequence corresponding to the tag, and extracting a target performance function from the target tag to obtain a simulation result of the equipment behavior of the preset equipment according to the target performance function. The equipment 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; Figure 2 is a device behavior simulation method step flowchart provided by an embodiment of the present application; Figure 3 is a simulation effect schematic diagram provided by an embodiment of the present application; Figure 4 is a device behavior simulation method step flowchart provided by an embodiment of the present application; Figure 5 is a device behavior simulation method step flowchart provided by an embodiment of the present application; Figure 6 is an external device display interface schematic diagram provided by an embodiment of the present application; Figure 7 is an external device simulation display result schematic diagram provided by an embodiment of the present application; Figure 8 is a device behavior simulation device block diagram provided by an embodiment of the present application; Figure 9 is an electronic device block diagram provided by an embodiment of the present application; Figure 10 is another electronic device block diagram provided by another embodiment of the present application. DETAILED DESCRIPTION

[0014] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all the 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 scope of protection of the present application.

[0015] 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 association relationship of 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.

[0016] Figure 1 is an application scenario schematic diagram 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.

[0017] 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.

[0018] 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.

[0019] 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.

[0020] 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 model the external device and execute all the codes in the to-be-executed project program, so as to have the advantages of small amount of work to be processed and high simulation efficiency, and solve the defects of large amount of work to be processed and low simulation efficiency in the related art.

[0021] 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 through the cooperation of the MCU and the sequence monitor, or can be implemented through a processor, and the embodiments of the present application do not limit the execution subject.

[0022] 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.

[0023] Figure 2 is a step flow chart of a device behavior simulation method provided by the embodiments of the present application, as shown in Figure 2 The method can include the following steps. Step 101, obtaining a target program counter value sequence of a to-be-executed project program.

[0024] 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 an address of at least one to-be-executed instruction in the to-be-executed project program.

[0025] For example, the to-be-executed project program includes at least one to-be-executed instruction, a target program counter value (PC) 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.

[0026] 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.

[0027] Step 102, obtaining 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.

[0028] 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.

[0029] 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.

[0030] 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 corresponding relationship between the PC value sequence and the label is constructed according to the PC value sequence and the label.

[0031] 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.

[0032] 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.

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

[0034] 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.

[0035] 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.

[0036] 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.

[0037] In the related art, a virtual prototype responds to the data read-write operation of the MCU on the address interval of the external device through a modeling language, and then simulates and emulates the device behavior of the external device. When accessing the external device, 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.

[0038] 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 an actual behavioral effect 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.

[0039] 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, and 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.

[0040] 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.

[0041] 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 and the function of a behavioral level instruction set simulator can be implemented.

[0042] In the embodiment of the present application, the target program counter value sequence of the to-be-executed project program is acquired, the target label corresponding to the target program counter value sequence is acquired according to the correspondence between the program counter value sequence and the label, and the target function function in the target label is extracted, 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, and does not need to directly run the target machine code corresponding to the modeling program, but acquires the target label corresponding to the target program counter value sequence of the to-be-executed project program, and then acquires 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.

[0043] Figure 4 A device behavior simulation method provided in 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: Step 201, acquiring a target program counter value sequence of a to-be-executed project program.

[0044] 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.

[0045] 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: Step 202, acquiring a program counter value sequence corresponding to each program block, respectively.

[0046] 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: Void main() { if (button_press()){ DrawCircle(50,50,100) } else{ DrawRectangle(10,10,30,40) } } The to-be-executed project program includes two program blocks, and the first program block is taken as an example for description as follows: The first program block includes: {DrawCircle(50, 50, 100)}, the instructions corresponding to the program block to be executed include X5 = 50, X6 = 60, and X7 = 100, wherein X5, X6, and X7 are registers for writing the X coordinate, Y coordinate, and radius of the circle center, respectively.

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

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

[0049] The target PC value sequence set includes a plurality of 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 project program.

[0050] 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.

[0051] 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.

[0052] Further, the target PC value sequence set includes a plurality of target PC value sequences arranged in sequence, and the PC value sequence set includes a plurality of 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), N is an integer greater than or equal to 2.

[0053] In an example, the correspondence between the program counter value sequence set and the label set in step 204 is obtained according to the following sub-steps: Sub-step A1, obtaining a project program sample.

[0054] The project program sample includes 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.

[0055] For example, the project program sample is as follows: Void main() { if (button_press()){ START(“DrawCircle 50 50 100”); DrawCircle(50,50,100); END(); } else{ START(“DrawRectangle 10 10 30 40”); DrawRectangle(10,10,30,40) END() } } The project program sample includes two program segments, the first program segment has a label of DrawCircle 5050 100, and the first keyword and the second keyword are START and END respectively; the second program segment has a label of DrawRectangle 10 10 30 40, and the first keyword and the second keyword are START and END respectively.

[0056] Sub-step A2, obtaining 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; 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.

[0057] 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 as follows: { START(“DrawCircle 60 50 100”); DrawCircle(60,50,100); END(); } The instruction sample corresponding to the first program segment sample includes X5=60, 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. 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}.

[0058] 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, and 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 PC=1234, PC=1235, and PC=1236), and the registers for storing the parameters in the instructions also correspond to each other (all X5, X6, and X7).

[0059] In substep A4, a program register value sequence set is constructed according to the program register value sequence corresponding to each program block sample.

[0060] 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.

[0061] In substep A5, a label set is constructed according to the label corresponding to each program block sample.

[0062] In an example, a function function sample is obtained from the instruction sample of the program block sample, and the parameter corresponding to the function function sample. The function function sample and the parameter corresponding to the function function sample are determined as the label corresponding to the program block sample.

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

[0064] In substep A6, a 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.

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

[0066] 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 corresponding relationship 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.

[0067] Step 205, determining a target label in the target label set as a target label corresponding to the target program counter value sequence.

[0068] Step 206, extracting a target function from the target label to obtain a simulation result of the device behavior of the preset device according to the target function.

[0069] For example, the target label set has at least one target label, and each target label has a corresponding target function. Then, there is at least one target function obtained based on the embodiment. By executing each target function, a simulation result of the device behavior of the preset device is obtained.

[0070] For example, the target label set includes a target label with a target function DrawCircle and a target label with a target function DrawRectangle. By executing the target function DrawCircle and the target function DrawRectangle respectively, a simulation result of the device behavior of the preset device is obtained.

[0071] For example, the method further comprises: Step 207, obtaining a target register sequence corresponding to the target label according to the corresponding relationship between the register sequence and the label.

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

[0073] For example, the register sequence has at least one type, and the register sequence and the preset compiler optimization mode correspond to each other.

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

[0075] For example, in the embodiment of the substep A2, in the O1 mode, the register sequence used to store the X coordinate, the Y coordinate, and the 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, the Y coordinate, and the radius of the center of the circle can be {X4, X5, X6}.

[0076] Correspondingly, the step 207 can include the following substeps. The substep B1 obtains a target compiler optimization mode used to compile the project program to be executed.

[0077] The target compiler optimization mode is set according to the requirement of the user 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.

[0078] The substep B2 obtains at least one register sequence corresponding to the target label according to the correspondence between the register sequence and the label.

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

[0080] The substep B3 determines 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.

[0081] For example, the at least one register sequence corresponding to the target label includes the register sequence corresponding to the O1 mode and the register sequence corresponding to the O3 mode, and 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.

[0082] The step 208 extracts the target parameter of the target function from the target register sequence.

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

[0084] 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.

[0085] The target parameter is used to pass 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 passed in the target parameter.

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

[0087] In an example, before step 207, the method further includes: Step 209, obtaining the label added in the project program sample.

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

[0089] In an 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 function is DrawCircle, and the parameter samples 60, 50 and 100 of the function function are obtained from the instruction DrawCircle(60, 50, 100).

[0090] Step 210, determining a plurality of preset registers, and for each parameter sample of the function function, obtaining the parameter write value written in each preset register after executing the instruction sample corresponding to the parameter sample, and obtaining the register corresponding to the parameter sample according to the matching result of the parameter write value and the parameter sample.

[0091] In an 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 and the parameter sample match, 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 and the parameter sample do not match, and the preset register is not the register corresponding to the function function.

[0092] 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, 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.

[0093] For example, the step 210 can include the following sub-steps: 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.

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

[0095] 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.

[0096] 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.

[0097] 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.

[0098] 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.

[0099] 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.

[0100] The processing process of the embodiment is the training process of the corresponding relationship between the project program sample and the label, and in the training process, 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 other information.

[0101] For example, the same label corresponding to the project program sample is trained for multiple rounds, wherein the project program sample is run once, and one round of training of the project program sample is completed. The project program sample includes k instruction samples, and then k cycles are executed to complete one round of training, and one cycle corresponds to one instruction sample.

[0102] If the value of the register Xk changes constantly in the kth cycle corresponding to the same label 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 used to store 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, etc. 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.

[0103] Further, in the training process, different situations of different labels also need to be considered. For example, if the numerical value of a certain register is the same in the state sequence of different labels, it indicates that the register has a small effect on distinguishing the label type, and the weight of the register needs to be reduced.

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

[0105] 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.

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

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

[0108] The embodiment supports progressive development of a virtual prototype. For example, a preset device is an external device of a screen, and the external device of the screen is introduced in an application 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.

[0109] 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, and the mapping of a state sequence and a label is completed. The entire processing process can be automatically run, and the framework of the entire virtual prototype can be generated by one key.

[0110] 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 manually marked at a source code level to obtain a label obtained by a project program sample, an external device access is marked, and a corresponding relationship between a state sequence (that is, 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.

[0111] Referring to Figure 5 The device behavior simulation method of the embodiment can include the following steps: Step S1, obtaining a project program sample.

[0112] 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 first keyword and the second keyword belong.

[0113] For example, part of the code in the project program sample is as follows: Void main() { if (button_press()){ DrawCircle(50,50,100) } else{ DrawRectangle(10,10,30,40) } } The project program sample is used to display a circle on the screen when a button is pressed, and display a rectangle when the button is released.

[0114] The embodiment is used to simulate the drawing operation of the display screen. For example, the result of drawing a circle in the display screen is as followsFigure 6 The simulation result obtained by simulation is shown in FIG. 3. Figure 7 The simulation result obtained by simulation is shown in FIG. 3. Figure 6 The simulation result obtained by simulation is shown in FIG. 3. Figure 7 According to the result shown in FIG. 3, the device behavior simulation result obtained by the embodiment is highly consistent with the actual operation result of the device.

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

[0116] The project program sample includes at least one program block sample, the program block sample includes at least one instruction sample, and the start position and the end position of the instruction sample are the start position and the end position of the program block sample where the instruction sample is located.

[0117] The labels are added in the 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 keywords is as follows: Void main() { if (button_press()){ START(“DrawCircle 50 50 100”); DrawCircle(50,50,100); END(); } else{ START(“DrawRectangle 10 10 30 40”); DrawRectangle(10,10,30,40) END() } } In the above embodiment, the construction process of the virtual prototype of the embodiment is illustrated by taking a screen as an example, 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 the input, output, communication and other device behavior simulation of other external devices.

[0118] Based on the embodiment, a general virtual prototype can be quickly constructed, and the development cost and time can be greatly reduced. At the same time, the device behavior simulation method based on the behavior level can improve the processing speed of the simulator and accelerate the project development and verification.

[0119] Step S3, running the project program sample on the virtual platform, the sequence monitor detects the keywords in the label, and obtains the state sequence corresponding to the instruction sample between the keywords, and the correspondence between the state sequence and the label, the state sequence includes the program counter sequence and the register sequence.

[0120] For example, in the embodiment of step S1, there are two code blocks, 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.

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

[0122] 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 of the rectangle (x2, y2), the width w and the height h.

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

[0124] Steps S1 to S3 are the training process, after a large amount of time running, the trainer can identify the state sequence of each label.

[0125] 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.

[0126] Step S5, obtaining the program counter sequence matched with the target program counter sequence, and obtaining the target label corresponding to the state sequence to which the program counter sequence belongs.

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

[0128] 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.

[0129] The weight information of each register of the state sequence of the to-be-executed project program and the trained state sequence and the label corresponding to the state sequence can be used to obtain the label of the state sequence of the to-be-executed project program and a function corresponding to the label.

[0130] In step S6, a target register is determined from the state sequence corresponding to the target label, and a parameter is extracted from the target register, which is passed to a target function in the target label to obtain a device behavior simulation result of the preset device.

[0131] After identifying the label corresponding to the state sequence, the parameter extracted from the register can be passed through a callback function. Based on this, a user interface (UI) engineer for constructing a virtual prototype only needs to implement a function corresponding to the label, and device behavior simulation of an external device can be implemented. For example, a circle or a rectangle can be drawn on a specified position on a virtual screen using a parameter.

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

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

[0134] Taking drawing a figure in a screen external device as an example, based on the method in related technologies, operations such as drawing a point and clearing a screen need to be performed, and the workload is large. According to the method in this embodiment, a user-level 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 can be, for example, the DrawCircle function, the DrawRectangle function, and the like in the foregoing embodiment. Based on this embodiment, a machine code file running on a real object does not need to be modified, and the machine code file can be directly run on a virtual prototype software instance to obtain a presentation effect identical to that of the real object, and has the advantages of high simulation result accuracy and high simulation efficiency.

[0135] Reference Figure 8 which shows a device behavior simulation apparatus provided by an embodiment of the present application. The device behavior simulation apparatus 30 includes: The 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 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. The second obtaining module 302 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 for indicating an address of at least one instruction sample in a project program sample; and the label includes a function function, and the function function is used for implementing a function of the project program sample. The third obtaining module 303 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.

[0136] Optionally, the apparatus 30 further includes a fourth obtaining module configured to obtain a target register sequence corresponding to the target label according to a correspondence between a register sequence and a label; the register sequence is used for storing a parameter 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 for being input 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 input with the target parameter.

[0137] Optionally, in a case where the register sequence corresponding to the label is at least one, and the register sequence and a preset compiler optimization mode correspond to each other, the fourth obtaining module is further configured to: obtain a target compiler optimization mode used for compiling the to-be-executed project program; obtain at least one register sequence corresponding to the target label according to the correspondence between the register sequence and the label; and determine, as the target register sequence corresponding to the target label, a register sequence corresponding to the target compiler optimization mode in the at least one register sequence corresponding to the target label.

[0138] Optionally, the fourth obtaining module is further configured to, before obtaining the target register sequence corresponding to the target label according to the correspondence between the register sequence and the label, obtain a label added in the project program sample; the label includes at least one parameter sample of the function function, and the parameter sample is obtained by extracting an instruction sample included in the project program sample; a plurality of preset registers are determined, and for each parameter sample of the function function, a parameter write value written in each preset register after executing an instruction sample corresponding to the parameter sample is obtained, and a preset register corresponding to the parameter sample is obtained according to a matching result of the parameter write value and the parameter sample; a register sequence corresponding to the function function is obtained according to the preset register corresponding to each parameter sample; and the correspondence between the register sequence and the label is constructed according to the register sequence corresponding to the function function and the label to which the function function belongs.

[0139] Optionally, the fourth obtaining module is further configured to: execute the project program sample multiple times, and obtain, for each parameter sample of the function function, parameter write values respectively written in each preset register after each execution of the instruction sample corresponding to the parameter sample; and obtain the register corresponding to the parameter sample according to a matching result of the parameter write values and the parameter sample, including: obtaining, for each parameter sample of the function function, a difference degree value between the multiple parameter write values; the parameter write values and the operation of executing the instruction sample corresponding to the parameter sample are in one-to-one correspondence; and obtaining the register corresponding to the parameter sample according to the difference degree value and the matching result of the parameter write values and the parameter sample.

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

[0141] Optionally, the second obtaining module 302 is further configured to: obtain a project program sample; the project program sample includes 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 a start position and an 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 sequence of program register values 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 sequence set of program register values according to the sequence of program register values corresponding to each program block sample respectively; construct a set of labels according to the label corresponding to each program block sample respectively; and construct a correspondence relationship between a sequence set of program counter values and a set of labels according to the sequence set of program register values and the set of labels.

[0142] 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 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.

[0143] Figure 9 FIG. 4 is a block diagram of an electronic device 400 according to an example embodiment. The electronic device 400 can be, for example, a mobile phone, a computer, a digital broadcasting terminal, a message transmitting / receiving device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like.

[0144] 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.

[0145] 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 method. In addition, the processing component 402 can include one or more modules so as to facilitate interactions 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.

[0146] The memory 404 is used to store various types of data to support the operation of the electronic device 400. Examples of such 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 nonvolatile memory, 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 memory, flash memory, magnetic disk or optical disk.

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

[0148] 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 the touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a 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. The front and / or rear camera can receive external multimedia data when the electronic device 400 is in an operation mode, such as a photographing mode or a multimedia mode. Each of the front and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0149] 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 operation 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.

[0150] 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.

[0151] The sensor component 414 includes one or more sensors for providing status assessments for various aspects of the electronic device 400. For example, the sensor component 414 can detect an open / closed position of the electronic device 400, relative positioning of components, such as a display and keypad of the electronic device 400, a change in position of the electronic device 400 or a component of the electronic device 400, the presence or absence of user contact with the electronic device 400, the orientation or acceleration / deceleration of the electronic device 400, and a temperature change of the electronic device 400. The sensor component 414 can include an accelerometer or other input device that facilitates multiple degrees of freedom of movement by the electronic device 400. The sensor component 414 can include proximity sensor configured to detect presence of nearby objects without any physical contact. The sensor component 414 can further include a light sensor (e.g., a CMOS or CCD image sensor) utilized in imaging applications.

[0152] 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, to enable wired or wireless communication between the electronic device 400 and other devices. In an exemplary embodiment, the communication component 416 receives a broadcast signal 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.

[0153] In an exemplary embodiment, the electronic device 400 can be implemented with 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, to implement a method for device behavior simulation according to embodiments of the present application.

[0154] In an exemplary embodiment, a non-transitory computer readable storage medium, such as the memory 404 including instructions stored

[0155] 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 FIG. 5, the electronic device 500 includes a bus 510, a processor 520, a memory 530, a storage 540, an input device 550, an output device 560, a display 570, a communication device 580, and a sensor component 590. Figure 10The electronic device 500 further 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 the embodiments of the present application.

[0156] The electronic device 500 can further 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.

[0157] The embodiments of the present application further provide a computer program product, which includes a computer program, and the computer program, when executed by a processor, implements a device behavior simulation method.

[0158] Other embodiments of the present 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 present application cover any and all variations of the application that come within the scope of the claims and their equivalents. It is intended that the specification and examples be considered exemplary only, with the true scope of the application being indicated by the following claims.

[0159] It should be understood that the application is not limited to the precise construction that has been described above and illustrated in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application.

[0160] 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.

[0161] The above describes in detail the device behavior simulation method, device, electronic device and computer readable storage medium provided by the present application, the principle and implementation manner of the present application are described by applying specific examples in the text, and the above embodiment description is only for helping to 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 manner and application range can be changed, and the above, the content of the specification should not be understood as limiting the present application.

Claims

1. A method for simulating device behavior, characterized in that: include: Get the target program counter value sequence of the project program to be executed; The project program to be executed is used to simulate the device behavior of the preset device; The target program counter value sequence is used to indicate the address of at least one instruction to be executed in the project program to be executed; According to a correspondence between a program counter value sequence and a label, a target label corresponding to the target program counter value sequence is obtained; the program counter value sequence is used to indicate an address of at least one instruction sample in a project program sample; the label includes a function, and the function is used to implement a function of the project program sample; An objective function is extracted from the target tag to obtain a simulation result of the device behavior of the preset device according to the objective function.

2. The method according to claim 1, characterized in that The method further comprises: According to the correspondence between the register sequence and the label, a target register sequence corresponding to the target label is obtained; the register sequence is used to store parameters of the function corresponding to the label; Extracting target parameters of the target function from the target register sequence; The target parameter is used to input the target function, so as to obtain the simulation result of the device behavior of the preset device according to the target function input with the target parameter.

3. The method according to claim 2, characterized in that When there is at least one register sequence corresponding to the label, and the register sequence corresponds to the preset compiler optimization mode in a one-to-one manner, obtaining the target register sequence corresponding to the target label according to the correspondence between the register sequence and the label includes: Obtaining a target compiler optimization mode for compiling the project program to be executed; Acquire at least one register sequence corresponding to the target tag according to the correspondence between the register sequence and the tag; A register sequence corresponding to the target compiler optimization mode in at least one register sequence corresponding to the target label is determined as a target register sequence corresponding to the target label.

4. The method according to claim 2, characterized in that Before acquiring a target register sequence corresponding to the target tag according to the correspondence between the register sequence and the tag, the method further includes: Acquire a label added to the project program sample; the label includes at least one parameter sample of the function, and the parameter sample is extracted from an instruction sample included in the project program sample; Determine a plurality of preset registers, and for each parameter sample of the function function, obtain and execute an instruction sample corresponding to the parameter sample, write parameter write values ​​into each of the preset registers respectively, and obtain the preset register corresponding to the parameter sample based on a matching result between the parameter write values ​​and the parameter sample; Obtaining a register sequence corresponding to the functional function according to the preset registers corresponding to each of the parameter samples; According to the register sequence corresponding to the function and the label to which the function belongs, a corresponding relationship between the register sequence and the label is established.

5. The method according to claim 4, characterized in that The step of obtaining, for each parameter sample of the function function, executing an instruction sample corresponding to the parameter sample and writing the parameter write value into each preset register includes: Executing the project program sample multiple times, and for each parameter sample of the functional function, obtaining a parameter write value written into each preset register after each execution of an instruction sample corresponding to the parameter sample; Obtaining a register corresponding to the parameter sample according to a matching result between the parameter write value and the parameter sample includes: For each parameter sample of the functional function, obtaining a difference degree value between a plurality of parameter write values; the parameter write values ​​correspond one to one with the operation of executing the instruction sample corresponding to the parameter sample; According to the difference degree value and the matching result between the parameter write value and the parameter sample, a register corresponding to the parameter sample is obtained.

6. The method according to claim 1, characterized in that In a case where the to-be-executed project program includes at least one program block, and 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 of the program counter value sequence sets, obtaining a target label corresponding to the target program counter value sequence based on the correspondence between the program counter value sequence and the label includes: Obtaining a sequence of program counter values ​​corresponding to each of the program blocks; Obtaining a target program register value sequence set of the to-be-executed project program according to a program counter value sequence corresponding to each of the program blocks; Acquire a target tag set that matches the target program counter value sequence set according to a correspondence between the program counter value sequence set and the tag set; The target tags in the target tag set are determined as target tags corresponding to the target program counter value sequence.

7. The method according to claim 6, characterized in that The method further comprises: Obtain a project program sample; the project program sample includes at least one program block sample, the program block sample having a corresponding label, a first keyword, and a second keyword, the first keyword and the second keyword being used to identify a starting position and an ending position of the program block, respectively; Acquire instruction samples between the first keyword and the second keyword, and program register value samples corresponding to the instruction samples between the first keyword and the second keyword; Obtaining a program register value sequence corresponding to a program block sample based on program register value samples corresponding to instruction samples between the first keyword and the second keyword; Constructing the program register value sequence set according to the program register value sequence corresponding to each of the program block samples; Constructing the label set according to the labels corresponding to each of the program block samples; A correspondence between the program counter value sequence set and the tag set is established according to the program register sequence set and the tag set.

8. A device behavior simulation device, characterized in that: The device comprises: a first acquisition module, configured to acquire a target program counter value sequence of a project program to be executed; the project program to be executed is used to perform device behavior simulation on a preset device; the target program counter value sequence is used to indicate an address of at least one instruction to be executed in the project program to be executed; a second acquisition module, configured to acquire a target label corresponding to the target program counter value sequence based on a correspondence between a program counter value sequence and labels; the program counter value sequence is used to indicate an address of at least one instruction sample in the project program sample; the label includes a function, and the function is used to implement a function of the project program sample; The third acquisition module is used to extract the target function from the target tag to obtain the simulation result of the device behavior of the preset device according to the target function.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to 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 a processor of an electronic device, the electronic device is enabled to perform the method according to 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

  • Embedded device firmware simulation method and device and storage medium

    CN117539586A

  • Verification method and device, electronic equipment and readable storage medium

    CN118395917A

  • Graphical high-level synthesis circuit performance analysis method, system, apparatus, and medium

    WO2024045436A1