Real-time controller software and hardware collaborative optimization system based on hardware perception

Through the real-time controller software and hardware collaborative optimization system based on hardware perception, the problem of insufficient hardware characteristics in real-time controllers and imbalance in power consumption and performance is solved, efficient utilization of hardware resources and performance optimization are achieved, and real-time response is enhanced Capability and system reliability, suitable for controllers of cross-domain unmanned systems.

CN118938655APending Publication Date: 2024-11-12EAST CHINA NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411009976.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In the design and production process of existing real-time controllers, there are problems such as insufficient hardware characteristics, imbalance in power consumption and performance, and real-time constraints. There is a lack of software and hardware collaboration solutions suitable for cross-domain unmanned systems, making it difficult for software to be sufficient. Using hardware resources, it is difficult to ensure high performance and high reliability work.

Method used

Adopt a real-time controller software and hardware collaborative optimization system based on hardware perception, and realizes efficient utilization and performance optimization of hardware resources through hardware driver development and hardware perception determination modes, including hardware abstraction, hardware acceleration, device control, resource management and real-time Task scheduling and other functions, design efficient software and hardware interfaces to ensure high performance and high reliability of the system.

Benefits of technology

It significantly improves hardware resource utilization, realizes balanced optimization of power consumption and performance, enhances real-time response capabilities, improves system flexibility and scalability, simplifies software development process, and improves the reliability and reliability of the overall system. Great.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118938655A_ABST
    Figure CN118938655A_ABST
Patent Text Reader

Abstract

A real-time controller software and hardware collaborative optimization system based on hardware perception is characterized in that a controller formed by an upper computer defines a mode of a hardware perception determination total software unit in the upper computer through functional requirements based on hardware driving program development, hardware perception determination, performance optimization and real-time performance; the controller is ensured to fully utilize hardware resources, and high performance and high reliability of the system are realized to control the electric equipment to work; the function of determining the total software unit by hardware perception is realized through hardware abstraction and hardware acceleration, a hardware instruction set, equipment control, resource management, real-time task scheduling and an efficient software and hardware interface software unit. According to the method, hardware resources can be efficiently utilized, power consumption and performance optimization can be realized, the real-time response capability is enhanced, the flexibility and expandability of the system are improved, the development process is simplified, and the reliability of the system is improved. According to the invention, the data integrity and security are enhanced, the system crash risk is reduced, and the robustness and reliability of the whole controller system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of control technology, and in particular to a hardware-aware based real-time controller software-hardware collaborative optimization system. Background Art

[0002] The development of controllers (such as PLC, single-chip microcomputer modules, host computers, etc.) has always been an important direction in engineering technology, and its software and hardware collaboration, as a key component, plays a vital role. With the continuous advancement of science and technology and the growing demand for applications, the status and role of software and hardware collaboration in controller design and application have become increasingly prominent. In the early days, the way controllers controlled related electrical equipment was mainly implemented by hardware, using analog circuits or simple digital circuits; these controllers had simple functions and were usually used in industrial control, automated production lines and other fields; and software was less used in controllers, mainly some simple logic controls. Due to the advancement of computer technology, controllers have gradually become software-based. The emergence of microprocessors and embedded systems has enabled controllers to have more complex functions and are easier to program and update; at this stage, the software part of the controller began to dominate, and the hardware part gradually moved closer to the software part, forming a trend of software and hardware collaboration. With the development of Internet of Things technology, controllers are facing new challenges and opportunities. The Internet of Things requires controllers to have higher communication and data processing capabilities to adapt to large-scale device interconnection and data exchange. In this context, software and hardware collaboration becomes more important. It is necessary to optimize software algorithms and hardware architecture to achieve efficient operation and low power consumption requirements for controllers.

[0003] In the current practice (production) of real-time controller hardware and software collaborative design, due to technical limitations, there are widespread problems such as insufficient hardware characteristics, imbalance between power consumption and performance, and real-time constraints. At the same time, in the research on hardware and software collaborative mechanisms, there is currently no research on real-time controller hardware and software collaborative mechanisms suitable for cross-domain unmanned control systems, resulting in a lack of solutions to solve hardware and software collaboration for real-time controllers of cross-domain unmanned systems (for the prior art, there is a lack of solutions to solve hardware and software collaboration for real-time controllers of cross-domain unmanned systems, which are introduced accordingly in the specific embodiments), that is, in real-time controllers, it is difficult for software to fully utilize hardware resources, and it is difficult to guarantee the high performance and high reliability of electrical equipment controlled by the controller. Summary of the invention

[0004] In order to overcome the shortcomings of existing real-time controllers due to technical limitations, such as insufficient hardware characteristics during design and production, imbalance between power consumption and performance, and real-time constraints, the present invention provides a real-time controller hardware and software collaborative optimization system based on hardware perception, which can achieve efficient software utilization of hardware resources, optimize power consumption and performance balance, enhance real-time response capabilities, improve system flexibility and scalability, simplify software development processes, and provide strong technical support for the reliability and stability of real-time controllers under the joint action of relevant functional modules and units.

[0005] The technical solution adopted by the present invention to solve its technical problem is:

[0006] A hardware-based real-time controller hardware-software collaborative optimization system, characterized in that the controller composed of the host computer defines the mode of the hardware-based hardware-based software unit based on hardware driver development, hardware-based hardware-based determination, performance optimization, and real-time functional requirements, ensuring that the controller can make full use of hardware resources and achieve high performance and high reliability of the system to control the operation of electrical equipment; the function of the hardware-based hardware-based software unit is achieved through its own hardware abstraction and hardware acceleration, hardware instruction set, device control, resource management, real-time task scheduling, and efficient hardware-software interface software units: the hardware abstraction unit includes a task context management subunit, an interrupt / exception management subunit, a CACHE management subunit, an MMU management subunit, a floating-point management subunit, and a clock management subunit; the interrupt / exception management subunit has an external interrupt enable / shield interface, an external interrupt vector installation / uninstall interface, and an enable / disable interface. The invention discloses a method for implementing a plurality of external interrupt interface software; the MMU management subunit has an MMU management interface, a memory management and PCIE address space mapping interface software, the MMU management interface software includes an MMU module initialization interface subunit, an MMU virtual-real address mapping interface subunit, and an idle TLB acquisition interface subunit, and the memory management and PCIE address space mapping interface software includes a memory management interface subunit and a PCIE address space mapping interface subunit; the floating-point management subunit has a floating-point context internal setting and a floating-point context management interface software, the floating-point context management interface software includes a floating-point module initialization interface subunit, a floating-point context initialization interface subunit, and a floating-point context switching interface subunit; the clock management subunit includes a CLOCK_REALTIME real-time clock subunit, a CLOCK_MONOTONIC monotonic rate clock subunit, a clock management interface subunit, and a clock library interface subunit.

[0007] Furthermore, the function of the device control software unit is realized through its own external interrupt enable / shield interface and external interrupt vector installation / uninstallation interface, and enabling / disabling a certain external interrupt interface sub-unit; the function of the resource management software unit is realized through its own external interrupt enable / shield interface, external interrupt vector installation / uninstallation interface, and enabling / disabling a certain external interrupt interface sub-unit; the function of the hardware acceleration function software unit is realized through its own CACHE management interface, MMU management interface, and floating-point management interface sub-unit; the function of the hardware instruction set software unit is realized through its own MIPS traditional fully associative TLB method to manage page table rule items and configuration register management floating-point operation sub-unit; the function of the real-time task scheduling software unit is realized by providing two types of clock management, real-time and monotonic rate, and switching and management of task contexts in the real-time controller hardware and software collaborative system.

[0008] Furthermore, the hardware abstraction software unit is used to abstract the underlying hardware into a unified interface and provide it to the upper-level software for use, so as to shield hardware differences and simplify software development; the device control software unit is used to provide a unified management and control interface for various types of equipment, and realize flexible scheduling and resource allocation of equipment; the resource management software unit is used to dynamically manage system resources, ensure the optimal allocation and use of resources, and improve system efficiency; the hardware acceleration software unit is used to improve the processing speed of computing-intensive tasks and reduce system latency through dedicated hardware accelerators; the hardware instruction set software unit is used to design specific hardware instruction sets, optimize common real-time control operations, and improve instruction execution efficiency; the real-time task scheduling software unit is used to realize priority scheduling of real-time tasks, and ensure the real-time and response speed of key tasks; the efficient hardware and software interface design software unit is used to design efficient interfaces to ensure fast and stable data transmission between hardware and software.

[0009] Furthermore, the task context management subunit is used to initialize the task context. When initializing the context, the task will be calculated and placed on the bottom of the stack first. During initialization, several key attributes of the context need to be assigned values: storing the task entry function and storing the function parameters. At the same time, the context pointer and the task ID of the current application need to be stored in the task control block.

[0010] Furthermore, the external interrupt enable / shield interface software configures some functions of the processor based on the status register used by the PLC or the CPU of the host computer, wherein the SR[IE] bit is a global interrupt enable bit, which is used to control whether the external interrupt is enabled. When the bit is 1, it indicates that the external interrupt is enabled, and when it is 0, it indicates that the external interrupt is shielded; enabling / disabling a certain external interrupt interface software is used to manage all interrupts and exceptions of the operating system of the host computer, and provide a general exception handling interface to take over all exceptions except external interrupts, provide an exception vector installation or uninstallation interface, which is used to write the custom exception handling function entry address into the corresponding position of the exception vector table or remove it from the exception vector table, and provide an exception vector setting interface for debugging; a CACHE management subunit is used to provide a management interface function for the CACHE of the host computer.

[0011] Furthermore, the MMU module initialization interface subunit is used to complete the initial mapping of the system address space, and describes the virtual address, physical address, extended physical address and page attributes through the static address space description table; the MMU virtual-real address mapping interface subunit is executed before the memory management is initialized, and is responsible for writing the virtual address, physical address, TID and page attributes into the MMU register to realize the mapping of the virtual address to the physical address; the idle TLB interface is used to obtain the idle TLB items for new address mapping.

[0012] Furthermore, the memory management subunit is used to manage the virtual address space. After mapping the virtual address and the physical address, all memory space lists are passed to the memory management module. The CPU accesses the memory through the virtual address, and the hardware is responsible for converting the virtual address into a physical address; the PCIE address space mapping interface subunit is used to allocate physical address space to the PCIE device and establish a mapping from the virtual address to the physical address. The CPU accesses the physical address of the PCIE device through the virtual address, thereby accessing the address space of the device.

[0013] Furthermore, the floating point context internal setting software can set whether the CPU enables floating point overflow exception, floating point underflow exception, floating point division by zero exception data,

[0014] Furthermore, the floating-point module initialization interface subunit is used to initialize floating-point registers and set pointers for floating-point scene saving and restoration. The interface is called when the system is started to ensure that the floating-point operation environment is correctly configured; the context initialization interface subunit is called when a task is created to initialize the floating-point context in the task control block of the newly created task. This interface ensures that each newly created task has an independent floating-point context to avoid floating-point operation interference between tasks; the floating-point context switching interface subunit is called when the task context is switched to save the floating-point context of the currently executed task and restore the floating-point context of the task to be run. This interface ensures the correct saving and restoration of the floating-point operation state when the task is switched, thereby ensuring the correctness and continuity of task execution.

[0015] Furthermore, the clock management subunit provides precise time control and timeout management for the system by managing and providing real-time clocks and monotonic rate clocks, supports task scheduling, synchronization mechanisms and event processing, and ensures the real-time and reliability of the system.

[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) Efficient use of hardware resources: Through the sophisticated hardware abstraction layer design, the software can deeply perceive and intelligently schedule the hardware characteristics, significantly improve the utilization rate of hardware resources, reduce the resource idle rate, and improve the overall system performance. (2) Optimization of power consumption and performance balance: The software and hardware coordination mechanism of the present invention can dynamically adjust the hardware working mode, automatically balance power consumption and performance according to the task load, and ensure low-power operation while meeting the real-time requirements, extending the working time of the equipment and reducing energy consumption. (3) Enhanced real-time response capability: The optimized interrupt and clock management module can quickly respond to external events, reduce delays, improve the real-time response speed and reliability of the system, and is suitable for application scenarios with strict real-time requirements. (4) Improved system flexibility and scalability: By introducing flexible task context management, it can easily adapt to different application requirements, enhance the configurability and scalability of the system, and facilitate the addition and upgrade of subsequent functions. (5) Simplified software development process, standardized hardware abstraction layer interface reduces the difficulty of software development, reduces the error rate, accelerates the time to market, and ensures the high quality and stability of the software. (6) Improve the overall reliability of the system: Through the optimization of the MMU management module and the CACHE management module, the present invention strengthens data integrity and security, reduces the risk of system crash, and improves the robustness and reliability of the entire controller system. Based on the above, the present invention has a good application prospect. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0018] Figure 1It is a block diagram of the processor architecture of the present invention.

[0019] Figure 2 It is a schematic diagram of task context switching of the present invention.

[0020] Figure 3 It is a block diagram of the overall software unit architecture determined by hardware perception of the present invention.

[0021] Figure 4 It is a relationship diagram between the hardware abstraction layer of the present invention, the real-time controller hardware layer and the operating system kernel. DETAILED DESCRIPTION

[0022] Figure 4 As shown in the figure, in the hardware-aware real-time controller hardware-software collaborative optimization system, the controller composed of the host computer (or PLLC, etc.) defines the mode of the hardware-aware total software unit in the host computer based on hardware driver development, hardware-aware determination, performance optimization, and real-time functional requirements, ensuring that the controller can make full use of hardware resources and realize high performance and high reliability of the system to control the operation of electrical equipment; the function of the hardware-aware total software unit is realized through its own hardware abstraction (hardware architecture) and hardware acceleration, hardware instruction set, device control, resource management, real-time task scheduling (real-time controller functional requirements), and efficient hardware-software interface (performance) software units (although hardware abstraction, device control, and resource management are all software units at the hardware architecture layer, the implementation of device control and resource management is based on hardware abstraction, and the functional requirements of the real-time controller are further realized by perceiving the hardware architecture, and finally completing the efficient hardware-software interface design and efficient communication mechanism design. In this design idea of ​​real-time controller hardware-software collaborative system based on hardware perception, performance and reliability are guaranteed). Specifically, the hardware abstraction software unit is used to abstract the underlying hardware into a unified interface and provide it to the upper-level software for use, so as to shield hardware differences and simplify software development; the device control software unit is used to provide a unified management and control interface for various types of equipment, and realize flexible scheduling and resource allocation of equipment; the resource management software unit is used to dynamically manage system resources, ensure the optimal allocation and use of resources, and improve system efficiency; the hardware acceleration software unit is used to improve the processing speed of computationally intensive tasks and reduce system latency through dedicated hardware accelerators; the hardware instruction set software unit is used to design specific hardware instruction sets, optimize common real-time control operations, and improve instruction execution efficiency; the real-time task scheduling software unit is used to realize priority scheduling of real-time tasks, and ensure the real-time and response speed of key tasks; the efficient hardware and software interface software unit is used to design efficient interfaces to ensure fast and stable data transmission between hardware and software.

[0023] The hardware abstraction unit includes the task context management subunit, the interrupt / exception management subunit, the cache management subunit, the MMU (Memory Management Unit) management subunit, the floating point management subunit, and the clock management subunit (such as Figure 4 As shown in the figure, the hardware abstraction layer is located between the hardware layer and the operating system kernel, and is the key to the real-time controller's hardware and software collaboration. The function of the hardware abstraction layer is to abstract the hardware implementation logic into a unified interface. Therefore, the present invention focuses on the design of the hardware abstraction layer, abstracting the hardware integration into the following 6 modules for the operating system kernel to call, such as Figure 1 The implementation of the CSP (Communicating Sequential Processes, CSP is usually located between the operating system kernel and the hardware abstraction layer, used to handle communication and synchronization between concurrent tasks and processes) library depends on the hardware abstraction unit. The identification and description of the six sub-units of the processor abstraction layer are shown in Table 1:

[0024]

[0025] Figure 2 As shown in the figure, the following content explains the implementation principle of the task context management subunit, interrupt / exception management subunit, CACHE management subunit, MMU management subunit, floating point management subunit, and clock management subunit. 1: Task context management subunit. When the COU task of the host computer is created, the task context will be initialized. The task context refers to all the status information when the task is executed, including CPU registers, program counters, and the bit stack pointer stored below. Figure 2As shown. When initializing the context, the task context is calculated first and generally placed at the bottom of the stack (the bottom of the stack refers to the starting position of the task stack. The purpose of calculating the task context position is to ensure that the task can correctly save and restore its state when switching). During initialization, several key attributes of the context need to be assigned values: specifically, the task entry function and function parameters are stored. At the same time, the context pointer and the task ID (task identifier) ​​of the current application need to be stored in the task control block. When the real-time controller context switches, control registers such as SR (status register), EPC (exception program counter) and general registers from $0 to $31 are saved. These control registers and general registers need to be restored when the context is restored to ensure the correctness of the task switch. The overall function of the task context management subunit is to save and restore the running status of the task to ensure that the task does not lose its execution progress and context during the switching process, thereby ensuring the stability and reliability of the real-time operating system. 2: Interrupt / exception management subunit, mainly used for interrupt management of the host computer's CPU (such as Loongson 2K), including external interrupt and exception management; CSP provides processor-related implementation for the external interrupt management of the Loongson 2K operating system core, which is used to manage the external interrupts of the entire system, mainly including the following interface software: (1) External interrupt enable / disable interface software: Loongson 2K uses the status register (SR) to configure some functions of the processor, where the SR[IE] bit is the global interrupt enable bit, which is used to control whether the external interrupt is enabled. When this bit is 1, it means enabling the external interrupt, and when it is 0, it means disabling the external interrupt; (2) External interrupt vector installation / uninstallation interface software; (3) Enable / disable a certain external interrupt interface software. CSP also provides processor-related implementations for the exception management of the operating system core, which is used to manage exceptions of the entire system; CSP maintains an exception vector table to manage all interrupts and exceptions, and provides a general exception handling interface to take over all exceptions except external interrupts; provides an exception vector installation or uninstallation interface to write the entry address of the custom exception handling function to the corresponding position of the exception vector table or remove it from the exception vector table; provides an exception vector setting interface for debugging. For external interrupts, CSP provides a general external interrupt handling interface to take over all external interrupts, and provides a unified external interrupt mounting and uninstallation interface; when the peripheral needs to use the interrupt framework of the operating system, it is necessary to use the CSP interrupt mounting interface to write the entry address of the peripheral interrupt service program into the corresponding interrupt vector table; after the interrupt is successfully mounted, the peripheral can start the interrupt mode; when the peripheral needs to release this relationship, call the interrupt uninstallation interface.For all uninitialized external interrupts / exceptions, a default processing function will be specified; Loongson 2K supports 32 types of interrupts / exceptions (see Table 1-2), and the maintained interrupt vector table has a total of 32 entries, each of which includes two elements: vector number and vector entry address; among them, the interrupt / exception vector processing of system calls, clocks, and watchdogs is uniformly handled by the function reworks_exception_handler, and the interrupt vectors of external interrupts are installed separately using the external interrupt vector installation interface int_install_handler. In addition, the handler entries of shared interrupts are installed using the shared_int_install interface to realize the processing of shared interrupts.

[0026] Table 2 Interrupt / exception handling functions supported by real-time processors

[0027]

[0028]

[0029] The functions of the interrupt / exception management subunit are summarized as follows: CSP provides the operating system core with processor-related implementations for effectively managing external interrupts and exceptions for the entire system, including enabling, masking, installing, uninstalling, and enabling and disabling specific interrupts. By maintaining an exception vector table containing 32 entries, CSP ensures the consistency and controllability of interrupt and exception handling, and provides a unified interface for installing, uninstalling, and handling interrupts and exceptions, thereby improving the stability and responsiveness of the system. In addition, CSP supports interrupt management of peripherals, allowing peripherals to register their interrupt service routines to the system's interrupt framework through interrupt mount and uninstall interfaces. When the peripheral no longer needs to use the interrupt mode, this relationship can be released through the uninstall interface. For uninitialized external interrupts and exceptions, the system specifies a default processing function to ensure that unhandled interrupts and exceptions do not cause system crashes or instability. Overall, these steps ensure that the system can efficiently and stably handle various interrupt and exception situations by providing a unified and flexible interrupt and exception management mechanism, thereby improving the reliability and performance of the system.

[0030] 3. CACHE management subunit, CACHE management provides a set of management interfaces for the CACHE (cache memory) of the target platform, as shown in Table 3.

[0031] Table 3 CACHE management interface

[0032]

[0033] 4. MMU management unit, which provides management interface for system address space mapping and memory management and PCIE address space mapping, including MMU management interface, memory management and PCIE address space mapping interface software; MMU management interface software includes MMU module initialization interface subunit, MMU virtual address mapping interface subunit and free TLB interface subunit. The MMU module initialization interface subunit is used to complete the initial mapping of system address space. Loongson 2K provides a static address space description table for MMU management module. The entries of the description table mainly describe virtual address, physical address, extended physical address and MMU page attribute. The MMU virtual address mapping interface subunit is executed before initializing memory management. The establishment of virtual address mapping mainly writes virtual address, physical address, TID (Thread Identifier) ​​and page attribute into the corresponding position of MMU register. In MMU virtual address mapping interface subunit, the basis for Loongson 2K to establish virtual address mapping is 3 TLB (Translation Lookaside Buffer) words, and the corresponding registers are EntryLo0, EntryLo1 and EntryHi. The organization and operation of TLB adopt the traditional fully associative TLB method of MIPS (Microprocessor without Interlocked Pipeline Stages). There are 64 page table rule items in Loongson 2K. The functions of the three interface subunits are summarized as follows: (1) The function of the MMU module initialization interface subunit is to complete the initial mapping of the system address space, and describe the virtual address, physical address, extended physical address and page attributes through the static address space description table; the function of the MMU virtual-real address mapping interface subunit is to execute before the memory management is initialized, and is responsible for writing the virtual address, physical address, TID and page attributes into the MMU register to realize the mapping of virtual address to physical address; (2) The function of the get free TLB interface subunit is to get free TLB items for new address mapping. The functions of memory management and PCIE address space mapping interface software are as follows: the system memory management actually manages the virtual address space. Before performing memory management, the virtual address and the physical address need to be mapped, and then all the memory space lists are passed to the memory management. The CPU then uses the virtual address to access the memory, and the actual virtual address conversion to the physical address is completed by the hardware; the PCIE address space also needs to be mapped between the virtual address and the physical address before use, and the physical address space is allocated for the PCIE device. Then the CPU accesses the physical address of the PCIE device through the corresponding virtual address according to the mapping relationship, thereby accessing the address space of the device.The functions of the MMU management interface, memory management and PCIE (3) address space mapping interface software are summarized as follows: the memory management interface is divided into units, which manage the virtual address space. After mapping the virtual address and the physical address, all memory space lists are passed to the memory management module. The CPU accesses the memory through the virtual address, and the hardware is responsible for converting the virtual address into the physical address; the PCIE address space mapping interface is divided into units: physical address space is allocated to the PCIE device, and a mapping from the virtual address to the physical address is established. The CPU accesses the physical address of the PCIE device through the virtual address, thereby accessing the address space of the device.

[0034] 5. The floating point management subunit provides floating point context management functions for CSP. Specifically, (1) the internal structure of the floating point context is as follows: the floating point context structure of Loongson 2K contains 32 floating point registers (double fpr

[32] ) and a floating point control status register (FCSR). By configuring the FCSR register, you can set whether to enable floating point overflow exception, floating point underflow exception, floating point division by zero exception, etc. The floating point context is saved in the task control block. When floating point support is checked, the task control block contains a floating point context member. The floating point context management interface software of the floating point management subunit provides a set of floating point context management interfaces for the processor abstraction layer, including floating point module initialization interface, floating point context initialization interface, and floating point context switching interface. The floating point module initialization interface initializes the floating point registers, sets the floating point scene save and floating point scene restore pointers. The floating point context initialization interface is called when a task is created to initialize the floating point context in the task control block of the newly created task. The floating-point context switch interface is called when the task context is switched to save the floating-point context of the currently executing task and restore the floating-point context of the task to be run. The functions of the three interfaces of this module are summarized as follows: (1) Floating-point module initialization interface: used to initialize floating-point registers and set pointers for floating-point scene save and restore. This interface is called when the system starts to ensure that the floating-point operation environment is correctly configured. (2) Floating-point context initialization interface: called when the task is created to initialize the floating-point context in the task control block of the newly created task. This interface ensures that each newly created task has an independent floating-point context to avoid interference between floating-point operations between tasks. (3) Floating-point context switch interface: called when the task context is switched to save the floating-point context of the currently executing task and restore the floating-point context of the task to be run. This interface ensures the correct preservation and restoration of the floating-point operation state when the task is switched, thereby ensuring the correctness and continuity of task execution.

[0035] 6. In the clock management module, the system defines two software clocks: CLOCK_REALTIME real-time clock and CLOCK_MONOTONIC monotonic rate clock. Both the real-time clock and the monotonic rate clock are system-level clocks. The real-time clock can be restarted, while the monotonic rate clock cannot be restarted. That is, once the system is restarted, the record of the monotonic rate clock will disappear. The clock management provided by the system can provide time slices for round-robin scheduling and is used for timeout management of operations such as semaphores, events, messages, and signals. The clock library also provides an interface for setting and obtaining kernel tick count values. The functions of the clock management interface provided by the system are as follows: (1) CLOCK_REALTIME real-time clock: used to provide the current real-time time and can be reset during system operation. This clock can be restarted and is suitable for operations that require accurate current time. (2) CLOCK_MONOTONIC monotonic rate clock: used to provide the length of time the system has been running. It cannot be reset or restarted. Once the system is restarted, the record of the monotonic rate clock will disappear. It is suitable for operations that require the calculation of time intervals. (3) Clock management interface: used to provide time slices to support round-robin scheduling and manage timeouts for operations such as semaphores, events, messages, and signals. Through these interfaces, the system can complete tasks or timeouts within a specified time, ensuring real-time and reliability. (4) Clock library interface: provides the function of setting and obtaining kernel tick count values, enabling the system to accurately control and query time information. In summary, these interfaces provide the system with precise time control and timeout management by managing and providing real-time clocks and monotonic rate clocks, and support task scheduling, synchronization mechanisms, and event processing, ensuring the real-time and reliability of the system.

[0036] The present invention Figure 3The five modules of device control, resource management, hardware acceleration, hardware instruction set, and real-time task scheduling can all meet the basic functional requirements of the real-time controller based on the implementation of the hardware abstraction layer, and can be implemented through some functions in the hardware abstraction layer. The efficient software and hardware interface design covers all interfaces of the six modules in the hardware abstraction layer. 1. Device control can be implemented through the following interfaces: external interrupt enable / shield interface, external interrupt vector installation / uninstallation interface, enable / disable a certain external interrupt interface. 2. Resource management can be implemented through the following interfaces: external interrupt enable / shield interface, partial interrupt vector installation / uninstallation interface, enable / disable a certain external interrupt interface. 3. Hardware acceleration can be implemented through the following interfaces: CACHE management interface: enable, disable, refresh, invalidate, MMU management: address space mapping, memory management, PCIE address space mapping, floating point management: floating point context initialization, switching. 4. The hardware instruction set can be implemented through the following interfaces, using MIPS's traditional fully associative TLB method to manage page table rule items. Floating point operations are managed through configuration registers. 5. Real-time task scheduling can be implemented through the following interfaces, providing real-time and monotonic rate clock management, and task context switching and management in the real-time controller hardware and software collaborative system. 6. Efficient hardware and software interface design, the hardware abstraction layer should provide a unified interface to access the underlying hardware resources. The present invention designs 6 general basic modules and integrates them in the csp program library, including task context management module, interrupt / exception management module, CACHE (cache) management module, MMU (Memory Management Unit, memory management unit) management module, floating point management module and clock management module.

[0037] In summary, the present invention has the following advantages. (1) Efficient utilization of hardware resources: Through the sophisticated hardware abstraction layer design, the present invention realizes the deep perception and intelligent scheduling of hardware characteristics by software, significantly improves the utilization rate of hardware resources, reduces the resource idle rate, and improves the overall system performance (mainly achieved through the CACHE management module, MMU management module, floating point management module, etc.). (2) Optimization of power consumption and performance balance: The software and hardware coordination mechanism of the present invention can dynamically adjust the hardware working mode, automatically balance power consumption and performance according to the task load, and ensure low-power operation while meeting the real-time requirements, extend the working time of the equipment and reduce energy consumption (mainly achieved through the floating point management module, etc.). (3) Enhanced real-time response capability: The optimized interrupt and clock management module can respond quickly to external events, reduce delays, improve the real-time response speed and reliability of the system, and is suitable for application scenarios with strict real-time requirements (mainly achieved through the interrupt / exception management module, clock management module, etc.). (4) Improve system flexibility and scalability: By introducing flexible task context management, the present invention can easily adapt to different application requirements, enhance the configurability and scalability of the system, and facilitate the addition and upgrade of subsequent functions (mainly achieved through task context management modules, etc.) (5) Simplify the software development process: The standardized hardware abstraction layer interface reduces the difficulty of software development, reduces the error rate, and accelerates the time to market, while ensuring the high quality and stability of the software (mainly achieved through standardized hardware abstraction layer interfaces (general advantages)). (6) Improve the overall reliability of the system: Through the optimization of the MMU management module and the CACHE management module, the present invention enhances data integrity and security, reduces the risk of system crashes, and improves the robustness and reliability of the entire controller system (mainly achieved through the MMU management module and the CACHE management module). In summary, the present invention not only solves the shortcomings of the hardware and software coordination mechanism in the prior art, but also significantly improves the performance, efficiency and scope of application of the real-time controller, providing a more advanced and reliable solution for industrial automation, the Internet of Things and other real-time control applications.

[0038] The reasons why the existing technology lacks a solution for the software and hardware collaboration of the real-time controller of a cross-domain unmanned system are as follows. Specifically, as the control center of an autonomous unmanned system (such as unmanned spraying equipment, unmanned machine tools, etc.), the intelligent controller directly determines the control performance of the unmanned system. The research and application of its openness, versatility and intelligence are of great value and are a hot spot in the control technology of unmanned systems. At present, many achievements have been made in related fields at home and abroad. From the hardware point of view, it is gradually developing in the direction of integration and miniaturization; while the software has higher requirements for the architecture, gradually changing from closed to open, from dedicated to general, from functional to intelligent, and reducing the degree of dependence on special hardware. There are already many unmanned system architectures in various application fields. In 1998, the US Department of Defense proposed the JAUS architecture, which has realized cross-domain communication and interoperability between autonomous unmanned systems and unmanned submarines. However, the JAUS architecture supports a single scenario and is difficult to guide the development and application of autonomous unmanned systems in complex cross-domain scenarios. In 2002, the US military defined the 4D Real-time Control Systems (4D / RCS). This architecture defines the method of multi-task analysis, planning, execution and coordination. However, the 4D / RCS architecture is too complex, and its current implementation is mainly aimed at low- and medium-level vehicle-level control. In 2003, several automakers jointly launched the AUTOSAR specification, which improved the scalability, flexibility, and reusability of software, but its system resource allocation was fixed, making it difficult to meet the needs of complex cross-domain scenarios. In 2017, Baidu open-sourced the Apollo architecture, which is based on ROS and has been transformed in three aspects: communication performance optimization, decentralized network topology, and data compatibility expansion. However, this architecture is mainly aimed at the field of unmanned driving, and its support for multi-scenario cross-domain unmanned systems is weak. In 2020, Huawei's CCA architecture uses software to define cars. By using Huawei's chips and operating systems, it can achieve cross-model intelligent driving for the whole vehicle. In addition, in 2007, the robot operating system ROS effectively integrated various tools required for the operation of intelligent devices. ROS2 launched in 2017 supports cross-platform and real-time performance, and uses DDS as the communication system. DDS provides a cross-platform, cross-language and system communication mechanism, and can provide a standard communication interface, but its information warehouse mode has a single point bottleneck, and the real-time publish-subscribe protocol may generate a large amount of messages in the discovery phase, consuming more resources. It can be seen from the above that the controller architecture for a single application field is becoming more and more mature, but the controller architecture suitable for multiple fields is still relatively vacant. From the perspective of the development of the controller architecture, the autonomous controllability of the controller hardware and software platform, unified communication standards, packaging standards for multiple types of sensors, high-performance, high-precision industry integrated algorithm library interfaces and evaluation standards still need further research.Therefore, the main purpose of the present invention is to optimize the real-time controller software and hardware collaborative system in the cross-domain unmanned system architecture.

[0039] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It is obvious to those skilled in the art that the present invention is limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes that fall within the meaning and scope of the equivalent elements of the claims are included in the present invention.

[0040] In addition, it should be understood that although the present specification is described according to the implementation mode, the implementation mode does not only include an independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in the embodiments can also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.

Claims

1. A hardware-aware real-time controller hardware-software collaborative optimization system, characterized in that: The controller composed of the host computer defines the mode of the hardware perception determination total software unit in the host computer based on the functional requirements of hardware driver development, hardware perception determination, performance optimization, and real-time performance, ensuring that the controller can make full use of hardware resources and realize the high performance and high reliability of the system to control the operation of electrical equipment; the function of the hardware perception determination total software unit is realized through its own hardware abstraction and hardware acceleration, hardware instruction set, device control, resource management, real-time task scheduling, and efficient hardware and software interface software unit: the hardware abstraction unit includes a task context management subunit, an interrupt / exception management subunit, a CACHE management subunit, an MMU management subunit, a floating point management subunit, and a clock management subunit; the interrupt / exception management subunit has an external interrupt enable / shield interface, an external interrupt vector installation / uninstallation interface, and enables / disables a certain external interrupt interface software; the MMU The U management subunit has an MMU management interface, a memory management and PCIE address space mapping interface software, the MMU management interface software includes an MMU module initialization interface subunit, an MMU virtual-real address mapping interface subunit, and an idle TLB acquisition interface subunit, and the memory management and PCIE address space mapping interface software includes a memory management interface subunit and a PCIE address space mapping interface subunit; the floating-point management subunit has a floating-point context internal setting and a floating-point context management interface software, the floating-point context management interface software includes a floating-point module initialization interface subunit, a floating-point context initialization interface subunit, and a floating-point context switching interface subunit; the clock management subunit includes a CLOCK_REALTIME real-time clock subunit, a CLOCK_MONOTONIC monotonic rate clock subunit, a clock management interface subunit, and a clock library interface subunit.

2. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The function of the device control software unit is realized through its own external interrupt enable / shield interface and external interrupt vector installation / uninstallation interface, and enabling / disabling a certain external interrupt interface subunit; the function of the resource management software unit is realized through its own external interrupt enable / shield interface, external interrupt vector installation / uninstallation interface, and enabling / disabling a certain external interrupt interface subunit; The hardware acceleration software unit function is realized through its own CACHE management interface, MMU management interface, and floating-point management interface sub-units; the hardware instruction set software unit function is realized through its own MIPS traditional fully associative TLB method to manage page table rule items and configuration register management floating-point operation sub-units; the real-time task scheduling software unit function is realized by providing real-time and monotonic rate clock management, and switching and management of task contexts in the real-time controller hardware and software collaborative system.

3. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The hardware abstraction software unit is used to abstract the underlying hardware into a unified interface and provide it to the upper-level software for use, so as to shield hardware differences and simplify software development. The device control software unit is used to provide a unified management and control interface for various types of equipment, and realize flexible scheduling and resource allocation of equipment. The resource management software unit is used to dynamically manage system resources, ensure the optimal allocation and use of resources, and improve system efficiency. The hardware acceleration software unit is used to increase the processing speed of computationally intensive tasks and reduce system latency through dedicated hardware accelerators. The hardware instruction set software unit is used to design specific hardware instruction sets, optimize common real-time control operations, and improve instruction execution efficiency. The real-time task scheduling software unit is used to realize priority scheduling of real-time tasks and ensure the real-time and response speed of key tasks. The efficient hardware and software interface design software unit is used to design efficient interfaces to ensure fast and stable data transmission between hardware and software.

4. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The task context management subunit is used to initialize the task context. When initializing the context, the task is first calculated and placed on the bottom of the stack. During initialization, several key attributes of the context need to be assigned values: the task entry function and function parameters are stored. At the same time, the context pointer and the task ID of the current application need to be stored in the task control block.

5. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The external interrupt enable / disable interface software is based on the PLC or the CPU of the host computer using the status register to configure some functions of the processor, where the SR[IE] bit is the global interrupt enable bit, which is used to control whether the external interrupt is enabled. When the bit is 1, it means that the external interrupt is enabled, and when it is 0, it means that the external interrupt is disabled; the software for enabling / disabling a certain external interrupt interface is used to manage all interrupts and exceptions of the operating system of the host computer, and provide a general exception handling interface to take over all exceptions except external interrupts, provide an exception vector installation or uninstallation interface, which is used to write the custom exception handling function entry address to the corresponding position of the exception vector table or remove it from the exception vector table, and provide an exception vector setting interface for debugging; the CACHE management subunit is used to provide a management interface function for the CACHE of the host computer.

6. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The MMU module initialization interface subunit is used to complete the initial mapping of the system address space, and describes the virtual address, physical address, extended physical address and page attributes through the static address space description table; the MMU virtual-to-real address mapping interface subunit is executed before the memory management is initialized, and is responsible for writing the virtual address, physical address, TID and page attributes into the MMU register to achieve the mapping of the virtual address to the physical address; the free TLB interface is used to obtain free TLB entries for new address mapping.

7. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The memory management subunit is used to manage the virtual address space. After mapping the virtual address and the physical address, all memory space lists are passed to the memory management module. The CPU accesses the memory through the virtual address, and the hardware is responsible for converting the virtual address into the physical address. The PCIE address space mapping interface subunit is used to allocate physical address space for PCIE devices and establish a mapping from virtual address to physical address. The CPU accesses the physical address of the PCIE device through the virtual address, thereby accessing the address space of the device.

8. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The floating point context internal setting software can set whether the CPU enables floating point overflow exception, floating point underflow exception, and floating point division by zero exception data.

9. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The floating-point module initialization interface subunit is used to initialize the floating-point registers and set the pointers for floating-point scene saving and recovery. The interface is called when the system starts to ensure that the floating-point operation environment is correctly configured; the context initialization interface subunit is called when the task is created to initialize the floating-point context in the task control block of the newly created task. This interface ensures that each newly created task has an independent floating-point context to avoid interference between floating-point operations between tasks; The floating-point context switching interface is divided into units and is called when the task context is switched. It is used to save the floating-point context of the currently executing task and restore the floating-point context of the task to be run. This interface ensures the correct preservation and restoration of the floating-point operation state when the task is switched, thereby ensuring the correctness and continuity of task execution.

10. The hardware-aware real-time controller software-hardware collaborative optimization system according to claim 1, characterized in that: The clock management subunit provides precise time control and timeout management for the system by managing and providing real-time clock and monotonic rate clock, supports task scheduling, synchronization mechanism and event processing, and ensures the real-time and reliability of the system.