FPGA-based implementation of hot switching of PS / 2 keyboard and mouse interfaces in multiple hosts
Through real-time monitoring and control of FPGA, the simulation and hot switching of multi-host PS/2 interfaces are realized, and the problems of multi-host PS/2 interface simulation and hot switching in the existing technology are solved, reducing system complexity and improving reliability .
Patent Information
- Application Number
- CN202211097195.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-08
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-09-08
AI Technical Summary
The prior art is difficult to realize the simulation and hot switching of multi-host PS/2 interfaces, especially when there are many channels, multiple microcontrollers are required and system collaboration does not support.
Using FPGA as the master chip to monitor the power supply status of external hosts in real time, and implement simulation and switching of multi-host PS/2 ports through hot switching systems. Using the multi-threaded concurrent execution characteristics of FPGA, reduce system complexity and realize general PS/2 Simulation and hot switching of interfaces.
The hot switching of the PS/2 interface of multiple hosts has been realized, reducing the number of microcontrollers used, improving system reliability, and expanding the upper limit of hot switching hosts.
Smart Images

Figure CN115344128B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of industrial control and signal processing, and in particular relates to a method for realizing hot switching of PS / 2 keyboards and mouse interfaces of multiple hosts based on FPGA. Background Art
[0002] The PS / 2 interface is a common interface for mouse and keyboard. During the startup process of different operating systems, there are problems such as scanning first and then mounting, and hot plugging is not supported. The existing switching technology mainly uses a single-chip microcomputer to simulate each host. When there are many channels, a single-chip microcomputer equivalent to the number of channels will be used for simulation, and it is not suitable for achieving system coordination. Summary of the invention
[0003] 1. Technical issues to be resolved
[0004] The technical problem to be solved by the present invention is: how to solve the problem of realizing PS / 2 interface simulation and hot switching of multiple hosts.
[0005] (II) Technical solution
[0006] In order to solve the above technical problems, the present invention provides a method for hot switching of PS / 2 keyboard and mouse interfaces of multiple hosts based on FPGA. The method is implemented by a hot switching system, which includes FPGA, a public-side PS / 2 keyboard, a public-side PS / 2 mouse, and N hosts. The interfaces of the PS / 2 keyboard and the PS / 2 mouse of all hosts are connected to the FPGA. The PS / 2 keyboard and the PS / 2 mouse of the host are called the analog-side PS / 2 keyboard and the analog-side PS / 2 mouse. The switching switches of all hosts are switching control buttons. The public-side PS / 2 keyboard and the public-side PS / 2 mouse are PS / 2 keyboards and PS / 2 mice shared by all hosts, and are also connected to the FPGA at the same time.
[0007] The power supply for the interface of the PS / 2 keyboard on the analog side and the interface of the PS / 2 mouse on the analog side is provided by the host. The FPGA determines whether the host is powered by detecting the power supply conditions of the interface of the PS / 2 keyboard on the analog side and the interface of the PS / 2 mouse on the analog side;
[0008] In this method, the FPGA implements the hot switch button detection process for multiple host PS / 2 keyboards and mice as follows:
[0009] Step 1: The system starts and powers on, and is in the IDLE state. The next clock goes to Step 2.
[0010] Step 2: Use the switch status register to monitor the status of the switch in real time, and determine the value of each bit of the switch status register. If any bit of the switch status register is in a valid state, execute Step 3; if any bit of the switch status register is in an invalid state, it means that no switch is pressed, and return to Step 1 to enter the waiting state;
[0011] Step 3: After the delay, the valid bits of the sampled switch status register are judged. If only one bit of the switch status register is valid, it means that a single switch is pressed, and Step 4 is executed; if multiple bits of the switch status register are valid, it means that multiple switches are currently pressed, and Step 5 is executed;
[0012] Step 4: When the single switch is valid, select the host with a valid serial number, set the valid bit corresponding to the switch instruction register, and use it to simulate the communication process of the PS / 2 interface of the corresponding host, and execute Step 6;
[0013] Step 5: When multiple bits of the switch status register are valid, the lowest bit is taken as the valid bit, and the other bits are discarded. The valid bit corresponding to the switch instruction register is set to simulate the communication process of the PS / 2 interface of the corresponding host, and Step 6 is executed;
[0014] Step 6: Determine whether the bits of the switch status register have changed. If not, continue to determine; if there is a change, return to Step 3.
[0015] Preferably, in the method, after the interface hot-switch button detection of multiple host PS / 2 keyboards and mice is completed, the FPGA performs PS / 2 interface simulation communication on the selected host.
[0016] Preferably, when the FPGA performs PS / 2 interface simulation communication on the selected host, the process of simulating interface communication after hot switching the PS / 2 interface of a single host i is as follows:
[0017] Step 11: The system starts and powers on, and is in IDLE state. The next clock goes to Step 2.
[0018] Step 12: Real-time detection of whether the power supply of each host PS / 2 interface is effective, and whether the host is powered on; if it is detected that the host is powered on, execute Step 13; if the host is not powered on, continue to execute this step in a loop;
[0019] Step 13: Determine whether the switch has selected the powered-on host by switching the instruction register; if the external switch has selected the powered-on host, execute Step 18; if the external switch has not selected the powered-on host, execute Step 14;
[0020] Step 14: judge through the "host i simulation side loading completion status register" to determine whether the powered-on host has completed interface loading; if the host i simulation side loading is completed, return to Step 11; if the host i simulation side loading is not completed, execute Step 15;
[0021] Step 15: Start the simulated PS / 2 keyboard and mouse sub-process, perform PS / 2 simulated communication with the selected host, and execute Step 16;
[0022] Step 16: Monitor the data of the PS / 2 keyboard and mouse on the simulation side to determine whether the simulation side loading is completed. If the simulation side loading is completed, execute Step 17; if the simulation side loading is not completed, continue to execute this step in a loop;
[0023] Step 17: Identify the host i that has completed the simulated side loading, set the "host i simulated side loading completion status register" to be valid, and return to Step 11;
[0024] Step 18: Determine whether the switch has completed the switching through the "host i public side switching status register"; if the switching has not been completed, it means that the host i has been powered on and the switch has selected the host i. At this time, there is no need to simulate the PS / 2 interface, and execute Step 19; if the switching has been completed, execute Step 110;
[0025] Step 19: Connect the PS / 2 keyboard and PS / 2 mouse on the public side to the host selected by the switch, and execute Step 111;
[0026] Step 110: Determine whether the powered-on host has completed interface loading through the "host i public side loading completion status register". If the interface loading has not been completed, execute Step 111; if the loading has been completed, return to Step 11;
[0027] Step 111: monitor the loading data of the public side PS / 2 keyboard and the public side PS / 2 mouse to determine whether the public side loading is completed. If the public side loading is completed, execute Step 112; if the loading is not completed, continue to loop and execute this step;
[0028] Step 112: Identify the host i that has completed the public side loading, set the "host i public side loading completion status register" to be valid, and return to Step 11.
[0029] Preferably, the FPGA is implemented on a switching board.
[0030] Preferably, the switching switches of all hosts have the control end being low effective.
[0031] Preferably, the power supply voltage is 5V.
[0032] The invention also provides a hot switching system for implementing the method.
[0033] The invention also provides an application of the method in the technical field of industrial control and signal processing.
[0034] The invention also provides an application of the system in the technical fields of industrial control and signal processing.
[0035] (III) Beneficial effects
[0036] In order to solve the hot switching problem of PS / 2 interfaces of multiple hosts, the present invention adopts FPGA as the main control chip, monitors the power supply of the external host in real time, realizes the simulation of PS / 2 ports of multiple hosts, and performs multi-channel switching inside the FPGA, thereby reducing the complexity of the system and improving the reliability of the system. The present invention makes full use of the feature that FPGA can perform multi-threaded concurrent execution, realizes the simulation of the general PS / 2 interface through FPGA, and realizes the hot switching of keyboards and mice of multiple PS / 2 interfaces, thereby reducing the number of single-chip microcomputers used in the traditional method, and expanding the upper limit of the number of hosts that can perform hot switching. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A system principle block diagram for implementing the multi-host PS / 2 interface hot switching method of the present invention;
[0038] Figure 2 It is a multi-host PS / 2 hot switch button detection flow chart of the present invention;
[0039] Figure 3 This is a flow chart of the host i simulating PS / 2 interface communication of the present invention. DETAILED DESCRIPTION
[0040] 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 accompanying drawings and examples.
[0041] The invention relates to a general implementation method for hot switching of PS / 2 keyboard and mouse interfaces of multiple hosts based on FPGA, and in particular to a hot switching method of PS / 2 interfaces of multiple hosts.
[0042] like Figure 1The figure shows a system connection block diagram for implementing the method of the present invention, wherein the system includes an FPGA, a public side PS / 2 keyboard, a public side PS / 2 mouse, and N hosts. The interfaces of the PS / 2 keyboards and the PS / 2 mice of all hosts are connected to the FPGA. The PS / 2 keyboards and PS / 2 mice of the hosts are called analog side PS / 2 keyboards and analog side PS / 2 mice. The switching switches of all hosts are external switching control buttons, and the control ends are low effective. The public side PS / 2 keyboard and the public side PS / 2 mouse are public PS / 2 keyboards and PS / 2 mice, which are also connected to the FPGA at the same time. The FPGA is located on the switching board.
[0043] Since the 5V power supply for the interface of the analog side PS / 2 keyboard and the interface of the analog side PS / 2 mouse is provided by the host, the FPGA can determine whether the host is powered by detecting the power supply status of the interface of the analog side PS / 2 keyboard and the interface of the analog side PS / 2 mouse.
[0044] like Figure 2 As shown, the FPGA implements the hot switch button detection process for multiple host PS / 2 keyboards and mice as follows:
[0045] Step 1: The system starts and powers on, and is in the IDLE state. The next clock goes to Step 2.
[0046] Step 2: Use the switch status register to monitor the status of the switch in real time, and determine the value of each bit of the switch status register. If any bit of the switch status register is in a valid state, execute Step 3; if any bit of the switch status register is in an invalid state, it means that no switch is pressed, and return to Step 1 to enter the waiting state;
[0047] Step 3: After the delay, the valid bits of the sampled switch status register are judged. If only one bit of the switch status register is valid, it means that a single switch is pressed, and Step 4 is executed; if multiple bits of the switch status register are valid, it means that multiple switches are currently pressed, and Step 5 is executed;
[0048] Step 4: When the single switch is valid, select the host with a valid serial number, set the valid bit corresponding to the switch instruction register, and use it to simulate the communication process of the PS / 2 interface of the corresponding host, and execute Step 6;
[0049] Step 5: When multiple bits of the switch status register are valid, the lowest bit is taken as the valid bit, and the other bits are discarded. The valid bit corresponding to the switch instruction register is set to simulate the communication process of the PS / 2 interface of the corresponding host, and Step 6 is executed;
[0050] Step 6: Determine whether each bit of the switch status register has changed. If not, continue to determine; if there is a change, return to Step 3;
[0051] After the hot switch button detection is completed, the PS / 2 interface simulation communication is performed on the selected host, such as Figure 3 As shown, the process of simulating interface communication after hot switching of the PS / 2 interface of a single host i is described, and the steps are as follows:
[0052] Step 11: The system starts and powers on, and is in IDLE state. The next clock goes to Step 2.
[0053] Step 12: Real-time detection of whether the 5V power supply of each host PS / 2 interface is effective, and whether the host is powered on; if it is detected that the host is powered on, execute Step 13; if the host is not powered on, continue to execute this step in a loop;
[0054] Step 13: Determine whether the switch has selected the powered-on host by switching the instruction register; if the external switch has selected the powered-on host, execute Step 18; if the external switch has not selected the powered-on host, execute Step 14;
[0055] Step 14: judge through the "host i simulation side loading completion status register" to determine whether the powered-on host has completed interface loading; if the host i simulation side loading is completed, return to Step 11; if the host i simulation side loading is not completed, execute Step 15;
[0056] Step 15: Start the simulated PS / 2 keyboard and mouse sub-process, perform PS / 2 simulated communication with the selected host, and execute Step 16;
[0057] Step 16: Monitor the data of the PS / 2 keyboard and mouse on the simulation side to determine whether the simulation side loading (simulated PS / 2 loading) is completed. If the simulation side loading is completed, execute Step 17; if the simulation side loading is not completed, continue to loop and execute this step;
[0058] Step 17: Identify the host i that has completed the simulated side loading, set the "host i simulated side loading completion status register" to be valid, and return to Step 11;
[0059] Step 18: Determine whether the switch has completed the switching through the "host i public side switching status register"; if the switching has not been completed, it means that the host i has been powered on and the switch has selected the host i. At this time, there is no need to simulate the PS / 2 interface, and execute Step 19; if the switching has been completed, execute Step 110;
[0060] Step 19: Connect the public PS / 2 keyboard and PS / 2 mouse to the host selected by the switch, and execute Step 111;
[0061] Step 110: Determine whether the powered-on host has completed interface loading through the "host i public side loading completion status register". If the interface loading has not been completed, execute Step 111; if the loading has been completed, return to Step 11;
[0062] Step 111: monitor the loading data of the public side PS / 2 keyboard and the public side PS / 2 mouse to determine whether the public side loading is completed. If the public side loading is completed, execute Step 112; if the loading is not completed, continue to loop and execute this step;
[0063] Step 112: Identify the host i that has completed the public side loading, set the "host i public side loading completion status register" to be valid, and return to Step 11.
[0064] 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 method for implementing hot switching of PS / 2 keyboard and mouse interfaces of multiple hosts based on FPGA, characterized in that: The method is implemented by a hot switching system, which includes an FPGA, a public-side PS / 2 keyboard, a public-side PS / 2 mouse, and N hosts. The interfaces of the PS / 2 keyboards and PS / 2 mice of all hosts are connected to the FPGA. The PS / 2 keyboards and PS / 2 mice of the hosts are called analog-side PS / 2 keyboards and analog-side PS / 2 mice. The switching switches of all hosts are switching control buttons. The public-side PS / 2 keyboard and the public-side PS / 2 mouse are PS / 2 keyboards and PS / 2 mice shared by all hosts and are also connected to the FPGA. The power supply for the interface of the PS / 2 keyboard on the analog side and the interface of the PS / 2 mouse on the analog side is provided by the host. The FPGA determines whether the host is powered by detecting the power supply conditions of the interface of the PS / 2 keyboard on the analog side and the interface of the PS / 2 mouse on the analog side; In this method, the FPGA implements the hot switch button detection process for multiple host PS / 2 keyboards and mice as follows: Step 1: The system starts and powers on, and is in the IDLE state. The next clock goes to Step 2. Step 2: Use the switch status register to monitor the status of the switch in real time, and determine the value of each bit of the switch status register. If any bit of the switch status register is in a valid state, execute Step 3; if any bit of the switch status register is in an invalid state, it means that no switch is pressed, and return to Step 1 to enter the waiting state; Step 3: After the delay, the valid bits of the sampled switch status register are judged. If only one bit of the switch status register is valid, it means that a single switch is pressed, and Step 4 is executed; if multiple bits of the switch status register are valid, it means that multiple switches are currently pressed, and Step 5 is executed; Step 4: When the single switch is valid, select the host with a valid serial number, set the valid bit corresponding to the switch instruction register, and use it to simulate the communication process of the PS / 2 interface of the corresponding host, and execute Step 6; Step 5: When multiple bits of the switch status register are valid, the lowest bit is taken as the valid bit, and the other bits are discarded. The valid bit corresponding to the switch instruction register is set to simulate the communication process of the PS / 2 interface of the corresponding host, and Step 6 is executed; Step 6: Determine whether the bits of the switch status register have changed. If not, continue to determine; if there is a change, return to Step 3.
2. The method according to claim 1, characterized in that In this method, after the hot-switch button detection of the interfaces of the PS / 2 keyboards and mice of multiple hosts is completed, the FPGA performs PS / 2 interface simulation communication with the selected host.
3. The method according to claim 2, characterized in that During the process of FPGA simulating PS / 2 interface communication with the selected host, the process of simulating interface communication after hot switching of the PS / 2 interface of a single host i is as follows: Step 11: The system starts and powers on, and is in IDLE state. The next clock goes to Step 12. Step 12: Real-time detection of whether the power supply of each host PS / 2 interface is effective, and judgment of whether the host is powered on; if it is detected that the host is powered on, then execute Step 13; if the host is not powered on, then continue to execute this step in a loop; Step 13: Determine whether the switch has selected the powered-on host by switching the instruction register; if the external switch has selected the powered-on host, execute Step 18; if the external switch has not selected the powered-on host, execute Step 14; Step 14: Determine whether the powered-on host has completed interface loading through the "host i analog side loading completion status register"; if the host i analog side loading is completed, return to Step 11; if the host i analog side loading is not completed, execute Step 15; Step 15: Start the simulated PS / 2 keyboard and mouse sub-process, perform PS / 2 simulated communication with the selected host, and execute Step 16; Step 16: Monitor the data of the PS / 2 keyboard and mouse on the simulation side to determine whether the simulation side loading is completed. If the simulation side loading is completed, execute Step 17; if the simulation side loading is not completed, continue to execute this step in a loop; Step 17: Identify the host i that has completed the simulated side loading, set the "host i simulated side loading completion status register" to be valid, and return to Step 11; Step 18: Determine whether the switch has completed the switching through the "host i public side switching status register"; if the switching has not been completed, it means that the host i has been powered on and the switch has selected the host i. At this time, there is no need to simulate the PS / 2 interface, and execute Step 19; if the switching has been completed, execute Step 110; Step 19: Connect the PS / 2 keyboard and PS / 2 mouse on the public side to the host selected by the switch, and execute Step 111; Step 110: Determine whether the powered-on host has completed interface loading through the "host i public side loading completion status register". If the interface loading has not been completed, execute Step 111; if the loading has been completed, return to Step 11; Step 111: monitor the loading data of the public side PS / 2 keyboard and the public side PS / 2 mouse to determine whether the public side loading is completed. If the public side loading is completed, execute Step 112; if the loading is not completed, continue to loop and execute this step; Step 112: Identify the host i that has completed the public side loading, set the "host i public side loading completion status register" to be valid, and return to Step 11.
4. The method according to claim 1, characterized in that The FPGA is implemented on a switching board.
5. The method according to claim 1, characterized in that The power supply voltage is 5V.
6. A hot switching system for implementing the method according to any one of claims 1 to 5.
