Synchronous communication multi-clock fitting detection technology based on FPGA
By sampling and registering the SPI communication clock on the FPGA, a new fitted clock is generated, which solves the problem of insufficient FIFO resources in cross-clock domain data transmission, and achieves efficient data transmission and resource savings.
Patent Information
- Application Number
- CN202411167815.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-03
AI Technical Summary
When the FPGA slave and the DSP host communicate SPI, data transmission across the clock domain requires a large number of FIFO resources, making it difficult to achieve stable and efficient data transmission under limited resources.
Using FPGA-based multi-clock fit detection technology, the synchronous communication clock is sampled through external clock or PLL times/dividing clock, the metastable state is eliminated by n-level registers, and the waveform outputs to the synchronous communication clock are performed through the last-level register. 'or' operation, generate a new fit clock for data cache.
This technology can save FIFO resources, improve the accuracy and efficiency of data transmission, and is suitable for high-frequency SPI communication, with small delay and flexible configuration, and is suitable for scenarios with limited resources.
Smart Images

Figure CN119066014A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a multi-clock fitting detection technology, in particular to a multi-clock fitting detection technology for synchronous communication based on FPGA. Background Art
[0002] In the industrial field, synchronous communications such as SPI have a common synchronous clock, and the sending and receiving of master and slave data need to be driven by the clock signal. FPGA is one of the most common control chips in the field of industrial control. It has powerful computing speed and computing performance. Using FPGA to implement SPI communication is a very common communication method in the industry.
[0003] When DSP is used as the host and FPGA is used as the slave for SPI communication, since the SPI clock is sent by DSP, in order to ensure stable data transmission, the clock line is usually pulled high after eight clocks to wait for the next frame of data. The slave needs to cache the data across clock domains to process the data.
[0004] In this case, FIFO resources are needed. FIFO (First Input First Output), that is, first in first out, is a type of memory, generally used for data buffering. The similarities between FIFO and RAM are that they can both store data and have signals to control writing and reading; the difference is that FIFO has no address, so it is not possible to arbitrarily specify to read a certain data. Data can only be output in the order in which the data is input, that is, first in first out, and reading and writing can be performed at the same time. If the data fills the depth of the FIFO, the data will not be able to enter again, and the original data will not be overwritten; the data read from the FIFO can only be read once, and the FIFO will be empty after reading it once, and data needs to be written to the FIFO again to read new data, otherwise the data read out will always be the data when the FIFO was read for the last time.
[0005] Therefore, when resources are limited, it is necessary to provide a multi-clock fitting detection technology for synchronous communication based on FPGA that can save FIFO. Summary of the invention
[0006] To overcome the deficiencies of the prior art, the present invention aims to provide a multi-clock fitting detection technology for synchronous communication based on FPGA.
[0007] In order to achieve the above object, the present invention adopts the following technical solution: The multi-clock fitting detection technology of synchronous communication based on FPGA includes the following steps: S1. Use the external clock of FPGA or PLL multiplication / division clock to sample the synchronous communication clock. S2, the sampling signal is continuously stored in n-level registers to eliminate metastable state; S3, performing an “OR” operation on the output waveform of the last-stage register and the synchronous communication clock to obtain a fitting clock; S4: Use the fitted clock as a new synchronous communication clock for data caching.
[0008] The above n is 5~8.
[0009] The present invention is beneficial in that: The invention discloses a multi-clock fitting detection technology for synchronous communication based on FPGA. When the SPI communication frequency is high, PLL frequency multiplication can be selected for synchronization. Then, the "metastable state" in the data transmission process is eliminated by "beating" the register to improve the sampling accuracy. The fitting clock obtained by performing an "OR" operation on the output waveform of the last-level register and the synchronous communication clock is used as a new synchronous communication clock for data caching.
[0010] The invention discloses a multi-clock fitting detection technology based on synchronous communication of FPGA, which can save FPGA FIFO and other resources in the communication process, effectively solve some cross-clock domain problems, and improve development efficiency; the technology consumes less resources and can flexibly configure the FPGA sampling clock. If the FPGA clock is fast enough, the delay between the fitted clock and the original SPI clock is very small, and the maximum delay is 1-2 1 / f FPGA Therefore, by adjusting f FPGA Changing the delay is very practical and widely applicable. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 Flowchart of multi-clock fitting detection technology.
[0012] Figure 2 The "ninth" clock for the fit. DETAILED DESCRIPTION
[0013] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0014] Take n=8 as an example, In SPI communication with FPGA as a slave, there are usually eight SPI clocks, and FPGA needs a "ninth" clock for data buffering.
[0015] The steps are: S1, use the external clock of FPGA or the clock f multiplied / divided by PLL FPGA Sample the synchronous communication clock fspi; if the SPI communication clock is f spi =XMHz, then the recommended FPGA sampling clock is f FPGA=8XMHz and higher, the external clock or PLL clock must be stable enough and fast enough, and the external clock or PLL clock signal must be of high quality and fast enough to fit a better waveform.
[0016] Assuming the sampling clock is 8XMHz, then the SPI communication single sampling clock requires n=f FPGA / fspi FPGA sampling clock, that is, n=8.
[0017] S2. The sampling signal is continuously stored in 5-8 level registers to eliminate metastable state and improve sampling accuracy.
[0018] S3, performing an “OR” operation on the output waveform of the last-stage register and the synchronous communication clock to obtain a fitting clock; S4: Use the fitted clock as a new synchronous communication clock for data caching.
[0019] As attached Figure 2 As shown, it is the fitted "ninth" clock, in the figure: rst_n is the reset signal, f_clk is the input clock, sck is the synchronization signal clock, n_clk is the output fitting clock, temp is a register group.
[0020] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form, and any technical solution obtained by equivalent replacement or equivalent transformation falls within the protection scope of the present invention.
Claims
1. Multi-clock fitting detection technology for synchronous communication based on FPGA, characterized in that: The following steps are involved: S1. Use the external clock of FPGA or PLL multiplication / division clock to sample the synchronous communication clock. S2, the sampling signal is continuously stored in n-level registers to eliminate metastable state; S3, performing an "OR" operation on the output waveform of the last-stage register and the synchronous communication clock to obtain a fitting clock; S4: Use the fitted clock as a new synchronous communication clock for data caching.
2. The multi-clock fitting detection technology according to claim 1, characterized in that: The n is 5~8.
