Endpoint device emulation system, transaction layer packet processing method, and electronic device
By introducing a function body distribution module into the SystemC simulation platform, the problem that the EP device simulation model cannot support multi-function features is solved, realizing comprehensive simulation of multi-function PCIe devices and improving the functional completeness and application value of the simulation model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINAN MAIWEI INTELLIGENT TECHNOLOGY CO LTD
- Filing Date
- 2026-05-20
- Publication Date
- 2026-06-19
AI Technical Summary
The existing EP device simulation model in the SystemC simulation platform only supports basic simulation of a single function, which cannot meet the multi-function characteristics of complex PCIe devices and makes it difficult to achieve comprehensive and realistic modeling and simulation.
An endpoint device simulation system is provided, including a function distribution module, which includes a receiving and parsing unit, a type identification unit, a function identification unit, and a transaction layer packet forwarding unit. These units enable addressing, routing, and independent processing of multiple functions, and support the simulation of multiple function features.
It enables comprehensive and realistic modeling and simulation of multi-function PCIe devices, improving the functional completeness and application value of the simulation model, and is suitable for driver verification and system integration in the chip design stage.
Smart Images

Figure CN122240244A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of chip simulation technology, and in particular to endpoint device simulation systems, transaction layer packet processing methods, and electronic devices. Background Technology
[0002] With the rapid development of chip technology, chip simulation systems are increasingly widely used. SystemC, as a commonly used modeling and simulation tool, has significant application value in the research of Peripheral Component Interconnect Express (PCIe) devices, enabling system-level modeling and verification of PCIe device functions, protocols, and timing. In the PCIe specification, endpoint (EP) devices typically possess multiple functions to support different functional modules. However, the EP device simulation models in the SystemC simulation platform only support basic simulation of single functions, lacking effective support for multi-function characteristics, making it difficult to meet the comprehensive and realistic modeling and simulation needs of complex PCIe devices. Summary of the Invention
[0003] This application provides an endpoint device simulation system, a transaction layer packet processing method, and an electronic device to at least solve the problem that EP device simulation models in related technologies cannot support multi-function features and are difficult to meet the comprehensive and realistic modeling and simulation needs of complex PCIe devices.
[0004] This application provides an endpoint device simulation system, including a function body distribution module; the function body distribution module includes a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit;
[0005] The receiving and parsing unit is used to receive the transaction layer packet to be processed, parse the transaction layer packet to be processed, and obtain the routing and location information of the transaction layer packet to be processed. The type identification unit is used to determine the transaction type of the transaction layer packet to be processed based on the routing and location information of the transaction layer packet to be processed; The functional body identification unit is used to determine the target functional body of the transaction layer packet to be processed based on the routing location information and the transaction type of the transaction layer packet to be processed. The transaction layer packet forwarding unit is used to forward the transaction layer packet to be processed to the target functional body based on the transaction layer packet to be processed, so that the target functional body can process the transaction layer packet to be processed.
[0006] This application also provides a transaction layer packet processing method, applied to any of the above-mentioned endpoint device simulation systems, including: Using the receiving and parsing unit, the transaction layer packet to be processed is received, the transaction layer packet to be processed is parsed, and the routing and location information of the transaction layer packet to be processed is obtained. Using the type recognition unit, the transaction type of the transaction layer packet to be processed is determined based on the routing and location information of the transaction layer packet to be processed; Using the functional body identification unit, the target functional body of the transaction layer packet to be processed is determined based on the routing location information and the transaction type of the transaction layer packet to be processed. The transaction layer packet forwarding unit forwards the transaction layer packet to the target functional body based on the target functional body of the transaction layer packet to be processed, so that the target functional body can process the transaction layer packet to be processed.
[0007] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of the transaction layer packet processing method described above when executing the computer program.
[0008] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the above-described transaction layer packet processing method.
[0009] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described transaction layer packet processing method.
[0010] Through this application, the endpoint device simulation system includes a function body distribution module; the function body distribution module includes a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit; the receiving and parsing unit is used to receive transaction layer packets to be processed, parse the transaction layer packets to be processed, and obtain the routing location information of the transaction layer packets to be processed; the type identification unit is used to determine the transaction type of the transaction layer packets to be processed based on the routing location information of the transaction layer packets to be processed; the function body identification unit is used to determine the target function body of the transaction layer packets to be processed based on the routing location information and the transaction type of the transaction layer packets to be processed; the transaction layer packet forwarding unit is used to forward the transaction layer packets to be processed to the target function body based on the target function body of the transaction layer packets to be processed, so that the target function body can process the transaction layer packets to be processed. By implementing the receiving and parsing unit, type identification unit, function identification unit, and transaction layer packet forwarding unit, the addressing, routing, isolation, and independent processing of multifunction functions based on the PCIe specification are realized, thus achieving the simulation of multifunction function characteristics. Therefore, it can solve the problem that the EP device simulation model in related technologies cannot support multifunction characteristics and is difficult to meet the comprehensive and realistic modeling and simulation requirements of complex PCIe devices, achieving the technical effect of meeting the comprehensive and realistic modeling and simulation requirements of complex PCIe devices. Attached Figure Description
[0011] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of the structure of an EP equipment simulation model in related technologies; Figure 2 This is a schematic diagram of the structure of an endpoint device simulation system provided in an embodiment of this application; Figure 3 A schematic diagram of the structure of another endpoint device simulation system provided in this application embodiment; Figure 4 A flowchart illustrating the workflow of the functional body distribution module provided in this application embodiment; Figure 5 A flowchart illustrating a transaction layer packet processing method provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0014] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0015] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0016] With the rapid development of chip technology, chip simulation systems are being used more and more widely. A chip simulation system is a software tool used to design, verify, and evaluate integrated circuits (chips). It provides a virtual environment that allows design engineers to simulate the behavior of a chip on a computer and to test, debug, and optimize it. From design verification to physical implementation, chip simulation systems play a crucial role in all stages of integrated circuit design, helping design engineers to quickly and accurately verify and optimize chip designs, thereby accelerating product development cycles and improving design quality.
[0017] SystemC simulation systems are computer software or hardware systems used to simulate real-world systems or processes. They are widely used in various fields to study, test, and optimize the behavior and performance of complex systems, and are particularly common in the chip industry for modeling and simulation. Their core value lies in their ability to efficiently model and verify the functionality, protocols, and timing of PCIe devices at the system level. They support Transaction-Level Modeling (TLM) and hardware-software co-simulation, helping to identify and fix problems early in the design process, accelerating development, and improving design quality. SystemC is a collection of C++ libraries and methods that can be used to create models accurate to clock cycles, enabling simulations of software algorithms, hardware architectures, System-on-Chip (SoC) interfaces, and system-level simulations. Through rapid modeling, designs can be verified and optimized, algorithms can be studied, and a feasible system design specification can be provided for software and hardware development.
[0018] The PCIe interface, as a high-performance bus protocol, is widely used in various computer and communication systems. In the PCIe specification, EP devices typically have multiple functions to carry different functional modules, adapting to various service scenarios. EP devices are slave devices based on the PCIe bus protocol, acting as functional modules in the PCIe system, connected to the end of the PCIe bus to receive and respond to various data access and control commands from the PCIe Root Complex (RC). A function is the basic functional unit of a PCIe device. Each PCIe device can contain one or more functions, and each function is considered an independent logical device with its own configuration space, base address register (BAR), and other resources.
[0019] Figure 1 This is a structural schematic diagram of the EP equipment simulation model in related technologies, such as... Figure 1As shown, the EP device simulation model in related technologies includes a transaction distribution and routing module and a resource management module. The transaction distribution and routing module receives PCIe Transaction Layer Packets (TLPs) sent by external modules, determines the corresponding processing function based on the transaction type of the TLP, and enables the functions included in the EP device simulation model to process the TLP using the determined processing function. It should be noted that the EP device simulation model in related technologies includes one function, and all received transaction layer packets are processed by this single function. The resource management module manages the internal resource information of the EP device, including configuration space, BAR space, interrupts, and capabilities. The resource management module includes a configuration space management module, a base address register space resource management module, and other resource management modules. The configuration space management module manages the allocation, reading, and writing of configuration space. The base address register space resource management module comprehensively manages the address space resources in the PCIe EP device that can be enumerated and mapped by the system, specifically including resource description, allocation, mapping, access control, and transaction response processing. Other resource management modules are used to manage resources other than configuration space and BAR space.
[0020] It is evident that the EP device simulation model in the SystemC simulation platform of related technologies only supports basic simulation of a single function and lacks effective support for multi-function features, making it difficult to meet the comprehensive and realistic modeling and simulation needs of complex PCIe devices.
[0021] Specifically, the EP device simulation model in the relevant technology has the following shortcomings: 1. It does not support the transaction distribution and processing mechanism based on Function; 2. It cannot simulate the real working characteristics of EP devices with multiple functions on the PCIe bus; 3. It limits the development of software drivers and the joint debugging and verification in multi-Function scenarios.
[0022] Therefore, there is a need for an EP device simulation model that can support multiple functions, enabling complete and accurate simulation of real PCIe devices with multiple functions, thereby improving the functionality and application value of the simulation model.
[0023] To address the aforementioned technical problems, embodiments of this application provide an endpoint device simulation system, a transaction layer packet processing method, and an electronic device. The switching device simulation system includes a function body distribution module; the function body distribution module includes a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit; the receiving and parsing unit is used to receive transaction layer packets to be processed, parse the transaction layer packets to be processed, and obtain the routing location information of the transaction layer packets to be processed; the type identification unit is used to determine the transaction type of the transaction layer packets to be processed based on the routing location information of the transaction layer packets to be processed; the function body identification unit is used to determine the target function body of the transaction layer packets to be processed based on the routing location information and the transaction type of the transaction layer packets to be processed; the transaction layer packet forwarding unit is used to forward the transaction layer packets to be processed to the target function body based on the target function body of the transaction layer packets to be processed, so that the target function body can process the transaction layer packets to be processed. The system provided by the above solution realizes the addressing, routing, isolation and independent processing of multi-function bodies based on the PCIe specification through the receiving and parsing unit, type identification unit, function body identification unit and transaction layer packet forwarding unit. That is, it realizes the simulation of multi-function body characteristics. Therefore, it can solve the problem that the EP device simulation model in related technologies cannot support multi-function characteristics and is difficult to meet the comprehensive and realistic modeling and simulation requirements of complex PCIe devices. It achieves the technical effect of meeting the comprehensive and realistic modeling and simulation requirements of complex PCIe devices.
[0024] The endpoint device simulation system provided in this application is a simple extension of the endpoint device simulation model in the related technology that does not support multiple functions. It can support transaction identification and simulation functions of multiple functions without modifying the PCIe protocol stack implementation and the endpoint device simulation model implementation in the related technology. The model structure is clear and the functional module boundaries are well defined. It is suitable for driver verification, system integration and debugging and complex device modeling scenarios in the chip design stage.
[0025] Embodiments of this application provide an endpoint device simulation system. Figure 2 This is a schematic diagram of the structure of the endpoint device simulation system provided in the embodiments of this application, such as... Figure 2 As shown, the endpoint device simulation system includes a function body distribution module. The function body distribution module includes a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit.
[0026] The receiving and parsing unit is used to receive the transaction layer packets to be processed, parse the transaction layer packets to be processed, and obtain the routing and location information of the transaction layer packets to be processed.
[0027] The transaction layer packets to be processed can originate from an external PCIe link, specifically from an external PCIe root multiplexing port. They can also originate from functions within the EP device emulation system. A transaction layer packet is essentially a transaction layer data packet.
[0028] Routing location information is used to determine the target functional body of the transaction layer packet to be processed. The receiving and parsing unit, as the front-end unit of the functional body distribution module, serves as the transaction entry point, providing necessary raw data support and a parsing foundation for subsequent operations such as type identification, functional body identification, validity verification, and transaction layer packet forwarding. Through modular design, this receiving and parsing unit supports unified access and processing of transaction layer packets from different sources, ensuring that various TLPs can be consistently and accurately identified and forwarded in the simulation environment.
[0029] After obtaining the routing location information of the transaction layer packet to be processed, the receiving and parsing unit completes the format unification and semantic standardization processing of the routing location information according to the PCIe protocol specification.
[0030] The type identification unit is used to determine the transaction type of the transaction layer packet to be processed based on the routing location information of the transaction layer packet to be processed.
[0031] The transaction types include memory transaction type, input / output (IO) transaction type, configuration transaction type, completion (Cpl) transaction type, completion with data (CplD) transaction type, and message transmission transaction type.
[0032] Memory transaction types include memory read and write; input / output transaction types include IO read and write; configuration transaction types include type 0 configuration transactions and type 1 configuration transactions.
[0033] The functional body identification unit is used to determine the target functional body of the transaction layer packet to be processed based on the routing location information and the transaction type of the transaction layer packet to be processed.
[0034] The transaction layer packet forwarding unit is used to forward the transaction layer packet to be processed to the target functional body based on the transaction layer packet to be processed, so that the target functional body can process the transaction layer packet to be processed.
[0035] The endpoint device simulation system provided in this application realizes the addressing, routing, isolation, and independent processing of multi-function bodies based on the PCIe specification through a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit. That is, it realizes the simulation of multi-function body characteristics. Therefore, it can solve the problem that the EP device simulation model in related technologies cannot support multi-function characteristics and is difficult to meet the comprehensive and realistic modeling and simulation requirements of complex PCIe devices. It achieves the technical effect of meeting the comprehensive and realistic modeling and simulation requirements of complex PCIe devices.
[0036] The endpoint device simulation system provided in this application solves the problem that the EP device simulation model in related technologies cannot effectively identify multiple functions and perform accurate transaction distribution. It has high scalability and simulation consistency and is suitable for verification and joint debugging scenarios of complex PCIe systems.
[0037] In some optional implementations, the receiving and parsing unit is specifically used for: Receive the transaction layer packet to be processed through the transaction-level modeling interface.
[0038] By directly accessing the original data of the transaction layer packet to be processed using the original data pointer provided in the transaction-level modeling interface, the secondary copying operation of the data content is avoided, thereby improving simulation efficiency.
[0039] Obtain the raw data pointer provided by the transaction-level modeling interface, which points to the raw data of the transaction layer package to be processed.
[0040] The original data pointer is converted into a pointer to a predefined union data structure type. Through the member variables of the predefined union data structure, the transaction layer packet to be processed is directly accessed and parsed to obtain the routing and location information of the transaction layer packet to be processed.
[0041] The predefined union data structure includes member variables for mapping routing location information of the transaction layer packets to be processed, which includes at least header information.
[0042] To achieve efficient parsing, the receiving and parsing units employ a predefined union pointer approach for structured access to the transaction layer packets to be processed. By forcibly casting the raw data pointer to a union type, the system can directly access and parse the required field parameters, i.e., routing and location information, through union member variables, without the need for repeated field-level extraction or manual offset calculations. This method not only improves the efficiency and conciseness of field parsing but also effectively reduces potential offset errors or redundant operations during parsing, making it suitable for high-performance simulation environments with large-scale TLP pipeline processing.
[0043] The endpoint device simulation system provided in this application receives transaction layer packets through a transaction-level modeling interface and directly maps the raw data pointer to a predefined union data structure. It can directly access and parse transaction layer packets with zero copying and high efficiency, quickly obtain routing location information, greatly improve the efficiency of data packet parsing, simplify the parsing logic, reduce code complexity, and ensure the real-time and high efficiency of routing processing.
[0044] In some optional implementations, the routing location information includes header information, which includes a data type field and a data format field. The type identification unit is specifically used for: Based on the data type and data format fields in the routing location information of the transaction layer packet to be processed, the transaction type of the transaction layer packet to be processed is determined.
[0045] The type identification unit receives the routing location information parsed by the receiving and parsing unit. Based on the data type (Type) and data format (Fmt) fields in the header information of the routing location information, it determines the transaction type of the transaction layer packet to be processed. According to the PCIe protocol definition, this type identification unit can identify and distinguish memory transaction types, input / output transaction types, configuration transaction types, completion transaction types, completion transaction types with data types, and message transmission transaction types. The identification result will serve as an important basis for subsequent target function body identification.
[0046] The endpoint device simulation system provided in this application embodiment can quickly and accurately identify transaction types by directly extracting the data type field and data format field from the routing location information, without having to parse the entire data packet. This greatly improves the efficiency of type judgment, provides an accurate basis for subsequent route distribution and transaction processing, and ensures the efficiency and accuracy of system processing.
[0047] In some alternative implementations, the functional entity identification unit is specifically used for: Based on the unique identifier of the functional body, the state information of the endpoint device simulation system is determined.
[0048] First, the function identification unit needs to determine whether the current endpoint device simulation system contains only one function. The function uniqueness flag in this embodiment is not the same as the multi-function (MF) flag in the Function0 configuration space, because in the endpoint device simulation system supporting multiple functions in this embodiment, there may still be use cases where only one function is enabled.
[0049] Furthermore, when the Alternative Initialization Routing (AIR) attribute is enabled, the only existing Function may not be Function0. Therefore, the Function number cannot be relied upon for judgment. Thus, this application introduces a unique identifier for the functional body to accurately identify whether the current mode is a single Function, ensuring that the logical judgment of the model in Function identification and routing processing is consistent and universal.
[0050] In the context of the endpoint device simulation system, which represents the state information of the endpoint device simulation system, and which includes at least two functional entities, the target functional entity of the transaction layer packet to be processed is determined based on the routing location information and the transaction type of the transaction layer packet.
[0051] The endpoint device simulation system provided in this application embodiment can quickly determine the system operating status through the unique identifier of the functional body. It only triggers accurate matching based on routing location information and transaction type in multi-functional body scenarios, realizes state-aware dynamic routing optimization, avoids invalid full lookup overhead, and improves distribution efficiency.
[0052] In some optional implementations, the function identification unit is further configured to: When the state information of the endpoint device simulation system indicates that the endpoint device simulation system includes a functional body, the functional body included in the endpoint device simulation system is determined to be the target functional body of the transaction layer package to be processed.
[0053] The endpoint device simulation system provided in this application embodiment can directly lock a single functional body as the target functional body in a single functional body scenario, which significantly improves the transaction processing efficiency and response speed in the single functional body mode.
[0054] In some optional implementations, the routing location information includes transaction address information and header information. The header information includes target host identification information, whereby the target host identification information is the target host's bus / device / function number (BDF) information. The function body identification unit is specifically used for: In the context of the endpoint device simulation system, where the endpoint device simulation system includes at least two functional entities, if the transaction type of the transaction layer packet to be processed is a memory transaction type or an input / output transaction type, then based on the target host identification information, the first functional entity is matched from the mapping table of functional entities, address ranges, and host identification information; based on the transaction address information, the target address range is matched from the first address range corresponding to the first functional entity; and the functional entity corresponding to the target address range is determined to be the target functional entity.
[0055] Each function in the system is configured with the size of its corresponding address range during registration. During system enumeration, the host allocates a base address for each function's address range and stores it in its corresponding configuration space. The system stores a function resource table, which is a mapping table between functions and address ranges. The address range is determined based on the size of the address range and its base address.
[0056] The system generates and stores a mapping table of function body, address range, and host identification information based on the Function resource table and the host identification information corresponding to each Function.
[0057] It is understandable that PCIe devices can exist in multi-host scenarios. Simply put, some functions of an EP device can be accessed by host A, and other functions can be accessed by host B. In this case, the host identification information corresponding to the function that can be accessed by host A is the host identification information of host A, and the host identification information corresponding to the function that can be accessed by host B is the host identification information of host B.
[0058] It should be noted that during the mapping process of storing functional units, address ranges, and host identifier information, the corresponding address ranges for the same functional unit will be integrated. Specifically, multiple consecutive address ranges corresponding to the same function are merged to reduce the number of lookups during matching.
[0059] When the transaction type of the transaction packet to be processed is a memory transaction or an input / output transaction, the first level index is performed using the target host BDF to traverse to the corresponding valid Function, i.e., the first functional body. Then, the Function resource table is traversed to determine the first address range corresponding to the first functional body. Based on the transaction address information, the target address range is matched from the first address range to determine the functional body corresponding to the target address range. In other words, the address range within which the transaction address represented by the transaction address information falls is the target address range. A valid Function is a Function with corresponding BDF information.
[0060] The endpoint device simulation system provided in this application, in a scenario where multiple hosts share a multi-functional entity, accurately locates the target functional entity through a two-level indexing mechanism of "coarse screening of target host identification information + fine matching of transaction addresses." This design not only solves the address conflict problem between multiple hosts but also significantly reduces the number of address matching traversals, thereby significantly improving the routing efficiency and addressing accuracy of memory / IO transactions.
[0061] In some optional implementations, the routing location information includes header information, which includes the identifier information of the target functional entity, i.e., the BDF information of the target functional entity. It should be noted that the header information includes a configuration access field, which includes the identifier information of the target functional entity. The functional entity identification unit is specifically used for: In the context of the endpoint device simulation system, where the endpoint device simulation system includes at least two functional entities, if the transaction type of the transaction layer packet to be processed is a configuration transaction type, then the target functional entity is determined based on the identification information of the target functional entity.
[0062] Understandably, if the function number in the target function's identification information is not a valid function number, meaning the target function is not registered, an error is returned. If the function number in the target function's identification information is a valid function number, then the target function is determined based on the function number in the target function's identification information. The function number is the same as the function body number.
[0063] The endpoint device simulation system provided in this application embodiment directly extracts the target functional body identifier information in the header for configuration transactions and performs accurate matching, thereby realizing rapid targeted distribution of configuration transactions, significantly improving the processing efficiency and response speed of configuration transactions, while ensuring the accuracy of configuration access in multi-functional body scenarios.
[0064] In some optional implementations, the routing location information includes header information, which includes the identification information of the target functional entity. The functional entity identification unit is specifically used for: In the case where the endpoint device simulation system includes at least two functional entities, if the transaction type of the transaction layer packet to be processed is a completed transaction type or a completed transaction with data type, the target functional entity is determined based on the identification information of the target functional entity.
[0065] Understandably, if the function number in the target function's identification information is not a valid function number, meaning the target function is not registered, an error is returned. If the function number in the target function's identification information is a valid function number, then the target function is determined based on the function number in the target function's identification information.
[0066] The endpoint device simulation system provided in this application embodiment directly extracts the target functional body identifier information from the header for matching of completed transactions (Cpl / CplD), thereby achieving extremely fast reverse routing of completed transactions, significantly improving the processing efficiency of response messages, and ensuring the accuracy and real-time performance of transaction responses in multi-functional body scenarios.
[0067] In some optional implementations, the transaction layer packet forwarding unit is specifically used for: Based on the target function body of the transaction layer package to be processed, obtain the handle of the target function body.
[0068] Based on the transaction type of the transaction layer packet to be processed, the pointer to the target processing function is determined from the handle of the target function body.
[0069] The pending transaction layer packet is forwarded to the target function body so that the target function body can process the pending transaction layer packet based on the target processing function pointed to by the target processing function pointer.
[0070] After identifying the target functional body, the system needs to route the corresponding TLP to the correct Function instance for further processing. This application adopts a structured distribution mechanism to achieve an efficient and scalable transaction processing flow.
[0071] Specifically, the system internally maintains an array of structures consisting of Function instance handles, with each array member corresponding to a Function instance. Each array member contains the resource context information of the corresponding Function and a set of processing function pointers categorized by transaction type. In other words, each Function instance handle contains the resource context information of the corresponding Function and a set of processing function pointers categorized by transaction type.
[0072] During actual routing, the function identification unit outputs the target function number corresponding to the target function. The system uses this as an array index to directly locate the corresponding Function instance handle without traversal, thus improving access efficiency. Subsequently, based on the transaction type of the transaction layer packet to be processed, the corresponding target processing function pointer is selected, and the transaction layer packet to be processed is passed to the target processing function in the target function to complete the simulation of specific business logic.
[0073] In some optional implementations, the function body distribution module also includes an abnormal transaction detection and processing unit.
[0074] The abnormal transaction detection and processing unit is used to, when the endpoint device simulation system represents the status information of the endpoint device simulation system, if the transaction type of the transaction layer packet to be processed is a memory transaction type or an input / output transaction type, and the first functional body is not matched from the mapping table of functional body, address range and host identification information based on the target host identification information, then return an error response message for the transaction layer packet to be processed or discard the transaction layer packet to be processed.
[0075] The abnormal transaction detection and processing unit is also used to, when the endpoint device simulation system's status information characterization indicates that the endpoint device simulation system includes at least two functional units, if the transaction type of the transaction layer packet to be processed is a memory transaction type or an input / output transaction type, and based on the transaction address information, the target address range is not matched from the first address range corresponding to the first functional unit, then return an error response message for the transaction layer packet to be processed or discard the transaction layer packet to be processed.
[0076] Understandably, the abnormal transaction detection and processing unit is used to detect and process (return an error response or discard) illegal, out-of-bounds, and miss transactions.
[0077] The endpoint device simulation system provided in this application provides a way to accurately identify illegal access and invalid address transactions by performing dual verification of host identifier and address range for memory / IO transactions in a multi-functional scenario. It promptly returns error responses or discards packets, effectively improving the robustness and security of the system. At the same time, it avoids invalid transactions from occupying system resources and ensures the processing efficiency of normal transactions.
[0078] In some optional implementations, the abnormal transaction detection and processing unit is used to return an error response message for the pending transaction layer packet or to lose the pending transaction layer packet if the transaction type of the pending transaction layer packet is a configuration transaction type and the target functional body is not determined based on the identification information of the target functional body when the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional bodies.
[0079] It is understandable that the abnormal transaction detection and processing unit is also used to, when the endpoint device simulation system includes at least two functional entities, return an error response message for the pending transaction layer packet or lose the pending transaction layer packet if the transaction type of the pending transaction layer packet is a completed transaction type or a completed transaction with data type, and the target functional entity is not determined based on the identification information of the target functional entity.
[0080] The endpoint device simulation system provided in this application, for configuration transactions and completion transactions, accurately intercepts abnormal transactions that access non-existent functional entities by verifying the validity of the target functional entity identifier, and promptly returns error responses or discards messages. This effectively avoids system logic errors caused by invalid transactions, improves the security and stability of transaction processing in multi-functional entity scenarios, and reduces the occupation of system resources by invalid transactions. The abnormal transaction detection and processing unit ensures the stability and consistency of model behavior.
[0081] In some optional implementations, the transaction layer packet forwarding unit is also used for: If the target function body based on the pending transaction layer packet fails to forward the pending transaction layer packet to the target function body, then repeat the step of forwarding the pending transaction layer packet to the target function body based on the pending transaction layer packet.
[0082] If the number of times the step of forwarding the transaction layer packet to the target function body is executed repeatedly exceeds a preset threshold, and the transaction layer packet to the target function body is not successfully forwarded, an alarm will be issued.
[0083] The endpoint device simulation system provided in this application embodiment effectively copes with transient abnormal scenarios such as temporary busyness of the target functional body and full buffer through a limited number of forwarding retry mechanisms, thereby improving the reliability and success rate of transaction forwarding; after exceeding the retry threshold, an alarm is triggered to expose persistent faults in a timely manner, avoid invalid retries from occupying system resources, and ensure the stability and maintainability of the simulation system.
[0084] Embodiments of this application provide an endpoint device simulation system. Figure 3 This is a schematic diagram of the structure of the endpoint device simulation system provided in the embodiments of this application, such as... Figure 3 As shown, the endpoint device simulation system includes a transaction receiving module, a function body distribution module, and a resource management module. The transaction receiving module receives transaction layer packets sent by external modules and forwards them to the function body distribution module. The function body distribution module receives transaction layer packets to be processed, parses them to obtain their routing information, determines their transaction type based on this information, determines their target function body, and forwards them to the target function body for processing. This explanation uses an endpoint device simulation system with multiple functions as an example. The resource management module is the same as in related technologies and will not be described further.
[0085] The function body distribution module includes a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit. Figure 4 The flowchart of the function body distribution module provided in the embodiments of this application is as follows: Figure 4 As shown, the workflow of the function body distribution module includes: The receiving and parsing unit is used to receive transaction layer packets from the PCIe bus, perform preliminary parsing of their structure, and extract key field information, namely, extracting routing location information.
[0086] To determine whether an endpoint device simulation system supports multiple functional entities, specifically, based on the unique identifier of the functional entity, it is determined whether the endpoint device simulation system includes at least two functional entities.
[0087] If the endpoint device emulation system does not support multiple function bodies, a default function body handle is obtained. Using the transaction layer packet forwarding unit, based on the transaction type of the transaction layer packet, the corresponding processing function pointer is determined from the default function body handle, and the transaction layer packet is forwarded to the default function body. This allows the default function body to process the transaction layer packet based on the corresponding processing function. The default function body handle is the handle of the function bodies included in the endpoint device emulation system. The transaction type of the transaction layer packet is determined based on routing location information.
[0088] If the endpoint device simulation system supports multiple functions, the type identification unit uses the routing location information of the transaction layer packet to determine the transaction type. If the transaction type of the transaction layer packet is a memory transaction, the function identification unit extracts the target host identifier information and transaction address information from the routing location information. Based on the target host identifier information, it traverses the mapping table of function type, address range, and host identifier information to determine the first function type. Based on the transaction address information, it traverses the first address range corresponding to the first function type and determines whether a target address range is matched. If a target address range is matched, the function type corresponding to the target address range is determined as the target function type. If no target address range is matched, an error is returned. If the transaction type of the transaction layer packet is a configuration transaction, a completion transaction, or a completion transaction with data, the function identification unit directly extracts the identifier information of the target function type from the routing location information and determines whether the identifier information of the target function type is valid. If valid, the target function type is determined based on the identifier information of the target function type. If invalid, an error is returned. The transaction layer packet forwarding unit obtains the handle of the target function body. Based on the transaction type of the transaction layer packet, the corresponding processing function pointer is determined from the handle of the target function body. The transaction layer packet is then forwarded to the target function body so that the target function body can process the transaction layer packet based on the corresponding processing function.
[0089] The functional body identification unit enables accurate identification of the target functional body, while the transaction layer packet forwarding unit enables isolated processing and accurate simulation of the functional body.
[0090] The endpoint device simulation system provided in this application implements the simulation of multiple functions in the SystemC environment. The multiple functions are logically independent, each handling its own dedicated transactions without interference. It can accurately identify the target objects of various transactions and precisely distribute the transaction layer packets sent by the driver software to the specified functions according to standard PCIe protocol rules, providing reliable support for end-to-end transaction transmission from the driver software to the target functions.
[0091] The endpoint device simulation system provided in this application embodiment is based on the PCIe specification and fully considers the architecture and behavioral characteristics of actual PCIe multi-Function devices. By setting a function body distribution module in the EP device simulation model, the target function distribution in multi-Function scenarios is realized.
[0092] The endpoint device simulation system provided in this application supports the independent operation, resource isolation, and collaborative access of multiple functions during the simulation process, and has good scalability and flexible configuration capabilities. Each function can independently respond to basic PCIe transactions such as configuration access, memory read / write, and interrupt handling, and can share some resources as needed, enabling flexible deployment in various application scenarios.
[0093] The endpoint device simulation system provided in this application greatly improves the functionality and engineering adaptability of the SystemC simulation platform in PCIe system verification by introducing a multi-Function support mechanism. It is particularly suitable for SoC system-level verification, hardware and software co-debugging and large-scale system integration scenarios of EP devices containing multiple functions.
[0094] The embodiments of this application provide a transaction layer packet processing method, applicable to any of the aforementioned endpoint device simulation systems. Figure 5 This is a flowchart illustrating the transaction layer packet processing method provided in an embodiment of this application, as shown below. Figure 5 As shown, the transaction layer packet processing method includes the following steps: Step S501: Using the receiving and parsing unit, receive the transaction layer packet to be processed, parse the transaction layer packet to be processed, and obtain the routing and location information of the transaction layer packet to be processed.
[0095] Step S502: Using the type identification unit, determine the transaction type of the transaction layer packet to be processed based on the routing location information of the transaction layer packet to be processed.
[0096] Step S503: Using the functional body identification unit, the target functional body of the transaction layer packet to be processed is determined based on the routing location information and the transaction type of the transaction layer packet to be processed.
[0097] Step S504: Using the transaction layer packet forwarding unit, based on the target functional body of the transaction layer packet to be processed, forward the transaction layer packet to be processed to the target functional body so that the target functional body can process the transaction layer packet to be processed.
[0098] For details, please refer to the corresponding description of the aforementioned endpoint device simulation system, which will not be repeated here.
[0099] The transaction layer packet processing method provided in this application realizes the addressing, routing, isolation and independent processing of multi-function bodies based on the PCIe specification through a receiving and parsing unit, a type identification unit, a function body identification unit and a transaction layer packet forwarding unit. That is, it realizes the simulation of multi-function body characteristics. Therefore, it can solve the problem that the EP device simulation model in related technologies cannot support multi-function characteristics and is difficult to meet the comprehensive and realistic modeling and simulation requirements of complex PCIe devices. It achieves the technical effect of meeting the comprehensive and realistic modeling and simulation requirements of complex PCIe devices.
[0100] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0101] Embodiments of this application also provide an electronic device, such as... Figure 6 As shown, it includes a processor 601 and a memory 602, in which a computer program is stored. The processor 601 is configured to run the computer program to perform the steps in the above-described transaction layer packet processing method embodiment.
[0102] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in the above-described transaction layer packet processing method embodiments at runtime.
[0103] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0104] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in the above-described transaction layer packet processing method embodiments.
[0105] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the above-described transaction layer packet processing method embodiments.
[0106] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0107] The foregoing has provided a detailed description of the endpoint device simulation system, transaction layer packet processing method, and electronic device provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. An endpoint device simulation system, characterized in that, It includes a function body distribution module; the function body distribution module includes a receiving and parsing unit, a type identification unit, a function body identification unit, and a transaction layer packet forwarding unit; The receiving and parsing unit is used to receive the transaction layer packet to be processed, parse the transaction layer packet to be processed, and obtain the routing and location information of the transaction layer packet to be processed. The type identification unit is used to determine the transaction type of the transaction layer packet to be processed based on the routing and location information of the transaction layer packet to be processed; The functional body identification unit is used to determine the target functional body of the transaction layer packet to be processed based on the routing location information of the transaction layer packet to be processed and the transaction type of the transaction layer packet to be processed. The transaction layer packet forwarding unit is used to forward the transaction layer packet to be processed to the target functional body based on the target functional body of the transaction layer packet to be processed, so that the target functional body can process the transaction layer packet to be processed.
2. The system according to claim 1, characterized in that, The receiving and parsing unit is specifically used for: Receive the transaction layer packet to be processed through the transaction-level modeling interface; Obtain the raw data pointer provided by the transaction-level modeling interface, which points to the raw data of the transaction layer packet to be processed; The original data pointer is converted into a pointer of a predefined union data structure type. The member variables of the predefined union data structure are used to directly access and parse the transaction layer packet to be processed, and obtain the routing and location information of the transaction layer packet to be processed. The predefined union data structure includes member variables for mapping the routing location information of the transaction layer packet to be processed, and the routing location information includes at least header information.
3. The system according to claim 1, characterized in that, The routing location information includes header information, which includes a data type field and a data format field; the type identification unit is specifically used for: The transaction type of the transaction layer packet to be processed is determined based on the data type field and data format field in the routing location information of the transaction layer packet to be processed.
4. The system according to claim 1, characterized in that, The functional body identification unit is specifically used for: Based on the unique identifier of the functional body, the state information of the endpoint device simulation system is determined; When the state information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional entities, the target functional entity of the transaction layer packet to be processed is determined based on the routing location information of the transaction layer packet to be processed and the transaction type of the transaction layer packet to be processed.
5. The system according to claim 4, characterized in that, The functional body identification unit is also used for: If the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes a functional body, then the functional body included in the endpoint device simulation system is determined to be the target functional body of the transaction layer packet to be processed.
6. The system according to claim 4, characterized in that, The routing location information includes transaction address information and header information. The header information includes target host identification information. The functional body identification unit is specifically used for: When the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional bodies, if the transaction type of the transaction layer packet to be processed is a memory transaction type or an input / output transaction type, then based on the target host identification information, the first functional body is matched from the mapping table of functional body, address range and host identification information; Based on the transaction address information, a target address range is matched from the first address range corresponding to the first functional body; the functional body corresponding to the target address range is determined to be the target functional body.
7. The system according to claim 4, characterized in that, The routing location information includes header information, which includes the identification information of the target functional entity. The functional entity identification unit is specifically used for: When the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional entities, if the transaction type of the transaction layer packet to be processed is a configuration transaction type, then the target functional entity is determined based on the identification information of the target functional entity.
8. The system according to claim 4, characterized in that, The routing location information includes header information, which includes the identification information of the target functional entity. The functional entity identification unit is specifically used for: When the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional entities, if the transaction type of the transaction layer packet to be processed is a completed transaction type or a completed transaction with data type, then the target functional entity is determined based on the identification information of the target functional entity.
9. The system according to claim 1, characterized in that, The transaction layer packet forwarding unit is specifically used for: Based on the target function body of the transaction layer package to be processed, obtain the handle of the target function body; Based on the transaction type of the transaction layer packet to be processed, the target processing function pointer is determined from the handle of the target function body; The pending transaction layer packet is forwarded to the target function body, so that the target function body processes the pending transaction layer packet based on the target processing function pointed to by the target processing function pointer.
10. The system according to claim 6, characterized in that, The functional body distribution module also includes an abnormal transaction detection and processing unit; The abnormal transaction detection and processing unit is used to, when the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional bodies, if the transaction type of the transaction layer packet to be processed is a memory transaction type or an input / output transaction type, and the first functional body is not matched from the mapping table of functional body, address range and host identification information based on the target host identification information, then return an error response message for the transaction layer packet to be processed or discard the transaction layer packet to be processed. The abnormal transaction detection and processing unit is further configured to, when the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional bodies, if the transaction type of the pending transaction layer packet is a memory transaction type or an input / output transaction type, and based on the transaction address information, no target address range is matched from the first address range corresponding to the first functional body, then return an error response message for the pending transaction layer packet or discard the pending transaction layer packet.
11. The system according to claim 7, characterized in that, The functional body distribution module also includes an abnormal transaction detection and processing unit; The abnormal transaction detection and processing unit is used to, when the status information of the endpoint device simulation system indicates that the endpoint device simulation system includes at least two functional entities, return an error response message for the pending transaction layer packet or lose the pending transaction layer packet if the transaction type of the pending transaction layer packet is a configuration transaction type and the target functional entity is not determined based on the identification information of the target functional entity.
12. A transaction layer packet processing method, characterized in that, Applied to the endpoint device emulation system as described in any one of claims 1 to 11, the method comprises: Using the receiving and parsing unit, a transaction layer packet to be processed is received, and the transaction layer packet to be processed is parsed to obtain the routing and location information of the transaction layer packet to be processed. Using the type recognition unit, the transaction type of the transaction layer packet to be processed is determined based on the routing and location information of the transaction layer packet to be processed; Using the functional body identification unit, the target functional body of the transaction layer packet to be processed is determined based on the routing location information and the transaction type of the transaction layer packet to be processed; Using the transaction layer packet forwarding unit, the transaction layer packet to be processed is forwarded to the target functional body based on the target functional body, so that the target functional body can process the transaction layer packet to be processed.
13. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the transaction layer packet processing method as described in claim 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the transaction layer packet processing method as described in claim 12.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the transaction layer packet processing method as described in claim 12.