State recovery circuit and method, apparatus, electronic device, and storage medium
By combining the control module and the lookup table module, the state machine can be quickly restored using the state information stored in the lookup table module. This solves the problem of low efficiency when the state machine fails and achieves efficient state restoration.
Patent Information
- Application Number
- CN202510190712.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-02-20
AI Technical Summary
State machines have low efficiency in restoring state from failures, and existing technologies often suffer from inefficiency due to initialization issues.
The control module connects to the lookup table module. The lookup table module stores the state information of the state machine when it is running without faults. The control module identifies faults and transmits the correct state information to achieve state recovery.
It enables fast state recovery of the state machine, improves state recovery efficiency, and avoids the loss of state information during the initialization process.
Smart Images

Figure CN119675652B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of circuit technology, and in particular to a state recovery circuit, method, apparatus, electronic device and storage medium thereof. Background Technology
[0002] A state machine is a sequential logic circuit. A state machine has multiple states and different functions are achieved by transitioning between different states. When a state machine fails, it is necessary to restore the state of the state machine.
[0003] In state recovery techniques, the state machine is usually initialized and restarted from its initial state to the state before the failure, resulting in low state recovery efficiency. Summary of the Invention
[0004] This application provides state recovery circuits, methods, apparatuses, electronic devices, and storage media thereof, to at least address the problem of low state recovery efficiency of state machines in related technologies.
[0005] This application provides a state recovery circuit, including: a control module and a lookup table module;
[0006] The control module and lookup table module are connected to the state machine; the control module is also connected to the lookup table module.
[0007] The lookup table module is used to store state information of the state machine in at least one state during fault-free operation;
[0008] The control module is used to determine whether a fault has occurred when the state machine is in its current state. If a fault is determined to have occurred when the state machine is in its current state, the first state information is transmitted to the state machine so that the state machine can recover its state based on the first state information. The first state information is the state information generated when the state machine is operating without faults, obtained from the lookup table module.
[0009] This application also provides a state recovery method, including:
[0010] The control module is used to determine whether a fault has occurred while the state machine is in its current state.
[0011] If a fault occurs while the state machine is in its current state, the control module will transmit the first state information generated when the state machine is operating without faults, obtained from the lookup table module, to the state machine so that the state machine can recover its state based on the first state information. The lookup table module contains state information of at least one state in which the state machine is operating without faults.
[0012] This application also provides a state recovery device, comprising:
[0013] The determination unit is used by the control module to determine whether a fault has occurred when the state machine is in its current state.
[0014] The transmission unit is used to transmit first state information obtained from the lookup table module when the state machine is in the current state and a fault occurs, using the control module to transmit the first state information generated when the state machine is in the current state without faults to the state machine, so that the state machine can recover its state based on the first state information; the lookup table module contains state information of at least one state in which the state machine is in the fault-free running state.
[0015] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described state recovery methods when executing the computer program.
[0016] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described state recovery methods.
[0017] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described state restoration methods.
[0018] Through this application, since the control module in the state recovery circuit is connected to the state machine, the control module can determine whether a fault has occurred when the state machine is in its current state. If a fault is determined to have occurred, the control module retrieves the first state information generated during fault-free operation of the state machine in its current state from the lookup table module. The control module then transmits this first state information to the state machine. Because the first state information is generated during fault-free operation of the state machine in its current state, even if a fault occurs and the state information is lost, the first state information allows the state machine to directly recover to its current state without requiring initialization. Therefore, this solves the technical problem of low state recovery efficiency of state machines and achieves the technical effect of improving the state recovery efficiency of state machines. Attached Figure Description
[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the structure of a state recovery circuit provided in an embodiment of this application;
[0021] Figure 2 This is a schematic diagram of another state recovery circuit provided in an embodiment of this application;
[0022] Figure 3 This is a schematic diagram of another state recovery circuit provided in an embodiment of this application;
[0023] Figure 4 A comparative diagram illustrating a power supply method provided in an embodiment of this application;
[0024] Figure 5 A schematic flowchart illustrating a state recovery method provided in an embodiment of this application;
[0025] Figure 6 This is an internal structure diagram of a control module provided in an embodiment of this application;
[0026] Figure 7 This is an internal structural diagram of a power monitoring module provided in an embodiment of this application;
[0027] Figure 8 This is an internal structure diagram of a status display module provided in an embodiment of this application;
[0028] Figure 9 This is a schematic diagram of a state recovery device provided in an embodiment of this application. Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0030] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0031] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] The embodiments of this application provide a state recovery circuit, and the method is described in detail in conjunction with the execution flow of the state recovery circuit.
[0033] Figure 1 This is a schematic diagram of a state recovery circuit provided in an embodiment of this application, as shown below. Figure 1 As shown, the state recovery circuit includes: a control module 10 and a lookup table module 20.
[0034] The control module 10 and the lookup table module 20 are connected to the state machine 30. The control module 10 is connected to the lookup table module 20.
[0035] In the embodiments of this application, a state machine is a circuit design that follows sequential logic and possesses multiple different states. Its operating principle lies in switching between different states to achieve specific functions. For example, in a vending machine, the state machine can switch to different states based on the user's actions (such as inserting coins or selecting goods), such as waiting, inserting coins, selecting goods, and dispensing, thereby realizing the process of product delivery.
[0036] To facilitate a better understanding of state machine state transitions, an example is provided. Assume the state machine consists of N states: state 1, state 2, ..., state n, and N trigger conditions 1 to n. When the state machine is reset (i.e., the reset signal is valid), it enters state 1. When the reset process ends (the reset signal is invalid) and trigger condition 1 occurs, it enters state 2. Subsequently, for each trigger condition, the state machine enters the next state, until it returns to state 1, and then the state transition cycle repeats. However, it should be clarified that this explanation does not imply that state transitions can only occur between adjacent states; transitions can also occur between non-adjacent states.
[0037] To better understand the transitions between non-adjacent states, such as Figure 2 As shown, Figure 2 This is a schematic diagram of another state recovery circuit provided in an embodiment of this application. Each state has a corresponding logic module. The logic module controls the opening and closing of the corresponding state. The transition between non-adjacent states can be realized through the logic module.
[0038] The control module is the core control unit in the state recovery circuit, responsible for monitoring and managing the state machine's state. The lookup table module is a storage unit used to store the state information of at least one state of the state machine during fault-free operation. The lookup table module can be a non-volatile storage unit, such as read-only memory (ROM), where data stored in the ROM will not be lost after power failure. The lookup table module stores the state information of n states during normal operation of the state machine. The state information includes, but is not limited to, the inputs, outputs, and data generated in each state. Specifically, for a state n (n=1,2,…,N), its input is trigger condition n-1, its output is trigger condition n, and the generated data is data n. Trigger condition n-1 is the start condition for state n, and trigger condition n is the transition condition for state n, i.e., the start condition for the next state of state n. However, it should be clarified that this description does not imply that the lookup table module can only be a non-volatile storage unit; other storage units are also possible.
[0039] Through direct connection, the control module can quickly obtain the status information of fault-free operation from the lookup table module and transmit the status information to the state machine, thereby achieving rapid state recovery.
[0040] The lookup table module 20 is used to store state information of at least one state of the state machine 30 when it is operating without faults.
[0041] In addition to the inputs, outputs, and data generated in each state, state information may also include state codes, internal variables, timestamps or durations, fault detection flags, and transition conditions. A state code is a unique code or identifier used to distinguish different states. Internal variables are variables or counter values stored internally by the state machine; these variables change during state transitions. The duration or timestamp is the length of time the state machine is in the current state or the time it enters the current state. Fault detection flags indicate whether the current state is normal, used for fault detection and recovery. Transition conditions are the conditions or events that cause the state machine to transition from the current state to the next state. Inputs and outputs include trigger conditions, and inputs may also include input signals—the input signal values received by the state machine in the current state, which may come from the external environment or other circuit modules. Outputs may also include output signals—the output signal values generated by the state machine in the current state, used to drive other circuits or perform specific operations.
[0042] The lookup table module is connected to the state machine. When the state machine does not experience a fault within a state transition loop, the lookup table module stores all state information within that loop. Alternatively, all state information generated by the state machine's fault-free operation can be stored in the lookup table module via external input. The fault-free state information (first state information) stored in the lookup table module provides a precise reference for the control module to determine whether the current state of the state machine is normal.
[0043] The control module 10 is used to determine whether a fault has occurred when the state machine 30 is in its current state. If a fault has occurred when the state machine 30 is in its current state, the control module 10 transmits first state information to the state machine 30 so that the state machine 30 can recover its state based on the first state information. The first state information is the state information generated when the state machine 30 is operating without faults in its current state, which is obtained from the lookup table module 20.
[0044] The control module collects the second state information generated by the state machine in the current state and retrieves the first state information corresponding to this state when the state machine is running without faults from the lookup table module. The control module compares the first and second state information for consistency. If they are inconsistent, it is determined that the current state has a fault. For example, in the state machine of a vending machine, the inventory quantity should decrease accordingly when dispensing normally (first state information). If the inventory quantity does not change in the current state (second state information), it indicates that the dispensing state may have a fault. However, it should be clarified that this statement is not intended to limit the determination of the state and whether a fault has occurred in the current state to the above method; other methods can also be used to determine this.
[0045] After receiving the first state information, the state machine restores itself to the corresponding state it was in when operating without faults, based on the first state information. Specific operations include, but are not limited to, resetting the state machine's internal registers, adjusting output signals, and reconfiguring internal logic based on the first state information.
[0046] The fault-free status information stored in the lookup table module is accurate data that has been verified and confirmed in advance. The control module uses this as a benchmark for comparison and judgment, which can effectively avoid misjudgment and omission, and improve the accuracy of fault detection.
[0047] Through this application, since the control module in the state recovery circuit is connected to the state machine, the control module can determine whether a fault has occurred when the state machine is in its current state. If a fault is determined to have occurred, the control module retrieves the first state information generated during fault-free operation of the state machine in its current state from the lookup table module. The control module then transmits this first state information to the state machine. Because the first state information is generated during fault-free operation of the state machine in its current state, even if a fault occurs and the state information is lost, the first state information allows the state machine to directly recover to its current state without requiring initialization. Therefore, this solves the technical problem of low state recovery efficiency of state machines and achieves the technical effect of improving the state recovery efficiency of state machines.
[0048] In some embodiments, please continue reading Figure 1 The control module 10 includes a status register 101, a status monitor 102, and a status transmitter 103.
[0049] The status register 101 is connected to the state machine 30 and the status monitor 102, respectively.
[0050] The status monitor 102 is connected to the lookup table module 20 and the status transmitter 103, respectively.
[0051] State transmitter 103 is connected to state machine 30;
[0052] The status register 101 is used to obtain the second state information of the state machine 30 and transmit the second state information to the state monitor 102; the second state information is the state information generated when the state machine 30 is in the current state, obtained from the state machine 30.
[0053] The state monitor 102 is used to receive the second state information, and the state monitor 102 is used to obtain the first state information from the lookup table module 20, and determine whether a fault has occurred when the state machine 30 is in the current state based on the first state information and the second state information.
[0054] The state monitor 102 is used to transmit first state information to the state transmitter 103 when it determines that a fault has occurred while the state machine 30 is in its current state.
[0055] The state transmitter 103 is used to receive the first state information and transmit the first state information to the state machine 30.
[0056] A state register is a circuit or storage unit used to store the current state information of a state machine. A state monitor is a circuit or logic unit used to monitor and analyze the state of a state machine. A state transmitter is a circuit or interface unit used to transmit state information within a circuit.
[0057] The status register can also temporarily store the status code value of the current state of the state machine, distinguishing different states through the status code value. For example, if binary encoding is used, the status code value for state 2 is '2', the status code value for state 3 is '3', and so on. The status monitor can also monitor the input / output trigger conditions of the current state and compare them with the correct input / output information of the corresponding state stored in the lookup table module. When the comparison matches, it indicates that the current state is normal; when the comparison does not match, it indicates that the current state is abnormal, and a fault signal is generated to the state machine. In addition, a preset time threshold is set in the status monitor to monitor whether the value of the status register changes within the preset time threshold. If the value of the status register changes within the preset time threshold, it indicates that the state has transitioned; if the value of the status register does not change after the preset time threshold, it indicates that the state machine has malfunctioned and remains in the current state, at which point a fault signal is also generated. Furthermore, the preset time threshold can be manually set and changed according to the actual operation of the system. The state transmitter is a data buffer. It can be a volatile storage unit, such as Random Access Memory (RAM). Its function is to transmit the corresponding state information from the lookup table module to the state transmitter when a state anomaly occurs. However, it should be clarified that this statement does not mean that the state transmitter can only be a volatile storage unit; it can also be other storage units.
[0058] The entire fault detection and recovery process is automatically completed by the status register, status monitor, and status transmitter, requiring no manual intervention and improving the system's automation level. This automation capability enables the system to respond more intelligently to various fault conditions, improving system operating efficiency and management level.
[0059] In some embodiments, please continue reading Figure 1 The status register 101 is also used to obtain the duration of the state machine 30 in the current state and transmit the duration to the status monitor 102 so that the status monitor 102 can determine whether a fault has occurred when the state machine 30 is in the current state based on the duration.
[0060] Duration refers to the length of time a state machine remains in its current state. By comparing the duration with a preset time threshold, it can be determined whether a fault has occurred in the current state. Some faults may not immediately cause changes in state information, but will manifest as anomalies in state duration. This design allows the state recovery circuit to adapt to a wider variety of fault scenarios.
[0061] In some embodiments, please continue reading Figure 1The state monitor 102 is also used to receive the duration; compare the duration with a preset time threshold; and if the duration is greater than the preset time threshold, determine that a fault has occurred when the state machine 30 is in the current state.
[0062] To facilitate understanding, an example is provided, assuming the duration is 10 seconds and the preset time threshold is 8 seconds. Since 10 seconds is greater than 8 seconds, it is determined that the current state has failed.
[0063] By combining consistency comparison of state information and judgment of state duration, faults can be detected from multiple dimensions. When the first state information is consistent with the second state information, but the state duration is too long, it can also be determined that the state machine may be faulty, thereby improving the accuracy of fault detection and reducing false positives and false negatives.
[0064] In some embodiments, please continue reading Figure 1 The state monitor 102 is used to determine whether a fault has occurred when the state machine 30 is in its current state, based on the first state information and the second state information, including:
[0065] The consistency of the first state information and the second state information is compared.
[0066] If the first state information is inconsistent with the second state information, it is determined that a fault has occurred when state machine 30 is in its current state.
[0067] When the state machine encounters an inconsistency between the first and second state information, or when the inconsistency lasts for a duration exceeding a preset time threshold, the state machine stagnates in a certain state. It reads the first state information from the lookup table module, transmits it to the state transmitter, and generates a fault signal. Upon receiving the fault signal, the state machine reads the correct first state information from the state transmitter, thus restoring itself to the current state and continuing operation from there. This eliminates the need for manual system reset and prevents data loss from the state machine.
[0068] Furthermore, in one possible implementation of this embodiment, such as Figure 3 As shown, the state recovery circuit also includes: a power monitoring module 40;
[0069] The power monitoring module 40 is connected to the mains power 50, and the power monitoring module 40 is also connected to the control module 10.
[0070] The power monitoring module 40 transmits the mains power 50 to the control module so that the control module 10 can operate based on the mains power 50;
[0071] The power monitoring module 40 is used to monitor whether the mains power 50 is cut off when the state machine 30 is in the current state, so that the control module 10 can determine whether a fault has occurred when the state machine 30 is in the current state based on the monitoring results of whether the mains power 50 is cut off.
[0072] A power monitoring module is an electronic circuit or device used to monitor the status of a power source. Its main function is to monitor the status of the mains power in real time, including whether it is powered on and whether the voltage is stable. The power monitoring module transmits the monitored mains power status information to the control module, allowing the control module to make corresponding judgments and take appropriate actions based on this information. In the event of a mains power outage, the power monitoring module will send a signal to notify the control module to disconnect the mains power. Mains power refers to the alternating current (AC) supplied by the city's power grid, typically the 220V or 380V AC power used in daily life.
[0073] Monitoring results include, but are not limited to, whether the mains power is on, voltage level, voltage stability, fault type, and fault duration.
[0074] The external 220V AC mains power is converted to DC power to generate 3.3V and 1.2V DC voltages, which serve as the input / output (IO) voltages and core voltage of the state recovery circuit, respectively. The IO voltages supply the state machine's input / output (IO) modules, while the core voltage supplies the control module. In addition to identifying faults through consistency comparison of state information and monitoring of duration, the addition of a power monitoring module allows for fault detection from the perspective of power supply. As a crucial energy source for system operation, the availability of AC mains power directly affects the system's normal operation. By monitoring the AC mains power status, faults caused by power supply problems can be detected promptly, thereby enhancing the comprehensiveness of fault detection.
[0075] Furthermore, in one possible implementation of this embodiment, such as Figure 3 As shown, the state recovery circuit also includes: a power supply 60;
[0076] The power supply 60 is connected to the control module 10;
[0077] The power supply 60 is used to provide uninterrupted power to the control module 10.
[0078] A power supply is a backup power device that provides power to the control module when the mains power fails during the current state of the state machine. This ensures the control module can continue operating and perform critical operations such as monitoring state machine faults, acquiring information, and restoring the state. Power supplies include, but are not limited to, button batteries and supercapacitors. To better understand the power supply method for the state recovery circuit, as follows... Figure 4 As shown, Figure 4 This is a comparison diagram of a power supply method provided in an embodiment of this application. Figure 4(a) in the diagram represents the power supply method of the relevant technology, which is powered solely by mains electricity. If the mains power fails, the state recovery circuit will malfunction. Figure 4 (b) in this application describes the power supply method, which ensures uninterrupted power supply to the control module even in the event of a mains power outage. By providing uninterrupted power support, the power supply enhances the reliability of the state recovery circuit, thereby improving the overall system reliability. The system can operate more stably in the face of external interference such as mains power outages, reducing the probability and scope of failures and providing strong support for the long-term stable operation of the system.
[0079] Furthermore, in one possible implementation of this embodiment, such as Figure 3 As shown, the status recovery circuit also includes: a status display module 70;
[0080] The status display module 70 is connected to the control module 10;
[0081] The status display module 70 is used to obtain second status information from the control module 10 and to visualize the second status information.
[0082] A status display module is a functional module that receives specific information and presents it in a visual form. Visualization can involve displaying text, numbers, graphics, or other information on a screen, or displaying status information through devices such as indicator lights and buzzers. For example, different colored indicator lights can represent different states, or the current state of the state machine and fault information can be displayed on the screen. Visualizing secondary status information can alert administrators to timely detection of state machine faults.
[0083] According to embodiments of this application, this application also proposes a state recovery method, such as... Figure 5 As shown, Figure 5 This is a flowchart illustrating a state recovery method provided in an embodiment of this application. The method is applied in a state recovery circuit and includes the following steps:
[0084] Step 801: Use the control module to determine whether a fault has occurred when the state machine is in its current state.
[0085] Step 802: If a fault occurs while the state machine is in its current state, the control module transmits the first state information generated when the state machine is running without faults in its current state, obtained from the lookup table module, to the state machine so that the state machine can recover its state based on the first state information; the lookup table module contains state information of at least one state in which the state machine is running without faults.
[0086] Since the embodiments of the state recovery method and the state recovery circuit correspond to each other, please refer to the description of the embodiments of the state recovery circuit for the embodiments of the state recovery method, which will not be repeated here. Furthermore, it has the same beneficial effects as the state recovery circuit mentioned above.
[0087] Through this application, since the control module in the state recovery circuit is connected to the state machine, the control module can determine whether a fault has occurred when the state machine is in its current state. If a fault is determined to have occurred when the state machine is in its current state, the control module retrieves the first state information generated when the state machine is operating without faults from the lookup table module. The control module then transmits the first state information to the state machine. Since the first state information is generated when the state machine is operating without faults, if a fault occurs when the state machine is in its current state and the state information is lost, the first state information can be used to directly restore the state machine to its current state without initializing it. Therefore, this solves the technical problem of low state recovery efficiency of the state machine and achieves the technical effect of improving the state recovery efficiency of the state machine.
[0088] As a refinement of step 801, when determining whether a fault has occurred while the state machine is in its current state using the control module, the following methods can be used, but are not limited to: obtaining second state information generated when the state machine is in its current state using the state register in the control module, and transmitting the second state information to the state monitor in the control module using the state register; the control module includes a state register and a state monitor; receiving the second state information using the state monitor, and obtaining first state information from the lookup table module using the state monitor; and determining whether a fault has occurred in the current state based on the first state information and the second state information using the state monitor.
[0089] For more detailed information on the working process of the above embodiments, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0090] As a refinement of step 801, when determining whether a fault has occurred while the state machine is in its current state using the control module, the following methods can also be used, but are not limited to: obtaining the duration of the state machine in its current state using the state register and transmitting the duration to the state monitor; and using the state monitor to determine whether a fault has occurred while the state machine is in its current state based on the duration.
[0091] For more detailed information on the working process of the above embodiments, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0092] As a refinement of step 802, when the first state information generated by the state machine in the current state obtained from the lookup table module is transmitted to the state machine by the control module, it can be implemented in the following ways, but is not limited to: when it is determined that a fault has occurred while the state machine is in the current state, the first state information is transmitted to the state transmitter in the control module by the state monitor; the control module includes a state register, a state monitor and a state transmitter; the first state information is transmitted to the state machine by the state transmitter.
[0093] For more detailed information on the working process of the above embodiments, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0094] In one possible implementation of this application embodiment, in order to facilitate a better understanding of the internal structure of the control module, such as Figure 6 As shown, Figure 6 The internal structure diagram of a control module provided in the embodiments of this application includes a timer (Count, CNT), a comparator (Compare, CMP)_1, a comparator (Compare, CMP)_2, a flip-flop D_FF_1 with an enable input (Enable, E) and a clear input (Remove, R), an input AND gate AND_1, an input AND gate AND_2, an input OR gate, an XOR gate, and NOT_1~NOT_5 gates.
[0095] The CMP_1 and CMP_2 compare inputs 1 and 2. When input 1 is less than or equal to the value of input 2, the comparator outputs a high level; when input 1 is greater than the value of input 2, the comparator outputs a low level. The XOR operation performs an exclusive OR operation on inputs 1 and 2. When inputs 1 and 2 are the same, the output is low; when they are different, the output is high. The CNT register tracks the time based on the clock cycle (Clock, CLK) signal and outputs the timing duration T_out. `reg` is the register value, i.e., the state code value. During the state machine's operation, the state code value of the current running state is written to the controller. The CNT register tracks the duration of the current state and compares it with a preset time threshold, Threshold. The Threshold value can be manually set and adjusted by developers, administrators, etc. When the state changes, the `reg` value changes, and the timing duration is cleared via the `R` (clear) pin of the CNT register so that the timing restarts after the state machine switches to the next state.
[0096] When the state machine is reset (reset signal RSTn='0'), RSTn becomes high after passing through NOT_5, making the clear input R='1' of D_FF_1 valid, and the output (Q) low, connected to the input of the OR gate; when the state machine is running normally (RSTn='1'), the clear input R='0' of D_FF_1 is invalid, and the output value of D_FF_1 is determined by the enable input (E) and the data input input (D); in a certain state during the state machine's operation, the controller obtains the trigger signal Tri_sig of the current state, reads the corresponding reference trigger signal Tri_base from lookup table 2, and compares them using XOR. When Tri_sig ≠ Tri_base, the XOR output is high, then becomes low after passing through NOT_1, and then becomes high again after passing through AND_2 and NOT_3, inputting to the enable terminal (E) of D_FF_1. At the same time, the low level output of NOT_1 becomes high after passing through AND_1 and NOT_2, inputting to the data input terminal (D) of D_FF_1. Because the enable terminal (E) of D_FF_1 is active (high level) at this time, the output of D_FF_1 depends on the input terminal (D), so the output terminal (Q) is high. After passing through OR, the fault signal error='1' is output. In addition, when Tri_sig = Tri_base, it means that the trigger signal is normal, and the output of D_FF_1 depends on other circuit components. The current state's timing duration T_out is compared with the time threshold Threshold using CMP_1 and CMP_2. When T_out > Threshold, CMP_2 outputs a high level, which becomes low after passing through NOT_4, and then high again after passing through AND_2 and NOT_3, inputting to the enable terminal (E) of D_FF_1. At this time, CMP_1 outputs a low level, which becomes high after passing through AND_1 and NOT_2, inputting to the data input terminal (D) of D_FF_1. Since terminal (E) is valid (high level) at this time, D_FF_1 outputs a high level, which then outputs a fault signal error='1' after passing through OR. Additionally, when T_out ≤ Threshold, it indicates that the state duration has not timed out, and it is a normal state. In this case, the output of D_FF_1 depends on other circuit components. The power-down signal vol_off is also connected to the input of the OR gate. When vol_off = '1', the fault signal error = '1' is output.
[0097] In one possible implementation of this application embodiment, in order to facilitate a better understanding of the internal structure of the power monitoring module, such as Figure 7 As shown, Figure 7The diagram illustrates the internal structure of a power monitoring module provided in this application embodiment. It includes a flip-flop (D_FF_2) with a clear input (R), and NOT gates NOT_6 and NOT_7. The clock signal CLK is connected to the clock port of D_FF_2; vol_in is the 3.3V I / O voltage output of the state machine, which, after passing through NOT_6, is connected to the data input port of D_FF_2; the reset signal RSTn, after passing through NOT_7, is connected to the clear port R of D_FF_2; the data output of D_FF_2 is the vol_off signal.
[0098] When the state machine is reset (RSTn='0'), RSTn becomes high after passing through NOT_7, making the clear input R='1' of D_FF_2 valid, and the output vol_off='0'. When the state machine is running normally (RSTn='1'), the clear input R='0' of D_FF_2 is invalid. At this time, the output value of D_FF_2 is determined by the input D: when vol_in is 3.3V high, it becomes low after passing through NOT_6 and is input to D_FF_2, and the output of D_FF_2 is also low. When the external 220V power of the state machine is cut off, vol_in becomes zero accordingly, becomes high after passing through NOT_6 and is input to D_FF_2, and the output of D_FF_2 is vol_off='1'.
[0099] In one possible implementation of this application embodiment, in order to facilitate a better understanding of the internal structure of the status display module, such as... Figure 8 As shown, Figure 8 This is an internal structure diagram of a status display module provided in an embodiment of this application. Figure 8 The function of (a) is to display the current state code value based on the value of the control module. It consists of a decoder and a digital tube. The input terminals S1~S3 of the decoder are connected to bits reg(0)~reg(2) of the register, where reg(0) is the least significant bit, reg(1) is the middle bit, and reg(2) is the most significant bit. The enable terminal ENB of the decoder is connected to a high level (5V) to enable the decoder. The output terminals D1~D8 of the decoder are connected to an 8-segment digital tube. Based on the value 0~7 input to the register, the decoder enables the digital tube to display the 8 different states 0~7 of the state machine. This embodiment shows the case where the control module has 3 bits. If the number of states in the state machine is greater than 8, the number of bits in the control module needs to be increased, and the number of decoders and digital tubes also needs to be increased accordingly to display the state values when the number of states is greater than 8. This embodiment does not specify a particular number of states.
[0100] Figure 8The function of circuit (b) is to illuminate the alarm light and emit an alarm sound when the state machine loses power, serving as a notification so that the administrator can promptly detect the power failure and take measures to restore power. The circuit specifically includes a resistor R1, a light-emitting diode (LED), and a buzzer (BUZ); the LED serves as the alarm light, and the BUZ emits an alarm sound. Figure 8 In this context, vol_off represents the input signal of the circuit.
[0101] When the state machine is powered normally, when vol_off is low, the positive terminal of the LED and the input terminal of the BUZ are both low. At this time, the LED will not light up and the BUZ will not sound.
[0102] When the state machine is powered off, vol_off becomes high, and the positive terminal of the LED and the input terminal of the BUZ are both high. At this time, the LED is turned on and emits light, and the BUZ sounds.
[0103] R1 is a pull-up resistor, typically 10KΩ. Its function is to increase the voltage signal strength of vol_off, which is driven by the core voltage of the state machine and has a relatively weak voltage value (around 1.2V), by using R1 and the external 5V voltage, so as to ensure that the vol_off signal can drive the LED and BUZ normally.
[0104] in addition, Figure 8 The 5V voltage is also provided by an independent power supply module, ensuring that the circuit can work normally when the 220V power to the state machine is cut off.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0106] Embodiments of this application also provide a state recovery device. Figure 9 This is a schematic diagram of the structure of a state recovery device provided in an embodiment of this application, as shown below. Figure 9 As shown, it includes:
[0107] Determining unit 91 is used by the control module to determine whether a fault has occurred when the state machine is in its current state.
[0108] The transmission unit 92 is used to transmit first state information obtained from the lookup table module when the state machine is in the current state and a fault occurs, to the state machine using the control module, so that the state machine can perform state recovery based on the first state information. The lookup table module contains state information of at least one state in which the state machine is in the fault-free operation.
[0109] Through this application, since the control module in the state recovery circuit is connected to the state machine, the control module can determine whether a fault has occurred when the state machine is in its current state. If a fault is determined to have occurred, the control module retrieves the first state information generated during fault-free operation of the state machine in its current state from the lookup table module. The control module then transmits this first state information to the state machine. Because the first state information is generated during fault-free operation of the state machine in its current state, even if a fault occurs and the state information is lost, the first state information allows the state machine to directly recover to its current state without requiring initialization. Therefore, this solves the technical problem of low state recovery efficiency of state machines and achieves the technical effect of improving the state recovery efficiency of state machines.
[0110] Furthermore, in one possible implementation of this embodiment, the determining unit 91 is also used to,
[0111] The second state information generated when the state machine is in its current state is obtained using the state register in the control module, and the second state information is transmitted to the state monitor in the control module using the state register; the control module includes a state register and a state monitor;
[0112] The second state information is received using the state monitor, and the first state information is obtained from the lookup table module using the state monitor.
[0113] The status monitor is used to determine whether a fault has occurred in the current state based on the first and second status information.
[0114] Furthermore, in one possible implementation of this embodiment, the determining unit 91 is also used to,
[0115] The duration of the state machine's current state is obtained using the state register, and the duration is transmitted to the state monitor.
[0116] The state monitor is used to determine whether a fault has occurred while the state machine is in its current state, based on the duration of the fault.
[0117] Furthermore, in one possible implementation of this embodiment, the transmission unit 92 is also used to,
[0118] In the event of a fault occurring while the state machine is in its current state, the state monitor transmits the first state information to the state transmitter in the control module; the control module includes a state register, a state monitor, and a state transmitter.
[0119] The first state information is transmitted to the state machine using a state transmitter.
[0120] For a description of the features in the embodiment corresponding to the state recovery device, please refer to the relevant description in the embodiment corresponding to the state recovery method, which will not be repeated here.
[0121] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above-described state recovery method embodiments.
[0122] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described state recovery method embodiments when it is run.
[0123] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0124] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described state recovery method embodiments.
[0125] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described state recovery method embodiments.
[0126] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0127] The foregoing has provided a detailed description of a state recovery circuit, method, apparatus, electronic device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A state recovery circuit, characterized in that, include: Control module, lookup table module, power monitoring module; The control module and the lookup table module are connected to the state machine. The control module is connected to the lookup table module. The power monitoring module is connected to the DC voltage generated after AC / DC conversion of the mains power. The power monitoring module is also connected to the control module. The lookup table module is used to store state information of at least one state of the state machine during fault-free operation; the state information includes the state input, output and data generated in the state; The state information is pre-verified and confirmed data. All state information generated by the state machine during fault-free operation is stored in the lookup table module through external input. The control module is used to determine whether a fault has occurred when the state machine is in the current state. If it is determined that a fault has occurred when the state machine is in the current state, the first state information is transmitted to the state machine so that the state machine can perform state recovery based on the first state information. The first state information is the state information of the state machine when it is running without faults in the current state, which is obtained from the lookup table module. The power monitoring module transmits the DC voltage to the control module so that the control module can operate based on the DC voltage; The power monitoring module is used to monitor whether the mains power is cut off when the state machine is in the current state, so that the control module can determine whether a fault has occurred when the state machine is in the current state based on the monitoring result of whether the mains power is cut off; The control module includes: a status register, a status monitor, and a status transmitter; The state register is connected to the state machine and the state monitor, respectively. The status monitor is connected to the lookup table module and the status transmitter, respectively. The state transmitter is connected to the state machine; The status register is used to acquire second status information and transmit the second status information to the status monitor; the second status information is the status information generated when the state machine is in the current state, which is obtained from the state machine. The state monitor is used to receive the second state information, and the state monitor is used to obtain the first state information corresponding to the state machine when it is running without faults from the lookup table module, and determine whether a fault has occurred when the state machine is in the current state based on the first state information and the second state information. The state monitor is used to transmit the first state information to the state transmitter when it determines that a fault has occurred while the state machine is in the current state; The state transmitter is used to receive the first state information and transmit the first state information to the state machine.
2. The state recovery circuit according to claim 1, characterized in that, The state monitor is used to determine whether a fault has occurred when the state machine is in the current state, based on the first state information and the second state information, including: The consistency of the first state information and the second state information is compared. If the first state information is inconsistent with the second state information, it is determined that a fault has occurred when the state machine is in the current state.
3. The state recovery circuit according to claim 1, characterized in that, The status register is also used to obtain the duration of the state machine in the current state and transmit the duration to the status monitor so that the status monitor can determine whether a fault has occurred when the state machine is in the current state based on the duration.
4. The state recovery circuit according to claim 3, characterized in that, The status monitor is also used for, Receive the duration; The duration is compared with a preset time threshold. If the duration is greater than the preset time threshold, it is determined that a fault has occurred when the state machine is in the current state.
5. The state recovery circuit according to claim 1, characterized in that, The state recovery circuit also includes: a power supply; The power supply is connected to the control module; The power supply is used to provide uninterrupted power to the control module.
6. A state recovery method, characterized in that, include: The control module is used to determine whether a fault has occurred while the state machine is in its current state. If a fault occurs while the state machine is in the current state, the control module transmits the first state information generated by the state machine during fault-free operation corresponding to the current state, obtained from the lookup table module, to the state machine so that the state machine can recover its state based on the first state information. The lookup table module contains state information of at least one state in which the state machine is in fault-free operation. The state information includes the state's input, output, and data generated in that state. The state information is pre-verified and confirmed data. All state information generated by the state machine during fault-free operation is stored in the lookup table module through external input. The power monitoring module transmits the DC voltage generated after AC / DC conversion from the mains power to the control module, so that the control module can operate based on the DC voltage; The power monitoring module is used to monitor whether the mains power is cut off when the state machine is in the current state, so that the control module can determine whether a fault has occurred when the state machine is in the current state based on the monitoring result of whether the mains power is cut off; The step of using the control module to determine whether a fault has occurred when the state machine is in its current state includes: The control module uses a status register to obtain second state information generated when the state machine is in the current state, and uses the status register to transmit the second state information to a status monitor in the control module; the control module includes the status register and the status monitor. The state monitor receives the second state information and retrieves the first state information corresponding to the state machine when it is running without faults from the lookup table module. The status monitor is used to determine whether a fault has occurred in the current state based on the first status information and the second status information. The step of transmitting the first state information generated by the state machine operating without faults when it is in the current state, obtained from the lookup table module, to the state machine using the control module includes: If a fault occurs while the state machine is in the current state, the first state information is transmitted to the state transmitter in the control module using the state monitor; the control module includes the state register, the state monitor, and the state transmitter. The first state information is transmitted to the state machine using the state transmitter.
7. The state recovery method according to claim 6, characterized in that, The method of using the control module to determine whether a fault has occurred when the state machine is in its current state also includes: The duration of the state machine in the current state is obtained using the state register, and the duration is transmitted to the state monitor. The state monitor uses the duration to determine whether a fault has occurred while the state machine is in the current state.
8. A state recovery device, characterized in that, include: The determination unit is used by the control module to determine whether a fault has occurred when the state machine is in its current state. A transmission unit is configured to, when a fault occurs while the state machine is in the current state, utilize the control module to transmit first state information generated during fault-free operation of the state machine in the current state, obtained from a lookup table module, to the state machine, so that the state machine can recover its state based on the first state information; the lookup table module contains state information of at least one state in which the state machine is in fault-free operation; the state information includes the state's input, output, and data generated in that state; The state information is pre-verified and confirmed data. All state information generated by the state machine during fault-free operation is stored in the lookup table module through external input. The transmission unit is also used to transmit the DC voltage generated after AC / DC conversion with the mains power to the control module using the power monitoring module, so that the control module can operate based on the DC voltage; The determining unit is further configured such that the power monitoring module monitors whether the mains power is cut off when the state machine is in the current state, so that the control module determines whether a fault has occurred when the state machine is in the current state based on the monitoring result of whether the mains power is cut off; The determining unit is further configured to: The control module uses a status register to obtain second state information generated when the state machine is in the current state, and uses the status register to transmit the second state information to a status monitor in the control module; the control module includes the status register and the status monitor. The state monitor receives the second state information and retrieves the first state information corresponding to the state machine when it is running without faults from the lookup table module. The status monitor is used to determine whether a fault has occurred in the current state based on the first status information and the second status information. The transmission unit is further configured to: If a fault occurs while the state machine is in the current state, the first state information is transmitted to the state transmitter in the control module using the state monitor; the control module includes the state register, the state monitor, and the state transmitter. The first state information is transmitted to the state machine using the state transmitter.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the state recovery method as described in any one of claims 6 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the state recovery method as described in any one of claims 6 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the state recovery method as described in any one of claims 6 to 7.
Citation Information
Patent Citations
Fire early warning device for aircraft engine
CN104700547A
Fault management and recovery controller for FPGA triple-modular redundancy framework and control method thereof
CN104731668A
Data recovery method, a data backup method, a related device and a system
CN109522154A
Dynamic Configurable Microcontroller Recovery
US20210124655A1