Simulation hardware component operation method and device, storage medium and electronic equipment

By creating multiple processes in the chip simulation system and allocating simulation hardware components to different CPU cores, efficient resource utilization is achieved, solving the problem of low operating efficiency of simulation CPUs in the existing technology, and improving the performance of the simulation system.

CN118585328APending Publication Date: 2024-09-03SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410720642.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

In the existing chip simulation system, especially the Gem5 simulation CPU based on SystemC, the operating efficiency is low, which leads to the bottleneck of the entire simulation system. When the number of physical cores increases, the consumption of the multi-core CPU model increases due to the additional overhead of switching between simulation cores. , failing to effectively utilize the host’s CPU resources.

Method used

By determining the number of simulated hardware components in the computer system simulator, and creating multiple processes based on the number of simulated hardware components and the number of cores of the host CPU, each simulated hardware component runs on a different CPU core, using the socket protocol or TLM interface Communicate to enable efficient communication and resource allocation between simulation hardware components.

Benefits of technology

It improves the operating efficiency of the computer system simulator, makes full use of the CPU resources of the host, solves the problem of low operating efficiency of the simulated CPU, and improves the overall performance of the simulation system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585328A
    Figure CN118585328A
Patent Text Reader

Abstract

The embodiment of the invention provides an operation method and device of simulation hardware components, a storage medium and electronic equipment, and relates to the field of simulation, and the method comprises the steps that the number of the simulation hardware components in a computer system simulator is determined; under the condition that the number of the simulation hardware components is larger than or equal to 2, the target number of processes to be created is determined according to the number of the simulation hardware components and the core number of a CPU of a host, the computer system simulator runs on the host, and the target number is larger than or equal to 2 and smaller than or equal to the core number of the CPU; the target number of processes are created, N simulation hardware components run in the target number of processes, each process in the target number of processes is scheduled to a core of a CPU of the host, the cores to which the processes are scheduled are different, and N is the number of the simulation hardware components.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of simulation, and more specifically, to a method and device for simulating the operation of hardware components, a storage medium, and an electronic device. Background Art

[0002] In recent years, with the rapid development of chip technology, the application of chip simulation systems has become more and more extensive. The integration of chips is getting higher and higher, and the scale is getting larger and larger. The resource requirements for simulation systems are getting higher and higher, and the bottlenecks and pain points of simulation systems in the chip development process are becoming more and more obvious. The SystemC simulation system is a technology that is widely used in software simulation systems. Its technical feature is to use a specific System library in the C environment to achieve functional simulation or performance simulation of chip behavior. SystemC provides basic port logic, line signals, and rich bus communication models and address access models. SystemC implements a standard TLM interface for communication between bus communication modules.

[0003] When SystemC implements a chip model with firmware functions, it is necessary to simulate a real central processing unit (CPU) core to run the firmware. The efficiency of simulating the CPU core operation becomes the bottleneck of the entire chip simulation system. This is the case with Gem5, which is based on SystemC. Gem5 implements CPU core models of multiple architectures and is usually used to build chip simulation systems that include firmware. However, the operating efficiency of the simulated CPU of the chip simulation system will become the bottleneck of the entire simulation system.

[0004] Gem5 based on SystemC is a single-process model. SystemC's Sc_thread (the interface for implementing multi-threading in SystemC) is implemented by cutting its own resources according to time slices to achieve the effect of multi-threaded operation. The Gem5 multi-core CPU model based on SystemC is also implemented based on the same process simulation, so that all codes can only run in the same physical core. Therefore, even if the Gem 5 multi-core CPU model runs in a multi-physical core server, the operating efficiency does not increase due to the increase in the number of physical cores of the server. On the contrary, the increase in the number of simulated cores will increase the additional switching overhead between simulated cores, resulting in increased consumption.

[0005] With regard to the problem of low operating efficiency of computer system simulators in related technologies, no effective solution has been proposed so far. Summary of the invention

[0006] The embodiments of the present application provide a method and device for simulating the operation of a hardware component, a storage medium, and an electronic device, so as to at least solve the problem of low operation efficiency of a computer system simulator.

[0007] According to one embodiment of the present application, a method for running a simulated hardware component is provided, comprising: determining the number of simulated hardware components in a computer system simulator; when the number of the simulated hardware components is greater than or equal to 2, determining a target number of processes to be created based on the number of the simulated hardware components and the number of cores of a host's CPU, wherein the computer system simulator runs on the host, and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU; creating the target number of processes, and running N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the host's CPU, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

[0008] In an exemplary embodiment, determining the target number of processes to be created based on the number of simulated hardware components and the number of cores of the host's CPU includes: when the number of simulated hardware components is less than or equal to the number of cores of the host's CPU, determining the target number to be the number of simulated hardware components; when the number of simulated hardware components is greater than or equal to the number of cores of the host's CPU, determining the target number to be the number of cores of the host's CPU.

[0009] In an exemplary embodiment, running N simulated hardware components in the target number of processes includes: when the target number is the number of simulated hardware components, running each of the N simulated hardware components in one of the target number of processes, and each simulated hardware component runs a different process; when the target number is the number of cores of the host's CPU, dividing the N simulated hardware components into M groups of simulated hardware components, and running each group of the M groups of simulated hardware components in one of the target number of processes, and each group of simulated hardware components runs a different process, wherein M is the target number.

[0010] In an exemplary embodiment, after running the N simulated hardware components in the target number of processes, the method further includes: when a first simulated hardware component among the N simulated hardware components runs in a first process and an instruction connector in the computer system simulator does not run in the first process, instructing the first simulated hardware component to communicate with the instruction connector through a socket protocol, wherein the instruction connector is used to handle the flow and interaction of instructions, and the target number of processes includes the first process.

[0011] In an exemplary embodiment, after running the N simulated hardware components in the target number of processes, the method further includes: when a second simulated hardware component among the N simulated hardware components runs in a second process and an instruction connector in the computer system simulator runs in the second process, instructing the second simulated hardware component to communicate with the instruction connector through a transaction level modeling TLM interface and / or a single-line interface, wherein the instruction connector is used to handle the flow and interaction of instructions, and the target number of processes includes the second process.

[0012] In an exemplary embodiment, the first analog hardware component is connected to a first protocol converter, the instruction connector is connected to a second protocol converter, the first protocol converter and the second protocol converter communicate with each other via a Socket protocol, the first protocol converter and the second protocol converter are both a type of protocol converter, wherein the first analog hardware component and the instruction connector both have a TLM interface and a single-wire interface, the protocol converter is used to convert data acquired via the TLM interface and / or the single-wire interface into Socket protocol data, and to convert Socket protocol data into data to be sent via the TLM interface and / or the single-wire interface.

[0013] In an exemplary embodiment, the protocol converter includes: a socket initialization unit, a first data transceiver unit, a second data transceiver unit, a socket sending unit, a socket receiving unit, a data adaptation unit, a data format encapsulation unit, a data parsing unit, a first cache queue, and a second cache queue; wherein the socket initialization unit is used to complete the creation and connection of the socket, and pass the generated connection handle to the socket sending unit and the socket receiving unit, wherein the connection handle is an identifier used to identify a specific network connection; the first data transceiver unit is connected to the TLM interface of the first analog hardware component or the instruction connector, and is used to obtain data from the TLM interface or send the data to be sent to the TLM interface; the second data transceiver unit is connected to the single-line interface of the first analog hardware component or the instruction connector, and is used to obtain data from the single-line interface or send the data to be sent to the single-line interface; The data adaptation unit is connected to the first data transceiver unit and the second data transceiver unit, and is used to send the data obtained from the TLM interface and the corresponding data type and / or the data obtained from the single-line interface and the corresponding data type to the data format encapsulation unit; the data adaptation unit is also used to send the data obtained from the data parsing unit to the TLM interface and / or the single-line interface accordingly; the data format encapsulation unit is used to encapsulate the data obtained from the data adaptation unit according to the data type, and send the encapsulated data to the first cache queue; the data parsing unit is used to obtain data from the second cache queue and send the obtained completion message to the data adaptation unit; the socket sending unit is used to obtain data from the first cache queue and send the obtained data through the connection handle; the socket receiving unit is used to obtain data through the connection handle and send the obtained data to the second cache queue.

[0014] According to another embodiment of the present application, a device for running a simulated hardware component is provided, comprising: a first determination module, used to determine the number of simulated hardware components in a computer system simulator; a second determination module, used to determine the target number of processes to be created according to the number of simulated hardware components and the number of cores of a host's CPU when the number of the simulated hardware components is greater than or equal to 2, wherein the computer system simulator runs on the host, and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU; a processing module, used to create the target number of processes and run N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the host's CPU, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

[0015] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0016] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0017] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0018] Through the present application, N simulated hardware components in a computer system simulator are run in multiple processes, each process is scheduled to a core of the host's CPU, and each process is scheduled to a different core, thereby utilizing the host's CPU resources to a greater extent, improving the operating efficiency of the computer system simulator, and solving the problem of low operating efficiency of the computer system simulator. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0020] Figure 1 is a hardware structure block diagram of a server device for simulating an operation method of a hardware component according to an embodiment of the present application;

[0021] Figure 2 It is a schematic diagram of Gem5 multi-core resource occupation in related technology;

[0022] Figure 3 is a flow chart of a method for simulating the operation of a hardware component according to an embodiment of the present application;

[0023] Figure 4 is a modified Gem5 multi-core resource occupancy diagram according to an embodiment of the present application;

[0024] Figure 5 is a communication diagram of a simulated hardware component in Gem5 according to an embodiment of the present application;

[0025] Figure 6 is a schematic diagram of a protocol converter according to an embodiment of the present application;

[0026] Figure 7 is a structural block diagram of an operation device for simulating a hardware component according to an embodiment of the present application;

[0027] Figure 8 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0028] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0030] The embodiment of the method for simulating the operation of a hardware component provided in the embodiment of the present application can be executed in a server device or a similar computing device. Taking the operation on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device for simulating the operation method of a hardware component in an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0031] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the operation method of the simulated hardware component in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0032] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0033] In order to better understand the relevant technologies, Figure 2 The diagram shows that the chip simulation system (Gem5) is running in the host. The host has 4 core resources. Although the CPU occupancy rate of 3 cores is 5%, the operation efficiency is relatively low because Gem5 only occupies one CPU-core resource. In addition, the hardware simulation logic part and the simulated CPU part in the chip simulation system will also occupy the same host-CPU resource. It should be noted that the hardware simulation logic specifically refers to the chip simulation logic other than the simulated CPU core when using Gem5 to simulate the chip.

[0034] In order to solve the above problems, this embodiment provides a method for simulating the operation of a hardware component, such as Figure 3 As shown, the process includes the following steps S302-S306:

[0035] Step S302: Determine the number of simulated hardware components in the computer system simulator;

[0036] Optionally, the computer system simulator is Gem5, and the simulated hardware components include but are not limited to: simulated CPU and simulated memory, simulated cache, simulated bus, simulated network interface, and simulated storage device.

[0037] Step S304: when the number of the simulated hardware components is greater than or equal to 2, determining a target number of processes to be created according to the number of the simulated hardware components and the number of cores of the CPU of the host, wherein the computer system simulator runs on the host, and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU;

[0038] Step S306: Create the target number of processes, and run N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the host's CPU, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

[0039] Through the above steps, the N simulated hardware components in the computer system simulator are run in multiple processes, each process is scheduled to a core of the host's CPU, and each process is scheduled to a different core, thereby making greater use of the host's CPU resources, improving the operating efficiency of the computer system simulator, and solving the problem of low operating efficiency of the computer system simulator.

[0040] Optionally, this application can modify the Gem5 code mechanism to run the simulated hardware components (each CPU simulation core) into different processes, so that the simulated CPU can run in other idle host-CPUs, making greater use of host resources and improving the operating efficiency of the simulation system from the perspective of hardware resources. When the simulated CPU and the hardware simulation logic run on different cores, the hardware simulation logic can also run more efficiently, thereby improving the operating efficiency of the entire simulation system. For a better understanding, Figure 4 It shows a modified gem multi-core resource usage.

[0041] In an exemplary embodiment, the above-mentioned determination of the target number of processes to be created based on the number of the simulated hardware components and the number of cores of the host's CPU includes: when the number of the simulated hardware components is less than or equal to the number of cores of the host's CPU, determining the target number to be the number of the simulated hardware components; when the number of the simulated hardware components is greater than or equal to the number of cores of the host's CPU, determining the target number to be the number of cores of the host's CPU.

[0042] It should be noted that the above method can accurately determine the number of processes to be created, thereby making more effective use of the CPU resources in the host, thereby improving the operating efficiency of the simulation system from the perspective of hardware resources.

[0043] In an exemplary embodiment, the above-mentioned running the N simulated hardware components in the target number of processes includes: when the target number is the number of the simulated hardware components, each of the N simulated hardware components is run in one of the target number of processes, and each simulated hardware component runs a different process; when the target number is the number of cores of the CPU of the host, the N simulated hardware components are divided into M groups of simulated hardware components, and each group of simulated hardware components in the M groups of simulated hardware components is run in one of the target number of processes, and each group of simulated hardware components runs a different process, wherein M is the target number.

[0044] Optionally, each simulated CPU among the N simulated hardware components may be run separately in one process, and the simulated hardware components except the simulated CPU among the N simulated hardware components may be run together in one process.

[0045] Optionally, the N analog hardware components are divided into M groups of analog hardware components, including: dividing P analog hardware components with high importance among the N analog hardware components into P groups of analog hardware components, and dividing analog hardware components with low importance into one group, where P is a positive integer less than N.

[0046] It should be noted that, through the above method, N simulated hardware components can be evenly distributed in different processes, thereby making more full use of the CPU resources in the host, and improving the operating efficiency of the simulation system from the perspective of hardware resources.

[0047] In an exemplary embodiment, after running N simulated hardware components in the target number of processes, the method further includes: when a first simulated hardware component among the N simulated hardware components runs in a first process and an instruction connector in the computer system simulator does not run in the first process, the first simulated hardware component communicates with the instruction connector via a socket protocol, wherein the instruction connector is used to process the flow and interaction of instructions, and the target number of processes includes the first process.

[0048] In an exemplary embodiment, the first analog hardware component is connected to a first protocol converter, the instruction connector is connected to a second protocol converter, the first protocol converter and the second protocol converter communicate with each other via a Socket protocol, the first protocol converter and the second protocol converter are both a type of protocol converter, wherein the first analog hardware component and the instruction connector both have a TLM interface and a single-wire interface, the protocol converter is used to convert data acquired via the TLM interface and / or the single-wire interface into Socket protocol data, and to convert Socket protocol data into data to be sent via the TLM interface and / or the single-wire interface.

[0049] Optionally, the first simulated hardware component is a simulated CPU.

[0050] Alternatively, if Figure 5As shown in the modified CPU communication diagram of Gem5, the present application can modify the interface connection of the analog hardware component of Gem5, connect the interface of the analog hardware component that accesses the address bus through the TLM interface to the x-connect module (i.e., a protocol converter), connect the interface accessed through the single-line signal in the analog hardware component to x-connect, and modify the analog hardware component to communicate externally through the socket interface.

[0051] It should be noted that TLM is a transmission method for building a higher-level abstract model and is the core transmission method between SystemC models. TLM2.0 provides rich and powerful transmission features, including: bidirectional blocking or non-blocking interface, time stamp, and identical data packets. Through these features, TLM2.0 makes the communication between interfaces more standardized and easier to build system abstract models.

[0052] It should be noted that Figure 5 The "i-connect" in gem5 is the instruction connector, which is responsible for handling the flow and interaction of instructions. The main function of the i-connect connector is to connect the CPU core and the instruction cache, ensuring that instructions can be smoothly transferred from the cache to the CPU core for execution. In gem5, "i-connect" plays a key role, which affects the efficiency and performance of instruction execution.

[0053] It should be noted that, through the above modifications, this application enables the simulated CPU of Gem5 to run in multiple processes, and can realize the communication between multiple simulated CPUs and other modules of Gem5, completing the functions that can be realized by the original model, but the performance is significantly improved.

[0054] In an exemplary embodiment, the protocol converter includes: a socket initialization unit, a first data transceiver unit, a second data transceiver unit, a socket sending unit, a socket receiving unit, a data adaptation unit, a data format encapsulation unit, a data parsing unit, a first cache queue, and a second cache queue; wherein,

[0055] The socket initialization unit is used to complete the creation and connection of the socket, and pass the generated connection handle to the socket sending unit and the socket receiving unit, wherein the connection handle is an identifier used to identify a specific network connection;

[0056] The first data transceiver unit is connected to the TLM interface of the first analog hardware component or the instruction connector, and is used to obtain data from the TLM interface or send data to be sent to the TLM interface;

[0057] The second data transceiver unit is connected to the single-wire interface of the first analog hardware component or the instruction connector, and is used to obtain data from the single-wire interface or send data to be sent to the single-wire interface;

[0058] The data adaptation unit is connected to the first data transceiver unit and the second data transceiver unit, and is used to send the data obtained from the TLM interface and the corresponding data type and / or the data obtained from the single-line interface and the corresponding data type to the data format encapsulation unit; the data adaptation unit is also used to send the data obtained from the data parsing unit to the TLM interface and / or the single-line interface accordingly;

[0059] The data format encapsulation unit is used to encapsulate the data acquired from the data adaptation unit according to the data type, and send the encapsulated data to the first cache queue;

[0060] The data parsing unit is used to obtain data from the second cache queue and send the obtained completion message to the data adaptation unit;

[0061] The socket sending unit is used to obtain data from the first cache queue and send the obtained data through the connection handle;

[0062] The socket receiving unit is used to obtain data through the connection handle and send the obtained data to the second cache queue.

[0063] In this embodiment, through the above-mentioned protocol converter, the first analog hardware components in different processes can achieve more efficient communication without the instruction connector.

[0064] In order to better understand the above protocol converter, Figure 6 The structural block diagram of the protocol converter is shown below. Figure 6 The following is a detailed description, including: Figure 6 Socket-init is the socket initialization unit, Initiator is the first data receiving and sending unit, line is the second data receiving and sending unit, Socket-send is the socket sending unit, Socket-recv is the socket receiving unit, the sending FIFO is the first cache queue, and the receiving FIFO is the second cache queue.

[0065] It should be noted that there are two interfaces for simulating CPU communication with other modules in Gem5: TLM2.0 and single-line communication. The x-connect module is used to convert the TLM2.0 interface and single-line signal into a socket interface between processes.

[0066] It should be noted that the LM2.0 communication method consists of an initiator and a receiver, the initiator is the initiator, and the receiver is the target. TLM2.0 is a point-to-point communication method and cannot complete many-to-many communication by itself. Therefore, Gem5 implements an i-connect bus inside to connect each node to the i-connect. The i-connect completes the routing and exchange of data. The i-connect and each module are connected using the TLM2.0 interface. In Gem5, in addition to the TLM2.0 interface, a small number of single-line signals are still retained for transmission status changes. Socket is a method of communication between processes in an operating system, which can be based on files, networks, etc. Optionally, the present application adopts a file-based approach.

[0067] It should be noted that this application separates the receiving socket from the sending socket in x-connect. Socket-init is used to create a socket and disconnect it. The node of the socket is passed to the x-connect module from the outside as a parameter module.

[0068] The socket transmits data payload and encapsulates the TLM and line signals once to distinguish the TLM data from the single-line signals.

[0069] The following is a detailed description of each part of the x-connect module:

[0070] (1) Socket-init unit: used for socket initialization, mainly to complete the creation and connection of the socket. The socket node path is the input parameter of socket-init. First, determine whether the socket node exists. If it exists, connect to the socket and pass the connection handle to the socket-send module and the socket-recv module; if it does not exist, enter the exception process.

[0071] (2) Socket-send unit: The socket data transmission unit determines whether the transmission FIFO data is empty. When the transmission FIFO is empty, it is in a blocked state and does not occupy any host CPU resources. If it is not empty, it reads the data in the transmission FIFO and sends the data through the transmission socket. The socket-send unit does not perform other operations such as disassembly and encapsulation on the data stream.

[0072] (3) Socket-recv unit: The socket receiving unit reads the socket content in a blocking manner. When the data in the socket is empty, it is in a blocking state and does not occupy any CPU resources. When it is not empty, the socket data is read and placed in the data FIFO. The socket-recv unit does not perform other processing such as parsing and splicing on the data.

[0073] (4) Initiator unit: TLM2.0 Initiator unit supported by Gem5. Interconnected with the internal bus of Gem5. Used to initiate access to the Gem5 hardware simulation logic; provides read and write interfaces for the data adapter unit to call.

[0074] (5) Line unit: used to connect single-line signals and receive or send the status of single-line signals. When a signal is received, the status change of the signal is sent to the data adapter unit. An interface is provided for the data adapter unit to call and actively modify the changes on the single-line signal.

[0075] (6) FIFO unit: The receive FIFO is used to temporarily store the data received from the socket. The transmit FIFO is used to cache the data received from the initiator and line. The FIFO unit stores the data in the order in which it is received, without parsing the data.

[0076] (7) Data adapter unit: The data adapter unit mainly connects two different modules, the TLM initiator interface and the line. Call the initiator module to read or send data. Call the line module to send status signals and receive changes in line status. Send the received TLM data and data type to the data format encapsulation unit. Send the received single-line number status and data type to the data format encapsulation unit. Provide an interface for the data parsing unit to call. According to the data type obtained by the data parsing unit, send TLM data to the TLM initiator interface, send unit data to the single-line interface, or change the status of the specified single-line signal in the line module.

[0077] (8) Data parsing unit: The data in the FIFO is a message in a custom format. However, during the transmission of the socket, or due to the different speeds of reading the cache in the FIFO, packets may be broken or stuck. The data parsing unit reads the data in the FIFO and determines the integrity of each message based on the length field in the custom message. After receiving a complete message, the data is sent to the data adaptation layer.

[0078] (9) Data format encapsulation unit: simply encapsulates the acquired data according to the data source. It is mainly used for the other end to identify whether the data is TLM data or a single-line signal. The encapsulation format is defined as shown in Table 1 below:

[0079] Table 1

[0080] Type Len Payload 1byte 2byte Greater than 1 byte

[0081] Among them, Type: used to identify whether it is line signal data or TLM data; Len: data length; Payload: encapsulated TLM data or single-line signal data. When type indicates that the data is line signal data, payload can transmit the changes of multiple signal lines at a time. Its format is shown in Table 2 below. Among them, L1 and L2 are linenum, and V1 and V2 are the values ​​of their corresponding lines.

[0082] Table 2

[0083] L1 V1 L2 V2 … 2B 1B 2B 1B …

[0084] In an exemplary embodiment, after running N simulated hardware components in the target number of processes, the method further includes: when a second simulated hardware component among the N simulated hardware components runs in a second process and an instruction connector in the computer system simulator runs in the second process, the second simulated hardware component communicates with the instruction connector through a transaction level modeling TLM interface and / or a single-line interface, wherein the instruction connector is used to handle the flow and interaction of instructions, and the target number of processes includes the second process.

[0085] Alternatively, if Figure 5 As shown in the CPU communication diagram before Gem5 modification, the simulated CPU1 and the instruction connector run in the same process, and then the simulated CPU1 and the instruction connector communicate with the instruction connector through the TLM interface and / or the single-wire interface.

[0086] Optionally, the second simulated hardware component is a non-simulated CPU among the N simulated hardware components.

[0087] Optionally, when the first simulated hardware component is a simulated CPU and the second simulated hardware component is a non-simulated CPU among N simulated hardware components, the operating performance of the simulated CPU among the N simulated hardware components can be ensured by the above method.

[0088] Optionally, Gem5 uses two instances, process and thread, to identify the core and thread corresponding to the real CPU. For example, the 8 cores and 16 threads corresponding to the X86 structure correspond to 8 processes and 2 threads / process. When Gem5 is running, all threads are polled and executed in the same module in time slices, which is why multiple simulated CPUs of Gem5 can only occupy one core of a host CPU. In this regard, changes are made to the Gem5 code so that the simulated CPU in Gem5 can run in multiple processes. Two parameters are added to the CPU module parameters: multi-process enable flag and multi-process socket node. The multi-process enable parameter is used to determine whether to use multiple processes. The multi-process socket node is used for data communication between processes. Make logical modifications in the process instance creation code to determine the multi-process enable flag. If the multi-process feature is not enabled, continue the original process. If the multi-process feature is enabled, create a new process, and then create the logic created by the original thread instance in the corresponding CPU. The logic of the CPU module runs in the newly created process. The process creation interface uses the operating system process creation interface. It should be noted that process is the class identifier of the CPU implemented by Gem5, and thread is the class identifier of the CPU thread implemented in Gem5.

[0089] Optionally, when creating the simulated CPU in Gem5, the simulated CPU module is connected to the external bus through the TLM interface and the single-wire signal. Modify Gem5 to modify the relevant code so that the simulated CPU external interface is connected to an x-connect module instance. In this way, the previous code of the simulated CPU module does not need to be modified at all, only the bus connection relationship needs to be changed, and the data sent and received on the interface does not need to be changed.

[0090] It should be noted that the i-connect node previously connected to the CPU in Gem5 is also connected to a connect instance. This way, the i-connect module code does not need to be modified. When creating the connection relationship, you only need to connect the port originally connected to the CPU to the x-connect. The data sent and received on the interface does not need to be changed.

[0091] It should be noted that the connection relationship between the x-connect module connected to the simulated CPU and the external bus is established through the socket interface created by the x-connect module, thereby realizing the communication function between CPU processes.

[0092] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0093] In the present embodiment, a running device for simulating hardware components is also provided to implement the above-mentioned embodiments and preferred implementation modes, which have been described and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the modules described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0094] Figure 7 : is a structural block diagram of a device for simulating the operation of a hardware component according to an embodiment of the present application, the device comprising:

[0095] A first determination module 702 is used to determine the number of simulated hardware components in the computer system simulator;

[0096] A second determining module 704 is used to determine a target number of processes to be created according to the number of the simulated hardware components and the number of cores of the CPU of the host when the number of the simulated hardware components is greater than or equal to 2, wherein the computer system simulator runs on the host and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU;

[0097] The processing module 706 is used to create the target number of processes and run N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the CPU of the host, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

[0098] Through the above-mentioned device, N simulated hardware components in the computer system simulator are run in multiple processes, each process is scheduled to a core of the host's CPU, and each process is scheduled to a different core, thereby utilizing the host's CPU resources to a greater extent, improving the operating efficiency of the computer system simulator, and solving the problem of low operating efficiency of the computer system simulator.

[0099] In an exemplary embodiment, the second determination module 704 is also used to determine the target number as the number of simulated hardware components when the number of simulated hardware components is less than or equal to the number of cores of the host's CPU; and to determine the target number as the number of cores of the host's CPU when the number of simulated hardware components is greater than or equal to the number of cores of the host's CPU.

[0100] In an exemplary embodiment, the processing module 706 is also used to, when the target number is the number of the simulated hardware components, run each of the N simulated hardware components in one of the target number of processes, and each simulated hardware component runs a different process; when the target number is the number of cores of the CPU of the host, divide the N simulated hardware components into M groups of simulated hardware components, and run each group of the M groups of simulated hardware components in one of the target number of processes, and each group of simulated hardware components runs a different process, wherein M is the target number.

[0101] In an exemplary embodiment, the processing module 706 is also used to, after running N simulated hardware components in the target number of processes, instruct a first simulated hardware component among the N simulated hardware components to communicate with the instruction connector through a socket protocol when the first simulated hardware component is running in a first process and the instruction connector in the computer system simulator is not running in the first process, wherein the instruction connector is used to process the flow and interaction of instructions, and the target number of processes includes the first process.

[0102] In an exemplary embodiment, the processing module 706 is also used to, after running the N simulated hardware components in the target number of processes, instruct a second simulated hardware component among the N simulated hardware components to communicate with the instruction connector through a transaction level modeling TLM interface and / or a single-line interface when the second simulated hardware component is running in a second process and the instruction connector in the computer system simulator is running in the second process, wherein the instruction connector is used to process the flow and interaction of instructions, and the target number of processes includes the second process.

[0103] In an exemplary embodiment, the first analog hardware component is connected to a first protocol converter, the instruction connector is connected to a second protocol converter, the first protocol converter and the second protocol converter communicate with each other via a Socket protocol, the first protocol converter and the second protocol converter are both a type of protocol converter, wherein the first analog hardware component and the instruction connector both have a TLM interface and a single-wire interface, the protocol converter is used to convert data acquired via the TLM interface and / or the single-wire interface into Socket protocol data, and to convert Socket protocol data into data to be sent via the TLM interface and / or the single-wire interface.

[0104] In an exemplary embodiment, the protocol converter includes: a socket initialization unit, a first data transceiver unit, a second data transceiver unit, a socket sending unit, a socket receiving unit, a data adaptation unit, a data format encapsulation unit, a data parsing unit, a first cache queue, and a second cache queue; wherein the socket initialization unit is used to complete the creation and connection of the socket, and pass the generated connection handle to the socket sending unit and the socket receiving unit, wherein the connection handle is an identifier used to identify a specific network connection; the first data transceiver unit is connected to the TLM interface of the first analog hardware component or the instruction connector, and is used to obtain data from the TLM interface or send the data to be sent to the TLM interface; the second data transceiver unit is connected to the single-line interface of the first analog hardware component or the instruction connector, and is used to obtain data from the single-line interface or send the data to be sent to the single-line interface; The data adaptation unit is connected to the first data transceiver unit and the second data transceiver unit, and is used to send the data obtained from the TLM interface and the corresponding data type and / or the data obtained from the single-line interface and the corresponding data type to the data format encapsulation unit; the data adaptation unit is also used to send the data obtained from the data parsing unit to the TLM interface and / or the single-line interface accordingly; the data format encapsulation unit is used to encapsulate the data obtained from the data adaptation unit according to the data type, and send the encapsulated data to the first cache queue; the data parsing unit is used to obtain data from the second cache queue and send the obtained completion message to the data adaptation unit; the socket sending unit is used to obtain data from the first cache queue and send the obtained data through the connection handle; the socket receiving unit is used to obtain data through the connection handle and send the obtained data to the second cache queue.

[0105] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0106] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0107] Optionally, in this embodiment, the computer program may be configured to perform the following steps by means of the computer program:

[0108] S1, determining the number of simulated hardware components in the computer system simulator;

[0109] S2, when the number of the simulated hardware components is greater than or equal to 2, determining a target number of processes to be created according to the number of the simulated hardware components and the number of cores of the CPU of the host, wherein the computer system simulator runs on the host, and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU;

[0110] S3, creating the target number of processes, and running N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the CPU of the host, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

[0111] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0112] The embodiment of the present application also provides an electronic device, such as Figure 8 As shown, the electronic device includes a memory 802 and a processor 804. The memory 802 stores a computer program, and the processor 804 is configured to execute the steps in any of the above method embodiments through the computer program.

[0113] Optionally, in this embodiment, the processor 804 may be configured to perform the following steps through a computer program:

[0114] S1, determining the number of simulated hardware components in the computer system simulator;

[0115] S2, when the number of the simulated hardware components is greater than or equal to 2, determining a target number of processes to be created according to the number of the simulated hardware components and the number of cores of the CPU of the host, wherein the computer system simulator runs on the host, and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU;

[0116] S3, creating the target number of processes, and running N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the CPU of the host, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

[0117] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0118] Alternatively, a person skilled in the art may understand that: Figure 8 The structure shown is for illustration only. Figure 8 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 8 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 8 Different configurations shown.

[0119] Among them, the memory 802 can be used to store software programs and modules, such as the program instructions / modules corresponding to the operating method of the simulated hardware component and the operating device of the simulated hardware component in the embodiment of the present application. The processor 804 executes various functional applications and data processing by running the software programs and modules stored in the memory 802, that is, realizing the operating method of the simulated hardware component mentioned above. The memory 802 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 802 may further include a memory remotely arranged relative to the processor 804, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks and combinations thereof. Among them, the memory 802 can be specifically but not limited to being used to store information such as system configuration files. As an example, such as Figure 8 As shown, the memory 802 may include, but is not limited to, the first determination module 702, the second determination module 704, and the processing module 706 in the operating device of the simulated hardware component. In addition, other module units in the operating device of the simulated hardware component may also be included but are not limited to, which will not be described in detail in this example.

[0120] Optionally, the transmission device 806 is used to receive or send data via a network. Specific examples of the network may include wired networks and wireless networks. In one example, the transmission device 806 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 806 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0121] In addition, the electronic device further includes: a display 808; and a connection bus 810, which is used to connect various module components in the electronic device.

[0122] In other embodiments, the electronic device may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes in the form of network communication. Among them, the nodes may form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.

[0123] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0124] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0125] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the above method embodiments.

[0126] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0127] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for simulating the operation of a hardware component, characterized in that: include: determining the number of simulated hardware components in a computer system simulator; When the number of the simulated hardware components is greater than or equal to 2, determining a target number of processes to be created according to the number of the simulated hardware components and the number of cores of a CPU of a host, wherein the computer system simulator runs on the host, and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU; Create the target number of processes, and run N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the CPU of the host, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

2. The method according to claim 1, characterized in that The step of determining the target number of processes to be created according to the number of the simulated hardware components and the number of cores of the CPU of the host comprises: In a case where the number of the simulated hardware components is less than or equal to the number of cores of the CPU of the host, determining the target number to be the number of the simulated hardware components; When the number of the simulated hardware components is greater than or equal to the number of cores of the CPU of the host, the target number is determined to be the number of cores of the CPU of the host.

3. The method according to claim 2, characterized in that The step of running the N simulated hardware components in the target number of processes includes: When the target number is the number of the simulated hardware components, each of the N simulated hardware components is run in one of the target number of processes, and each simulated hardware component runs a different process; When the target number is the number of cores of the CPU of the host, the N simulated hardware components are divided into M groups of simulated hardware components, and each group of simulated hardware components in the M groups of simulated hardware components is run in one of the processes of the target number, and each group of simulated hardware components runs a different process, where M is the target number.

4. The method according to claim 1, characterized in that After running the N simulated hardware components in the target number of processes, the method further includes: When a first simulated hardware component among the N simulated hardware components runs in a first process and an instruction connector in the computer system simulator does not run in the first process, instruct the first simulated hardware component to communicate with the instruction connector through a socket protocol, wherein the instruction connector is used to handle the flow and interaction of instructions, and the target number of processes includes the first process.

5. The method according to claim 1, characterized in that After running the N simulated hardware components in the target number of processes, the method further includes: When a second simulated hardware component among the N simulated hardware components runs in a second process and an instruction connector in the computer system simulator runs in the second process, instruct the second simulated hardware component to communicate with the instruction connector through a transaction level modeling TLM interface and / or a single-line interface, wherein the instruction connector is used to handle the flow and interaction of instructions, and the target number of processes includes the second process.

6. The method according to claim 4, characterized in that The first analog hardware component is connected to a first protocol converter, and the instruction connector is connected to a second protocol converter. The first protocol converter and the second protocol converter communicate with each other via a Socket protocol. The first protocol converter and the second protocol converter are both a type of protocol converter, wherein the first analog hardware component and the instruction connector both have a TLM interface and a single-wire interface, and the protocol converter is used to convert data acquired via the TLM interface and / or the single-wire interface into data of the Socket protocol, and to convert data of the Socket protocol into data to be sent via the TLM interface and / or the single-wire interface.

7. The method according to claim 6, characterized in that The protocol converter includes: a socket initialization unit, a first data transceiver unit, a second data transceiver unit, a socket sending unit, a socket receiving unit, a data adaptation unit, a data format encapsulation unit, a data parsing unit, a first cache queue, and a second cache queue; wherein, The socket initialization unit is used to complete the creation and connection of the socket, and pass the generated connection handle to the socket sending unit and the socket receiving unit, wherein the connection handle is an identifier used to identify a specific network connection; The first data transceiver unit is connected to the TLM interface of the first analog hardware component or the instruction connector, and is used to obtain data from the TLM interface or send data to be sent to the TLM interface; The second data transceiver unit is connected to the single-wire interface of the first analog hardware component or the instruction connector, and is used to obtain data from the single-wire interface or send data to be sent to the single-wire interface; The data adaptation unit is connected to the first data transceiver unit and the second data transceiver unit, and is used to send the data obtained from the TLM interface and the corresponding data type and / or the data obtained from the single-line interface and the corresponding data type to the data format encapsulation unit; the data adaptation unit is also used to send the data obtained from the data parsing unit to the TLM interface and / or the single-line interface accordingly; The data format encapsulation unit is used to encapsulate the data acquired from the data adaptation unit according to the data type, and send the encapsulated data to the first cache queue; The data parsing unit is used to obtain data from the second cache queue and send the obtained completion message to the data adaptation unit; The socket sending unit is used to obtain data from the first cache queue and send the obtained data through the connection handle; The socket receiving unit is used to obtain data through the connection handle and send the obtained data to the second cache queue.

8. A device for simulating the operation of a hardware component, characterized in that: include: A first determination module, used to determine the number of simulated hardware components in the computer system simulator; A second determination module is used to determine a target number of processes to be created according to the number of the simulated hardware components and the number of cores of the CPU of the host when the number of the simulated hardware components is greater than or equal to 2, wherein the computer system simulator runs on the host and the target number is greater than or equal to 2 and less than or equal to the number of cores of the CPU; A processing module is used to create the target number of processes and run N simulated hardware components in the target number of processes, wherein each process in the target number of processes is scheduled to a core of the CPU of the host, and each process is scheduled to a different core, and N is the number of the simulated hardware components.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.