Universal peripheral equipment function behavior level modeling and simulation method
Through the general peripheral device functional behavioral modeling and simulation methods, the problems of complex and diverse peripheral devices interfaces in embedded systems are solved, and the standardization and efficient simulation of device modeling are realized, and simulation efficiency and model reusability are improved.
Patent Information
- Application Number
- CN202411251561.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-08
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-09-08
AI Technical Summary
The complex interfaces and wide variety of peripheral devices in embedded systems lead to complex equipment modeling processes, high development costs, low simulation efficiency and poor reusability.
Adopt general peripheral device function behavior-level modeling and simulation methods, and realize abstract description and logical simulation of device functions by defining device description files, behavior-level modeling, C code generation, functional consistency inspection and standard equipment model library packaging. Form a digital device model that is equivalent to hardware functions.
The equipment modeling method is standardized, the modeling efficiency and model reusability are improved, the problem of difficult device model interconnection is solved, efficient peripheral equipment simulation is achieved, and development costs are reduced.
Smart Images

Figure CN119148994A_ABST
Abstract
Description
Technical Field
[0001] The 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 with hardware, and developers usually need to debug based on hardware target machines. Hardware target machines have a wide variety of peripheral devices, complex interfaces, and strong specialization, which makes it difficult to reuse between different configuration items of software, resulting in high customization costs for software development environments and low development efficiency. At present, a virtualization technology is often used to model and simulate the functions of peripheral devices at the behavioral level, build a fully digital device model equivalent to the hardware function, reduce dependence on hardware, increase reuse rate, and thus improve software development efficiency.
[0003] According to the differences in the granularity of peripheral device modeling and simulation, a variety of device models will be generated. Common device models include clock cycle accurate device model, event-driven device model, and behavioral device model. Among them, the clock cycle accurate model has the highest accuracy, describes the hardware details of the device, and ensures that each cycle is consistent with the hardware behavior; the behavioral device model is the fastest, and the models interact through function calls, with the highest level of abstraction; the accuracy and speed of the event-driven device model are between the two. Peripheral device behavioral level simulation uses high-level languages to model peripheral registers, interfaces, and properties through function calls, structure definitions, etc., and performs logical function behavioral level simulation. Device objects are created by abstractly representing functions and characteristics, and the interaction relationship between objects is used to describe the composition relationship of hardware devices, forming a fully digital device model to provide support for embedded software development and testing.
[0004] The interfaces of embedded system peripherals are complex and varied, and generally have problems such as low utilization, high cost, and irreversible failures. It is difficult to carry out effective embedded software development and testing when the hardware equipment is not available. Although virtualization technology can be used to simulate hardware peripherals, it cannot be popularized in actual engineering applications of embedded software development due to the lack of unified peripheral modeling standards, low functional simulation efficiency, and high customization difficulty.
[0005] In order to meet the demand of improving the efficiency of embedded software development, the target machine peripheral devices are modeled and simulated. This invention provides a general peripheral device behavior-level function modeling and simulation method. The device is abstractly described through modeling, and the peripheral device logical function is realized through behavior-level simulation to form a digital device model equivalent to the hardware function, build an operating environment, and 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] (II) 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] The behavior-level modeling method is used to model the 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 the register read and write content, and to perform corresponding logical behavior descriptions; IO interface behavior modeling is used to describe the data receiving and sending functions based on the 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 on this basis to form a complete device model code;
[0016] Step 4: Check the consistency of device functions
[0017] Extract the device model code features, establish a mapping relationship between the device key feature description and the device model code features, and verify the consistency between the generated device model code and 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] (III) Beneficial effects
[0021] The present invention proposes a general peripheral device functional behavior level modeling and simulation method, and the general peripheral device functional behavior level modeling and simulation method of the present invention has the following characteristics:
[0022] 1) Widely adopt the peripheral device behavior modeling technology based on device description language, standardize the device modeling methods and standards, improve the efficiency of device modeling, and solve the problems of poor reusability of device models and difficulty in interconnection and interoperability;
[0023] 2) The device model code generation is realized. By translating the device description file, the key feature information such as interface, attribute, register, etc. is translated into C code. The mapping relationship between C code and 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 equipment universal to the present invention;
[0026] Figure 2 Composition diagram for standard equipment model;
[0027] Figure 3 It is the package and analysis diagram of the standard equipment 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 in conjunction with the drawings and examples.
[0029] The purpose of the present invention is to provide a universal peripheral device behavior-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 various types of peripheral devices in current embedded systems.
[0030] The present invention provides a general peripheral device behavior-level function modeling and simulation method. The method first defines a device description file *.vdl based on the characteristics of the peripheral device to describe the general information of the peripheral device; secondly, the peripheral device is modeled at the behavior level, including registers, IO interfaces and other contents; then, the device model function is improved, register reading and writing, data transmission and reception, device initialization and other function simulations are completed, and the device model description file is translated into device C code; finally, the device function model consistency check is performed, and after passing the check, the C code is compiled into a device dynamic library that can be called. The general peripheral device behavior-level function simulation method implemented by the method has a standardized modeling process, clear description of model attributes and interfaces, and accurate description of logical functions, forming a general and efficient peripheral device modeling and simulation method, and improving the simulation efficiency of peripheral devices.
[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. The device interface includes output interface, input interface, registration interface, and release interface; the device attributes include interrupt number, device base address, register offset address, etc.
[0033] Step 2: Peripheral device behavioral level functional modeling
[0034] The behavior-level modeling method is used to model the peripheral device functions, including registers, IO interfaces, simulation core scheduling behaviors, etc. Register behavior modeling is used to identify read and write operations based on the register read and write content, and to describe the corresponding logical behaviors; IO interface behavior modeling is used to describe the data receiving and sending functions based on the 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.
[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 on this basis, improve the device functions to form a complete device model code.
[0037] Step 4: Check the consistency of device functions
[0038] Extract device model code features, establish a mapping relationship between device key feature description 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 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 device dynamic library are packaged to form a standard device model library for unified management.
[0041] Embodiment 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 storage; second, behavioral-level functional modeling is carried out in combination with 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, reg_offset, etc. Keywords are used to model device registers, interfaces, and other functions. For example, the device description is "dev": "timer"; the register description is "reg": "TIMER_CNT"; the register offset description is "reg_offset": "0x4".
[0047] Secondly, extract the key features of peripheral devices. Analyze the functions of the simulated peripheral devices, extract key feature information such as device name, device registers, device IO interface, device attributes, etc., and describe them using device description language.
[0048] The second step is to model the functional behavior level of peripheral devices
[0049] First, the simulated peripheral functions are divided and abstractly described. The simulated peripheral functions are divided, including peripheral functions and simulation core scheduling functions. Peripheral functions include register access, IO interface access, etc., and simulation core scheduling functions include device registration, device release, etc. An abstract description of device behavior is performed, such as modeling of memory data reading function. The simulated data can be read once, without simulating the details of byte reading.
[0050] Secondly, the peripheral register behavior modeling. The peripheral register behavior modeling includes two parts: register size and method. The register size ranges from 1 to 8 bytes, stored by bytes, and 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 makes an abstract description.
[0051] Then, the peripheral interface behavior modeling is carried out. The peripheral 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, storage unit, etc.; the sending method implements the function of sending data to the outside, reads the contents of the device register, storage unit, etc., frames according to the device communication protocol, and sends data to the outside; communication between devices is realized by calling the receiving and sending methods of the corresponding device.
[0052] Finally, the simulation core scheduling behavior is modeled. The simulation core scheduling behavior includes methods such as device registration and device release. The device registration method implements the initialization of the device model function, establishes the IO interface function call mapping between devices, and adds the device to the simulation core device management queue; the device release method implements the device function release and removes the device from the simulation core device management queue.
[0053] The third step is to translate and generate the device model C code and improve the function
[0054] First, define the device description language translation rules, establish the mapping relationship between keywords and C language, and form a common 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 functional 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, 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 a unified device simulation scheduling framework, connected according to the device interface information, and addressed and accessed according to the device base address.
[0068] Finally, run the standard device model, and according to the access operation of the standard device model, call the corresponding function of the device function to realize the device behavior simulation and communication between models.
[0069] The key points of the present invention are:
[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, 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, where the device name interface provides a unified device identification; the device description interface provides an introduction to the basic functions of the device, including functions, interfaces, attributes, etc.; the register group interface provides device register read and write access functions; the attribute interface provides device attribute information setting and acquisition functions; the output interface provides the device with external data sending functions; the input interface provides the device with external data receiving functions; the registration interface provides device model initialization and simulation scheduling functions; the release interface provides device model resource release functions. The standard device model composition diagram is as follows: Figure 2 shown.
[0073] Logical function behavior level modeling uses high-level languages to describe the functions and behaviors of the device, mainly including register read and write behaviors, interface communication behaviors, etc. When modeling register read and write behaviors, first, use structures such as bytes and arrays to describe the register group and define the read and write methods; second, establish a mapping between the register group and the memory, address the register through the offset address and perform read and write operations; finally, improve the logical function according to the register read and write content. For example, write a start command to the timer control register, write data according to the control register function, and then create a timer thread and start timing. When modeling interface communication behavior, first define the data receiving and sending methods inside the device to implement data encoding and decoding; second, establish a mapping relationship between the device interface and the internal methods of the device; finally, the devices send data to or receive data from other devices by calling the internal methods of the device. For example, when a device generates an interrupt, the device calls the interrupt trigger function inside the processor to notify the processor that an interrupt has occurred, and then the processor jumps to the corresponding interrupt service program according to 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 difficult interconnection caused by different modeling methods.
[0076] The standard device model consists of two parts. One part 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 part 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 device method 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 adopt the peripheral device behavior modeling technology based on device description language, standardize the device modeling methods and standards, improve the efficiency of device modeling, and solve the problems of poor reusability of device models and difficulty in interconnection and interoperability;
[0079] 2) The device model code generation is realized. By translating the device description file, the key feature information such as interface, attribute, register, etc. is translated into C code. The mapping relationship between C code and 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 The behavior-level modeling method is used to model the 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 the register read and write content, and to perform corresponding logical behavior descriptions; IO interface behavior modeling is used to describe the data receiving and sending functions based on the 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 on this basis to form a complete device model code; Step 4: Check the consistency of device functions Extract the device model code features, establish a mapping relationship between the device key feature description and the device model code features, and verify the consistency between the generated device model code and 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 as claimed in claim 1, characterized in that: The device description file *.vdl is a structured description file based on the JSON format. The 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 simulated peripheral device functions are analyzed, and the key feature information of the 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 as claimed in claim 2, characterized in that: In the second step, the modeling of register behavior includes two parts: register size and method; the register size ranges from 1 to 8 bytes, is stored by 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 makes an abstract description.
4. The general peripheral device functional behavior level modeling and simulation method as claimed in claim 2, characterized in that: In the second step, the IO interface behavior modeling includes: 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 as claimed in 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 comprises: 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 function, 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 as claimed in 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 as claimed in claim 7, characterized in that: The fifth step comprises: 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, 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 as claimed in claim 9, characterized in that: The method further includes a sixth step after the fifth step: standard equipment model simulation scheduling, and the standard equipment model simulation scheduling 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, run the standard device model, and according to the access operation of the standard device model, call the corresponding function of the device function to realize the device behavior simulation and communication between models.
10. The general peripheral device functional behavior level modeling and simulation method according to claim 9, characterized in that: Use high-level language to describe the functions and behaviors of the device, including register read and write behaviors and interface communication behaviors; when modeling register read and write behaviors, first, use byte and array structures to describe the register group and define read and write methods; second, establish a mapping between the register group and the memory, address the register through the offset address and perform read and write operations; finally, improve the logical function according to the register read and write content; when modeling interface communication behaviors, first define the data receiving and sending methods inside the device to implement data encoding and decoding; second, establish a mapping relationship between the device interface and the internal methods of the device; finally, devices send data to or receive data from other devices by calling the internal methods of the device.
Citation Information
Patent Citations
Entity behavioral modeling assembling method and system
CN103336694A
Visual modeling method for virtual operation environment of complex embedded system
CN112926109A
Chip modeling simulation method, product, equipment and medium
CN118211547A
Construction method and equipment of simulation system based on neutral simulation language
CN118605848A
