An I2C bus communication optimization method, system, device and storage medium
By continuously sampling and constructing eye diagrams for the I2C bus, and combining timing prediction and reinforcement learning models, the timing parameters are dynamically adjusted, thus solving the communication reliability problem of the I2C bus in dynamic environments and achieving stable communication under changing environments.
Patent Information
- Application Number
- CN202611694351.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Traditional I2C bus protocols are difficult to adapt to dynamically changing environments, leading to increased communication error rates and decreased reliability, especially in scenarios involving multiple master devices competing for contention and mixed-rate communication.
By continuously sampling the clock and data lines of the I2C bus to construct an eye diagram, timing parameters are dynamically adjusted using timing prediction models and reinforcement learning models to achieve non-intrusive monitoring and forward-looking prediction of signal quality, and to maintain reliable communication under environmental changes.
It improves the I2C bus's adaptability and communication stability under environmental changes such as temperature, voltage, and load, reduces the communication error rate, and ensures the reliability and efficiency of communication.
Smart Images

Figure CN123178332A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to an I2C bus communication optimization method, system, device and storage medium. Background Technology
[0002] The I2C (Inter-Integrated Circuit) bus is a two-wire serial communication bus widely used in servers, embedded systems, automotive electronics, and industrial control due to its advantages such as fewer pins, simple implementation, and support for multi-master / slave architectures. With increasing system integration, the number of devices connected to the I2C bus is increasing, and the operating environment (temperature, voltage, electromagnetic interference) is becoming more complex, leading to increasingly common scenarios such as multi-master device contention and mixed-rate communication. Traditional I2C protocols use static timing parameter configuration, which is difficult to adapt to dynamically changing environments, resulting in increased communication error rates and decreased reliability. Therefore, how to achieve adaptive optimization of the I2C bus has become a key technical issue for improving system stability. Summary of the Invention
[0003] This application provides an I2C bus communication optimization method, system, device, and storage medium to at least solve the above-mentioned technical problems existing in the prior art.
[0004] According to a first aspect of this application, an I2C bus communication optimization method is provided, the method comprising: The analog waveforms of the clock and data lines of the I2C bus are continuously sampled to obtain sampled data; The clock data is recovered based on the sampled data to obtain the recovered clock; Using the recovery clock as a reference, the sampled data are aligned and superimposed according to the bit period divided by the recovery clock to construct the eye diagram at the current moment; Signal quality features are extracted from the eye diagram, and the signal quality features are combined with historical signal quality features in a time sequence to obtain the input sequence; wherein, the historical signal quality features are signal quality features extracted from multiple times prior to the current time. The input sequence is input into the time series prediction model to obtain the signal quality prediction features within a future preset time window output by the time series prediction model. The timing configuration of the I2C bus at the current moment is obtained, and the signal quality characteristics, the signal quality prediction characteristics, and the timing configuration are used as states. A timing parameter adjustment strategy is determined through a reinforcement learning model. The timing parameters of the I2C bus are adjusted according to the timing parameter adjustment strategy.
[0005] According to a second aspect of this application, an I2C bus communication optimization system is provided, the system comprising: The analog front-end and acquisition module are used to continuously sample the analog waveforms of the clock and data lines of the I2C bus to obtain sampled data. The eye diagram construction and analysis module is used to recover clock data based on the sampled data to obtain a recovered clock; using the recovered clock as a reference, the sampled data is aligned and superimposed according to the bit period divided by the recovered clock to construct the eye diagram at the current moment; signal quality features are extracted from the eye diagram, and the signal quality features are combined with historical signal quality features in time sequence to obtain an input sequence; wherein, the historical signal quality features are signal quality features extracted from multiple moments before the current moment; The prediction module is used to input the input sequence into the time series prediction model to obtain the signal quality prediction features within a future preset time window output by the time series prediction model. The reinforcement learning decision module is used to obtain the timing configuration of the I2C bus at the current time, take the signal quality characteristics, the signal quality prediction characteristics and the timing configuration as the state, and determine the timing parameter adjustment strategy through the reinforcement learning model. A programmable timing configuration module is used to adjust the timing parameters of the I2C bus according to the timing parameter adjustment strategy.
[0006] According to a third aspect of this application, an electronic device is provided, comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method described in this application.
[0007] According to a fourth aspect of this application, a non-transitory computer-readable storage medium is provided storing computer instructions for causing the computer to perform the methods described in this application.
[0008] The I2C bus communication optimization method, system, device, and storage medium of this application achieve non-intrusive continuous monitoring and forward-looking prediction of I2C bus signal quality by constructing eye diagrams through continuous sampling, performing timing prediction based on eye diagram features, and making decisions through reinforcement learning. It can detect the trend of changes in signal quality in advance before it actually deteriorates, and dynamically determine the timing parameter adjustment strategy through a reinforcement learning model, so that the I2C bus can maintain reliable communication performance under environmental changes such as temperature, voltage, and load, thereby improving the adaptive capability and communication stability of the I2C bus.
[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0010] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. Several embodiments of this application are illustrated in the drawings by way of example and not limitation, in which: In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
[0011] Figure 1 A schematic diagram illustrating the implementation flow of the I2C bus communication optimization method provided in an embodiment of this application is shown. Figure 2 The schematic diagram shows the uninterrupted clock domain switching operation of the I2C bus communication optimization method provided in the embodiments of this application; Figure 3 This paper illustrates a flowchart of the multi-master contention detection and triggering process of the I2C bus communication optimization method provided in an embodiment of this application. Figure 4 This illustration shows a flowchart of the multi-master contention optimization operation of the I2C bus communication optimization method provided in this application embodiment; Figure 5 A schematic diagram illustrating the implementation flow of the clock recovery operation in the I2C bus communication optimization method provided in this application embodiment is shown. Figure 6 This paper illustrates a schematic diagram of the eye diagram construction operation of the I2C bus communication optimization method provided in an embodiment of this application. Figure 7 This paper illustrates a schematic diagram of the implementation process of the reinforcement learning decision operation of the I2C bus communication optimization method provided in the embodiments of this application; Figure 8 This paper illustrates a schematic diagram of the implementation process of the health diagnosis and lifespan prediction operation of the I2C bus communication optimization method provided in the embodiments of this application; Figure 9 This illustration shows a schematic diagram of the implementation process of a specific application example of the I2C bus communication optimization method provided in the embodiments of this application; Figure 10 This paper shows a schematic diagram of the composition structure of the I2C bus communication optimization system provided in an embodiment of this application; Figure 11 A schematic diagram of the composition structure of an electronic device according to an embodiment of this application is shown. Detailed Implementation
[0012] To make the objectives, features, and advantages of this application more apparent and understandable, the technical solutions in 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 skilled in the art without creative effort are within the scope of protection of this application.
[0013] Figure 1 A schematic diagram illustrating the implementation flow of the I2C bus communication optimization method provided in this application embodiment is shown.
[0014] refer to Figure 1 This application provides an I2C bus communication optimization method, which includes: Operation 101 continuously samples the analog waveforms of the clock and data lines of the I2C bus to obtain sampled data.
[0015] The I2C bus, or Inter-Integrated Circuit bus, is a two-wire serial communication bus. It consists of a serial clock line (SCL) and a serial data line (SDA). SCL transmits the clock signal for synchronous data transmission, while SDA transmits addresses, commands, and data. The signals transmitted on SCL and SDA physically appear as analog voltage waveforms that vary over time.
[0016] Continuous sampling refers to the continuous acquisition of analog voltage waveforms on SCL and SDA, resulting in sampled data arranged in chronological order. The sampled data includes multiple sampling points, each corresponding to a sampling time and the sampled voltage value on SCL or SDA at that time. Through continuous sampling, sampled data covering multiple bit cycles can be obtained.
[0017] Operation 102: Recover the clock data based on the sampled data to obtain the recovered clock.
[0018] Clock Data Recovery (CDR) refers to extracting a clock signal synchronized with data transmission from sampled data. Since the sampled data contains information about the changes in data level on the SDA signal over time, the boundaries of data bits can be determined based on the level transitions of the SDA signal in the sampled data, and the period of the data bits can be determined based on the time interval between adjacent transitions, thereby recovering a clock synchronized with the data bits. The recovered clock is used to indicate the position of each bit period in the sampled data, providing a time reference for subsequent alignment and superposition of the sampled data according to bit periods.
[0019] Operation 103: Using the recovery clock as a reference, align and superimpose the sampled data according to the bit periods divided by the recovery clock to construct the eye diagram at the current moment.
[0020] An eye diagram is a statistical graph formed by superimposing signal waveforms of multiple bit cycles on the same time base, resembling an eye. It can be used to visually assess signal quality. After obtaining the recovered clock, the start and end positions of each bit cycle in the sampled data can be determined using the recovered clock as a reference, thus dividing the sampled data into multiple bit cycles. The sampled data of multiple bit cycles are aligned according to their relative time positions within the bit cycles, so that the sampled data of different bit cycles overlap on the time axis. The overlapping sampled data is then statistically analyzed in a two-dimensional space composed of time and voltage to obtain the distribution of sampling points in the two-dimensional space, thereby constructing the eye diagram for the current moment. The eye diagram can reflect the statistical distribution of signal levels within multiple bit cycles, such as the voltage distribution of logic "1" and logic "0", and the positional distribution of signal edges.
[0021] Operation 104 extracts signal quality features from the eye diagram and combines the signal quality features with historical signal quality features in a temporal sequence to obtain the input sequence; wherein, the historical signal quality features are the signal quality features extracted at multiple times before the current time.
[0022] Signal quality characteristics refer to the features extracted from the eye diagram that characterize the quality of the bus signal. These include, but are not limited to, eye height, eye width, peak-to-peak jitter, rise time (Tr), and fall time (Tf).
[0023] Historical signal quality features are obtained by constructing eye diagrams for each time point prior to the current time point using operations 101 to 103, and then extracting signal quality features from these eye diagrams. The signal quality features at the current time point are combined with the historical signal quality features in chronological order to form the input sequence. This input sequence contains both the signal quality status at the current time point and the signal quality changes prior to the current time point, which is used to predict future signal quality trends.
[0024] Operation 105: Input the input sequence into the time series prediction model to obtain the signal quality prediction features within the future preset time window output by the time series prediction model.
[0025] A time-series prediction model is a model that can predict numerical values or trends over a future period based on input time-series data. After inputting the input sequence obtained in operation 104 into the time-series prediction model, the model processes the signal quality features arranged chronologically in the input sequence, learns the pattern of signal quality changes over time, and outputs predicted signal quality features for a future preset time window. The future preset time window refers to a period of time after the current moment. The predicted signal quality features characterize the trend of signal quality changes over a future period. For example, predicting a continuous increase in rise time may indicate a decrease in link driving capability; predicting a continuous decrease in eye height may indicate a reduction in noise margin. Through this operation, the trend of signal quality changes can be known in advance before the actual deterioration of signal quality.
[0026] In one embodiment of this application, the time-series prediction model is preferably a Long Short-Term Memory (LSTM) model. This LSTM model can be trained offline in advance and deployed in a Field-Programmable Gate Array (FPGA) or an Application-Specific Integrated Circuit (ASIC), or it can be deployed in an embedded processor.
[0027] Operation 106: Obtain the timing configuration of the I2C bus at the current moment, take the signal quality characteristics, signal quality prediction characteristics, and timing configuration as the state, and determine the timing parameter adjustment strategy through a reinforcement learning model.
[0028] Timing configuration refers to the timing parameters set for the I2C bus at the current moment. Obtaining the current timing configuration of the I2C bus allows you to understand the actual values of these timing parameters. Timing parameters include, but are not limited to: Setup Time, Hold Time, Drive Current, Rising Edge Slope, Falling Edge Slope, SCL clock frequency, SCL clock duty cycle, and bus termination impedance.
[0029] The setup time is used to limit the time that SDA data remains stable before the valid edge of SCL; the hold time is used to limit the time that SDA data remains stable after the valid edge of SCL; the drive current is used to control the output capability of the I2C bus pin driver, affecting the rising and falling edges of the signal; the rising edge slope and falling edge slope are used to control the rate of change of the signal edges; the SCL clock frequency and SCL clock duty cycle are used to control the bus clock rhythm; and the bus termination impedance is used to match the characteristic impedance of the transmission line and improve signal integrity.
[0030] Reinforcement Learning (RL) is a machine learning paradigm that learns optimal policies by interacting with the environment and receiving rewards or penalties. Taking the signal quality features obtained from operation 104 at the current time step, the predicted signal quality features obtained from operation 105, and the timing configuration at the current time step as input to the reinforcement learning model, the model outputs a timing parameter adjustment policy based on this state and the pre-learned decision policy. This timing parameter adjustment policy instructs how to adjust the timing parameters of the I2C bus to adapt it to the current signal quality conditions and future signal quality trends.
[0031] Operation 107: Adjust the timing parameters of the I2C bus according to the timing parameter adjustment strategy.
[0032] Modify the timing configuration of the I2C bus at the current moment according to the timing parameter adjustment strategy, so that the adjusted timing parameters match the current signal quality characteristics and the predicted future signal quality characteristics.
[0033] Thus, this application embodiment achieves non-intrusive continuous monitoring and forward-looking prediction of I2C bus signal quality by constructing eye diagrams through continuous sampling, performing timing prediction based on eye diagram features, and making decisions through reinforcement learning. It can detect the trend of change before the actual deterioration of signal quality, and dynamically determine the timing parameter adjustment strategy through the reinforcement learning model, so that the I2C bus can still maintain reliable communication performance under environmental changes such as temperature, voltage, and load, thereby improving the adaptive capability and communication stability of the I2C bus.
[0034] In one embodiment of this application, after determining the timing parameter adjustment strategy through a reinforcement learning model, a non-interrupted clock domain switching operation is performed in response to the detection that the I2C bus meets the rate switching conditions. The rate switching conditions include at least one of the following: the capability information reported by the slave device to be communicated during the enumeration phase is inconsistent with the current operating rate of the I2C bus; the signal quality prediction feature indicates that the signal quality degradation is due to insufficient clock precision; a hot-plugging of a device is detected, and the capability information of the newly connected device does not match the current operating rate of the I2C bus.
[0035] Rate switching conditions are used to determine whether a clock domain switch is needed. Specifically, if the capability information reported by the slave device during the enumeration phase is inconsistent with the current operating rate of the I2C bus, it means the master device learns through slave device enumeration that the target slave device supports a different communication rate than the current bus operating rate. Continuing to communicate at the current rate may result in the slave device failing to respond correctly. Signal quality prediction characteristics indicating signal quality degradation stemming from insufficient clock precision means the future signal quality prediction characteristics output by the timing prediction model show a deteriorating trend in eye diagram quality, and this deterioration trend is related to clock precision. In this case, switching the clock source can improve signal quality. If a hot-plug is detected and the capability information of the newly connected device does not match the current operating rate of the I2C bus, it means the communication rate supported by the newly connected slave device is inconsistent with the current operating rate, requiring a clock source switch to match the newly connected device.
[0036] Uninterrupted clock domain switching refers to switching clock sources without pausing data transmission on the I2C bus and without generating glitches. By performing uninterrupted clock domain switching, the clock source can be switched without affecting current communication, allowing the I2C bus to continue data transmission at the target frequency after the switch.
[0037] Figure 2 The diagram illustrates the principle of the uninterrupted clock domain switching operation of the I2C bus communication optimization method provided in this application embodiment.
[0038] refer to Figure 2 In one embodiment of this application, the uninterrupted clock domain switching operation includes: maintaining the SCL clock output of the first phase-locked loop and determining the target frequency according to the target communication rate corresponding to the rate switching condition, configuring the second phase-locked loop to lock to the target frequency; comparing the output phase difference between the first and second phase-locked loops using a phase detector; when the output phase difference is stable within a preset phase threshold, starting a digitally controlled oscillator to fine-tune the output frequency in a stepwise manner to absorb the remaining phase difference; during the low-level range of the clock line, switching the clock source from the first phase-locked loop to the digitally controlled oscillator or the second phase-locked loop so that the I2C bus transmits data at the target frequency output by the second phase-locked loop; wherein, data transmission on the I2C bus is not paused during the switching process; and updating the timing configuration at the current moment according to the target frequency.
[0039] like Figure 2 As shown, Figure 2The system comprises four parts: the current PLL (Phase-Locked Loop), the target PLL, the clock scaling unit, and the I2C controller. The current PLL is the first PLL currently outputting the SCL clock, the target PLL is the second PLL to be switched to the target frequency, the clock scaling unit is the Digital Controlled Oscillator (DCO), and the I2C controller is responsible for data transmission on the I2C bus. Accordingly, the uninterrupted clock domain switching operation specifically includes the following process: When a rate switching requirement is detected, the current PLL continuously outputs the SCL clock, I2C bus communication proceeds normally, and the I2C controller maintains the current transmission. Simultaneously, the target PLL begins locking onto the target frequency, receiving the target frequency configuration value and entering the locking process, typically taking 100~300μs. After the target PLL locks, it enters the phase synchronization phase, where the phase detector continuously monitors the phase difference between the two PLLs. When the phase difference is less than a preset threshold, for example, less than 5°, it is determined that the two PLLs are phase-synchronized and ready to switch. At this time, the clock scaling unit starts clock scaling, i.e., it starts the digitally controlled oscillator, fine-tuning the output frequency in 0.1% steps to gradually absorb the remaining phase difference. This process lasts for 5~10 SCL clock cycles, with the SCL edge undergoing a slight displacement but still remaining within the effective sampling window of the eye diagram.
[0040] Subsequently, during the SCL low-level interval, the clock selector switches the clock source from the current PLL to the target PLL, enabling the I2C bus to transmit data at the target frequency output by the target PLL. The switching is seamless and without interruptions, and data transmission on the I2C bus is not paused during the switching process. After the switching is complete, the clock source stabilizes at the target PLL output, the frequency is the target frequency, SCL remains continuous without interruption, and the I2C controller continues transmission. Following this, the timing configuration is updated according to the target frequency, including recalculating the baseline values for setup and hold times (i.e., re-determining the current setup and hold times), and updating the number of bit-period sampling points M = fs / f_SCL_new, where fs is the sampling rate and f_SCL_new is the SCL frequency after the switch. The updated timing configuration is used for subsequent adjustments to the timing parameters.
[0041] The parameters or values mentioned above, such as 100~300μs, 5°, 0.1%, 5~10 SCL clock cycles, and M=fs / f_SCL_new, are merely illustrative examples. Those skilled in the art can adjust them according to the actual bus speed, PLL performance, and signal integrity requirements. This application is not limited thereto.
[0042] Thus, this embodiment of the application uses a dual phase-locked loop, a phase detector, and a digitally controlled oscillator to perform uninterrupted clock domain switching. The clock source switching is completed in the SCL low-level range, so that the SCL clock is continuously output without glitches. Data transmission on the I2C bus is not interrupted during the switching process, realizing uninterrupted and smooth transition when devices communicate at different rates. After the switching is completed, the timing configuration is updated according to the target frequency to ensure the reliability of subsequent communication.
[0043] Figure 3 The flowchart illustrating the multi-master contention detection and triggering process of the I2C bus communication optimization method provided in this application embodiment is shown.
[0044] In one embodiment of this application, after determining the timing parameter adjustment strategy through a reinforcement learning model, a bus idle listening window is opened before the I2C master device initiates bus access; it is determined whether bus activity is detected within the bus idle listening window; if bus activity is detected, multi-master contention optimization is triggered; if no bus activity is detected, bus waveform characteristics are determined based on sampled data, and the collision probability is predicted based on the bus waveform characteristics, and it is determined whether the collision probability is greater than a preset collision probability threshold; if the collision probability is greater than the preset collision probability threshold, multi-master contention optimization is triggered; if the collision probability is not greater than the preset collision probability threshold, it is determined whether multiple master devices are active based on signal quality characteristics and / or signal quality prediction characteristics; if multiple master devices are active, multi-master contention optimization is triggered; if no multiple master devices are active, the I2C master device is controlled to initiate bus access.
[0045] like Figure 3 As shown, after determining the timing parameter adjustment strategy through the reinforcement learning model, before the I2C master device initiates bus access, the bus idle listening window is opened, and the following judgments are executed in sequence.
[0046] Specifically, the I2C bus supports a multi-master, multi-slave architecture, where multiple master devices may simultaneously attempt to access the bus. If a bus access is initiated without proper checks, conflicts with other master devices can easily occur, leading to bus access failure or data corruption. Therefore, before an I2C master device initiates a bus access, a bus idle listener window is opened. This window is a preset observation period used to monitor the current bus status. Within this window, the SCL and SDA lines are continuously monitored to determine if bus activity exists. Bus activity refers to level transitions, start conditions, or other non-idle level changes on the SCL or SDA lines, indicating that another master device is already communicating or initiating access on the bus. If bus activity is detected, it means the current bus is already occupied, triggering multi-master contention optimization, i.e., contention handling.
[0047] If no bus activity is detected, the bus waveform characteristics are further determined based on the sampled data. Bus waveform characteristics refer to features extracted from the sampled data that reflect signal changes when multiple devices simultaneously drive the bus, such as abnormal level fluctuations on the SCL line or signs of overlapping start conditions. The collision probability is predicted based on these waveform characteristics and compared to a preset collision probability threshold. If the collision probability is greater than the preset threshold, it indicates a high probability that multiple devices are simultaneously driving the bus, triggering multi-master contention optimization.
[0048] If the collision probability is not greater than the preset collision probability threshold, the system determines whether multiple active master devices exist based on the current / predicted features (signal quality features and / or predicted signal quality features). If multiple active master devices exist, multi-master contention optimization is triggered; if no multiple active master devices exist, the I2C master device initiates bus access normally, and the bus access is successful.
[0049] Multi-master contention optimization refers to a bus access optimization process performed when the risk of multi-master contention is detected. Its purpose is to reduce the probability of conflict when multiple master devices initiate bus access at the same time through conflict prediction and adaptive backoff, thereby improving bus utilization and communication reliability.
[0050] Thus, through the above sequential judgments, this embodiment of the application identifies multi-master contention risks from three levels—bus activity, conflict probability, and master device activity level—before the I2C master device initiates bus access. If a risk is detected at any level, multi-master contention optimization is triggered. Only when there is no risk at all levels is normal bus access allowed, thereby effectively avoiding or reducing bus conflicts.
[0051] In one embodiment of this application, the analog waveforms of the clock line and data line of the I2C bus are continuously sampled to obtain sampled data. This includes: continuously sampling the analog waveforms of the clock line and data line using an analog-to-digital converter without interrupting I2C bus data transmission or inserting probe pulses into the I2C bus to obtain sampled data.
[0052] Traditional eye diagram monitoring methods typically insert probe pulses of a preset width during the idle phase of the I2C bus, monitoring signal quality parameters by measuring the change in bus voltage level under the probe pulse. However, this method is intrusive: the probe pulses occupy the bus idle time and cannot be continuously monitored during normal communication, resulting in incomplete signal quality information. In contrast, this implementation uses a non-intrusive continuous eye diagram monitoring method. During normal I2C bus data transmission, analog waveforms on the clock and data lines are continuously sampled without inserting any probe pulses into the bus. Therefore, the sampling process does not occupy bus bandwidth and is completely transparent to normal communication.
[0053] Specifically, the analog waveforms of the clock and data lines are continuously sampled using an analog-to-digital converter (ADC). The ADC converts continuous analog voltage signals into discrete digital samples. In one embodiment of this application, a high-speed ADC with a sampling rate of at least 100MHz is used to achieve nanosecond-level waveform capture. For example, the ADC can continuously acquire clock line waveforms at a sampling rate of 200MHz, and the same applies to the data lines. Through this continuous sampling, sampled data arranged in chronological order is obtained.
[0054] Figure 4 This paper illustrates a schematic diagram of the implementation process of the multi-master contention optimization operation of the I2C bus communication optimization method provided in the embodiments of this application.
[0055] refer to Figure 4 In one embodiment of this application, multi-master contention optimization includes: Operation 201: Count the bus idle time within the bus idle listener window.
[0056] Within the bus idle listening window, the voltage levels of the SCL and SDA lines are continuously monitored, and the actual time the bus is idle is recorded, i.e., the bus idle time. This operation utilizes the real-time voltage information of the SCL and SDA lines in the sampled data, and captures accurate time intervals through timing capabilities to obtain the bus idle time.
[0057] Operation 202: Determine the bus waveform characteristics based on the sampled data, and assess the bus conflict risk by combining the bus waveform characteristics with the bus idle time.
[0058] Bus waveform characteristics are determined based on sampled data, including abnormal level fluctuations on the SCL line and signs of overlapping start conditions. The bus collision risk is assessed by combining these characteristics with bus idle time. When the total bus idle time is less than a preset percentage of a bus idle time threshold, the bus is determined to be busy, indicating a collision risk. In one implementation, when the bus idle time is less than 80% of the minimum bus idle time specified in the protocol (i.e., the bus idle time is less than 0.8 times the minimum bus idle time), the bus is determined to be busy. Furthermore, the bus can be busy by predicting whether the collision probability exceeds a threshold based on signal waveform characteristics that indicate multiple devices simultaneously driving the bus.
[0059] Operation 203: When the assessment shows that the conflict risk meets the preset conditions, it is determined that the I2C bus is in a busy state. An initial backoff time slot is allocated to the I2C master device according to the device priority, so that the I2C master device waits for the initial backoff time slot to end before attempting to initiate I2C bus access.
[0060] Among them, the initial backoff time slot for high-priority devices is shorter than that for low-priority devices.
[0061] When the assessment determines that the conflict risk meets preset conditions, the I2C bus is considered busy. An initial backoff time slot is allocated to the I2C master device based on its priority. High-priority devices, such as Baseboard Management Controllers (BMCs) with high real-time requirements, are allocated shorter initial backoff time slots; low-priority devices, such as ordinary management master devices, are allocated longer initial backoff time slots. The backoff window for high-priority devices can be reduced by 20% to 50%. The device waits for the allocated initial backoff time slot and then attempts to initiate bus access, i.e., sends the start condition.
[0062] Operation 204: If a conflict occurs when the I2C master device attempts to initiate an I2C bus access, determine the conflict duration and waveform characteristics based on the sampled data, and determine the number of devices involved in the conflict based on the conflict duration and waveform characteristics.
[0063] In the event of a collision—that is, multiple master devices simultaneously sending start conditions—the number of devices involved in the collision is estimated by analyzing the collision duration and waveform characteristics. The collision duration refers to the length of time the bus is occupied, and the waveform characteristics refer to signal overlap patterns, etc. Based on the bus occupancy duration and signal overlap patterns in the sampled data, the number of devices involved in the collision is determined.
[0064] Operation 205: Adjust the backoff window size according to the number of devices so that the I2C master device randomly selects a backoff time within the adjusted backoff window and retryes the I2C bus access after the delayed backoff time.
[0065] The backoff window size is dynamically adjusted based on the estimated number of conflicting devices. If the number of devices is high, the window increases; if the number of devices is low, the window decreases. In one implementation, the standard binary exponential backoff time is calculated by multiplying a random function value between zero and 2^3 minus one by a time slot, i.e., backoff time = random(0, 2^conflict count - 1) × time slot. This application employs adaptive backoff: the initial backoff uses a time slot allocated based on priority, considering device importance; subsequent backoffs are calculated by multiplying a random function value between zero and the minimum of 2^3 and the dynamic upper limit by a time slot, i.e., subsequent backoff = random(0, min(2^conflict count, dynamic upper limit)) × time slot, where the dynamic upper limit is a function of the number of conflicting devices and bus load; the backoff window for high-priority devices is reduced by 20%~50%; the upper limit increases when the number of conflicting devices is high and decreases when the number is low; the upper limit is moderately increased when the bus load is high to distribute access.
[0066] For example, the dynamic adjustment strategy can be as follows: when the number of conflicting devices is greater than 5, the backoff window is increased by 1.5; when the number of conflicting devices is less than or equal to 3, the backoff window is decreased by 0.8; when the bus idle rate is high, the backoff window is decreased to speed up retries; when the bus conflict frequency is high, the backoff window is increased to reduce further conflicts. A new backoff time is randomly selected in the adjusted backoff window, and the bus access is retried after the delay. Operations 203 to 205 are repeated until the access is successful or the maximum number of retries is exceeded.
[0067] Thus, this application embodiment achieves coordinated optimization of bus access for multiple master devices in a multi-master contention scenario by combining bus idle listening, conflict risk prediction, initial backoff allocation based on device priority, and dynamic adjustment of the backoff window according to the number of conflicting devices. This reduces the probability of conflict when multiple master devices initiate bus access simultaneously, improves the retry success rate and bus utilization, thereby enhancing the communication reliability and efficiency of the I2C bus in a multi-master contention scenario.
[0068] Figure 5 This paper illustrates a schematic diagram of the implementation process of the clock recovery operation in the I2C bus communication optimization method provided in this application embodiment.
[0069] In one embodiment of this application, the sampling data includes clock line sampling data and data line sampling data. The data line sampling data includes multiple data bits, each data bit corresponding to one bit period. Each bit period includes multiple sampling points arranged in chronological order, and each sampling point includes a sampling time and a sampling voltage value. Accordingly, refer to... Figure 5 The above operation 102, which recovers clock data based on the sampled data to obtain the recovered clock, includes: Operation 301 performs a differential operation on the sampled voltage values of adjacent sampling points in the data line sampling data to obtain the voltage difference between adjacent sampling points.
[0070] Differential calculations are performed on the sampled voltage values of adjacent sampling points in the data line sampling data. This involves subtracting the sampled voltage value of the previous sampling point from the current sampling voltage value to obtain the voltage difference between adjacent sampling points. This voltage difference reflects the degree of change in the data line signal between adjacent sampling points. When the data line signal level changes abruptly, the voltage difference increases significantly; when the data line signal level remains stable, the voltage difference approaches zero. Through differential calculations, the abrupt positions of level changes in the data line sampling data can be preliminarily identified, providing a basis for subsequent determination of signal transitions.
[0071] Operation 302: When the absolute value of the voltage difference exceeds the preset threshold, determine that there is a signal transition between adjacent sampling points in the data line sampling data, and record the transition direction and the corresponding sampling point position.
[0072] After obtaining the voltage difference between adjacent sampling points, the absolute value of the voltage difference is compared with a preset threshold. The preset threshold can be set according to the voltage swing and noise level of the data line signal, for example, approximately 0.2V. When the absolute value of the voltage difference exceeds the preset threshold, it indicates that a significant level change has occurred in the data line signal between the adjacent sampling points, i.e., a signal jump exists. At this time, it is determined that there is a signal jump between the data line sampling data and the adjacent sampling points, and the jump direction and the corresponding sampling point position are recorded. The jump direction is used to distinguish between rising and falling edges: if the voltage difference is positive and exceeds the preset threshold, the jump direction is a rising edge; if the voltage difference is negative and the absolute value exceeds the preset threshold, the jump direction is a falling edge. The corresponding sampling point position is used to indicate the time position of the signal jump in the sampled data.
[0073] Operation 303 arranges the sampling point positions corresponding to the multiple recorded signal transitions in chronological order to obtain the transition edge position sequence.
[0074] Data line sampling data typically contains multiple signal transitions, each corresponding to a sampling point. The sampling point positions corresponding to these signal transitions, recorded in operation 302, are arranged in chronological order to form a transition edge position sequence. This sequence reflects the temporal positions of all transition edges of the data line signal within a given time period. Since each data bit boundary usually corresponds to a signal transition, the transition edge position sequence can be used to determine the data bit boundaries and bit period, providing a basis for subsequently determining the center position of the data bit and generating a recovered clock.
[0075] Operation 304 determines the center position of the data bits on the data line based on the transition edge position sequence, and uses a digital phase-locked loop to generate a recovery clock, so that the sampling edge of the recovery clock is aligned with the center position of the data bits on the data line, thus obtaining the recovery clock.
[0076] Since the transition edge corresponds to the boundary of the data bit, the midpoint between two adjacent transition edges is the center position of the data bit. This position is the most stable position for the data bit level and is also the optimal sampling position. After determining the center position of the data bit, a Digital Phase-Locked Loop (DPLL) is used to generate a recovery clock. The DPLL uses the transition edge position sequence as a phase reference, calculates the phase error between the recovery clock edge and the target position through a phase detector, and obtains the frequency adjustment amount by proportional and integral processing of the phase error through a loop filter. A numerically controlled oscillator adjusts the frequency and phase of the output clock according to the frequency adjustment amount, so that the sampling edge of the recovery clock is aligned with the center position of the data bit on the data line. When the sampling edge of the recovery clock is stably aligned with the center position of the data bit, the DPLL completes locking and outputs the recovery clock. The frequency of the recovery clock is equal to the data bit rate, and the phase is located at the center position of the data bit, which is used for subsequent bit periodization and eye diagram construction of the sampled data.
[0077] In one embodiment of this application, a second-order digital phase-locked loop is used to lock the sampling edge of the recovered clock to the center position of the eye diagram. The digital phase-locked loop includes a phase detector, a loop filter, and a digitally controlled oscillator.
[0078] In one embodiment of this application, after obtaining the recovery clock, the sampled voltage value in the data line sampled data can be latched at the edge of the recovery clock and compared with a decision threshold. In one embodiment, the decision threshold is 1.65V. Sampled voltage values higher than the threshold are judged as logic "1", and sampled voltage values lower than the threshold are judged as logic "0", thereby obtaining a synchronization data sequence.
[0079] Specifically, the output of clock data recovery includes: a recovered clock CLK_CDR, whose frequency is equal to the current SCL frequency (100kHz / 400kHz / 1MHz), and whose phase is located at the center of the eye diagram; a synchronization data sequence D_Sync[k], which is a bit-level decision result (0 / 1); and the number of sampling points per bit M, M=fs / f_SCL, where fs is the sampling rate and f_SCL is the current SCL frequency. For example, when the sampling rate is 200MHz, the number of sampling points per bit M=500 at a communication rate of 400kHz.
[0080] Figure 6 This paper illustrates a schematic diagram of the eye diagram construction operation of the I2C bus communication optimization method provided in this application embodiment.
[0081] In one embodiment of this application, the above-described operation 103, using the recovery clock as a reference, aligns and superimposes the sampled data according to the bit periods divided by the recovery clock to construct the eye diagram at the current moment, including: Operation 401 uses the edge of the recovery clock as the dividing boundary to segment the sampled data, resulting in multiple independent bit period waveform segments.
[0082] After obtaining the recovered clock, using the rising edge of the recovered clock as a reference, the start and end positions of each bit period are marked in the original sampling sequence. The continuous sampling sequence is then divided into multiple independent bit period waveform segments, each with a length of M sampling points. Each bit period waveform segment obtained is independent of the others and corresponds to the signal waveform within one data bit period.
[0083] Operation 402 aligns all bit-cycle waveform segments according to their relative time positions within the bit cycle.
[0084] All bit-cycle waveform segments obtained from operation 401 are aligned with the same relative time position, that is, the starting position of each bit-cycle waveform segment is aligned so that sampling points at the same relative time position in different bit cycles are on the same time coordinate. After alignment, multiple bit-cycle waveform segments overlap on the time axis to form a multi-cycle superimposed waveform set.
[0085] Operation 403: Count the frequency of sampling points appearing in combinations of time positions and voltage ranges, and normalize the frequency to obtain the probability density.
[0086] After aligning all bit-period waveform segments with the same relative time position, statistical analysis is performed on a two-dimensional plane. The horizontal axis of this two-dimensional plane represents the sampling position within one bit period, and the vertical axis represents the voltage value. The horizontal axis is divided into M time positions (0 to M-1); the vertical axis divides the 0~3.3V range into 128 voltage intervals. The frequency of each (time position, voltage interval) combination is counted across all bit periods, i.e., the frequency of sampling points occurring at each time position and voltage interval combination. Then, the count is divided by the total number of bits involved in the superposition (typically 5000~10000) to convert it into a probability density. This probability density represents the probability of a sampling point occurring at a certain time position and in a certain voltage interval.
[0087] Operation 404 generates an eye diagram data matrix based on the probability density, and constructs the eye diagram at the current time step based on the eye diagram data matrix.
[0088] Arrange the probability density obtained from operation 403 according to time position and voltage interval to obtain the eye diagram data matrix EyeMatrix[j][bin], which has a dimension of M×128. Here, j represents the time position index, bin represents the voltage interval index, and each value in the matrix represents the probability of a sampling point occurring at the corresponding time position and voltage interval. The eye diagram for the current time moment can be constructed based on this eye diagram data matrix.
[0089] Figure 7 This paper illustrates a schematic diagram of the implementation process of the reinforcement learning decision operation of the I2C bus communication optimization method provided in the embodiments of this application.
[0090] refer to Figure 7 In one embodiment of this application, the above-described operation 106, taking signal quality features, signal quality prediction features, and timing configuration as states, determines a timing parameter adjustment strategy through a reinforcement learning model, including: Operation 501 concatenates the signal quality features, signal quality prediction features, and timing configuration to obtain the state; the signal quality features include at least one of eye height, eye width, peak-to-peak jitter, rise time, and fall time.
[0091] The eye height is obtained by extracting the voltage distribution in the central time region (0.4~0.6 bit cycles) from the eye diagram, and statistically analyzing the average voltage and voltage fluctuation of logic "1" and logic "0" levels respectively. The average voltage of logic "1" is then subtracted by three times the voltage fluctuation, and the average voltage of logic "0" is then subtracted by adding three times the voltage fluctuation to obtain the eye height. Eye height reflects the signal's noise immunity, measured in volts (V). The normal range is 0.5~1.5V; a continuous decrease indicates weakened driving capability or increased power supply noise.
[0092] The eye width is obtained as follows: Take the midpoint of the eye diagram, which is the midpoint between the average voltages of logic "1" and logic "0". Find the left and right crossover points at this level, i.e., the positions where the waveform crosses the midpoint. Subtract the left crossover point time position from the right crossover point time position and multiply by the sampling period to obtain the eye width. The eye width reflects the stable sampling time window, measured in nanoseconds (ns). The normal range is approximately 40% to 70% of the bit period. A continuously narrowing eye width indicates increased clock jitter or insufficient timing margin.
[0093] Peak-to-peak jitter is obtained as follows: For each bit period waveform, the positions where the rising edge crosses the mid-level and the falling edge cross the mid-level are found, forming two sets of edge position sequences; the maximum value of each set of sequences is subtracted from the minimum value to obtain the peak-to-peak value of the rising edge jitter and the peak-to-peak value of the falling edge jitter; the total peak-to-peak jitter is the larger of the two values. Peak-to-peak jitter reflects the edge offset under worst-case conditions, measured in nanoseconds (ns). Normally, it is less than 10% of the bit period; a sudden increase indicates clock lockout or power supply interference.
[0094] Rise and fall times are obtained by averaging all rising edge waveforms to obtain the average rising edge waveform. The rise time is the time required for the rise from 10% of the logic "0" level to 90% of the logic "1" level. Similarly, the fall time is the time required for the fall time to drop from 90% to 10%. Rise / fall times reflect bus load and drive capability, measured in nanoseconds (ns). Longer times indicate heavier load or insufficient drive. In the 400kHz standard mode, a rise time of less than 300ns and a fall time of less than 100ns are required.
[0095] The signal quality prediction features are output by the aforementioned time-series prediction model, including predicted eye height, eye width, jitter, rise time, and fall time within a preset future time window. The time-series configuration is the same as the one for the current moment. The state is obtained by concatenating the aforementioned signal quality features, signal quality prediction features, and time-series configuration.
[0096] In one implementation, the state S(t) consists of three parts: S(t) = [F(t), P(t+1...t+N), H(t)]. Wherein, F(t) = [eye height, eye width, peak-to-peak jitter, rise time, fall time]; P(t+1...t+N) are the five-dimensional signal quality prediction feature values for the next N time points; and H(t) are the currently used timing parameter settings such as setup time, hold time, and drive current.
[0097] Operation 502: Input the state into the reinforcement learning model. The reinforcement learning model outputs the action value corresponding to each action in the preset action space based on the preset reward function. The action value is the expected reward obtained by performing the corresponding action in the state.
[0098] Reinforcement learning models are used to determine the action value of each executable action in the current state based on the input state, and to select timing parameters to adjust the strategy accordingly.
[0099] In one embodiment of this application, a Deep Q-Network (DQN) is used as the reinforcement learning model. DQN combines deep learning with Q-learning, using a neural network to approximate the action-value function, making it suitable for high-dimensional state spaces. After receiving a state, DQN outputs the action value corresponding to each action; during training, the network parameters are updated based on the reward obtained after performing an action, so that the action value gradually approaches the true expected reward.
[0100] Operation 503: Select a target action from the preset action space based on the action value, and determine the target action as the timing parameter adjustment strategy.
[0101] The preset action space includes at least one of setup time adjustment, hold time adjustment, and drive current adjustment; the reward function is determined based on at least one of communication success rate, number of adjustments, and constraint conditions.
[0102] After obtaining the action value corresponding to each action, the action with the highest action value is selected from the preset action space as the target action, and this target action is determined as the timing parameter adjustment strategy. The timing parameter adjustment strategy is used to indicate the adjustment of the timing parameters of the I2C bus, including at least one of the setup time adjustment, hold time adjustment, and drive current adjustment.
[0103] The reward function is determined based on at least one of the following: communication success rate, number of adjustments, and constraints. In one embodiment of this application, the reward function is R = α × R_success - β × R_change. Wherein, R is the overall reward, i.e., the action value, typically normalized to [-1, 1]; R_success is the communication success rate reward, measuring the degree of improvement in communication quality after executing action a, ranging from [0, 1]; R_change is the adjustment magnitude penalty, measuring the magnitude of the timing parameter adjustment, ranging from [0, 1]; α is the weighting coefficient for the communication success rate, ranging from 0.5 to 0.8, typically 0.7; β is the weighting coefficient for the adjustment magnitude, ranging from 0.2 to 0.5, typically 0.3, and α + β ≤ 1. Furthermore, a constraint penalty term can also be added. The following situations will result in an additional negative reward being forcibly added to the overall reward: when the adjusted eye height is <0.8V, a penalty of -0.5 will be applied to avoid signal quality degradation; when the adjusted rise time is >300ns, a penalty of -0.3 will be applied to avoid excessive bus load; when the adjustment range exceeds ±100ns and the condition is good, a penalty of -0.2 will be applied to avoid unnecessary over-adjustment.
[0104] For example, at time t, the signal quality features extracted from the eye diagram at the current time are obtained, denoted as S_t, and the signal quality prediction features for the next three times, output by the LSTM prediction model, are denoted as P_{t+1}, P_{t+2}, and P_{t+3}, respectively. S_t, P_{t+1}, P_{t+2}, P_{t+3}, and the temporal configuration at the current time are concatenated to obtain state S. Based on the current state S, DQN selects a target action a from the action space. Target action a includes setup time adjustment Δt_SU and hold time adjustment Δt_HD. After executing target action a, the success rate R_success of subsequent communication and the adjustment magnitude R_change are monitored. The comprehensive reward R = α × R_success - β × R_change is calculated based on the reward function. The experience (S, a, R, S') is stored in the experience pool, and the DQN network parameters are periodically sampled and updated, where S' is the state at the next time step after executing target action a. Finally, the establishment time adjustment Δt_SU and the hold time adjustment Δt_HD will be used as timing parameter adjustment strategies.
[0105] In one embodiment of this application, the above-described operation 107, adjusting the timing parameters of the I2C bus according to a timing parameter adjustment strategy, includes at least one of the following: adjusting the setup time of the I2C bus based on the setup time adjustment amount in the timing parameter adjustment strategy and the current setup time in the current timing configuration; adjusting the hold time of the I2C bus based on the hold time adjustment amount in the timing parameter adjustment strategy and the current hold time in the current timing configuration; and adjusting the drive current of the I2C bus based on the drive current adjustment amount in the timing parameter adjustment strategy and the current drive current in the current timing configuration. The setup time and hold time are adjusted via a programmable delay chain, and the drive current is adjusted via a programmable current source array.
[0106] Setup time (t_SU) is the time the data signal must remain stable before the valid edge of the clock signal; Hold time (t_HD) is the time the data signal must remain stable after the valid edge of the clock signal; Drive current (I_drive) is the output stage bias current of the I2C bus pin driver, used to control the signal driving capability.
[0107] Specifically, the setup time is controlled by a programmable delay chain within the I2C controller. This chain consists of multiple cascaded delay units, each with a fixed delay value. During adjustment, the current setup time configuration value T_setup_current is read, and the target setup time T_setup_target = T_setup_current + Δt_setup is calculated, where Δt_setup is the setup time adjustment amount. Then, a boundary check is performed on the target setup time. If T_setup_target is less than the lower limit, it is clamped to the lower limit; if it is greater than the upper limit, it is clamped to the upper limit. The clamped target setup time is then converted into the number of delay units N_delay and written to the corresponding bit field of the setup time configuration register, thereby changing the signal's transit time through the delay chain and adjusting the setup time.
[0108] The hold time adjustment mechanism is similar to the setup time, also implemented through a programmable delay chain, but using an independent delay chain and an independent configuration register. During adjustment, the current hold time configuration value T_hold_current is read, and the target hold time T_hold_target = T_hold_current + Δt_hold is calculated, where Δt_hold is the hold time adjustment amount. Then, a boundary check is performed on the target hold time. If T_hold_target is less than the lower limit, it is clamped to the lower limit; if it is greater than the upper limit, it is clamped to the upper limit. Finally, the clamped target hold time is converted into the number of delay units N_delay and written to the hold time configuration register, thus adjusting the hold time.
[0109] The drive current is controlled by the output stage bias current of the pin driver, which is implemented through a programmable current source array. The programmable current source array consists of multiple basic current source units connected in parallel. The current of each basic current source unit is fixed, and the total drive current is adjusted by controlling the number of conducting units. During adjustment, the current drive current value I_drive_current is read, and the target drive current I_drive_target = I_drive_current + ΔI_drive is calculated, where ΔI_drive is the drive current adjustment amount. Then, a boundary check is performed on the target drive current. If I_drive_target is less than the lower limit, it is clamped to the lower limit; if it is greater than the upper limit, it is clamped to the upper limit. The number of conducting current source units N_unit is then determined based on the clamped target drive current, and N_unit is written to the drive current configuration register, enabling the corresponding number of current source units to conduct, thereby adjusting the drive current.
[0110] Specifically, increasing the setup time allows for longer data preparation time for slave devices, suitable for scenarios with heavy bus load and slow slave device response; decreasing the setup time improves bus utilization, suitable for scenarios with good signal quality and a need for increased speed; increasing the hold time improves data sampling reliability, suitable for scenarios with large clock jitter and insufficient timing margin; decreasing the hold time reduces transmission latency, suitable for scenarios with good signal quality and high-speed transmission; increasing the drive current enhances signal driving capability and shortens rise time, suitable for scenarios with increased bus load and slow rise edge; decreasing the drive current reduces power consumption and electromagnetic interference, suitable for scenarios with light bus load and severe signal overshoot.
[0111] In one embodiment of this application, if at least one of the adjusted setup time, hold time, and drive current exceeds a corresponding preset range, the value exceeding the preset range is set as a boundary value of the preset range, so that the adjusted value is within the corresponding preset range. This is the clamping operation described above. For example, the preset range for setup time is 50ns to 300ns. If the target setup time is 350ns, the final setup time is set to 300ns; if the target setup time is -20ns, the final setup time is set to 50ns. The preset range for hold time is, for example, 50ns to 300ns, and the preset range for drive current is, for example, 2mA to 16mA. By using boundary clamping, timing parameters can be prevented from exceeding reasonable ranges due to excessive adjustment, thereby ensuring the reliability of I2C bus communication. The specific values mentioned above are merely illustrative examples. Those skilled in the art can set different preset ranges according to actual application scenarios, and this application is not limited to these.
[0112] In one embodiment of this application, the time series prediction model is trained through the following operations: obtaining a training sample set, each training sample including a sample input sequence and a sample label, wherein the sample input sequence is a combination of historical signal quality features of samples in chronological order, and the sample label is the sample signal quality feature within a future preset time window corresponding to the sample input sequence; inputting the sample input sequence into the initial time series prediction model to obtain the sample prediction output; determining the loss value based on the sample prediction output and the sample label; updating the parameters of the initial time series prediction model based on the loss value until a preset training termination condition is met to obtain the trained time series prediction model.
[0113] Specifically, an I2C bus test platform was built in a laboratory environment to systematically cover different temperatures, bus loads, and voltage conditions. For example, temperature variables included six temperature points: -40°C, -10°C, 25°C, 50°C, 70°C, and 85°C; load variables included four load configurations: 1, 2, 4, and 8 slave devices; and voltage variables included four bus voltage points: 3.0V, 3.2V, 3.3V, and 3.5V. Standard I2C communication was continuously run under each combination, and eye diagram parameter characteristics were continuously output through eye diagram construction and analysis. The data acquisition time was no less than 30 minutes, with a sampling interval T_s = 1μs, yielding approximately 1.8 million sets of feature data per combination. A total of 6 × 4 × 4 × 1.8 million ≈ 170 million sets of data were obtained. The collected data is preprocessed to remove abnormal data segments, and Z-score normalization is performed on each feature dimension to obtain standardized signal quality features. Outliers, such as samples that exceed the mean ± 5 times the standard deviation, are checked and removed.
[0114] Then, training samples are extracted from the dataset using a sliding window approach. Each training sample includes a sample input sequence and a sample label. The sample input sequence is a combination of historical signal quality features of the samples in chronological order, specifically the historical signal quality features of the past L time moments, where L is 50~100 (in this embodiment, L=100), corresponding to a 100μs historical window. The input part is the feature sequence of the past L time moments, X=[F(tL),...,F(t-1)], with a shape of 100×5. The sample label is the sample signal quality feature of the sample within a future preset time window corresponding to the sample input sequence, specifically the signal quality features of the future N time moments, where N is 5~20 (in this embodiment, N=10), corresponding to a 10μs future window. The label part is the feature sequence of the future N time moments, Y=[F(t),...,F(t+N-1)], with a shape of 10×5, which flattens out to a 50-dimensional vector. The sliding step size is set to 1 time moment, meaning that adjacent samples share 99 time moments of historical signal quality features to maximize sample utilization. All samples were divided into training set (70%), validation set (15%) and test set (15%) in chronological order.
[0115] Next, the sample input sequence is input into the initial time-series prediction model to obtain the sample signal quality prediction features. In one embodiment, the time-series prediction model is an LSTM model. The LSTM model includes: an input layer for receiving an input sequence of shape L×5; a first LSTM layer, including 64 units with dropout at a dropout rate of 0.2; a second LSTM layer, including 32 units with dropout at a dropout rate of 0.2; a fully connected layer, including 16 units, using the ReLU activation function; and an output layer for outputting the signal quality prediction features within a preset future time window, i.e., a 5×N dimensional vector, where N=10 in this embodiment, flattened into a 50-dimensional vector.
[0116] Then, the loss value is determined based on the sample signal quality prediction features and sample labels. In one implementation, the mean squared error (MSE) between the sample signal quality prediction features and sample labels is used as the loss function, which is the average of the squares of the differences between the predicted and true values. The parameters of the initial time series prediction model are updated based on the loss value until a preset training termination condition is met, resulting in the trained time series prediction model. In one implementation, the Adam optimizer is used with an initial learning rate of 0.001, a batch size of 64, a maximum training epoch of 200 epochs, and an early stopping strategy: training stops when the validation set loss does not decrease for 15 consecutive epochs, and the optimal model weights are restored. The model performance is evaluated on the test set, with key performance indicators including: mean absolute error of eye height prediction <50mV, mean absolute error of eye width prediction <50ns, and mean absolute error of peak-to-peak jitter prediction <30ns.
[0117] After training, the model can be compressed and deployed. In one implementation, the parameters (weights and biases) of the trained FP32 floating-point model are converted to INT8 fixed-point format. Symmetric quantization is used, and the scaling factor is determined based on the weight distribution range. The quantized model size is approximately one-quarter of the floating-point model size. Connections with absolute values less than a set threshold are removed; the threshold is 5% of the average absolute value of the weights in that layer. After pruning, the number of non-zero weights is controlled between 20,000 and 50,000. The compressed LSTM model is converted to Verilog code using High-Level Synthesis (HLS) and deployed on a Field-Programmable Gate Array (FPGA). The estimated FPGA resource usage is: approximately 120 DSP units, approximately 80 BRAM blocks, approximately 8000 LUTs, and inference latency <1μs.
[0118] During online prediction, the LSTM internal state is updated on a rolling basis upon receiving new signal quality features after deployment, outputting the prediction result for the next N steps. Specifically, when a new signal quality feature is generated through eye diagram construction and analysis, the feature is stored in the historical signal quality feature buffer, and the oldest feature in the buffer is removed. The latest L historical signal quality features are read from the buffer as the current input, and the mean μ_d and standard deviation σ_d calculated during offline training are used to normalize each dimension of the input sequence, where d represents the feature dimension. The normalized sequence is then fed into the LSTM network step by step in chronological order, performing forward inference: LSTM layer 1 receives the feature vector at the current time step and the hidden state and unit state passed from the previous time step, and updates the hidden state and unit state at the current time step; LSTM layer 2 receives the output of layer 1 and the state of this layer at the previous time step, and further updates it; the fully connected layer performs a linear transformation and adds a bias to the output of LSTM layer 2, and then activates it through ReLU; the output layer maps the 16-dimensional vector to a 5×N-dimensional vector, which is the predicted future signal quality feature. The output predicted value is multiplied by the standard deviation of the corresponding dimension and then added to the mean of the corresponding dimension, which is the inverse operation of normalization, restoring it to the actual physical unit. The output has two parts: the predicted value at the current time step, used to verify consistency with the actual collected values and evaluate the current state of the model; and the predicted trend at future time steps, used for reinforcement learning decision-making and for forward-looking adjustment of time-series parameters. The internal states of the LSTM layer (hidden states and unit states) are continuously retained and updated at each time step, achieving continuous rolling prediction rather than resetting at each step, allowing the model to fully utilize long-term dependency information in the historical sequence.
[0119] In one embodiment of this application, the reinforcement learning model is trained through the following operations: constructing an initial reinforcement learning model, which includes a preset action space and a preset reward function; determining training actions based on the preset action space, determining training rewards based on the preset reward function, and obtaining the next training state after executing the training actions to obtain an experience quadruple; the experience quadruple includes the training state, training action, training reward, and the next training state; obtaining multiple experience quadruples, and training the initial reinforcement learning model based on the multiple experience quadruples to obtain a trained reinforcement learning model.
[0120] Specifically, a hybrid random and manual strategy was used to collect and record the quadruplets (S(t), a(t), R(t+1), S(t+1)), with millions of data sets collected. The experience (S, a, R, S') was stored in an experience pool, and the DQN network parameters were periodically sampled and updated. Here, S(t) represents the training state at time t; a(t) represents the training action selected at time t according to the preset action space, i.e., the adjustment amount to the timing parameters, such as at least one of setup time adjustment, hold time adjustment, and drive current adjustment; R(t+1) represents the training reward obtained after performing action a(t) in state S(t), determined according to the preset reward function; S(t+1) represents the training state at the next time step after performing action a(t) in state S(t), and its composition is the same as S(t), including the current eye diagram parameters, prediction trend, and updated timing configuration at the next time step; S, a, R, and S' are abbreviations for the training state, training action, training reward, and next training state in the experience quadruplets, respectively.
[0121] In one embodiment of this application, the training configuration of the reinforcement learning model includes: the loss function is the mean squared error between the Q value and the target Q value; the optimizer is Adam with a learning rate of 0.001; the discount factor γ = 0.95; 64 sets of random sampling for experience replay to break data correlation; and the target network is synchronized once every 1000 steps to stabilize the training process.
[0122] Figure 8 This illustration shows a schematic diagram of the implementation process of the health diagnosis and lifespan prediction operation of the I2C bus communication optimization method provided in the embodiments of this application.
[0123] refer to Figure 8 In one embodiment of this application, link health diagnosis and lifespan prediction are also performed. Link health diagnosis and lifespan prediction are executed in the background at a low frequency, for example, automatically starting every 30-60 minutes to continuously accumulate historical data. The frequency can be accelerated when the health score drops below a threshold, and the diagnosis frequency can be increased to once every 5 minutes when abnormalities occur. Alternatively, it can be initiated by external software via registers, or manually started by maintenance personnel. Eye diagram feature data is stored long-term in two ways: recent detailed data is stored in the FPGA's internal BRAM or external RAM, with one complete five-dimensional feature record per minute, retaining the most recent 7 days; long-term summary data is stored in external Flash or cloud storage, with hourly statistical values (mean, maximum, minimum), retaining more than one year. Link health diagnosis and lifespan prediction include: Operation 601 extracts link trend indicators from historical signal quality characteristics. The link trend indicators include at least one of the following: rise time change rate, eye height descent slope, and jitter standard deviation trend.
[0124] The eye diagram feature data from the past period is loaded from storage, which is a collection of historical signal quality features over a period of time. Three key indicators are extracted from these historical signal quality features: the rise time change rate, calculated as (Tr(t)-Tr(t-Δt)) / Δt. A continuously increasing positive value indicates a decrease in driving capability or an increase in load. Tr(t) is the rise time extracted from the eye diagram at the current time t. Tr(t-Δt) is the rise time extracted from the historical eye diagram at time t-Δt, which is the rise time at time Δt before the current time. Δt is a preset time interval, representing the time difference between the current time and a historical time. The unit can be seconds, minutes, or days, depending on the diagnostic cycle. The eye height descent slope is calculated as (EyeHeight(t) - EyeHeight(t - Δt)) / Δt. A continuously increasing negative value indicates decreasing noise margin and link aging. EyeHeight(t) is the eye height extracted from the eye diagram at the current time t, and EyeHeight(t - Δt) is the eye height extracted from the historical eye diagram at time t - Δt, i.e., the eye height Δt before the current time. The jitter standard deviation trend is calculated as the jitter standard deviation within a sliding window. A continuously increasing value indicates clock or signal integrity degradation.
[0125] Operation 602 involves standardizing the features of the link trend indicators and using the isolated forest algorithm to detect anomalies in the standardized link trend indicators, thereby obtaining anomaly scores.
[0126] The link trend indicators are standardized using Z-score normalization, which involves subtracting the mean from each dimension and then dividing by the standard deviation to eliminate dimensional differences. Then, the Isolation Forest algorithm is used for anomaly detection, constructing multiple isolation trees to recursively divide the data space into smaller regions. Anomaly scores are calculated based on the length of isolated paths; shorter paths indicate a higher likelihood of isolation and thus a higher anomaly score.
[0127] Operation 603 determines the link health based on the anomaly score, and then determines the link health status of the I2C bus based on the link health score.
[0128] Link health is calculated as Link Health = 1 - Anomaly Score. The higher the anomaly score, the lower the link health. Link health status is categorized into health levels: ≥0.85 is good (green); 0.60~0.85 is warning (yellow); 0.30~0.60 is dangerous (orange); <0.30 is severe (red).
[0129] Operation 604 involves performing linear regression fitting on the eye height and / or rise time in the historical signal quality characteristics to obtain the degradation rate.
[0130] Least squares linear fitting is performed on historical data sequences such as eye height and rise time. The slope of the trend line is the degradation rate, which represents the amount of degradation per unit time. For example, eye height decreases by 0.02V per month.
[0131] Operation 605 predicts the remaining effective lifetime of the I2C bus based on the difference between the eye height and / or rise time in the signal quality characteristics at the current moment and the preset failure threshold, as well as the degradation rate.
[0132] The failure threshold is determined based on preset physical limits, such as eye height <0.5V or rise time >350ns. Remaining lifetime prediction uses an extrapolation method, calculated as (current value - failure threshold) / degradation rate.
[0133] Operation 606 outputs warning information and / or records diagnostic logs based on the link health status and / or remaining effective lifetime.
[0134] In one embodiment of this application, the warning information includes a level 2 warning, a level 1 warning, and a critical warning; when the link health is lower than a first threshold or the remaining effective lifetime is lower than a second threshold, a level 2 warning is output; when the link health is lower than a third threshold or the remaining effective lifetime is lower than a fourth threshold, a level 1 warning is output; when the remaining effective lifetime is lower than a fifth threshold, a critical warning is output and the I2C bus is degraded.
[0135] When the link health level is less than the first threshold (e.g., 0.60) or the remaining effective lifetime is less than the second threshold (e.g., 30 days), a level 2 warning is output, logged, and displayed on the software interface. When the link health level is less than the third threshold (e.g., 0.30) or the remaining effective lifetime is less than the fourth threshold (e.g., 7 days), a level 1 warning is output, and an emergency report is sent to the BMC, recommending immediate hardware replacement. When the remaining effective lifetime is less than the fifth threshold (e.g., 72 hours), a critical warning is output, forcing degraded operation, such as reducing the bus speed. After storing the diagnostic results, the current diagnostic session ends, awaiting the next trigger. The diagnostic results are output to the management platform (visual interface), the BMC (alarms), and registers (external read).
[0136] Thus, this application embodiment achieves the assessment of the health status of I2C bus links and the prediction of their remaining effective lifetime by extracting link trend indicators, detecting isolated forest anomalies, linear regression fitting, and extrapolation. It also outputs graded warnings when the health status or remaining lifetime is below a threshold, thereby achieving predictive maintenance and improving system reliability.
[0137] In one embodiment of this application, a software access interface is also provided through a configuration and status register. The software access interface is used to read and write timing parameters and to read the link health status and / or remaining effective lifetime.
[0138] The Configuration and Status Register provides a software access interface. This interface allows external software or a host computer to configure and read the status of the I2C bus. The readable and writable configuration parameters include timing parameters such as setup time, hold time, and drive current; the readable status information includes diagnostic results such as link health, link health status, and remaining lifetime.
[0139] The diagnostic results can be stored in the configuration and status register for external software to read. External software can also initiate manual diagnostics through this register, allowing maintenance personnel to manually start health checks. Furthermore, the configuration and status register can be used to control the enabling, bypassing, and resetting of time-series prediction models and reinforcement learning models, or to read prediction results.
[0140] Thus, the configuration and status registers provide the software with an interface to read and write timing parameters and read health status, enabling external software to make maintenance decisions based on the link health status and / or remaining effective lifetime, such as arranging maintenance or hardware replacement, thereby improving the maintainability of the system.
[0141] Figure 9 The diagram illustrates a specific application example of the I2C bus communication optimization method provided in this application.
[0142] To further illustrate the technical solution of this application, a specific application example is provided below.
[0143] refer to Figure 9 In this specific application example, an I2C bus communication optimization method, also known as an enhanced I2C bus adaptive communication optimization method, includes the following steps: non-intrusive continuous eye diagram monitoring, including high-speed ADC sampling and real-time eye diagram extraction; LSTM-based signal quality prediction; reinforcement learning-based timing decision-making; timing parameter adjustment; seamless switching of clock domains without interruption when multi-rate devices are detected; intelligent conflict detection and adaptive backoff when multi-master contention is detected; link health diagnosis and lifetime prediction, and long-term trend analysis; determining whether an early warning is needed, issuing an early warning / recording a log if so, otherwise returning to non-intrusive continuous eye diagram monitoring to form a closed loop.
[0144] For example, taking the I2C bus application on a server motherboard as an example, the I2C bus on the server motherboard is connected to multiple slave devices such as temperature sensors, voltage monitoring chips, and EEPROMs. After the system starts at a room temperature of 25°C, the temperature gradually rises to 65°C, and the bus signal quality gradually deteriorates due to temperature drift. Simultaneously, the BMC and CPU, the two master devices, may initiate bus access at the same time, posing a risk of contention. The initial state is: SCL frequency 400kHz, eye height 1.20V, eye width 1100ns, jitter 80ns, rise time 200ns, fall time 60ns, setup time 150ns, hold time 150ns, and drive current 8mA.
[0145] After the system powers on, the ADC continuously acquires SCL / SDA waveforms at a sampling rate of 200MHz to establish an eye diagram and extracts five-dimensional eye diagram parameters in real time. Initially, the signal quality appears good. Subsequently, due to rising temperature, the LSTM predicts, based on historical features, that the signal will significantly deteriorate within the next 10μs, with the eye height dropping to 0.70V, below the 0.8V safety threshold; the rise time increases to 355ns, exceeding the 300ns upper limit. The current eye diagram parameters, predicted features, and current timing configuration are concatenated into a state vector, which is input into the DQN agent. After forward propagation to calculate the Q-value of each action, the action with the highest Q-value is selected for a large adjustment: setup time +100ns, hold time +100ns, and drive current +4mA. The programmable timing configuration module writes the adjustment amount into a register, and the timing parameters take effect in the next SCL cycle. Before the adjustment, the predicted eye height would drop to 0.70V; after the adjustment, the actual eye height remains at 1.10V, and the reward value indicates that the decision was effective.
[0146] During execution, if a low-speed device supporting only 100kHz is mounted, a seamless, uninterrupted clock domain switching is performed. This involves phase locking via the second phase-locked loop, phase synchronization, digital control oscillator scaling, and SCL low-level switching, seamlessly changing the SCL from 400kHz to 100kHz. If both the BMC and CPU initiate access simultaneously, multi-master contention optimization is performed, allocating a short backoff time slot to the high-priority device. After successful access, the low-priority device retryes. Background health checks run every 30 minutes. Long-term monitoring shows a continuous increase in rise time of +2.5ns / day and a continuous decrease in eye height of -0.008V / day, with the health score dropping to 0.62, a warning level. The predicted remaining lifespan is 38 days, triggering a level-two warning. Maintenance personnel then schedule maintenance and replacements to prevent sudden failures. This achieves a complete closed loop of perception, prediction, decision-making, execution, verification, and feedback, proactively preventing signal quality degradation before it occurs.
[0147] Figure 10 A schematic diagram of the composition structure of the I2C bus communication optimization system provided in the embodiments of this application is shown.
[0148] refer to Figure 10 The I2C bus includes a serial clock line (SCL) and a serial data line (SDA). The bus exemplarily connects to a master device 1, a master device 2, and a slave device group. Master device 1 and master device 2 communicate with the slave device group via the SCL and SDA lines. The I2C bus communication optimization system provided in this application is connected to the I2C bus and is used for sampling, monitoring, and adaptively optimizing the I2C bus. The system includes: The analog front-end and acquisition module 701 is used to continuously sample the analog waveforms of the clock line and data line of the I2C bus to obtain sampled data; The eye diagram construction and analysis module 702 is used to recover clock data based on the sampled data to obtain the recovered clock; using the recovered clock as a reference, the sampled data is aligned and superimposed according to the bit period divided by the recovered clock to construct the eye diagram at the current moment; signal quality features are extracted from the eye diagram, and the signal quality features are combined with historical signal quality features in time sequence to obtain the input sequence; wherein, the historical signal quality features are the signal quality features extracted from multiple moments before the current moment. Prediction module 703 is used to input the input sequence into the time series prediction model to obtain the signal quality prediction features within a future preset time window output by the time series prediction model; The reinforcement learning decision module 704 is used to obtain the timing configuration of the I2C bus at the current moment, and uses the signal quality characteristics, signal quality prediction characteristics and timing configuration as the state to determine the timing parameter adjustment strategy through the reinforcement learning model. The programmable timing configuration module 705 is used to adjust the timing parameters of the I2C bus according to the timing parameter adjustment strategy.
[0149] In one embodiment of this application, the system further includes dual PLLs and a clock scaling module, used to: perform an uninterrupted clock domain switching operation in response to detecting that the I2C bus meets the rate switching conditions; wherein the rate switching conditions include at least one of the following: the capability information reported by the slave device to be communicated during the enumeration phase is inconsistent with the current operating rate of the I2C bus; the signal quality prediction feature indicates that the signal quality degradation is due to insufficient clock precision; a device hot-plugging is detected, and the capability information of the newly connected device does not match the current operating rate of the I2C bus.
[0150] In one embodiment of this application, the system further includes a health diagnosis module for link health diagnosis and lifetime prediction; an intelligent contention processing module for multi-master contention optimization; and a configuration and status register for providing a software access interface.
[0151] It should be noted that the description of the system in this application embodiment is similar to that of the method embodiment described above, and has similar beneficial effects as the method embodiment; therefore, it will not be repeated. For any technical details not covered in the I2C bus communication optimization system provided in this application embodiment, please refer to... Figures 1 to 9 The meaning is understood in accordance with the description of any of the accompanying drawings.
[0152] According to embodiments of this application, this application also provides an electronic device and a readable storage medium.
[0153] Figure 11 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of this application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile systems, such as personal digital processing units, cellular phones, smartphones, wearable devices, and other similar computing systems. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the application described and / or claimed herein.
[0154] like Figure 11 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. The RAM 803 may also store various programs and data required for the operation of the electronic device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0155] Multiple components in electronic device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of displays, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows electronic device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0156] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the I2C bus communication optimization method. For example, in some embodiments, the I2C bus communication optimization method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the I2C bus communication optimization method described above may be performed. Alternatively, in other embodiments, computing unit 801 may be configured to perform I2C bus communication optimization methods by any other suitable means (e.g., by means of firmware).
[0157] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input system, and at least one output system, and transferring data and instructions to the storage system, the at least one input system, and the at least one output system.
[0158] The program code used to implement the methods of this application may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing system, such that when executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0159] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, system, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0160] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display system for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing system (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of systems can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0161] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0162] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0163] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this application can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this application can be achieved, and this is not limited herein.
[0164] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0165] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An I2C bus communication optimization method, characterized in that, The method includes: The analog waveforms of the clock and data lines of the I2C bus are continuously sampled to obtain sampled data; The clock data is recovered based on the sampled data to obtain the recovered clock; Using the recovery clock as a reference, the sampled data are aligned and superimposed according to the bit period divided by the recovery clock to construct the eye diagram at the current moment; Signal quality features are extracted from the eye diagram, and the signal quality features are combined with historical signal quality features in a time sequence to obtain the input sequence; wherein, the historical signal quality features are signal quality features extracted from multiple times prior to the current time. The input sequence is input into the time series prediction model to obtain the signal quality prediction features within a future preset time window output by the time series prediction model. The timing configuration of the I2C bus at the current moment is obtained, and the signal quality characteristics, the signal quality prediction characteristics, and the timing configuration are used as states. A timing parameter adjustment strategy is determined through a reinforcement learning model. The timing parameters of the I2C bus are adjusted according to the timing parameter adjustment strategy.
2. The method according to claim 1, characterized in that, After determining the time-series parameter adjustment strategy through the reinforcement learning model, the method further includes: In response to the detection that the I2C bus meets the rate switching condition, an uninterrupted clock domain switching operation is performed; The rate switching conditions include at least one of the following: The capability information reported by the slave device to be communicated during the enumeration phase is inconsistent with the current operating rate of the I2C bus; The signal quality prediction feature indicates that the signal quality degradation is due to insufficient clock accuracy. A hot-plugging of a device was detected, and the capability information of the newly connected device does not match the current operating rate of the I2C bus.
3. The method according to claim 2, characterized in that, The uninterrupted clock domain switching operation includes: Maintain the clock line output of the first phase-locked loop, determine the target frequency according to the target communication rate corresponding to the rate switching condition, and configure the second phase-locked loop to lock to the target frequency; The output phase difference between the first phase-locked loop and the second phase-locked loop is compared using a phase detector; When the output phase difference stabilizes within a preset phase threshold, the digitally controlled oscillator is activated to fine-tune the output frequency in a step-by-step manner to absorb the remaining phase difference. During the low-level range of the clock line, the clock source is switched from the first phase-locked loop to the digitally controlled oscillator or the second phase-locked loop, so that the I2C bus performs data transmission at the target frequency output by the second phase-locked loop; wherein, data transmission on the I2C bus is not interrupted during the switching process. Update the timing configuration at the current moment according to the target frequency.
4. The method according to claim 1, characterized in that, After determining the time-series parameter adjustment strategy through the reinforcement learning model, the method further includes: Before the I2C master device initiates bus access, the bus idle listen window is opened; Determine whether bus activity is detected within the bus idle listening window; if bus activity is detected, trigger multi-master contention optimization; if no bus activity is detected, determine bus waveform characteristics based on the sampled data, predict the collision probability based on the bus waveform characteristics, and determine whether the collision probability is greater than a preset collision probability threshold. If the conflict probability is greater than the preset conflict probability threshold, then multi-master contention optimization is triggered; if the conflict probability is not greater than the preset conflict probability threshold, then it is determined whether multiple master devices are active based on the signal quality characteristics and / or the signal quality prediction characteristics. If multiple master devices are active, multi-master contention optimization is triggered; if no multiple master devices are active, the I2C master device is controlled to initiate bus access.
5. The method according to claim 4, characterized in that, The multi-master competition optimization includes: Statistically measure the bus idle time within the bus idle listening window; The bus waveform characteristics are determined based on the sampled data, and the bus collision risk is assessed by combining the bus waveform characteristics with the bus idle time. When the assessment shows that the conflict risk meets the preset conditions, it is determined that the I2C bus is in a busy state. An initial backoff time slot is allocated to the I2C master device according to the device priority, so that the I2C master device waits for the initial backoff time slot to end before attempting to initiate I2C bus access. The initial backoff time slot for high-priority devices is shorter than that for low-priority devices. If a conflict occurs when the I2C master device attempts to initiate an I2C bus access, the conflict duration and waveform characteristics are determined based on the sampled data, and the number of devices involved in the conflict is determined based on the conflict duration and waveform characteristics. The backoff window size is adjusted according to the number of devices, so that the I2C master device randomly selects a backoff time within the adjusted backoff window and retryes I2C bus access after delaying the backoff time.
6. The method according to claim 1, characterized in that, The continuous sampling of the analog waveforms of the I2C bus clock and data lines to obtain sampled data includes: Without interrupting I2C bus data transmission or inserting probe pulses into the I2C bus, the analog waveforms of the clock and data lines are continuously sampled using an analog-to-digital converter to obtain sampled data.
7. The method according to claim 1, characterized in that, The sampling data includes clock line sampling data and data line sampling data. The data line sampling data includes multiple data bits, each data bit corresponds to a bit period, and each bit period includes multiple sampling points arranged in time order. Each sampling point includes a sampling time and a sampling voltage value. The step of recovering clock data based on the sampled data to obtain the recovered clock includes: Perform a differential operation on the sampled voltage values of adjacent sampling points in the data line sampling data to obtain the voltage difference between adjacent sampling points; When the absolute value of the voltage difference exceeds a preset threshold, it is determined that there is a signal transition between the data line sampling data and the adjacent sampling points, and the transition direction and the corresponding sampling point position are recorded. Arrange the sampling point positions corresponding to the recorded multiple signal transitions in chronological order to obtain the transition edge position sequence; The center position of the data bit on the data line is determined based on the transition edge position sequence, and a recovery clock is generated using a digital phase-locked loop, such that the sampling edge of the recovery clock is aligned with the center position of the data bit on the data line, thus obtaining the recovery clock.
8. The method according to claim 1, characterized in that, The step of constructing an eye diagram for the current moment by aligning and superimposing the sampled data according to the bit periods divided by the recovery clock, with the recovery clock as a reference, includes: Using the edge of the recovery clock as the dividing boundary, the sampled data is segmented to obtain multiple independent bit period waveform segments; All the aforementioned bit period waveform segments are aligned according to their relative time positions within the bit period; The frequency of sampling points occurring in combinations of each time location and each voltage range is statistically analyzed, and the frequency is normalized to obtain the probability density. An eye diagram data matrix is generated based on the probability density, and an eye diagram at the current time is constructed based on the eye diagram data matrix.
9. The method according to claim 1, characterized in that, The step of using the signal quality features, the signal quality prediction features, and the timing configuration as states, and determining the timing parameter adjustment strategy through a reinforcement learning model, includes: The state is obtained by concatenating the signal quality features, the signal quality prediction features, and the timing configuration; the signal quality features include at least one of eye height, eye width, peak-to-peak jitter, rise time, and fall time. The state is input into the reinforcement learning model, and the reinforcement learning model outputs the action value corresponding to each action in the preset action space based on the preset reward function. The action value is the expected reward obtained by performing the corresponding action in the state. Based on the action value, a target action is selected from the preset action space, and the target action is determined as the timing parameter adjustment strategy; The preset action space includes at least one of setup time adjustment, hold time adjustment, and drive current adjustment; the reward function is determined based on at least one of communication success rate, number of adjustments, and constraint conditions.
10. The method according to claim 9, characterized in that, The timing parameters include at least one of setup time, hold time, and drive current; adjusting the timing parameters of the I2C bus according to the timing parameter adjustment strategy includes at least one of the following: The establishment time of the I2C bus is adjusted according to the establishment time adjustment amount in the timing parameter adjustment strategy and the current establishment time in the timing configuration at the current moment. The hold time of the I2C bus is adjusted according to the hold time adjustment amount in the timing parameter adjustment strategy and the current hold time in the timing configuration at the current moment. The drive current of the I2C bus is adjusted according to the drive current adjustment amount in the timing parameter adjustment strategy and the current drive current in the timing configuration at the current moment. The setup time and the hold time are adjusted by a programmable delay chain, and the drive current is adjusted by a programmable current source array.
11. The method according to claim 10, characterized in that, The method further includes: If at least one of the adjusted setup time, hold time, and drive current exceeds the corresponding preset range, the value exceeding the preset range is set as the boundary value of the preset range, so that the adjusted value is within the corresponding preset range.
12. The method according to claim 1, characterized in that, The time-series prediction model is trained through the following operations: Obtain a training sample set. Each training sample includes a sample input sequence and a sample label. The sample input sequence is a combination of historical signal quality features of the samples in chronological order. The sample label is a sample signal quality feature within a future preset time window corresponding to the sample input sequence. The sample input sequence is input into the initial time series prediction model to obtain the sample prediction output; The loss value is determined based on the sample prediction output and the sample label; The parameters of the initial time series prediction model are updated based on the loss value until the preset training termination condition is met, thus obtaining the trained time series prediction model.
13. An I2C bus communication optimization system, characterized in that, The system includes: The analog front-end and acquisition module are used to continuously sample the analog waveforms of the clock and data lines of the I2C bus to obtain sampled data. The eye diagram construction and analysis module is used to recover clock data based on the sampled data to obtain a recovered clock; using the recovered clock as a reference, the sampled data is aligned and superimposed according to the bit period divided by the recovered clock to construct the eye diagram at the current moment; signal quality features are extracted from the eye diagram, and the signal quality features are combined with historical signal quality features in time sequence to obtain an input sequence; wherein, the historical signal quality features are signal quality features extracted from multiple moments before the current moment; The prediction module is used to input the input sequence into the time series prediction model to obtain the signal quality prediction features within a future preset time window output by the time series prediction model. The reinforcement learning decision module is used to obtain the timing configuration of the I2C bus at the current time, take the signal quality characteristics, the signal quality prediction characteristics and the timing configuration as the state, and determine the timing parameter adjustment strategy through the reinforcement learning model. A programmable timing configuration module is used to adjust the timing parameters of the I2C bus according to the timing parameter adjustment strategy.
14. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-12.
15. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-12.
