# Patent

## Title
Method, system and device for removing media access control addresses

## Abstract

Embodiments of the present invention disclose a method and device for selecting a sampling clock signal. The method includes: obtaining, by a logic chip, a data edge of a data signal and a clock edge of a clock signal, selecting a sampling edge according to the data edge and the clock edge, and sending a selecting signal corresponding to the sampling edge to a selector; and selecting, by the selector, a sampling clock signal according to the selecting signal. The technical solutions provided by the embodiments of the present invention can solve problems of poor system maintainability and high cost of operation and maintenance because a receiver device needs to select a sampling clock signal through manual configuration in the synchronous serial-port communication in the prior art.

## Background
CROSS-REFERENCE TO RELATED APPLICATION
This application claims priority to Chinese Patent Application No. 201110289023.5, filed on Sep. 26, 2011, which is hereby incorporated by reference in its entirety.
FIELD
The present invention relates to the field of network communications, and in particular, to a method and device for selecting a sampling clock signal.
BACKGROUND
In synchronous serial-port communication, a transmitter device sends a clock signal and a data signal simultaneously, and a receiver device samples data according to the clock signal.
In actual engineering applications, due to factors such as the length of the cable from the transmitter device to the receiver device and intra-board wiring, delay of the data signal may be inconsistent with delay of the clock signal. However, in data sampling, requirements of setup time and hold time must be satisfied simultaneously, and if any requirement is not satisfied, the data obtained by sampling may be incorrect. Setup time refers to a minimum period during which the data signal must keep stable before the sampling edge, and hold time refers to a minimum period during which the data signal must keep stable after the sampling edge. Therefore, the following case may exist at the receiver device: The rising edge of the clock signal must be used as the sampling edge for sampling data, or the falling edge of the clock signal must be used as the sampling edge for sampling data.
Generally, a receiver of the receiver device uses a fixed clock edge to sample the data signal. Therefore, a selecting signal needs to be provided for a selector according to the selected sampling edge, so that the selector selects the original clock signal or the clock signal inverted by an inverter (also called a NOT gate) as a sampling clock signal and provides the sampling clock signal for the receiver. Specifically, if the clock edge for sampling data by the receiver of the receiver device is the same as the selected sampling edge, the original clock signal is selected as the sampling clock signal; and if the clock edge for sampling data by the receiver of the receiver device is different from the selected sampling edge, the clock signal inverted by the inverter is selected as the sampling clock signal.
In synchronous serial-port communication in the prior art, a selecting signal is input to the selector by manually configuring the sampling edge, so that the selector selects a sampling clock signal. Generally, a configuration personnel does not know which clock edge should be configured for sampling, and can determine the sampling edge only by attempts. For example, first the clock edge for sampling data by the receiver is configured manually as the rising edge, and a corresponding selecting signal is input to the selector, for example, 1, so that the selector selects a sampling clock signal for the receiver according to the selecting signal; then packet loss and bit error rate of the device are observed manually for a period; and if no packet loss and bit error occurs, the configured sampling edge does not need to be adjusted; while if packet loss or bit error is found, the clock edge for sampling data by the receiver is configured manually as the falling edge, and a corresponding selecting signal is input to the selector, so that the selector selects a sampling clock signal for the receiver according to the selecting signal. As a result, the system maintainability is poor and the cost of operation and maintenance is high.
SUMMARY
Embodiments of the present invention provide a method and device for selecting a sampling clock signal, in order to solve problems of poor system maintainability and high cost of operation and maintenance because the receiver device needs to select a sampling clock signal through manual configuration in the synchronous serial-port communication in the prior art.
According to one aspect of the present invention, the present invention provides a method for selecting a sampling clock signal. The method for selecting a sampling clock signal is applied to a receiver device, where the receiver device includes a logic chip and a selector, and the logic chip is connected to the selector.
The method for selecting a sampling clock signal includes:
obtaining, by the logic chip, a data edge of a data signal and a clock edge of a clock signal, selecting a sampling edge according to the data edge and the clock edge, and sending a selecting signal corresponding to the sampling edge to the selector; and
selecting, by the selector, a sampling clock signal ac cording to the selecting signal.
According to another aspect of the present invention, the present invention provides a receiver device, including a logic chip and a selector, where:
the logic chip is connected to the selector;
the logic chip is configured to obtain a data edge of a data signal and a clock edge of a clock signal, select a sampling edge according to the data edge and the clock edge, and send a selecting signal corresponding to the sampling edge to the selector; and
the selector is configured to select a sampling clock signal according to the selecting signal.
With the technical solutions provided by embodiments of the present invention, the sampling edge can be automatically selected by detecting relative position of the data edge and, the clock edge by the logic chip. Thereby, the sampling clock signal is selected without manual configuration, the cost of operation and maintenance is reduced, and the system maintainability is improved.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a flowchart of a method for selecting a sampling clock signal according to an embodiment of the present invention;
FIG. 2 is a schematic diagram illustrating relative position of a data edge of a data signal and a clock edge of a clock signal according to an embodiment of the present invention; and
FIG. 3, FIG. 4, and FIG. 5 are block diagrams of a receiver device according to an embodiment of the present invention.



DETAILED DESCRIPTION OF THE EMBODIMENTS
FIG. 1 is a flowchart of a method for selecting a sampling clock signal according to an embodiment of the present invention. The method for selecting a sampling clock signal is applied to a receiver device, where the receiver device includes a logic chip and a selector, and the logic chip is connected to the selector. The method for selecting a sampling clock signal includes the following:
101. The logic chip obtains a data edge of a data signal and a clock edge of a clock signal, selects a sampling edge according to the data edge and the clock edge, and sends a selecting signal corresponding to the sampling edge to the selector.
The receiver device may be a data terminal equipment (Data Terminal Equipment, DTE for short) or a data communication equipment (Data Communication Equipment, DCE for short).
The logic chip may be a complex programmable logic device (Complex Programmable Logic Device, CPLD for short), a field-programmable gate array (Field-Programmable Gate Array, FPGA for short), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC for short) used for selecting a sampling edge, and so on.
The receiver device may further include a receive data line RXD and a receive clock line RXC. The logic chip is connected to the RXD and the RXC respectively.
The logic chip obtains the data signal from the RXD and obtains the clock signal from the RXC. Then the logic chip samples the data signal and the clock signal by using a high-frequency clock signal, and obtains the data edge of the data signal and the clock edge of the clock signal.
The logic chip selects the sampling edge according to the data edge and the clock edge. Specifically, the logic chip detects relative position of the data edge and the clock edge, and selects a rising edge or a falling edge nearest to a middle position of a data pulse from the clock edge as the sampling edge to ensure setup time and hold time.
For example, FIG. 2 is a schematic diagram illustrating relative position of a data edge of a data signal and a clock edge of a clock signal received by the receiver device. If the rising edge of the clock signal is selected for sampling data, setup time is short and the sampled data may be incorrect; while if the falling edge of the clock signal nearer to the middle position of the data pulse is selected for sampling data, both setup time and hold time can be ensured.
After selecting the rising edge or falling edge of the clock signal as the sampling edge, the logic chip sends the selecting signal corresponding to the sampling edge to the selector. For example, 1 indicates the rising edge, and 0 indicates the falling edge; or a high level indicates the rising edge, and a low level indicates the falling edge, and so on.
102. The selector selects a sampling clock signal according to the selecting signal.
Generally, the selector is a 2-to-1 selector.
The selector selects the clock signal or an inverted clock signal as the sampling clock signal according to the selecting signal. Specifically, the selector is connected to the RXC, and is also connected to the RXC through an inverter. The selector obtains the clock signal from the RXC, and obtains the inverted clock signal from the inverter.
Optionally, the receiver device may further include a receiver, where the receiver is connected to the RXD and the selector respectively.
Further optionally, the receiver obtains the sampling clock signal from the selector, and samples the data signal according to the sampling clock signal.
In the embodiment of the present invention, the sampling edge can be automatically selected by detecting relative position of the data edge and the clock edge by the logic chip to obtain the sampling clock signal. Thereby, the cost of operation and maintenance is reduced and the system maintainability is improved. The embodiment solves problems of poor system maintainability and high cost of operation and maintenance because the receiver device needs to select a sampling clock signal through manual configuration in the synchronous serial-port communication in the prior art.
FIG. 3 is a block diagram of a receiver device according to an embodiment of the present invention, where the receiver device includes a logic chip 301 and a selector 302.
The logic chip 301 is connected to the selector 302.
The logic chip 301 is configured to obtain a data edge of a data signal and a clock edge of a clock signal, select a sampling edge according to the data edge and the clock edge, and send a selecting signal corresponding to the sampling edge to the selector 302.
The selector 302 is configured to select a sampling clock signal according to the selecting signal.
The receiver device may be a data terminal equipment DTE or a data communication equipment DCE.
The logic chip 301 may be a complex programmable logic device CPLD, a field-programmable gate array FPGA, or an application specific integrated circuit ASIC used for selecting a sampling edge, and so on.
As shown in FIG. 4, the receiver device may further include a receive data line RXD 303 and a receive clock line RXC 304. The logic chip is connected to the RXD 303 and the RXC 304 respectively. The logic chip 301 is further configured to obtain the data signal from the RXD 303 and obtain the clock signal from the RXC 304.
Specifically, the logic chip 301 samples the data signal and the clock signal by using a high-frequency clock signal, obtains the data edge of the data signal and the clock edge of the clock signal, detects relative position of the data edge and the clock edge, and selects a rising edge or a falling edge nearest to a middle position of a data pulse from the clock edge as the sampling edge to ensure setup time and hold time. Then the logic chip 301 sends the selecting signal corresponding to the sampling edge to the selector 302. For example, 1 indicates the rising edge, and 0 indicates the falling edge; or a high level indicates the rising edge, and a low level indicates the falling edge, and so on.
The selector 302 is specifically configured to select the clock signal or an inverted clock signal as the sampling clock signal according to the selecting signal.
Specifically, as shown in FIG. 4, the selector 302 is connected to the RXC 304, and is also connected to the RXC 304 through an inverter. The selector 302 obtains the clock signal from the RXC 304, and obtains the inverted clock signal from the inverter.
As shown in FIG. 5, the receiver device may further include:
a receiver 305, connected to the RXD 303 and the selector 302 respectively.
The receiver 305 is configured to obtain the sampling clock signal from the selector 302, obtain the data signal from the RXD 303, and sample the data signal according to the sampling clock signal.
With the technical solution provided by the embodiment of the present invention, the sampling edge can be automatically selected by detecting relative position of the data edge and the clock edge by the logic chip to obtain the sampling clock signal. Thereby, the cost of operation and maintenance is reduced and the system maintainability is improved. The embodiment solves problems of poor system maintainability and high cost of operation and maintenance because the receiver device needs to select a sampling clock signal through manual configuration in the synchronous serial-port communication in the prior art.
It is understandable to a person of ordinary skill in the art that all or a part of the steps in the methods provided in the preceding embodiments may be performed by hardware instructed by a program. The program may be stored in a computer readable storage medium, such as a ROM/RAM, a magnetic disk, or a compact disc-read only memory.
Detailed above are only exemplary embodiments of the present invention, but the scope of the present invention is not limited thereto. Any modification or substitution readily conceivable by a person skilled in the art within the scope of the technology disclosed herein shall be covered within the scope of the present invention.

## Claims

1. A method for selecting a sampling clock signal, wherein the method is applied to a receiver device, the receiver device comprising a logic chip, a selector, a receive data line RXD and a receive clock line RXC, wherein the logic chip is connected to the selector, and wherein the logic chip is connected to the RXD and the RXC respectively; the selector is a 2-to-1 selector, and the selector is connected to the RXC through an inverter; wherein
the method for selecting a sampling clock signal comprises:
obtaining, by the logic chip, a data signal from the RXD and a clock signal from the RXC;
obtaining, by the logic chip, a data edge of the data signal and a clock edge of the clock signal, selecting a rising edge or a falling edge nearest to a middle position of a data pulse from the clock edge as a sampling edge by detecting only once, relative position of the data edge and the clock edge, and sending a selecting signal corresponding to the sampling edge to the selector; and
selecting, by the selector, the clock signal obtained from the RXC or an inverted clock signal obtained from the inverter as a sampling clock signal according to the selecting signal.

2. The method according to claim 1, wherein the obtaining, by the logic chip, the data edge of the data signal and the clock edge of the clock signal specifically comprises:
sampling, by the logic chip, the data signal and the clock signal by using a high-frequency clock signal, and obtaining the data edge of the data signal and the clock edge of the clock signal.

3. The method according to claim 1, further comprising:
obtaining, by a receiver, the sampling clock signal from the selector; and
sampling the data signal according to the sampling clock signal.

4. A receiver device, comprising a logic chip, a receive data line RXD, a receive clock line RXC, an inverter and a selector, wherein
the logic chip is connected to the selector;
the logic chip is connected to the RXD and the RXC respectively;
the selector is a 2-to-1 selector, the selector is connected to the RXC through the inverter;
the logic chip is configured to obtain a data signal from the RXD and a clock signal from the RXC, obtain a data edge of the data signal and a clock edge of the clock signal, select a rising edge or a falling edge nearest to a middle position of a data pulse from the clock edge as a sampling edge by detecting only once, relative position of the data edge and the clock edge, and send a selecting signal corresponding to the sampling edge to the selector; and
the selector is configured to select the clock signal obtained from the RXC or an inverted clock signal obtained from the inverter as a sampling clock signal according to the selecting signal.

5. The receiver device according to claim 4, further comprising a receiver, wherein the receiver is connected to the RXD and the selector; and
the receiver is configured to obtain the sampling clock signal from the selector, obtain the data signal from the RXD, and sample the data signal according to the sampling clock signal.

6. The receiver device according to claim 4, wherein
the logic chip is configured to sample the data signal and the clock signal by using a high-frequency clock signal.