A general peripheral device function behavior level modeling and simulation method
By using device description language and behavioral modeling technology, a standard device model library is generated, which solves the problem of complex peripheral device interfaces in embedded systems and improves simulation efficiency and the reusability of device models.
Patent Information
- Application Number
- CN202411251561.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-08
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-09-08
AI Technical Summary
The interfaces of peripheral devices in embedded systems are complex and diverse, which leads to complicated device modeling process, high development cost, low simulation efficiency and poor reusability.
A behavioral modeling method based on device description language is adopted to define device description files, model registers, IO interfaces and simulation core scheduling behaviors, generate device C code, and form a standard device model library through consistency checking.
It standardizes the equipment modeling method, improves simulation efficiency, solves the problems of poor reusability and difficulty in interconnection of equipment models, and realizes efficient management and unified simulation of equipment models.
Smart Images

Figure CN119148994B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of device modeling and simulation, and in particular relates to a universal peripheral device functional behavior level modeling and simulation method. Background Art
[0002] Embedded system software is highly coupled to hardware, requiring developers to debug on target hardware. However, target hardware peripherals are diverse, have complex interfaces, and are highly specialized, making them difficult to reuse across different configuration items. This leads to high customization costs and low development efficiency. Currently, virtualization technology is commonly used to model and simulate peripheral device functions at the behavioral level, creating fully digital device models that are equivalent to the hardware. This reduces hardware dependency, increases reuse, and ultimately improves software development efficiency.
[0003] Due to the differences in granularity of peripheral device modeling and simulation, a variety of device models are generated. Common device models include clock-cycle accurate device models, event-driven device models, and behavioral-level device models. Among them, clock-cycle accurate models have the highest accuracy, describing the hardware details of the device and ensuring that each cycle is consistent with the hardware behavior. Behavioral-level device models are the fastest, interacting between models through function calls and having the highest level of abstraction. Event-driven device models have an accuracy and speed somewhere in between. Behavioral-level simulation of peripheral devices uses high-level languages to model peripheral registers, interfaces, and properties through function calls and structure definitions, performing logical functional behavioral-level simulation. Device objects are created by abstractly representing functions and characteristics, and the interactions between objects are used to describe the composition of hardware devices, forming a fully digital device model that supports embedded software development and testing.
[0004] Embedded systems have complex and diverse peripheral device interfaces, often facing issues like low utilization, high costs, and irreversible failures. Without the hardware, effective embedded software development and testing is difficult. While virtualization technology can simulate hardware peripherals, the lack of standardized peripheral modeling standards, low functional simulation efficiency, and the difficulty of customization hinder its widespread adoption in actual embedded software development projects.
[0005] To improve embedded software development efficiency, this paper presents a general method for modeling and simulating target machine peripheral devices at the behavioral level. This method abstractly describes the device through modeling, implements the peripheral device's logical functions through behavioral-level simulation, and forms a digital device model equivalent to the hardware's functionality. This model then constructs an operating environment to support the development and testing of embedded software. Summary of the Invention
[0006] (1) Technical issues to be resolved
[0007] The technical problem to be solved by the present invention is how to provide a universal peripheral device functional behavior level modeling and simulation method to solve the problems of complex device modeling process, high development cost, low simulation efficiency, and poor reusability caused by the complex interfaces and wide variety of peripheral devices in current embedded systems.
[0008] (2) Technical solution
[0009] In order to solve the above technical problems, the present invention proposes a general peripheral device functional behavior level modeling and simulation method, which includes the following steps:
[0010] Step 1: Definition of key features of peripheral devices
[0011] Extract the key features of the device and define a structured device description file *.vdl to abstractly describe the key features of the device. The key features of the device include: device name, device description, device interface, and device attribute content; the device interface includes output interface, input interface, registration interface, and release interface; the device attributes include interrupt number, device base address, and register offset address;
[0012] Step 2: Behavioral functional modeling of peripheral devices
[0013] A behavioral modeling approach is used to model peripheral device functions, including registers, IO interfaces, and simulation core scheduling behaviors. Register behavior modeling is used to identify read and write operations based on register read and write content and describe corresponding logical behaviors. IO interface behavior modeling is used to describe data transmission and reception functions based on data output direction, and data communication is achieved between devices by calling IO interface functions. Simulation core scheduling behavior modeling is used to establish a unique device identifier based on the device name and device description, perform device registration and release operations, and simulate device access and deletion behaviors.
[0014] Step 3: Generate C code for peripheral device model
[0015] Define a translation rule from device description language to C language, translate the key features and logical behaviors of the device, generate device C code, and then improve the device functions based on this to form a complete device model code;
[0016] Step 4: Check device function consistency
[0017] Extract device model code features, establish a mapping relationship between device key feature descriptions and device model code features, and verify the consistency of the generated device model code with the key functions of the simulated device by comparing the device model code features with the device key features;
[0018] Step 5: Standard equipment model library packaging
[0019] The standard device model library package includes two parts: the device dynamic library and the device key feature description file; after passing the consistency check, the device model code is compiled into a callable device dynamic library, and the device key feature description and the device dynamic library are packaged to form a standard device model library for unified management.
[0020] (3) Beneficial effects
[0021] The present invention proposes a universal peripheral device functional behavior level modeling and simulation method, which has the following characteristics:
[0022] 1) Widely adopting peripheral device behavioral modeling technology based on device description language, standardizing device modeling methods and standards, improving device modeling efficiency, and solving the problems of poor reusability of device models and difficulty in interconnection and interoperability;
[0023] 2) The device model code is generated by translating the device description file, translating key feature information such as interfaces, properties, and registers into C code. A mapping relationship between the C code and the key features of the device is established, and the consistency check of the device code is performed based on the mapping relationship.
[0024] 3) The encapsulation and scheduling of standard device models are realized, and the device description file is combined with the device dynamic library to form a standard device model. The interface information provided by the device description file matches the simulation algorithm provided by the device dynamic library. Device models implemented using different modeling methods can be interconnected and communicated based on the standard device model and run based on a unified device simulation scheduling framework. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a structural diagram of the functional behavior level modeling and simulation method of peripheral devices generally used in the present invention;
[0026] Figure 2 Compose a structural diagram for the standard equipment model;
[0027] Figure 3 This is the package and analysis diagram of the standard device model. DETAILED DESCRIPTION
[0028] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below with reference to the accompanying drawings and examples.
[0029] The purpose of the present invention is to provide a universal peripheral device behavioral level functional modeling and simulation method to solve the problems of complex device modeling process, high development cost, low simulation efficiency and poor reusability caused by the complex interfaces and wide variety of peripheral devices in current embedded systems.
[0030] This invention provides a universal behavioral-level functional modeling and simulation method for peripheral devices. This method first defines a device description file (*.vdl) based on the characteristics of the peripheral device, describing the peripheral device's general information. Secondly, behavioral-level modeling is performed on the peripheral device, including registers, I / O interfaces, and other content. Then, the device model functions are refined, completing functional simulations such as register reading and writing, data transmission and reception, and device initialization, translating the device model description file into device C code. Finally, a consistency check is performed on the device functional model. Once the check passes, the C code is compiled into a callable device dynamic library. This method implements a universal behavioral-level functional simulation method for peripheral devices, featuring standardized modeling processes, clear descriptions of model attributes and interfaces, and accurate descriptions of logical functions. This method provides a universal and efficient peripheral device modeling and simulation method, improving peripheral device simulation efficiency.
[0031] Step 1: Definition of key features of peripheral devices
[0032] Extract the key features of the device and define a structured device description file *.vdl to abstractly describe the key features of the device. The key features of the device include: device name, device description, device interface, device attributes, etc. Device interfaces include output interface, input interface, registration interface, and release interface; device attributes include interrupt number, device base address, register offset address, etc.
[0033] Step 2: Behavioral functional modeling of peripheral devices
[0034] Behavioral modeling is used to model peripheral device functions, including registers, I / O interfaces, and simulation core scheduling behaviors. Register behavior modeling identifies read and write operations based on register read and write content and describes the corresponding logical behaviors. I / O interface behavior modeling describes data transmission and reception based on the data output direction, enabling data communication between devices by calling I / O interface functions. Simulation core scheduling behavior modeling establishes a unique device identifier based on the device name and description, performs device registration and release operations, and simulates device access and removal behaviors.
[0035] Step 3: Generate C code for peripheral device model
[0036] Define a translation rule from device description language to C language, translate the key features and logical behaviors of the device, generate device C code, and then improve the device functions on this basis to form a complete device model code.
[0037] Step 4: Device function consistency check
[0038] Extract device model code features, establish a mapping relationship between device key feature descriptions and device model code features, and verify the consistency of the generated device model code with the key functions of the simulated device by comparing the device model code features with the device key features.
[0039] Step 5: Standard equipment model library packaging
[0040] The standard device model library package consists of two parts: the device dynamic library and the device key feature description file. After passing the consistency check, the device model code is compiled into a callable device dynamic library. The device key feature description and device dynamic library are packaged to form a standard device model library for unified management.
[0041] Example 1:
[0042] A general implementation plan for the behavioral-level functional modeling and simulation method of peripheral devices includes four parts: device key feature extraction, device behavioral-level modeling, code generation and consistency checking, and device model encapsulation. Figure 1 shown.
[0043] First, the key features of the simulated device are described using a device description language to form a structured file for storage; second, behavioral-level functional modeling is carried out based on the key features of the simulated device, a high-level abstract description of the device functions visible to the software is made, and a peripheral device model is generated; then, the device model code is generated by translating the peripheral device model, and a functional consistency check is performed; finally, the device dynamic library is compiled and encapsulated to generate a standard device model library.
[0044] The specific implementation steps are:
[0045] The first step is to define the key characteristics of peripheral devices
[0046] First, define the device description file. The device description file (*.vdl) is a structured description file based on the JSON format. Keywords include dev, dev_desc, io_in, io_out, io_inout, reg, and reg_offset. These keywords are used to model device registers, interfaces, and other functions. For example, the device description might be "dev": "timer"; the register description might be "reg": "TIMER_CNT"; and the register offset description might be "reg_offset": "0x4."
[0047] Secondly, extract the key features of the peripheral device. Analyze the functions of the simulated peripheral device, extract key feature information such as device name, device registers, device IO interface, device attributes, and describe them using device description language.
[0048] The second step is to perform functional behavior level modeling of peripheral devices
[0049] First, the simulated peripheral functions are divided and abstractly described. This division includes peripheral functions and simulation core scheduling functions. Peripheral functions include register access and I / O interface access, while simulation core scheduling functions include device registration and device release. Device behavior is abstractly described. For example, when modeling memory data reads, data can be simulated in a single pass, eliminating the need to simulate byte-by-byte reads.
[0050] Next, peripheral register behavior modeling is performed. Modeling peripheral register behavior involves two components: register size and methods. Register sizes range from 1 to 8 bytes, stored byte-by-byte, and simulated using byte arrays. Register methods include read and write methods, which are triggered by register read and write accesses. Within these methods, the corresponding control and transfer behaviors are identified based on the read and write content and abstractly described.
[0051] Next, the peripheral interface behavior is modeled. This modeling consists of two parts: data reception and data transmission. The receive and transmit methods are implemented based on the data transmission direction. The receive method receives external data, parses the external data format according to the device communication protocol, and writes the received data to the device registers, storage units, etc. The transmit method transmits data externally, reading the contents of the device registers, storage units, etc., framing the data according to the device communication protocol, and transmitting it externally. Communication between devices is achieved by calling the receive and transmit methods of the corresponding device.
[0052] Finally, the simulation core scheduling behavior is modeled. This includes methods such as device registration and device release. The device registration method initializes device model functions, establishes a mapping of inter-device I / O interface function calls, and adds the device to the simulation core device management queue. The device release method releases device functions and removes the device from the simulation core device management queue.
[0053] The third step is to translate and generate device model C code and improve the function
[0054] First, the translation rules of device description language are defined, and the mapping relationship between keywords and C language is established to form a universal device description template and library.
[0055] Secondly, according to the device description template and translation rules, the key features in the device model are translated into device C code, including register group, register read and write functions, IO interface data receiving function, IO data sending function, device registration function, device release function, etc.
[0056] Then, the logical functions are improved based on the generated device model code to form an executable device library.
[0057] Step 4: Check device functionality consistency
[0058] Extract and generate the features of the device model code, including interface functions, device registration functions, device release functions, register read and write functions, register groups and other information, compare the code features with the key features of the device, and generate the coverage relationship between the code features and the key features of the device.
[0059] Step 5: Build a standard equipment model
[0060] First, compile the device model code to generate a device dynamic library.
[0061] Secondly, encapsulate the device description file *.vdl and the device dynamic library to generate a standard device model.
[0062] Then, the standard device model is parsed to extract key feature information from the device description file, including device name, device interface, device attributes and other feature information.
[0063] Finally, the standard device model is managed, and the extracted feature information is used as an index for unified management, and the standard device model is reused according to the provided interface.
[0064] Step 6: Standard equipment model simulation scheduling
[0065] First, load the standard device model, parse the device description file, and extract the interface information.
[0066] Secondly, a device simulation scheduling framework is established, and a linked list structure is used to manage standard device models. Each standard device model is managed as a node in the linked list. When a device is registered, the standard device model is added to the linked list, and when a device is released, the standard device model node is deleted from the linked list.
[0067] Then, the standard device model is registered to the unified device simulation scheduling framework, connected according to the device interface information, and addressed and accessed according to the device base address.
[0068] Finally, the standard device model is run, and according to the access operation of the standard device model, the corresponding function of the device function is called to realize the device behavior simulation and communication between models.
[0069] Key points of the present invention:
[0070] 1. Peripheral device functional behavior level modeling technology based on device description language
[0071] The peripheral device behavior level modeling technology based on device description language includes two parts: one is device interface model modeling, and the other is device logical function behavior level modeling. By organically combining device interface model modeling and logical function behavior level modeling, peripheral device functional behavior level modeling is achieved.
[0072] Device interface modeling is done by defining the key features of the device, including device name, device description, registration interface, release interface, input interface, output interface, register group, attribute interface, etc., using device description language to describe and generate a device description file in *.vdl format. The device name interface provides a unified device identifier; the device description interface provides an introduction to the basic functions of the device, including functions, interfaces, attributes, etc.; the register group interface provides read and write access to the device register; the attribute interface provides the device attribute information setting and acquisition function; the output interface provides the device external data sending function; the input interface provides the device external data receiving function; the registration interface provides the device model initialization and simulation scheduling function; the release interface provides the device model resource release function. The standard device model composition diagram is as follows Figure 2 shown.
[0073] Logical functional behavioral modeling uses a high-level language to describe the device's functions and behaviors, primarily including register read and write behavior and interface communication behavior. When modeling register read and write behavior, first, use structures such as bytes and arrays to describe the register group and define read and write methods. Second, establish a mapping between the register group and memory, using offset addresses to address registers and perform read and write operations. Finally, refine the logical functions based on the register read and write content. For example, write a start command to a timer control register, process the written data according to the control register function, then create a timer thread and start timing. When modeling interface communication behavior, first define data receiving and sending methods within the device to implement data encoding and decoding. Second, establish a mapping between the device interface and internal device methods. Finally, devices send and receive data to and from each other by calling internal device methods. For example, when a device generates an interrupt, it calls the interrupt trigger function within the processor to notify the processor of the interrupt. The processor then jumps to the corresponding interrupt service routine based on the interrupt vector table.
[0074] 2. Standard equipment model library packaging and scheduling technology
[0075] The standard device model library encapsulation and scheduling technology provides a standardized device model, improves reusability, and solves the problems of inconsistent device model interfaces and difficulty in interconnection caused by different modeling methods.
[0076] The standard device model consists of two parts. One is the device model description file *.vdl, which provides the core information of the device model, such as the name, function description, interface, and properties; the other is the device dynamic library file *.dll, which provides the device logic function algorithm model. When scheduling the standard device model, first, load the device description file to obtain the interface and property information, and match the internal method of the device according to the interface; secondly, assemble different device models, connect them according to the interface, and realize communication between devices by calling the interface matching method; finally, the standard device model is initialized and scheduled through a unified simulation scheduling framework. The specific components are as follows: Figure 3 shown.
[0077] A general peripheral device functional behavior level modeling and simulation method of the present invention has the following characteristics:
[0078] 1) Widely adopting peripheral device behavioral modeling technology based on device description language, standardizing device modeling methods and standards, improving device modeling efficiency, and solving the problems of poor reusability of device models and difficulty in interconnection and interoperability;
[0079] 2) The device model code is generated by translating the device description file, translating key feature information such as interfaces, properties, and registers into C code. A mapping relationship between the C code and the key features of the device is established, and the consistency check of the device code is performed based on the mapping relationship.
[0080] 3) The encapsulation and scheduling of standard device models are realized, and the device description file is combined with the device dynamic library to form a standard device model. The interface information provided by the device description file matches the simulation algorithm provided by the device dynamic library. Device models implemented using different modeling methods can be interconnected and communicated based on the standard device model and run based on a unified device simulation scheduling framework.
[0081] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A general peripheral device functional behavior level modeling and simulation method, characterized in that: The method comprises the following steps: Step 1: Definition of key features of peripheral devices Extract the key features of the device and define a structured device description file *.vdl to abstractly describe the key features of the device. The key features of the device include: device name, device description, device interface, and device attribute content; the device interface includes output interface, input interface, registration interface, and release interface; the device attributes include interrupt number, device base address, and register offset address; Step 2: Behavioral functional modeling of peripheral devices A behavioral modeling approach is used to model peripheral device functions, including registers, IO interfaces, and simulation core scheduling behaviors. Register behavior modeling is used to identify read and write operations based on register read and write content and describe corresponding logical behaviors. IO interface behavior modeling is used to describe data transmission and reception functions based on data output direction, and data communication is achieved between devices by calling IO interface functions. Simulation core scheduling behavior modeling is used to establish a unique device identifier based on the device name and device description, perform device registration and release operations, and simulate device access and deletion behaviors. Step 3: Generate C code for peripheral device model Define a translation rule from device description language to C language, translate the key features and logical behaviors of the device, generate device C code, and then improve the device functions based on this to form a complete device model code; Step 4: Check device function consistency Extract device model code features, establish a mapping relationship between device key feature descriptions and device model code features, and verify the consistency of the generated device model code with the key functions of the simulated device by comparing the device model code features with the device key features; Step 5: Standard equipment model library packaging The standard device model library package includes two parts: the device dynamic library and the device key feature description file; after passing the consistency check, the device model code is compiled into a callable device dynamic library, and the device key feature description and the device dynamic library are packaged to form a standard device model library for unified management.
2. The general peripheral device functional behavior level modeling and simulation method according to claim 1, characterized in that: The device description file *.vdl is a structured description file implemented in JSON format. Keywords include dev, dev_desc, io_in, io_out, io_inout, reg, and reg_offset. Keywords are used to model device registers and interface functions. The device functions are analyzed, and key feature information such as device name, device registers, device IO interface, and device attributes are extracted and described using the device description language.
3. The general peripheral device functional behavior level modeling and simulation method according to claim 2, characterized in that: In the second step, the register behavior modeling includes two parts: register size and method; the register size ranges from 1 to 8 bytes, is stored in bytes, and is simulated through byte arrays; the register method includes read and write methods, which are triggered when the register is read or written. The method identifies the corresponding control and transmission behaviors based on the read and write content and provides an abstract description.
4. The general peripheral device functional behavior level modeling and simulation method according to claim 2, characterized in that: In the second step, the IO interface behavior modeling includes two parts: data reception and data transmission. The receiving method and the sending method are implemented according to the data transmission direction; the receiving method implements the function of receiving external data, parses the external data format according to the device communication protocol, and writes the received data to the device register and storage unit; the sending method implements the function of sending data to the outside, reads the content of the device register and storage unit, frames according to the device communication protocol, and sends data to the outside; communication between devices is achieved by calling the receiving and sending methods of the corresponding device.
5. The general peripheral device functional behavior level modeling and simulation method according to claim 2, characterized in that: In the second step, the simulation core scheduling behavior modeling includes device registration and device release methods; the device registration method implements device model function initialization, establishes IO interface function call mapping between devices, and adds the device to the simulation core device management queue; the device release method implements device function release and removes the device from the simulation core device management queue.
6. The general peripheral device functional behavior level modeling and simulation method according to any one of claims 1 to 5, characterized in that: The third step includes: First, define the translation rules of device description language, establish the mapping relationship between keywords and C language, and form a universal device description template and library; Secondly, according to the device description template and translation rules, the key features in the device model are translated into device C code, including register group, register read and write functions, IO interface data receiving function, IO data sending function, device registration function, and device release function; Then, the logical functions are improved based on the generated device model code to form an executable device library.
7. The general peripheral device functional behavior level modeling and simulation method according to claim 6, characterized in that: The fourth step includes: extracting features of the generated device model code, including interface functions, device registration functions, device release functions, register read and write functions, and register group information, comparing the code features with the device key features, and generating a coverage relationship between the code features and the device key features.
8. The general peripheral device functional behavior level modeling and simulation method according to claim 7, characterized in that: The fifth step includes: First, compile the device model code to generate a device dynamic library; Secondly, encapsulate the device description file *.vdl and the device dynamic library to generate a standard device model; Then, the standard device model is parsed to extract key feature information in the device description file, including device name, device interface, and device attribute feature information; Finally, the standard device model is managed, and the extracted feature information is used as an index for unified management, and the standard device model is reused according to the provided interface.
9. The general peripheral device functional behavior level modeling and simulation method according to claim 8, characterized in that: The method further includes a sixth step after the fifth step: standard equipment model simulation scheduling, which includes: First, load the standard device model, parse the device description file, and extract the interface information; Secondly, a device simulation scheduling framework is established, and a linked list structure is used to manage standard device models. Each standard device model is managed as a node in the linked list. When a device is registered, the standard device model is added to the linked list, and when a device is released, the standard device model node is deleted from the linked list. Then, the standard device model is registered to the unified device simulation scheduling framework, connected according to the device interface information, and addressed and accessed according to the device base address; Finally, the standard device model is run, and according to the access operation of the standard device model, the corresponding function of the device function is called to realize the device behavior simulation and communication between models.
10. The universal peripheral device functional behavior level modeling and simulation method according to claim 9, characterized in that: A high-level language is used to describe the functions and behaviors of the device, including register reading and writing behaviors and interface communication behaviors. When modeling register reading and writing behaviors, first, byte and array structures are used to describe the register group, and read and write methods are defined. Secondly, a mapping between the register group and the memory is established, and the registers are addressed by offset addresses and read and write operations are performed. Finally, the logical functions are improved according to the register reading and writing contents. When modeling interface communication behaviors, first, data receiving and sending methods are defined within the device to implement data encoding and decoding. Secondly, a mapping relationship between the device interface and the internal methods of the device is established. Finally, devices send data to or receive data from other devices by calling internal methods of the device.
Citation Information
Patent Citations
Visual modeling method for virtual operation environment of complex embedded system
CN112926109A
Chip modeling simulation method, product, equipment and medium
CN118211547A