A Serdes data clock recovery method and circuit based on Matlab
The MATLAB-based SerDes data clock recovery method addresses signal distortion in high-speed communication by sampling, grouping, and correcting phase and frequency errors, enhancing data recovery accuracy and completeness.
Patent Information
- Application Number
- CN202411109696.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-14
AI Technical Summary
The challenge in high-speed serial communication using SerDes technology is the distortion of clock signals due to channel loss, inter-code interference, and clock jitter, which affects data recovery at the receiving end.
A MATLAB-based SerDes data clock recovery method that samples data based on a clock signal, groups it, determines the phase state of each group, generates modulation information from the previous group's phase state, and adjusts the current group's phase accordingly to correct frequency and phase differences.
The method effectively recovers distorted clock signals by continuously sampling, grouping, and correcting phase and frequency errors, improving data clock recovery accuracy and completeness in SerDes systems.
Smart Images

Figure CN118631409B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of data transmission, and in particular to a MATLAB-based Serdes data clock recovery method and circuit. Background Art
[0002] With the development of technology, the demand for high-speed data transmission speed and quality is increasing. The previous parallel data transmission method is affected by factors such as clock cycle jitter, inter-code crosstalk and synchronous switching noise. As a result, if the parallel transmission speed is to be increased, more transmission channels need to be added accordingly, which is expensive. Therefore, the use of deserializer (serdes) high-speed serial communication technology has developed rapidly. Serial communication technology only requires two transmission lines, which can significantly save transmission costs.
[0003] In the serdes high-speed serial communication technology method, the data to be transmitted needs to be serially encoded, converted into an analog signal and transmitted to the receiving end through a channel. Due to the influence of channel loss, inter-code interference and clock jitter during the receiving and transmission process, the signal received by the receiving end has a large distortion, so the distorted clock signal needs to be restored.
[0004] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in the field of this technology. Summary of the invention
[0005] The technical problem to be solved by the present invention is how to recover the clock signal from the distorted clock signal generated during the receiving transmission process.
[0006] The embodiment of the present invention adopts the following technical solution:
[0007] In a first aspect, a MATLAB-based Serdes data clock recovery method is provided, comprising:
[0008] Sampling data based on a clock signal;
[0009] Divide the data of a preset amount into one group according to the sampling order of the data, and judge the phase state of the clock signal corresponding to each group of data in turn according to the sampling order of each group of data;
[0010] Generate modulation information of a current group of clock signals according to a phase state of a previous group of clock signals;
[0011] The phase of the current group of clock signals is adjusted accordingly according to the modulation information.
[0012] Preferably, judging the phase state of the clock signal corresponding to each group of data in sequence according to the sampling order of each group of data specifically includes:
[0013] Determine the phase state of the clock signal corresponding to each beat of data in each group of data;
[0014] The total amount of data with a lagging phase state and the total amount of data with an advanced phase state in each group of data are counted respectively, and the data difference value of the total amount of data with a lagging phase state minus the total amount of data with an advanced phase state is obtained;
[0015] When the data difference is greater than 0, determining that the phase state of the clock signal of the corresponding group is lagging;
[0016] When the data difference is less than 0, determining that the phase state of the clock signal of the corresponding group is leading;
[0017] When the data difference is equal to 0, it is determined that the phase state of the clock signal of the corresponding group is normal.
[0018] Preferably, the determining of the phase state of the clock signal corresponding to each beat of data in each group of data specifically includes:
[0019] Compare the current shot data with the previous shot data and the next shot data;
[0020] When the current beat data is equal to the previous beat data, and the current beat data is not equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is lagging;
[0021] When the current beat data is not equal to the previous beat data, and the current beat data is equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is leading;
[0022] When the current beat data is not equal to the previous beat data, and the current beat data is not equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is normal.
[0023] Preferably, generating modulation information of a current group of clock signals according to a phase state of a previous group of clock signals specifically includes:
[0024] When the phase state of the previous group of clock signals is leading or lagging, the modulation information of the frequency difference of the current group of clock signals is calculated, and the modulation information of the phase difference is calculated;
[0025] When the phase state of the previous group of clock signals is normal, there is no need to correct the current group of clock signals.
[0026] Preferably, when the phase state of the previous group of clock signals is leading or lagging, calculating the modulation information of the frequency difference of the current group of clock signals specifically includes:
[0027] Set the frequency difference gain reg_vote_acc1_gain of the integral path and the shift width reg_acc1_add_p of the integral path;
[0028] When the phase state of the previous group of clock signals is leading, the correction formula for the frequency difference of the current group of clock signals is:
[0029] acc1_integral=(acc1_integral_cur+reg_vote_acc1_gain) / (2^reg_acc1_add_p);
[0030] Among them, acc1_integral is the modulation information of the frequency difference of the current group of clock signals, and acc1_integral_cur is the frequency difference of the previous group of clock signals.
[0031] Preferably, the modulation information for calculating the phase difference specifically includes:
[0032] Set the phase difference gain reg_vote_phase_gain of the proportional path and the shift width reg_phase_gain_p of the proportional path;
[0033] When the phase state of the current group of clock signals is leading, the correction formula for the phase difference of the subsequent group of clock signals is:
[0034] phase_add=(phase_add_cur+reg_vote_phase_gain+acc1_integral) / (2^reg_phase_gain_p);
[0035] Among them, phase_add is the modulation information of the phase difference of the current group of clock signals, and phase_add_cur is the phase difference of the previous group of clock signals.
[0036] Preferably, when the phase state of the previous group of clock signals is leading or lagging, calculating the modulation information of the frequency difference of the current group of clock signals specifically includes:
[0037] Set the frequency difference gain reg_vote_acc1_gain of the integral path and the shift width reg_acc1_add_p of the integral path;
[0038] When the phase state of the previous group of clock signals is lagging, the correction formula for the frequency difference of the current group of clock signals is:
[0039] acc1_integral=(acc1_integral_cur-reg_vote_acc1_gain) / (2^reg_acc1_add_p);
[0040] Among them, acc1_integral is the modulation information of the frequency difference of the current group of clock signals, and acc1_integral_cur is the frequency difference of the previous group of clock signals.
[0041] Preferably, the modulation information for calculating the phase difference specifically includes:
[0042] Set the phase difference gain reg_vote_phase_gain of the proportional path and the shift width reg_phase_gain_p of the proportional path;
[0043] When the phase state of the current group of clock signals is lagging, the correction formula for the phase difference of the subsequent group of clock signals is:
[0044] phase_add=(phase_add_cur-reg_vote_phase_gain+acc1_integral) / (2^reg_phase_gain_p);
[0045] Among them, phase_add is the modulation information of the phase difference of the current group of clock signals, and phase_add_cur is the phase difference of the previous group of clock signals.
[0046] Preferably, the performing corresponding phase adjustment on the current group of clock signals according to the modulation information specifically includes:
[0047] Adding the modulation information of the frequency difference of the current group of clock signals and the modulation information of the phase difference of the current group of clock signals to obtain total modulation information;
[0048] The frequency difference code and the phase difference code of the current group of clock signals are corrected according to the total modulation information, and the corrected clock signals are output to the external clock.
[0049] In a second aspect, a MATLAB-based SerDes data clock recovery circuit is used to implement the MATLAB-based SerDes data clock recovery method, including: an external clock module, a phase discriminator module, a modulation information generation module and a phase modulation module, wherein:
[0050] The external clock module, the phase discriminator module, the modulation information generation module and the phase modulation module are connected in sequence, and the phase modulation module is connected to the external clock module;
[0051] The external clock module is used to send a clock signal to the phase discriminator module; the phase discriminator module is used to judge the phase state of each group of clock signals in turn according to the acquisition order of each group of clock signals; the modulation information generation module is used to generate modulation information of the current group of clock signals according to the phase state of the previous group of clock signals; the phase modulation module is used to make corresponding phase adjustments to the current group of clock signals according to the modulation information; the adjusted clock signal is output to the external clock module, and the data is sampled again with the adjusted clock signal.
[0052] The invention provides a MATLAB-based Serdes data clock recovery method and circuit, which continuously receives data, groups the data according to the receiving order of the data, judges the phase state of the clock signal corresponding to each group of data, generates modulation information for the clock signal of the previous group of data according to the judgment result, and adjusts the phase of the clock signal of the previous group of data according to the modulation information, and completes the data clock recovery by continuously receiving and correcting the clock signal. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0054] Figure 1 It is a schematic diagram of a MATLAB-based Serdes data clock recovery method provided by an embodiment of the present invention applied in a Serdes serial data transmission scenario;
[0055] Figure 2 It is a method flow chart of a MATLAB-based Serdes data clock recovery method provided by an embodiment of the present invention;
[0056] Figure 3 It is a flow chart of a method for determining the phase state of each group of clock signals in a Serdes data clock recovery method based on MATLAB provided by an embodiment of the present invention;
[0057] Figure 4 It is a flow chart of a method for determining the phase state of each clock signal in a Serdes data clock recovery method based on Matlab provided by an embodiment of the present invention;
[0058] Figure 5It is a schematic diagram of a clock signal when the phase state of a Serdes data clock recovery method based on MATLAB provided by an embodiment of the present invention is lagging;
[0059] Figure 6 It is a schematic diagram of a clock signal when the phase state of a Serdes data clock recovery method based on MATLAB provided by an embodiment of the present invention is leading;
[0060] Figure 7 It is a module schematic diagram of a MATLAB-based Serdes data clock recovery circuit provided by an embodiment of the present invention;
[0061] Figure 8 It is a module schematic diagram of a modulation information generation module of a Serdes data clock recovery circuit based on MATLAB provided by an embodiment of the present invention;
[0062] Fig. 9 It is a schematic diagram in the form of vec.txt in a modeling method of a serdes data clock recovery circuit based on matlab provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0064] In the description of the present invention, the terms "inside", "outside", "longitudinal", "lateral", "upper", "lower", "top", "bottom" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and do not require that the present invention must be constructed and operated in a specific orientation. Therefore, they should not be understood as limitations on the present invention.
[0065] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0066] The present invention introduces a data clock recovery circuit based on PI (full name: Phase Interpolation) with good stability, good frequency tracking and large jitter tolerance. Matlab is used to accurately model the clock of the data clock recovery circuit. Based on the model, three benefits can be obtained: 1. It can provide a reference basis for the digital design part of the data clock recovery circuit; 2. Based on the model, a serdes transmission system model is built to analyze the transmission performance; 3. Based on the model, verification data can be provided for the digital design circuit of the data clock recovery circuit, so as to analyze the accuracy, completeness and precision of the digital design function. This solution solves the problem of the difficulty of verifying the digital design part in the serdes digital-analog hybrid circuit, and improves the accuracy and completeness of the digital design verification.
[0067] like Figure 1 As shown, it is a schematic diagram of a data clock recovery circuit applied to a serdes serial data transmission scenario, wherein the input parallel data is serially encoded by an encoder, converted into an analog signal, output to a channel through a transmitting system, and transmitted to a receiving end through the channel. During the transmission process, the signal is affected by channel loss, inter-symbol crosstalk, and clock jitter, etc., and the signal received by the receiving end is greatly distorted. The receiving end needs to convert the analog signal into digital data. The data clock recovery circuit provided in this embodiment finds the best clock from the edge information of the received analog data, so as to perform accurate data sampling.
[0068] The embodiment of the present invention provides a serdes data clock recovery method based on matlab, such as Figure 2 As shown, the method flow includes:
[0069] In step 101, data is sampled based on a clock signal.
[0070] In this embodiment, data is continuously sampled based on an externally input clock signal, and the clock signals corresponding to the continuously acquired data have the same frequency and a certain phase difference; wherein the clock signal may be affected by channel loss, inter-symbol crosstalk and clock jitter during transmission, resulting in a large distortion of the clock signal. The MATLAB-based Serdes data clock recovery method provided in this embodiment continuously acquires the phase state of the clock signal, and if the clock signal is ahead or behind, the clock signal is repaired.
[0071] In step 102, a preset amount of data is divided into a group according to the sampling order of the data, and the phase state of the clock signal corresponding to each group of data is judged in turn according to the sampling order of each group of data.
[0072] In this embodiment, the phase state may include: leading, lagging and normal. The preset data amount may be set by those skilled in the art, and the present invention does not impose any limitation on this.
[0073] In step 103, modulation information of the current group of clock signals is generated according to the phase state of the previous group of clock signals.
[0074] The current group of clock signals refers to clock signals corresponding to a group of data whose phase state is currently being determined, and the previous group of clock signals refers to: clock signals corresponding to the previous group of data adjacent to the current group of clock signals in the order of reception.
[0075] In this embodiment, the advance or lag of the phase of each group of clock signals is caused by the frequency difference and the phase difference, wherein the frequency difference is the difference in frequency between the data and the clock signal, and the phase difference is the phase difference between the data and the clock signal within one cycle; therefore, when correcting each group of clock signals, it is necessary to adjust the frequency difference and the phase difference at the same time, and the corresponding modulation information includes modulation information for the frequency difference and modulation information for the phase difference.
[0076] In step 104, the phase of the current group of clock signals is adjusted accordingly according to the modulation information.
[0077] In this embodiment, after the clock signals of the corresponding groups are adjusted, the adjusted clock signals are output through an external receiving clock and applied to the corresponding timing mechanism.
[0078] In this embodiment, clock signals are continuously received, the clock signals are grouped according to the order in which they are received, and the phase state of each group of clock signals is judged. Modulation information is generated for the previous group of clock signals based on the judgment result, and the phase of the previous group of clock signals is adjusted based on the modulation information. The data clock is recovered by continuously receiving and correcting the clock signals.
[0079] In this embodiment, the determination of the phase state of each group of clock signals involves the following designs:
[0080] The phase state of the clock signal corresponding to each group of data is judged in turn according to the sampling order of each group of data, such as Figure 3 As shown, the method flow includes:
[0081] In step 201, the phase state of the clock signal corresponding to each beat of data in each group of data is determined.
[0082] In this embodiment, each group of data includes multiple beats of data, each beat of data corresponds to a corresponding clock signal, and in this embodiment, each beat of data can be a bit. The phase state is determined according to the phase sequence and data content of the clock signal corresponding to each beat of data; the value of a can be 4, 6, 8, 12, 14, 16, 18 and 20.
[0083] In step 202, the total amount of data with a lagging phase state and the total amount of data with an advanced phase state in each group of data are counted respectively, and the data difference value of the total amount of data with a lagging phase state minus the total amount of data with an advanced phase state is obtained.
[0084] In step 203, when the data difference is greater than 0, it is determined that the phase state of the clock signal of the corresponding group is lagging.
[0085] In step 204, when the data difference is less than 0, it is determined that the phase state of the clock signal of the corresponding group is leading.
[0086] In step 205, when the data difference is equal to 0, it is determined that the phase state of the clock signal of the corresponding group is normal.
[0087] It should be noted that the data difference is the difference between the total amount of data with a lagging phase state and the total amount of data with an advanced phase state.
[0088] In order to more intuitively understand step 202 to step 205, this embodiment provides examples of corresponding scenarios:
[0089] The size of each set of data is 10 bits.
[0090] When the total amount of data whose phase state is lagging is 7 bits and the total amount of data whose phase state is leading is 3 bits, the data difference is 4, the data difference is greater than 0, and the phase state of the group of clock signals is lagging.
[0091] When the total amount of data whose phase state is lagging is 4 bits and the total amount of data whose phase state is leading is 6 bits, the data difference is -2, the data difference is less than 0, and the phase state of the group of clock signals is leading.
[0092] When the total amount of data whose phase state is lagging is 5 bits and the total amount of data whose phase state is leading is 5 bits, the data difference is 0, and the phase state of the group of clock signals is normal.
[0093] The method for determining the phase of each data shot involves the following designs:
[0094] The phase state of the clock signal corresponding to each beat of data in each group of data is determined, such as Figure 4 As shown, the method flow includes:
[0095] In step 301, the current beat data is compared with the previous beat data and the next beat data.
[0096] In this embodiment, the current beat data refers to the data whose phase state needs to be judged at present, the previous beat data refers to the previous beat data adjacent to the current beat data in phase order, and the next beat data refers to the next beat data adjacent to the current beat data in phase order.
[0097] In step 302, when the current beat data is equal to the previous beat data and the current beat data is not equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is lagging.
[0098] like Figure 5 As shown, it is a schematic diagram of a clock signal when the phase state is lagging.
[0099] In this embodiment, data represents the current beat data, edge_before represents the previous beat data, and edge_before represents the next beat data.
[0100] When it is determined that the phase state of the current shot data is lagging, the following formula is obtained:
[0101] edge_before==data&data!=edge_after;
[0102] Among them, “&” means and, and “!=” means not equal.
[0103] In step 303, when the current beat data is not equal to the previous beat data and the current beat data is equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is leading.
[0104] like Figure 6 As shown, it is a schematic diagram of a clock signal when the phase state is leading.
[0105] When it is determined that the phase state of the current beat data is leading, the following formula is obtained:
[0106] edge_before!=data&data==edge_after;
[0107] In step 304, when the current beat data is not equal to the previous beat data and the current beat data is not equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is normal.
[0108] When it is determined that the phase state of the current shot data is normal, the following formula is obtained:
[0109] edge_before!=data&data!=edge_after.
[0110] In this embodiment, since the phase error of the clock signal is caused by two factors, namely, the frequency difference and the phase difference, it is necessary to generate two modulation information of the frequency difference and the phase difference respectively according to the phase state of the clock signal.
[0111] The step of generating modulation information of a current group of clock signals according to a phase state of a previous group of clock signals specifically includes:
[0112] When the phase state of the previous group of clock signals is leading or lagging, the modulation information of the frequency difference of the current group of clock signals and the modulation information of the phase difference are calculated; when the phase state of the previous group of clock signals is normal, there is no need to correct the current group of clock signals.
[0113] In this embodiment, after the phase state of the clock signal of the current group is determined, the clock signal of the current group needs to be sent to the proportional path and the integral path respectively, wherein the proportional path is used to provide a phase difference gain, thereby calculating the corresponding phase difference modulation information, and the integral path is used to provide a frequency difference gain, thereby calculating the corresponding frequency difference modulation information.
[0114] In this embodiment, when the phase state of the current set of clock signals is leading, the modulation information of the frequency difference is calculated first:
[0115] Set the frequency difference gain reg_vote_acc1_gain of the integration path and the shift width reg_acc1_add_p of the integration path.
[0116] When the phase state of the previous group of clock signals is leading, the correction formula for the frequency difference of the current group of clock signals is:
[0117] acc1_integral=(acc1_integral_cur+reg_vote_acc1_gain) / (2^reg_acc1_add_p);
[0118] Wherein, acc1_integral is the modulation information of the frequency difference of the current group of clock signals, and acc1_integral_cur is the frequency difference of the previous group of clock signals. It should be noted that, in this embodiment, the characters suffixed with "cur" all represent the content of the previous group of data.
[0119] In this embodiment, the frequency difference gain reg_vote_acc1_gain refers to: a multiple of amplifying or reducing the calculated frequency difference value.
[0120] After the modulation information of the frequency difference is obtained, the modulation information of the phase difference is calculated according to the modulation information of the frequency difference, which specifically includes:
[0121] Set the phase gain reg_vote_phase_gain of the proportional path and the shift width reg_phase_gain_p of the proportional path.
[0122] When the phase state of the current group of clock signals is leading, the correction formula for the phase difference of the subsequent group of clock signals is:
[0123] phase_add=(phase_add_cur+reg_vote_phase_gain+acc1_integral) / (2^reg_phase_gain_p);
[0124] Among them, phase_add is the modulation information of the phase difference of the current group of clock signals, and phase_add_cur is the phase difference of the previous group of clock signals.
[0125] In this embodiment, when the phase state of the current set of clock signals is lagging, the modulation information of the frequency difference is calculated first:
[0126] The step of calculating the modulation information of the frequency difference when the phase state of the previous group of clock signals is leading or lagging specifically includes:
[0127] Set the frequency difference gain reg_vote_acc1_gain of the integration path and the shift width reg_acc1_add_p of the integration path.
[0128] When the phase state of the previous group of clock signals is lagging, the correction formula for the frequency difference of the current group of clock signals is:
[0129] acc1_integral=(acc1_integral_cur-reg_vote_acc1_gain) / (2^reg_acc1_add_p);
[0130] Among them, acc1_integral is the modulation information of the frequency difference of the current group of clock signals, and acc1_integral_cur is the frequency difference of the previous group of clock signals.
[0131] After the modulation information of the frequency difference is obtained, the modulation information of the phase difference is calculated according to the modulation information of the frequency difference, which specifically includes:
[0132] Set the phase gain reg_vote_phase_gain of the proportional path and the shift width reg_phase_gain_p of the proportional path.
[0133] When the phase state of the current group of clock signals is lagging, the correction formula for the phase difference of the subsequent group of clock signals is:
[0134] phase_add=(phase_add_cur-reg_vote_phase_gain+acc1_integral) / (2^reg_phase_gain_p);
[0135] Among them, phase_add is the modulation information of the phase difference of the current group of clock signals, and phase_add_cur is the phase difference of the previous group of clock signals.
[0136] The step of adjusting the phase of the current group of clock signals according to the modulation information specifically includes:
[0137] The modulation information of the frequency difference of the current group of clock signals and the modulation information of the phase difference of the current group of clock signals are added together to obtain the total modulation information; the code of the frequency difference and the code of the phase difference of the current group of clock signals are corrected according to the total modulation information, and the corrected clock signal is output to the external clock.
[0138] Based on the above method, this embodiment also provides a serdes data clock recovery circuit based on matlab, and its module diagram is as follows: Figure 7 As shown, it includes: an external clock module, a phase discriminator module, a modulation information generation module and a phase modulation module, wherein:
[0139] The external clock module, the phase discriminator module, the modulation information generation module and the phase modulation module are connected in sequence, and the phase modulation module is connected to the external clock module;
[0140] The external clock module is used to send a clock signal to the phase discriminator module; the phase discriminator module is used to judge the phase state of each group of clock signals in turn according to the acquisition order of each group of clock signals; the modulation information generation module is used to generate modulation information of the current group of clock signals according to the phase state of the previous group of clock signals; the phase modulation module is used to make corresponding phase adjustments to the current group of clock signals according to the modulation information; the adjusted clock signal is output to the external clock module, and the data is sampled again with the adjusted clock signal.
[0141] Among them, Figure 8As shown, the modulation information generation module includes a proportional path and an integral path, wherein the proportional path is used to provide a phase difference gain, thereby calculating the modulation information of the corresponding phase difference, and the integral path is used to provide a frequency difference gain, thereby calculating the modulation information of the corresponding frequency difference. An integrator is provided in the integral path, and the integrator is used to calculate the frequency deviation based on the phase difference. After obtaining the modulation information of the phase difference and the modulation information of the frequency difference, the modulation information of the phase difference and the modulation information of the frequency difference are used together as the modulation information, which is used to perform corresponding modulation actions on the subsequent modulation module.
[0142] This embodiment provides a modeling method of a serdes data clock recovery circuit based on matlab on the basis of the above-mentioned serdes data clock recovery circuit based on matlab and the serdes data clock recovery method based on matlab, as follows:
[0143] Step A: Define the intermediate data required in the operation process of the clock input module, phase discriminator module, modulation information generation module and modulation module.
[0144] In this embodiment, the phase discriminator module is represented by a PD module.
[0145] Step_A1: For the PD module, the required data is defined as follows:
[0146] PD_reg is used to indicate the amount of data in each group of clock signals, in bits.
[0147] datain_shift is used to store the current data of each clock signal transmitted to the PD module.
[0148] data_edge_shift is used to store the left and right boundary values of the current clock signal in datain_shift, that is, the previous beat data and the next beat data of the current beat data.
[0149] inc is used to indicate how many bits of data have an advanced phase state in the current group of clock signals based on statistics of datain_shift and data_edge_shift.
[0150] dec is used to indicate how many bits of data have an advanced phase state in the current group of clock signals based on datain_shift and data_edge_shift statistics.
[0151] Step_A2: For the modulation information generation module, in this embodiment, the modulation information generation module can be represented by a vote module, and the required data is defined as follows:
[0152] inno_pd_value, which is used to represent the difference between inc and dec.
[0153] pd_up is used to indicate that inno_pd_value is greater than 0;
[0154] pd_dn is used to indicate that inno_pd_value is less than 0.
[0155] reg_vote_acc1_gain is used to represent the phase difference gain in the integral path.
[0156] reg_vote_phase_gain represents the frequency difference gain in the proportional path.
[0157] Step_A3: For the modulation module, in this embodiment, the modulation module can be represented by a DLF module, and the required data is defined as follows:
[0158] acc1_integral is used to represent the modulation information of the frequency difference of each group of clock signals on the integral path.
[0159] phase_add is used to indicate the modulation information of the phase difference of each group of clock signals of the proportional path.
[0160] Phase: the phase of the final output of each group of clock signals.
[0161] reg_phase_gain_p, which is used to indicate the shift width of the proportional path.
[0162] reg_acc1_add_p is used to indicate the shift width of the integration path.
[0163] Step_B: Analyze the variables in Step_A to perform combinational logic and sequential logic analysis, and determine whether the operation mode of the corresponding variables is a sequential circuit or a logic circuit.
[0164] The variables that need to be considered in terms of timing are as follows:
[0165] Among them, acc1_integral is an integral link, so acc1_integral adopts the operation method of a sequential circuit.
[0166] Phase uses the operation method of timing circuit to record the previous shot data.
[0167] For datain_shift and data_edge_shift, since the clock signal input each time is different and the previous data may need to be cached, it is necessary to adopt the operation method of the timing circuit.
[0168] In this embodiment, other signals may be operated by logic circuits.
[0169] Step_C: Use matlab to model the above process. The specific method is as follows:
[0170] Step_C1: Build a digital_CDR class.
[0171] Step_C2: In the properties of the digital_CDR class, define and add the following properties:
[0172] The initialization value of inc is 0;
[0173] The initial value of dec is 0;
[0174] The initialization value of reg_phase_gain_p is 0;
[0175] The initialization value of reg_phase_gain_q is 0;
[0176] The initialization value of reg_vote_phase_phase is 0;
[0177] reg_vote_acc1_gain is initialized to 0;
[0178] pd_up is initialized to 0;
[0179] pd_dn is initialized to 0;
[0180] acc1_integral_cur is initialized to 0;
[0181] acc1_integral is initialized to 0;
[0182] phase_add_cur is initialized to 0;
[0183] phase_add is initialized to 0;
[0184] datain_shift is initialized to an array of length 64 containing all zeros;
[0185] datain_shift_cur is initialized to an array of all 0s with a length of 64;
[0186] data_edge_shift is initialized to an array of all 0s with a length of 64;
[0187] data_edge_shift_cur is initialized to a 64-length array of all zeros;
[0188] Step_C3: Add the following method to the digital_CDR class to calculate the phase of each beat of data in each group of clock signals:
[0189] The method run receives two parameters, data_in and data_edge, where data_in is used to represent the data received in the current beat, and data_edge is used to represent the data in the previous beat and the next beat, thereby simulating the calculation of one beat of the register transfer level (RTL) of the digital design.
[0190] Method delay, which does not receive any parameters, is used to simulate the operation process of variables involved in sequential logic operations in digital design RTL.
[0191] Method load_config, which receives at least two parameters, one of which is json_data, which is used to record the configuration of the register (reg); the other is a string path, which is used to point to the configuration file of the vector (vector) to be printed.
[0192] Method vec_log, which receives at least 4 parameters, one of which is a txt file identifier pointing to the txt file that outputs the printed vector, one of which is index, used to indicate the index corresponding to each group of clock signals, and the other two parameters are data_in and data_edge.
[0193] Step_C4: is the specific implementation method of the run method in Step_C3. The specific method is as follows:
[0194] The method run receives at least two parameters, one of which is data_in and the other is data_edge.
[0195] Step_C4_1: Shift datain_shift left by 20 bits, fill it with 0, and assign data_in to the upper 20 bits of datain_shift.
[0196] Step_C4_2: Shift data_edge_shift right by 20 bits, fill it with 0, and assign data_edge to the upper 20 bits of data_edge.
[0197] Step_C4_3: Calculate inc and dec. PD_reg indicates the amount of data processed in the current beat. Start = 64–PD_reg+1 indicates the starting bit of each beat of data. The calculation method of inc is:
[0198] xor(datain_shift(start:63), data_edge_shift(start:63))&~xor(data_edge_shift(start + 1 : 64), datain_shift(start:63)).
[0199] The calculation method of dec is:
[0200] xor(datain_shift(start:63), data_edge_shift(start:63))&~xor(data_edge_shift(start + 1 : 64), datain_shift(start:63)).
[0201] Among them, xor() means bitwise exclusive OR, ~ means negation, datain_shift(a,b) and data_edge_shift(a,b) mean the a-th bit to the b-th bit of datain_shift and data_edge_shift.
[0202] Step_C4_4: Calculate the inno_pd_value value, inno_pd_value=sum(inc)-sum(dec), where sum(inc)-sum(dec) is the data difference between the total amount of data with a lagging phase state and the total amount of data with an advanced phase state.
[0203] Step_C4_5: Calculate the values of pd_up and pd_dn. If inno_pd_value>0, then pd_up=1, pd_dn=0; if inno_pd_value<0, then pd_up=0, pd_dn=1; if inno_pd_value =0, then pd_up=0, pd_dn=0.
[0204] Step_C4_6: Calculate the integral value acc1_integral. If pd_up_cur = 1, then acc1_integral = acc1_integral_cur + reg_vote_acc1_gain; if pd_dn_cur = 1, then acc1_integral = acc1_integral_cur - reg_vote_acc1_gain.
[0205] Step_C4_7: acc1_integral=acc1_integral / (2^reg_acc1_add_p).
[0206] Step_C4_8: If pd_up_cur=1, then phase_add=phase_add_cur+reg_vote_phase_gain+acc1_integral; if pd_dn_cur=1, then phase_add=phase_add_cur–reg_vote_phase_gain+acc1_integral.
[0207] Step_C4_9: phase_add = phase_add / (2^reg_phase_gain_p).
[0208] Step_C4_10: Call its own delay method to simulate register delay.
[0209] Step_C5: Implement the specific method for the delay in Step_C3, and assign the frequency difference and phase difference obtained in the current beat to the corresponding frequency difference and phase difference in the previous beat data for calculation of the next beat data. The specific method is as follows:
[0210] This method delays the value calculated in the previous beat of the variable used to simulate the RTL timing calculation in the RTL to the current beat for use, that is, assigns the value of a certain attribute of digital_CDR to the cur value of the attribute, as follows:
[0211] The value of acc_integal is assigned to acc_integal_cur.
[0212] The value of phase_add is assigned to phase_add_cur.
[0213] The value of datain_shift is assigned to datain_shift_cur.
[0214] The value of data_edge_shift is assigned to data_edge_shift_cur.
[0215] Step_C6: Implement load_config in Step_C3 to load the model configuration information. The specific method is as follows:
[0216] Among them, the config file is mainly divided into json data file and txt file. Among them, the json data file is mainly used to configure the value of the register, and the txt file is used to configure the ID that needs to print out the variable value of the model for digital design verification.
[0217] In actual circuit design, according to the design style of technical personnel in this field, a suitable bit width is generally selected, and it is determined whether a sign bit is needed. For this reason, in this embodiment, for the configuration of each register value, the data format of lightweight data exchange (json) is used for configuration. The specific configuration is as follows: for each register, three attribute values of value, bits and signed are configured respectively, where value represents the size of the register value, bits represents the bit width of the register value, and signed represents the sign number of the register value (for example, 0 represents an unsigned number, and 1 represents a signed number).
[0218] This embodiment provides a method of writing a json config file using reg_phase_gain_p, as follows:
[0219] "reg_phase_gain_p": {
[0220] "value": 1,
[0221] "bits": 5,
[0222] "signed": 0
[0223] }
[0224] If you need to print out the values of intermediate variables, you can use txt to edit the name of each variable that needs to be printed line by line.
[0225] The load_config function receives two file directories, one of which is the file directory of the above reg.json, and the other is the file directory of the above txt.
[0226] Step_C6_1: Read each line of data in reg.json into the json_data string line by line; wherein the json_data string is used to record the configuration of reg.
[0227] Step_C6_2: Use the lightweight data exchange format decoding (jsondecode) function that comes with MATLAB to encode json_data into a usable structure in MATLAB.
[0228] Step_C6_3: Use the field names (fieldnames) provided by matlab to obtain each attribute name of json_data, and use reg_name, which is equivalent to obtaining the name of each register in each json_data.
[0229] Step_C6_4: For each register in reg_name, determine whether the value assigned to the register is within the correct value range based on the value, bits, and signed configuration of the register in json_data.
[0230] For signed numbers (signed=1), the value range is [-2^(bits-1), 2^(bits-1)-1].
[0231] For unsigned numbers (signed=0), the value range is [0,2^bits-1].
[0232] If the value of a register is not in the correct value range, it directly represents an error. If it is in the normal value range, the value is assigned to the corresponding register value.
[0233] Step_C6_5: Read each line in the vec.txt file and record the value of each line in the cdr_vec string array, that is, record the intermediate variable value to be printed in cdr_vec for subsequent vec output; wherein, the vec.txt file contains the value that needs to be checked for each beat printed by matlab.
[0234] Step_C7: Implement the specific method for vec_log in Step_C3. The specific method is as follows:
[0235] vec_log mainly receives four parameters, including: fid, clk_index, data and data_edge, where fid is used to represent the identifier of the open text file; clk_index is used to represent the number of beats; data is used to input the current beat of the data, and data_edge is used to input the previous beat and the next beat of the data.
[0236] Step_C7_1: Determine whether the value of clk_index is 1, that is, whether it is the first group of clock signals. If it is the first group of clock signals, append the print strings "CLK", "DATA" and "EDGE" to the first line of the text fid, and append each string in cdr_vec to the first line of fid, separated by space characters.
[0237] Step_C7_2: Separate the values of the variables corresponding to each character of the above clk_index, data, edge and cdr_vec with spaces, and append them to the new line of fid in sequence.
[0238] With respect to the above-mentioned MATLAB-based modeling method of the Serdes data clock recovery circuit, this embodiment also provides an application example in a practical scenario, so as to more comprehensively demonstrate the modeling method.
[0239] StepA_1: Configure all registers starting with "reg" in the above model as digitally designed registers and design the corresponding bit widths.
[0240] StepA_2: The variables with timing requirements in the above model (i.e. variables with the suffix cur) can be converted into the timing calculation logic process of the register transfer level hardware description language (RTL Verilog) during the run process, as follows:
[0241] acc1_integral=acc1_integral_cur+reg_vote_acc1_gain; where acc1_integral is sequential logic, it can be rewritten as:
[0242] always @(posedge i_cdr_clk or negedgei_resetn)
[0243] if(~i_restn)
[0244] acc1_integral = 0;
[0245] else
[0246] acc1_integral = acc1_integral + reg_vote_acc1_gain;
[0247] StepA_3: Refer to other calculation logics in the run process and convert them into RTL calculation logic.
[0248] Since there is no need to consider sequential logic, the syntax calculation form is the same as MATLAB.
[0249] The model is used to perform digital RTL design verification. The matlab model generates a vector. The RTL design verification performs level matching on each group of clock signals to determine whether the RTL design is consistent with the matlab model. If the matlab model and the RTL design are inconsistent, the model or RTL design is modified based on the difference.
[0250] StepB_1: Write register configuration information according to the json file. The configuration file cdr_config.json for this model can be as follows:
[0251] {
[0252] "PD_reg": {
[0253] "value": 16,
[0254] "bits": 10,
[0255] "signed": 0,
[0256] },
[0257] "reg_phase_gain_p": {
[0258] "value": 2,
[0259] "bits": 3,
[0260] "signed": 0
[0261] },
[0262] "reg_acc1_gain_p":{
[0263] "value":2,
[0264] "bits":3,
[0265] "signed":0
[0266] },
[0267] reg_vote_acc1_gain:{
[0268] "value": 2,
[0269] "bits": 3,
[0270] "signed": 0
[0271] },
[0272] reg_vote_phase_gain:{
[0273] "value": 2,
[0274] "bits": 3,
[0275] "signed": 0
[0276] }
[0277] }
[0278] Step B_2: Write the configuration file vec_config.txt of the vector to be exported and verified. For example, the txt file can be written as follows:
[0279] inc
[0280] dec
[0281] inno_pd_value
[0282] acc1_integral_cur
[0283] phase_add_cur;
[0284] StepB_3: Use matlab to build a digital_CDR instance, call the load_config function of the digital design part, and pass the path addresses of cdr_config.json and vec_config.txt in StepB_2 as parameters.
[0285] StepB_4: Determine the number of cycles that need to be verified, and randomly generate 20*num_cycles 0s and 1s of data_in_total and data_edge_total; data_in_total is the number of data, and data_edge_total is the number of edges in each data.
[0286] StepB_5: Use the following MATLAB language to determine the text identifier fid of the print output vector, as follows:
[0287] fid=fopen(vec_filename,'w');
[0288] fid=fopen(vec_filename,'a+');
[0289] vec_filename is the vector target output address storage space, assuming the file name is vec.txt.
[0290] StepB_5: Execute the loop num_cycles times, clk_index is used as the loop count counter.
[0291] StepB_5_1: In each loop, data_in takes 20 values from data_in_total, and data_edge takes 20 values from data_in_total.
[0292] StepB_5_2: Execute the run function of the digital design part, where data_in and data_edge are passed in as parameters.
[0293] StepB_5_3: Execute the vec_log function of the digital design part, and fid, clk_index, data_in and data_edge are passed in as parameters in turn.
[0294] Step B_6: The output vec.txt is as follows Fig. 9 shown.
[0295] Fig. 9 In the first line, CLK is the clock beat count, DATA and EDAG are both input excitation signals, inc is the increment instruction, dec is the decrement instruction, inno_pd_value is the difference between inc and dec, acc1_integral_cur is the frequency difference of the previous set of clock signals, and phase_add_cur is the phase difference of the previous set of clock signals. Fig. 9 The data in the second, third, and fourth rows are the values corresponding to the objects in the first row at different clock beats.
[0296] StepB_7: After the digital RTL design is completed, verification can be performed based on vec.txt. The verification method is as follows:
[0297] StepB_7_1: Parse vec.txt, read the data of each group of clock signals according to CLK, where DATA and EDAG are used as input stimulus signals, derive digital RTL in sequence and output the values of inc, dec, inno_pd_value, acc1_integral and phase_add.
[0298] StepB_7_2: Determine in sequence whether the values of inc, dec, inno_pd_value, acc1_integral, and phase_add output by the RTL, as well as the values of inc, dec, inno_pd_value, acc1_integral_cur, and phase_add_cur of the corresponding group of clock signals in vec.txt are consistent.
[0299] StepB_7_3: If they are inconsistent, an error is thrown, the CLK number is recorded, and RTL design logic error check or MATLAB logic error check is performed.
[0300] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A serdes data clock recovery method based on matlab, characterized in that, include: Sampling data based on a clock signal; Divide the data of a preset amount into one group according to the sampling order of the data, and judge the phase state of the clock signal corresponding to each group of data in turn according to the sampling order of each group of data; Generate modulation information of the current group of clock signals according to the phase state of the previous group of clock signals; wherein, when the phase state of the previous group of clock signals is leading or lagging, calculate the modulation information of the frequency difference of the current group of clock signals, and calculate the modulation information of the phase difference; when the phase state of the previous group of clock signals is normal, there is no need to correct the current group of clock signals; Among them, the frequency difference gain reg_vote_acc1_gain of the integral path and the shift width reg_acc1_add_p of the integral path are set; when the phase state of the previous group of clock signals is advanced, the correction formula of the frequency difference of the current group of clock signals is: acc1_integral=(acc1_integral_cur+reg_vote_acc1_gain) / (2^reg_acc1_add_p); Wherein, acc1_integral represents the modulation information of the frequency difference of the current group of clock signals, and acc1_integral_cur represents the frequency difference of the previous group of clock signals; The phase of the current group of clock signals is adjusted accordingly according to the modulation information.
2. The serdes data clock recovery method based on matlab according to claim 1, characterized in that: The determining the phase state of the clock signal corresponding to each group of data in sequence according to the sampling order of each group of data includes: Determine the phase state of the clock signal corresponding to each beat of data in each group of data; The total amount of data with a lagging phase state and the total amount of data with an advanced phase state in each group of data are counted respectively, and the data difference value of the total amount of data with a lagging phase state minus the total amount of data with an advanced phase state is obtained; When the data difference is greater than 0, determining that the phase state of the clock signal of the corresponding group is lagging; When the data difference is less than 0, determining that the phase state of the clock signal of the corresponding group is leading; When the data difference is equal to 0, it is determined that the phase state of the clock signal of the corresponding group is normal.
3. The serdes data clock recovery method based on matlab according to claim 2, characterized in that: The determining of the phase state of the clock signal corresponding to each beat of data in each group of data includes: Compare the current shot data with the previous shot data and the next shot data; When the current beat data is equal to the previous beat data, and the current beat data is not equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is lagging; When the current beat data is not equal to the previous beat data, and the current beat data is equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is leading; When the current beat data is not equal to the previous beat data, and the current beat data is not equal to the next beat data, it is determined that the phase state of the clock signal corresponding to the current beat data is normal.
4. The serdes data clock recovery method based on matlab according to claim 1, characterized in that: The modulation information for calculating the phase difference includes: Set the phase difference gain reg_vote_phase_gain of the proportional path and the shift width reg_phase_gain_p of the proportional path; When the phase state of the current group of clock signals is leading, the correction formula for the phase difference of the subsequent group of clock signals is: phase_add=(phase_add_cur+reg_vote_phase_gain+acc1_integral) / (2^reg_phase_gain_p); Among them, phase_add represents the modulation information of the phase difference of the current group of clock signals, and phase_add_cur represents the phase difference of the previous group of clock signals.
5. The serdes data clock recovery method based on matlab according to claim 1, characterized in that: The modulation information for calculating the frequency difference of the current group of clock signals when the phase state of the previous group of clock signals is leading or lagging includes: Set the frequency difference gain reg_vote_acc1_gain of the integral path and the shift width reg_acc1_add_p of the integral path; When the phase state of the previous group of clock signals is lagging, the correction formula for the frequency difference of the current group of clock signals is: acc1_integral=(acc1_integral_cur-reg_vote_acc1_gain) / (2^reg_acc1_add_p); Among them, acc1_integral represents the modulation information of the frequency difference of the current group of clock signals, and acc1_integral_cur represents the frequency difference of the previous group of clock signals.
6. The serdes data clock recovery method based on matlab according to claim 5, characterized in that: The modulation information for calculating the phase difference includes: Set the phase difference gain reg_vote_phase_gain of the proportional path and the shift width reg_phase_gain_p of the proportional path; When the phase state of the current group of clock signals is lagging, the correction formula for the phase difference of the subsequent group of clock signals is: phase_add=(phase_add_cur-reg_vote_phase_gain+acc1_integral) / (2^reg_phase_gain_p); Among them, phase_add represents the modulation information of the phase difference of the current group of clock signals, and phase_add_cur represents the phase difference of the previous group of clock signals.
7. The serdes data clock recovery method based on matlab according to claim 1, characterized in that: The performing corresponding phase adjustment on the current group of clock signals according to the modulation information comprises: Adding the modulation information of the frequency difference of the current group of clock signals and the modulation information of the phase difference of the current group of clock signals to obtain total modulation information; The frequency difference code and the phase difference code of the current group of clock signals are corrected according to the total modulation information, and the corrected clock signals are output to the external clock.
8. A MATLAB-based Serdes data clock recovery circuit, used to implement the MATLAB-based Serdes data clock recovery method as claimed in any one of claims 1 to 7, characterized in that: include: An external clock module, a phase discriminator module, a modulation information generation module and a phase modulation module, wherein: The external clock module, the phase discriminator module, the modulation information generation module and the phase modulation module are connected in sequence, and the phase modulation module is connected to the external clock module; The external clock module is used to send a clock signal to the phase discriminator module; the phase discriminator module is used to judge the phase state of each group of clock signals in turn according to the acquisition order of each group of clock signals; the modulation information generation module is used to generate modulation information of the current group of clock signals according to the phase state of the previous group of clock signals; the phase modulation module is used to make corresponding phase adjustments to the current group of clock signals according to the modulation information; the adjusted clock signal is output to the external clock module, and the data is sampled again with the adjusted clock signal.
