A virtual simulation verification method and system based on SystemC
Patent Information
- Application Number
- CN202211100767.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2042-09-09
AI Technical Summary
[0006]为了克服现有技术的不足,本发明提供一种基于SystemC的虚拟仿真验证方法及系统,用于解决现有的虚拟仿真验证系统无法实现仿真设备的动态配置且使用过程繁琐并占用资源的技术问题,从而达到通过网页即可实现虚拟仿真验证,并且可对仿真设备进行动态配置的目的
[0064] (1) This invention can be applied not only to teaching but also to the development of systems in the chip and aerospace fields, thereby improving the productivity of these industries, reducing production costs, and effectively enhancing the competitiveness of products.
Smart Images

Figure CN116306401B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of simulation technology, and specifically to a virtual simulation verification method and system based on SystemC. Background Technology
[0002] Traditional teaching methods largely rely on hands-on learning. Students can easily damage these devices with carelessness, and over time, these devices age and become obsolete, leading to inaccurate results. Furthermore, physical experimental equipment, such as development boards with fixed chip models, requires the purchase of new equipment to learn about new chips, resulting in significant teaching expenses and substantially increasing the school's budget.
[0003] Furthermore, students lack experience and are afraid of damaging valuable equipment such as electronic components when conducting experiments, which makes them hesitant to carry out experiments boldly, thus increasing the difficulty of their learning.
[0004] To address the aforementioned technical challenges, a virtual simulation verification system based on SystemC has been developed. This system allows students to test and debug software without requiring specific hardware. Students can also use it to build circuits, edit and compile code, create and interconnect virtual devices, and interact with virtual devices. By using this system, students can boldly experiment with interconnecting devices without fear of damaging physical equipment, effectively enriching their hands-on skills. This also saves schools a significant amount of money on equipment purchase and maintenance.
[0005] However, due to the language characteristics of SystemC, virtual device components developed based on SystemC must be created and have their ports bound before the SystemC emulation core starts; once started, no new virtual devices can be created. Therefore, most virtual simulation verification systems on the market based on SystemC provide fixed-model development boards and cannot achieve dynamic configuration of simulation devices. Furthermore, existing virtual simulation verification systems require downloading and installing an app, followed by system environment configuration, making the entire process cumbersome and consuming significant computer system resources. Summary of the Invention
[0006] To overcome the shortcomings of existing technologies, this invention provides a virtual simulation verification method and system based on SystemC, which solves the technical problems that existing virtual simulation verification systems cannot achieve dynamic configuration of simulation equipment and have a cumbersome and resource-intensive process. This invention achieves the goal of realizing virtual simulation verification through a webpage and enabling dynamic configuration of simulation equipment.
[0007] To solve the above problems, the technical solution adopted by the present invention is as follows:
[0008] Determine if a drag event has occurred; if so, generate the corresponding circuit configuration information.
[0009] The circuit configuration information is passed to the backend simulation model, which dynamically selects virtual device components from the virtual device component library based on the circuit configuration information to complete the construction of the virtual circuit.
[0010] Upon receiving the start command and the first run command, the backend simulation model is started, and a simulation command is output to the virtual CPU according to the received first run command.
[0011] After receiving the simulation instruction, the virtual CPU outputs a second running instruction to the virtual peripheral device.
[0012] After receiving the second running instruction, the virtual peripheral device executes the corresponding simulation action, generates the corresponding simulation data, and transmits the simulation data to the front end.
[0013] The front end displays the corresponding simulation results based on the received simulation data;
[0014] The virtual device components include a virtual CPU and virtual peripheral devices.
[0015] In a preferred embodiment of the present invention, the process of constructing the virtual circuit includes:
[0016] After receiving the circuit configuration information, the backend virtual simulation model parses the circuit configuration information;
[0017] Based on the parsing results, load the virtual component library, register the virtual device component type and virtual device component port information, and create the corresponding virtual device component;
[0018] Based on the parsing results, the ports of the virtual device components are grouped and managed according to their binding relationships;
[0019] A corresponding signal is created based on the port type of the virtual device component, and the port of the virtual device component is bound based on the signal.
[0020] In a preferred embodiment of the present invention, the creation of the corresponding virtual device component includes:
[0021] After receiving the circuit configuration information, the backend simulation model converts the circuit configuration information into a JSON object, and parses the JSON object by accessing a predefined first hook function. The parsing process includes:
[0022] The first hook function first determines whether the JSON object conforms to a predefined format;
[0023] If so, the virtual device component library is dynamically loaded according to the relevant fields in the JSON object, the virtual device type is registered, the virtual device component is created, and the already created virtual device component is registered.
[0024] In a preferred embodiment of the present invention, when managing the ports of the virtual device components in groups according to binding relationships, the following is included:
[0025] The backend simulation model predefines a global list of port information;
[0026] After the backend simulation model registers the created virtual device components, the backend simulation model registers the port binding information of the virtual device components by accessing the predefined second hook function. The registration process includes:
[0027] The second hook function first parses the port binding information of the virtual device component, and then registers the ports with mutual binding relationships into a list of the global port information list.
[0028] In a preferred embodiment of the present invention, binding the port of the virtual device component includes:
[0029] The backend simulation model traverses the global port information list by accessing a predefined third hook function to obtain the port name of each virtual device component;
[0030] And based on the port name, the corresponding port address and port type are obtained from the global port information list;
[0031] The backend simulation model calls the corresponding port binding function through the predefined fourth hook function and the obtained master and slave port types, and creates the signal of the master port through the port binding function, and completes the binding between ports according to the signal.
[0032] In a preferred embodiment of the present invention, the process of building and simulating the virtual circuit further includes:
[0033] The circuit configuration information is parsed, corresponding virtual device components are created, and corresponding network communication functions are registered for the virtual device components to complete the construction of the virtual circuit.
[0034] Start the backend simulation model, create a network communication thread, and predefine the corresponding network communication protocol;
[0035] The backend simulation model will receive the first running instruction and then output a simulation instruction to the virtual device component to debug the virtual device component. The virtual device component will generate corresponding simulation data.
[0036] The virtual device component encapsulates the simulation data according to a preset network communication protocol data frame format to obtain the corresponding encapsulated data.
[0037] The encapsulated data is fed back to the front end in real time by calling the hook function pointer, and the front end renders and displays the encapsulated data in real time.
[0038] According to a predefined network communication protocol, the encapsulated data is fed back to the backend simulation model in real time through the network communication thread, and the backend simulation model parses the encapsulated data and makes corresponding responses in real time.
[0039] In a preferred embodiment of the present invention, when the encapsulated data is fed back to the backend simulation model in real time through the network communication thread, the following is included:
[0040] The backend simulation model creates a network communication thread through a predefined fifth hook function, and receives encapsulated data generated from the virtual device component in real time through the network communication thread;
[0041] After receiving the encapsulated data, the network communication thread calls the SystemC-based thread lock to wake up the SystemC emulation core thread, while blocking its own thread.
[0042] After receiving the encapsulated data through the SystemC emulation core thread, the SystemC emulation core calls the SystemC data processing coroutine.
[0043] The SystemC data processing coroutine calls the hook function of the specific virtual device component to process the encapsulated data based on the ID field in the simulation data;
[0044] The SystemC data processing coroutine waits for one system clock cycle and calls a simple signal to wake up the TCP-based multithreaded process.
[0045] In a preferred embodiment of the present invention, when encapsulating the simulation data according to a preset network communication protocol data frame format, the following steps are included:
[0046] The size of each frame is represented by the first four bytes, and the valid data in the frame is represented by the remaining bytes.
[0047] The valid data is obtained, and its size is obtained through a predefined sixth hook function. Then, the valid data is encapsulated into a JSON-formatted string through a predefined seventh hook function.
[0048] In a preferred embodiment of the present invention, registering the corresponding network communication function for the virtual device component includes:
[0049] Define a function pointer in the virtual device component;
[0050] Once the virtual device component is created, the global send function is assigned to the function pointer;
[0051] The backend simulation model sends data by calling the assigned function pointer;
[0052] Define a data receiving function in the virtual device component;
[0053] Once the virtual device component is created, the data receiving function is registered to the SystemC data processing coroutine.
[0054] The SystemC data processing coroutine parses the received JSON data, and based on the ID field information in the JSON data, finds the object that needs to receive the data in the global object table by name, and then receives the data by calling the data receiving function in the SystemC data processing coroutine.
[0055] A virtual simulation verification system based on SystemC includes:
[0056] Configuration information generation unit: used to generate corresponding circuit configuration information based on the user's drag-and-drop events on the front end;
[0057] Virtual circuit construction unit: used to transmit the circuit configuration information to the back-end simulation model, and the back-end simulation model dynamically selects virtual device components from the virtual device component library according to the circuit configuration information to complete the construction of the virtual circuit;
[0058] Simulation instruction sending unit: After receiving the start instruction and the first run instruction sent by the user through the front end, the back end simulation model is started, and the back end simulation model outputs a simulation instruction to the virtual CPU according to the received first run instruction.
[0059] Run instruction sending unit: used to output a second run instruction to the virtual peripheral device after the virtual CPU receives the simulation instruction;
[0060] Simulation data transmission unit: After the virtual peripheral device receives the second running instruction, it executes the corresponding simulation action, generates the corresponding simulation data, and transmits the simulation data to the front end;
[0061] Display unit: used by the front end to display the corresponding simulation results based on the received simulation data;
[0062] The virtual device components include a virtual CPU and virtual peripheral devices.
[0063] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0064] (1) This invention can be applied not only to teaching but also to the development of systems in the chip and aerospace fields, thereby improving the productivity of these industries, reducing production costs, and effectively enhancing the competitiveness of products.
[0065] (2) When using this invention, there is no need to download an app. You can perform virtual simulation verification online through a webpage by installing a browser. The process is simple and does not require excessive use of computer system resources.
[0066] (3) This invention provides multiple functions such as dynamic circuit diagram construction, online editing, online compilation, online debugging, and real-time data interaction, thereby effectively realizing the dynamic configuration of simulation equipment;
[0067] (4) The present invention effectively improves the reusability of virtual device components, thereby making it convenient for users to dynamically configure the simulation core to the required model or customize the required virtual development board according to their own needs.
[0068] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. Attached Figure Description
[0069] Figure 1 - This is a flowchart illustrating the steps of the virtual simulation verification method based on SystemC according to an embodiment of the present invention;
[0070] Figure 2 - is an interface diagram of the front-end virtual circuit construction in an embodiment of the present invention;
[0071] Figure 3 - This is a schematic diagram of the startup backend simulation system according to an embodiment of the present invention;
[0072] Figure 4 - is an interface diagram of the front end issuing execution instructions in an embodiment of the present invention;
[0073] Figure 5 - This is a flowchart illustrating the dynamic creation and port interconnection of virtual device components according to an embodiment of the present invention;
[0074] Figure 6 - is a schematic diagram of the circuit configuration information generated by the front end in an embodiment of the present invention;
[0075] Figure 7 - is a flowchart of the port binding process of the virtual device component in an embodiment of the present invention;
[0076] Figure 8 - This is a diagram illustrating the dynamic port binding of an embodiment of the present invention. Detailed Implementation
[0077] The SystemC-based virtual simulation verification method provided by this invention, such as... Figure 1 As shown, it includes the following steps:
[0078] Step S1: Determine if a drag event has occurred. If so, generate the corresponding circuit configuration information.
[0079] Step S2: Pass the circuit configuration information to the back-end simulation model. The back-end simulation model dynamically selects virtual device components from the virtual device component library based on the circuit configuration information to complete the construction of the virtual circuit.
[0080] Step S3: After receiving the start command and the first run command, start the backend simulation model and output a simulation command to the virtual CPU according to the received first run command;
[0081] Step S4: After receiving the simulation command, the virtual CPU outputs the second execution command to the virtual peripheral device;
[0082] Step S5: After receiving the second running instruction, the virtual peripheral device executes the corresponding simulation action, generates the corresponding simulation data, and transmits the simulation data to the front end;
[0083] Step S6: The front end displays the corresponding simulation results based on the received simulation data;
[0084] The virtual device components include virtual CPUs and virtual peripheral devices.
[0085] Figure 2 It is a diagram of the front-end virtual circuit construction interface, such as Figure 2 As shown, each image in the device area on the right represents a virtual device component. Users can drag these components to the circuit building area on the left to build virtual circuits. After the circuit is built, a circuit configuration information will be generated, which mainly includes the types of virtual device components used, the names of the virtual device components, and the port binding relationships between the virtual device components.
[0086] Figure 3 This is a diagram illustrating the startup of the backend simulation system, such as... Figure 3As shown, when the user starts the backend simulation system, this circuit configuration information is transmitted to the backend simulation model via TCP in the form of a JSON string. The backend simulation model dynamically selects virtual device components from the virtual component library to build the circuit based on this configuration information. This mainly includes JSON string parsing, virtual component library loading, virtual device component creation, SystemC signal creation, and virtual device component port binding.
[0087] Figure 4 It is a screenshot of the interface where the front-end issues execution commands, such as... Figure 4 As shown, after starting the backend simulation model, the user issues a step-by-step execution command to the simulation model via the step-by-step debugging button on the frontend interface. Upon receiving the code command, the virtual processor sends peripheral instructions to the corresponding virtual peripheral components. Because the virtual device components in this invention are developed using time-level simulation, these virtual device components strictly execute the corresponding functional actions according to the device manual after receiving the command, and encapsulate the generated data into different data protocols based on the device type before sending it to the frontend display interface. After receiving the data sent from the backend virtual devices, the frontend display interface parses it according to the predetermined data protocol type and synchronously applies the parsed data to the frontend device image.
[0088] In step S2 above, as Figure 5 As shown, the process of building a virtual circuit includes:
[0089] After receiving the circuit configuration information, the backend virtual simulation model parses the circuit configuration information;
[0090] Based on the parsing results, load the virtual component library, register the virtual device component type and virtual device component port information, and create the corresponding virtual device component;
[0091] Based on the parsing results, the ports of the virtual device components are grouped and managed according to their binding relationships;
[0092] Create corresponding signals based on the port type of the virtual device component, and bind the ports of the virtual device component according to the signals.
[0093] Most existing virtual simulation verification methods exist in the form of specific simulation model development boards, meaning that the creation and port binding of virtual device components within their systems are statically completed. In contrast, the creation and port binding of virtual device components in this invention are performed dynamically, thereby effectively improving the reusability of virtual device components and allowing users to dynamically configure the simulation core to the required model or customize the virtual development board according to their own needs.
[0094] Furthermore, the circuit configuration information is as follows: Figure 6 As shown.
[0095] like Figure 5 As shown, the user converts the circuit configuration information of the virtual device component into a JSON string through the front end. The JSON string format is as follows: Figure 6 As shown, the "type" field indicates the data protocol type, the "obj_info" field indicates the information of the virtual device component object to be created, and the "bind_info" field indicates the port binding information of the virtual device component. This data is passed to the backend simulation model via TCP / IP protocol when the backend simulation model is started. After obtaining the above JSON string information, the backend simulation model performs the dynamic construction process of the virtual development board, where the port binding process is as follows: Figure 7 As shown.
[0096] Furthermore, when creating the corresponding virtual device components, the following are included:
[0097] After receiving the circuit configuration information, the backend simulation model converts the circuit configuration information into a JSON object and parses the JSON object by accessing the predefined first hook function. The parsing process includes:
[0098] The first hook function checks whether the JSON object conforms to the predefined format;
[0099] If so, then dynamically load the virtual device component library based on the relevant fields in the JSON object, register the virtual device type, create the virtual device component, and register the already created virtual device component.
[0100] Furthermore, the first hook function is obj_config_prase.
[0101] Furthermore, when grouping and managing the ports of virtual device components according to their binding relationships, this includes:
[0102] The backend simulation model predefines a global list of port information;
[0103] After the backend simulation model registers the created virtual device components, it registers the port binding information of the virtual device components by accessing the predefined second hook function. The registration process includes:
[0104] The second hook function first parses the port binding information of the virtual device component, and then registers the ports with mutual binding relationships into a list in the global port information list.
[0105] Furthermore, the global list of port information is module_pins_info, and the second hook function is _bind.
[0106] Furthermore, when binding ports to virtual device components, the following is included:
[0107] The backend simulation model accesses a predefined third hook function to traverse the global list of port information and obtain the port name of each virtual device component;
[0108] And based on the port name, the corresponding port address and port type are obtained from the global port information list;
[0109] The backend simulation model calls the corresponding port binding function through the predefined fourth hook function and the obtained master and slave port types, and creates the signal of the master port through the port binding function, and completes the binding between ports according to the signal.
[0110] Furthermore, the third hook function is pin_bind, the third hook function is vvs_bind_module, the port binding function is out_master_bind, and the signal is an out type signal.
[0111] In steps S2 to S6 above, the process of building and simulating the virtual circuit also includes:
[0112] Parse the circuit configuration information, create the corresponding virtual device components, and register the corresponding network communication functions for the virtual device components to complete the construction of the virtual circuit;
[0113] Start the backend simulation model, create a network communication thread, and predefine the corresponding network communication protocol;
[0114] The backend simulation model outputs a simulation instruction to the virtual device component after receiving the first running instruction, and debugs the virtual device component, which then generates corresponding simulation data.
[0115] The virtual device component encapsulates the simulation data according to the preset network communication protocol data frame format to obtain the corresponding encapsulated data;
[0116] By calling hook function pointers, the encapsulated data is fed back to the front end in real time, and the front end renders and displays the encapsulated data in real time.
[0117] According to a predefined network communication protocol, the encapsulated data is fed back to the backend simulation model in real time through the network communication thread. The backend simulation model parses the encapsulated data and responds accordingly in real time.
[0118] After the user starts the backend simulation model, the virtual device components generate corresponding simulation data during operation. These virtual device components, such as virtual temperature sensor devices, may also require data to be transmitted from the frontend. Since the virtual simulation verification method provided in this invention is a time-series simulation method, real-time data transmission between the frontend and backend is necessary. Figure 8 As shown, the backend simulation model communicates with the frontend using the TCP / IP protocol, and the backend simulation model has two communication methods: sending and receiving.
[0119] To ensure the real-time nature of data transmission between the front-end and back-end, the back-end data sending function is called within the SystemC runtime environment. That is, when the back-end virtual device component generates data, the hook function pointer net_send is called to send the data to the front-end, and the front-end renders and displays this data in real time.
[0120] Furthermore, when feeding the encapsulated data back to the backend simulation model in real time via a network communication thread, this includes:
[0121] The backend simulation model creates a network communication thread through a predefined fifth hook function, and receives encapsulated data generated by the virtual device component in real time through the network communication thread;
[0122] After receiving the encapsulated data, the network communication thread calls the SystemC-based thread lock to wake up the SystemC emulation core thread, while blocking its own thread.
[0123] After receiving the encapsulated data through the SystemC emulation core thread, the SystemC emulation core calls the SystemC data processing coroutine.
[0124] The SystemC data processing coroutine calls the hook function of the specific virtual device component to process the encapsulated data based on the ID field in the simulation data;
[0125] The SystemC data processing coroutine waits for one system clock cycle and calls a simple signal to wake up a TCP-based multithreaded system.
[0126] Furthermore, the fifth hook function is start_tcp_pthread, the thread lock is thread_safe_event, the hook function is net_recv, the simple signal is simple_signal, and TCP-based multithreading is start_tcp_pthread.
[0127] Furthermore, when encapsulating the simulation data according to the preset network communication protocol data frame format, it includes:
[0128] The size of each frame is represented by the first four bytes, and the valid data in the frame is represented by the remaining bytes.
[0129] The system retrieves valid data, obtains the size of the valid data through a predefined sixth hook function, and then encapsulates the valid data into a JSON-formatted string through a predefined seventh hook function.
[0130] Furthermore, the sixth hook function is json_len, and the seventh hook function is to_json.
[0131] Furthermore, when registering the corresponding network communication functions for virtual device components, the following is included:
[0132] Define a function pointer in the virtual device component;
[0133] Once the virtual device component is created, the global send function is assigned to the function pointer;
[0134] The backend simulation model sends data by calling the assigned function pointer;
[0135] Define a data receiving function in the virtual device component;
[0136] Once the virtual device component is created, the data receiving function is registered to the SystemC data processing coroutine;
[0137] The SystemC data processing coroutine parses the received JSON data, and based on the ID field information in the JSON data, finds the object that needs to receive the data in the global object table by name, and then receives the data by calling the data receiving function in the SystemC data processing coroutine.
[0138] Furthermore, the function pointer is net_send, the global send function is send_data, and the data receive function is net_recv.
[0139] Furthermore, to ensure that the front-end and back-end can correctly parse communication data, this invention predefines different network communication protocols based on the type of the back-end virtual device component and the characteristics of the virtual device data. For example, for virtual serial port device communication, the specific data protocol format is as follows: {"type":"uart_type","id":"uart_monitor1.TXD","baud_rate":"115200","data_length":"8","data":"0X0a","check_mode":"0","check_value":"0","stop_length":"1"}, where the "type" field indicates the data protocol type, the "id" field indicates the specific virtual device and its corresponding device pin, the "baud_rate" field indicates the serial port baud rate, the "data_length" field indicates the serial port data length, "data" indicates the serial port data, the "check_mode" field indicates the verification module, and the "check_value" field indicates the checksum.
[0140] The virtual simulation verification system based on SystemC provided by this invention includes:
[0141] Configuration information generation unit: used to generate corresponding circuit configuration information based on the user's drag-and-drop events on the front end;
[0142] Virtual circuit construction unit: used to pass circuit configuration information to the back-end simulation model. The back-end simulation model dynamically selects virtual device components from the virtual device component library according to the circuit configuration information to complete the construction of the virtual circuit.
[0143] Simulation instruction sending unit: After receiving the start instruction and the first run instruction sent by the user through the front end, the back-end simulation model is started. After starting, the back-end simulation model outputs a simulation instruction to the virtual CPU according to the received first run instruction.
[0144] Run instruction sending unit: used to output a second run instruction to the virtual peripheral device after the virtual CPU receives the simulation instruction;
[0145] Simulation data transmission unit: After the virtual peripheral device receives the second running instruction, it executes the corresponding simulation action, generates the corresponding simulation data, and transmits the simulation data to the front end;
[0146] Display unit: Used by the front end to display the corresponding simulation results based on the received simulation data;
[0147] The virtual device components include virtual CPUs and virtual peripheral devices.
[0148] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0149] (1) This invention can be applied not only to teaching but also to the development of systems in the chip and aerospace fields, thereby improving the productivity of these industries, reducing production costs, and effectively enhancing the competitiveness of products.
[0150] (2) When using this invention, there is no need to download an app. You can perform virtual simulation verification online through a webpage by installing a browser. The process is simple and does not require excessive use of computer system resources.
[0151] (3) This invention provides multiple functions such as dynamic circuit diagram construction, online editing, online compilation, online debugging, and real-time data interaction, thereby effectively realizing the dynamic configuration of simulation equipment;
[0152] (4) The present invention effectively improves the reusability of virtual device components, thereby making it convenient for users to dynamically configure the simulation core to the required model or customize the required virtual development board according to their own needs.
[0153] The above embodiments are merely preferred embodiments of the present invention and should not be construed as limiting the scope of protection of the present invention. Any non-substantial changes and substitutions made by those skilled in the art based on the present invention shall fall within the scope of protection claimed by the present invention.
Claims
1. A virtual simulation verification method based on SystemC, characterized in that, Includes the following steps: Determine if a drag event has occurred; if so, generate the corresponding circuit configuration information. The circuit configuration information is passed to the backend simulation model, which dynamically selects virtual device components from the virtual device component library based on the circuit configuration information to complete the construction of the virtual circuit. Upon receiving the start command and the first run command, the backend simulation model is started, and a simulation command is output to the virtual CPU according to the received first run command. After receiving the simulation instruction, the virtual CPU outputs a second running instruction to the virtual peripheral device. After receiving the second running instruction, the virtual peripheral device executes the corresponding simulation action, generates the corresponding simulation data, and transmits the simulation data to the front end. The front end displays the corresponding simulation results based on the received simulation data; The virtual device component includes a virtual CPU and virtual peripheral devices; When creating the corresponding virtual device components, the following are included: After receiving the circuit configuration information, the backend simulation model converts the circuit configuration information into a JSON object, and parses the JSON object by accessing a predefined first hook function. The parsing process includes: The first hook function first determines whether the JSON object conforms to a predefined format; If so, then dynamically load the virtual device component library according to the relevant fields in the JSON object, register the virtual device type, create the virtual device component, and register the already created virtual device component; When managing the ports of the virtual device components in groups according to their binding relationships, the following is included: The backend simulation model predefines a global list of port information; After the backend simulation model registers the created virtual device components, the backend simulation model registers the port binding information of the virtual device components by accessing the predefined second hook function. The registration process includes: The second hook function first parses the port binding information of the virtual device component, and then registers the ports with mutual binding relationships into a list of the global port information list.
2. The virtual simulation verification method based on SystemC according to claim 1, characterized in that, The process of building a virtual circuit includes: After receiving the circuit configuration information, the backend virtual simulation model parses the circuit configuration information; Based on the parsing results, load the virtual device component library, register the virtual device component type and virtual device component port information, and create the corresponding virtual device component; Based on the parsing results, the ports of the virtual device components are grouped and managed according to their binding relationships; A corresponding signal is created based on the port type of the virtual device component, and the port of the virtual device component is bound based on the signal.
3. The virtual simulation verification method based on SystemC according to claim 2, characterized in that, Binding the port of the virtual device component includes: The backend simulation model traverses the global port information list by accessing a predefined third hook function to obtain the port name of each virtual device component; And based on the port name, the corresponding port address and port type are obtained from the global port information list; The backend simulation model calls the corresponding port binding function through the predefined fourth hook function and the obtained master and slave port types, and creates the signal of the master port through the port binding function, and completes the binding between ports according to the signal.
4. The virtual simulation verification method based on SystemC according to claim 1, characterized in that, The process of building and simulating virtual circuits also includes: The circuit configuration information is parsed, corresponding virtual device components are created, and corresponding network communication functions are registered for the virtual device components to complete the construction of the virtual circuit. Start the backend simulation model, create a network communication thread, and predefine the corresponding network communication protocol; The backend simulation model will output a simulation instruction to the virtual device component after receiving the first running instruction, and debug the virtual device component. The virtual device component will generate corresponding simulation data. The virtual device component encapsulates the simulation data according to a preset network communication protocol data frame format to obtain the corresponding encapsulated data. The encapsulated data is fed back to the front end in real time by calling the hook function pointer, and the front end renders and displays the encapsulated data in real time. According to a predefined network communication protocol, the encapsulated data is fed back to the backend simulation model in real time through the network communication thread, and the backend simulation model parses the encapsulated data and makes corresponding responses in real time.
5. The virtual simulation verification method based on SystemC according to claim 4, characterized in that, When feeding back the encapsulated data to the backend simulation model in real time via the network communication thread, the following is included: The backend simulation model creates a network communication thread through a predefined fifth hook function, and receives encapsulated data generated from the virtual device component in real time through the network communication thread; After receiving the encapsulated data, the network communication thread calls the SystemC-based thread lock to wake up the SystemC emulation core thread, while blocking its own thread. After receiving the encapsulated data through the SystemC emulation core thread, the SystemC emulation core calls the SystemC data processing coroutine. The SystemC data processing coroutine calls the hook function of the specific virtual device component to process the encapsulated data based on the ID field in the simulation data.
6. The virtual simulation verification method based on SystemC according to claim 4, characterized in that, When encapsulating the simulation data according to a preset network communication protocol data frame format, the following steps are included: The size of each frame is represented by the first four bytes, and the valid data in the frame is represented by the remaining bytes. The valid data is obtained, and its size is obtained through a predefined sixth hook function. Then, the valid data is encapsulated into a JSON-formatted string through a predefined seventh hook function.
7. The virtual simulation verification method based on SystemC according to claim 4, characterized in that, When registering the corresponding network communication functions for the virtual device component, the following is included: Define a function pointer in the virtual device component; Once the virtual device component is created, the global send function is assigned to the function pointer; The backend simulation model sends data by calling the assigned function pointer; Define a data receiving function in the virtual device component; Once the virtual device component is created, the data receiving function is registered to the SystemC data processing coroutine. The SystemC data processing coroutine parses the received JSON data, and based on the ID field information in the JSON data, finds the object that needs to receive the data in the global object table by name, and then receives the data by calling the data receiving function in the SystemC data processing coroutine.
8. A virtual simulation verification system based on SystemC, characterized in that, include: Configuration information generation unit: used to generate corresponding circuit configuration information based on the user's drag-and-drop events on the front end; Virtual circuit construction unit: used to transmit the circuit configuration information to the back-end simulation model, and the back-end simulation model dynamically selects virtual device components from the virtual device component library according to the circuit configuration information to complete the construction of the virtual circuit; Simulation instruction sending unit: After receiving the start instruction and the first run instruction sent by the user through the front end, the back end simulation model is started, and the back end simulation model outputs a simulation instruction to the virtual CPU according to the received first run instruction. Run instruction sending unit: used to output a second run instruction to the virtual peripheral device after the virtual CPU receives the simulation instruction; Simulation data transmission unit: After the virtual peripheral device receives the second running instruction, it executes the corresponding simulation action, generates the corresponding simulation data, and transmits the simulation data to the front end; Display unit: used by the front end to display the corresponding simulation results based on the received simulation data; The virtual device component includes a virtual CPU and virtual peripheral devices; When creating the corresponding virtual device components, the following are included: After receiving the circuit configuration information, the backend simulation model converts the circuit configuration information into a JSON object, and parses the JSON object by accessing a predefined first hook function. The parsing process includes: The first hook function first determines whether the JSON object conforms to a predefined format; If so, then dynamically load the virtual device component library according to the relevant fields in the JSON object, register the virtual device type, create the virtual device component, and register the already created virtual device component; When managing the ports of the virtual device components in groups according to their binding relationships, the following is included: The backend simulation model predefines a global list of port information; After the backend simulation model registers the created virtual device components, the backend simulation model registers the port binding information of the virtual device components by accessing the predefined second hook function. The registration process includes: The second hook function first parses the port binding information of the virtual device component, and then registers the ports with mutual binding relationships into a list of the global port information list.
Citation Information
Patent Citations
Model integration method and device for online reloading of simulation models
CN111522731A