CN113615088B - Synchronization circuit and method across clock domains - Google Patents
Synchronization circuit and method across clock domains Download PDFInfo
- Publication number
- CN113615088B CN113615088B CN201980094534.6A CN201980094534A CN113615088B CN 113615088 B CN113615088 B CN 113615088B CN 201980094534 A CN201980094534 A CN 201980094534A CN 113615088 B CN113615088 B CN 113615088B
- Authority
- CN
- China
- Prior art keywords
- clock
- signal
- read
- sampling
- write
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03K—PULSE TECHNIQUE
- H03K19/00—Logic circuits, i.e. having at least two inputs acting on one output; Inverting circuits
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
- Dram (AREA)
Abstract
本申请实施例公开了一种跨时钟域同步电路,本申请跨时钟域同步电路包括时钟域通道电路、写地址产生电路、读地址产生电路和数据缓存电路,写地址产生电路用于根据写使能信号得到写地址,写地址用于控制数据缓存电路接收输入数据,输入数据处于写时钟域;时钟域通道电路用于对写使能信号进行采样以得到多个采样结果,并根据时钟相位差从多个采样结果中选择一个采样结果作为读使能信号,时钟相位差为处于写时钟域的写时钟信号和处于读时钟域的读时钟信号的相位差;读地址产生电路用于根据读使能信号得到读地址,读地址用于控制数据缓存电路产生输出数据,输出数据处于读时钟域;数据缓存电路用于根据写地址和读地址,将输入数据缓存并产生输出数据。
The embodiment of the present application discloses a cross-clock domain synchronization circuit. The cross-clock domain synchronization circuit of the present application includes a clock domain channel circuit, a write address generation circuit, a read address generation circuit, and a data cache circuit. The write address generation circuit is used to The write address is obtained from the enable signal, and the write address is used to control the data buffer circuit to receive input data, and the input data is in the write clock domain; the clock domain channel circuit is used to sample the write enable signal to obtain multiple sampling results, and according to the clock phase difference Select a sampling result from multiple sampling results as the read enable signal, and the clock phase difference is the phase difference between the write clock signal in the write clock domain and the read clock signal in the read clock domain; The read address is obtained from the energy signal, and the read address is used to control the data buffer circuit to generate output data, and the output data is in the read clock domain; the data buffer circuit is used to buffer the input data and generate output data according to the write address and the read address.
Description
技术领域technical field
本申请涉及电路领域,尤其涉及一种跨时钟域同步电路及其相关方法。The present application relates to the field of circuits, in particular to a synchronization circuit across clock domains and related methods.
背景技术Background technique
片上系统(system-on-chip,SOC)指的是在单个芯片上集成一个完整的系统,由于芯片上承载的功能越来越多,芯片内部也会有越来越多的时钟,每个时钟的工作频率都不一样,这就导致芯片内部有多个时钟域,当多个时钟域之间通信时,需要进行时钟域的同步才能完成跨时钟域的数据交互,异步电路处理技术可以完成这一过程。System-on-chip (SOC) refers to the integration of a complete system on a single chip. As more and more functions are carried on the chip, there will be more and more clocks inside the chip. Each clock The operating frequencies of different clock domains are different, which leads to multiple clock domains inside the chip. When communicating between multiple clock domains, synchronization of clock domains is required to complete data interaction across clock domains. Asynchronous circuit processing technology can complete this. a process.
一种典型的异步电路处理技术是异步先进先出(fist-in-fist-out,FIFO)技术,参照图1,首先写时钟域中写地址产生逻辑电路101产生二进制的写指针,将数据写入FIFO存储电路104,读时钟域的读地址产生逻辑电路103产生二进制的读指针,将数据从FIFO存储电路104中读出来,每进行一次读或写操作,相应的指针就递增一次,指向下一个内存地址。当满/空标识产生逻辑电路102产生读空标识时,不再进行读操作,但是可以进行写操作,当满/空标识产生逻辑电路102产生写满标识时,不再进行写操作,但是可以进行读操作。读空标识的产生需要将写时钟域的写指针同步到读时钟域,首先,为了避免出现毛刺,二进制写指针要先转化为格雷码,再将格雷码利用两级寄存器执行打两拍处理,或利用多级寄存器执行打多拍处理,随后将处理得到的写指针转化为二进制,并与二进制的读指针比较,当两指针的地址位相同,状态位也相同时产生读空信号,上述过程中,由于寄存器寄存数据需要保证数据的建立时间和保持时间,建立时间时指在时钟信号上升沿到来前,数据需要提前输入寄存器的时间,保持时间是上升沿到来后数据需要维持不变的时间,利用寄存器打一拍处理需要等到一个时钟周期,那么利用寄存器执行打两拍处理,或利用多个寄存器执行打两多处理时会对应产生两个或多个时钟周期的延时,写指针由写时钟域同步到读时钟域的过程需要至少两个时钟周期的延时。同样的,写满标识的产生需要将读时钟域的读指针同步到写时钟域,同步过程需要寄存器进行打两拍或打多拍处理,也有至少两个时钟周期的延时。A typical asynchronous circuit processing technology is an asynchronous first-in-first-out (fist-in-fist-out, FIFO) technology. Referring to FIG. into the
可见,写时钟域的写指针同步到读时钟域得到读空信号,会产生至少两个时钟周期的延时,同样的读时钟域的读指针同步到写时钟域得到写满信号,也会产生至少两个时钟周期的延时。写满标识会控制写指针的增加,读空标识也会控制读指针的增加,读写指针又会控制数据的写入和读取,从而控制了写时钟域的数据同步到读时钟域,因此两时钟域间数据的同步也会有至少两个时钟周期的延时。由于上述因素,如图1所示的异步FIFO在进行跨时钟域处理时存在较大的延迟,因此降低了数据跨时钟域处理的效率。It can be seen that the write pointer in the write clock domain is synchronized to the read clock domain to obtain a read empty signal, which will generate a delay of at least two clock cycles. The same read pointer in the read clock domain is synchronized to the write clock domain to obtain a write full signal. Delay of at least two clock cycles. The full mark will control the increase of the write pointer, and the read empty mark will also control the increase of the read pointer, and the read and write pointer will control the writing and reading of data, thereby controlling the synchronization of the data in the write clock domain to the read clock domain, so The synchronization of data between the two clock domains also has a delay of at least two clock cycles. Due to the above factors, the asynchronous FIFO shown in FIG. 1 has a relatively large delay in cross-clock domain processing, thus reducing the efficiency of data cross-clock domain processing.
发明内容Contents of the invention
本申请提供了的第一方面提供了一种跨时钟域同步电路,可以将输入数据由写时钟域同步到读时钟域,该跨时钟域同步电路包括时钟域通道电路、写地址产生电路、读地址产生电路以及数据缓存电路;写地址产生电路可以在写时钟信号驱动下,根据写使能信号得到写地址,写地址可以控制数据缓存电路接收输入数据,输入数据是写时钟域的数据;时钟域通道电路的两个输入端分别输入写使能信号和时钟相位差,时钟相位差指的是处于写时钟域的写时钟信号和处于读时钟域的读时钟信号之间的相位差,时钟域通道电路可以对写使能信号进行采样,得到采样信号集合,时钟域通道电路再根据时钟相位差从采样信号集合中选择采样信号作为读使能信号;读地址产生电路可以在读时钟信号驱动下,可以根据读使能信号得到读地址,读地址可以控制数据缓存电路产生输出数据,输出数据处于读时钟域,那么跨时钟域同步电路就完成了输入数据从写时钟域同步到读时钟域的过程。数据缓存电路根据写地址接收输入数据后缓存该输入数据,之后数据缓存电路再根据读地址产生输出数据。The first aspect provided by the present application provides a cross-clock domain synchronization circuit, which can synchronize input data from the write clock domain to the read clock domain. The cross-clock domain synchronization circuit includes a clock domain channel circuit, a write address generation circuit, a read The address generation circuit and the data cache circuit; the write address generation circuit can be driven by the write clock signal and obtain the write address according to the write enable signal, and the write address can control the data cache circuit to receive input data, and the input data is the data in the write clock domain; the clock The two input terminals of the domain channel circuit respectively input the write enable signal and the clock phase difference. The clock phase difference refers to the phase difference between the write clock signal in the write clock domain and the read clock signal in the read clock domain. The clock domain The channel circuit can sample the write enable signal to obtain a sample signal set, and the clock domain channel circuit selects the sample signal from the sample signal set as the read enable signal according to the clock phase difference; the read address generation circuit can be driven by the read clock signal, The read address can be obtained according to the read enable signal, and the read address can control the data buffer circuit to generate output data, and the output data is in the read clock domain, then the cross-clock domain synchronization circuit completes the process of synchronizing input data from the write clock domain to the read clock domain . The data buffer circuit receives input data according to the write address and buffers the input data, and then the data buffer circuit generates output data according to the read address.
本申请实施例具有以下优点:写地址产生电路根据写使能信号得到写地址,写地址用于控制数据数据缓存电路接收数据,数据缓存电路接收输入数据后将输入数据缓存,从而完成数据写入数据缓存电路的过程。时钟域通道电路可以将写使能信号采样得到多个采样结果,得到的多个采样结果中存在部分或全部的采样结果相对于写使能信号的延时在两个时钟周期内,其次,写时钟域的写时钟信号与读时钟域的读时钟信号之间的具有时钟相位差,根据该时钟相位差,从多个采样结果中选择一个读使能信号,选择得到的这个读使能信号与写使能信号的延时可以控制在两个时钟周期内。随后读地址产生电路可以根据读使能信号得到读地址,读地址用于控制数据缓存电路产生输出数据,从而完成数据的读取过程,那么由于读使能信号与写使能信号的延时控制在两个时钟周期内,那么两时钟域之间数据的同步也在两个时钟周期内,因此相对于现有两时钟域间数据的同步有至少两个时钟周期的延时的方案,本申请可以把数据同步的延时控制在两个时钟周期内,降低了数据同步的延时,进而提升了数据跨时钟域处理的效率。The embodiment of the present application has the following advantages: the write address generation circuit obtains the write address according to the write enable signal, the write address is used to control the data buffer circuit to receive data, and the data buffer circuit caches the input data after receiving the input data, thereby completing the data writing The process of data cache circuit. The clock domain channel circuit can sample the write enable signal to obtain multiple sampling results. Among the multiple sampling results obtained, some or all of the sampling results are delayed within two clock cycles relative to the write enable signal. Secondly, the write There is a clock phase difference between the write clock signal in the clock domain and the read clock signal in the read clock domain. According to the clock phase difference, a read enable signal is selected from multiple sampling results, and the selected read enable signal is the same as The delay of the write enable signal can be controlled within two clock cycles. Then the read address generation circuit can obtain the read address according to the read enable signal, and the read address is used to control the data cache circuit to generate output data, thereby completing the data read process, then due to the delay control of the read enable signal and the write enable signal Within two clock cycles, the synchronization of data between the two clock domains is also within two clock cycles. Therefore, compared with the existing scheme of delaying at least two clock cycles for data synchronization between the two clock domains, this application The data synchronization delay can be controlled within two clock cycles, which reduces the data synchronization delay and improves the efficiency of data cross-clock domain processing.
在本申请的一种可选实施方式中,时钟域通道电路具体包括多个触发器,多个触发器分别在可以在读时钟信号的上升沿和下降沿对写使能信号进行采样得到采样信号集合,采样信号集合中包括至少一个采样信号,时钟域通道电路还包括多路信号选择器,多路信号选择器可以根据时钟相位差,从预先设置的时钟相位差与写使能信号的映射关系中选择目标映射关系,随后再根据目标映射关系从采样信号集合中确定采样信号,并将确定的采样信号作为读使能信号。在本实施例中,多个触发器组可以采样得到采样信号集合,同时预先设置了时钟相位差与读使能信号的映射关系,那么时钟相位差变化确定的读使能信号也会发生变化,由此可以在不同时钟相位差条件下,从采样信号集合中选择对应的采样信号作为读使能信号,这样得到的读使能信号与写使能信号的时钟延迟可以控制在两个时钟周期,同时得到的读使能信号与写使能信号的时钟延迟也可以保证足够的时间将输入数据从写时钟域同步至读时钟域。In an optional implementation manner of the present application, the clock domain channel circuit specifically includes a plurality of flip-flops, and the plurality of flip-flops can respectively sample the write enable signal on the rising edge and the falling edge of the read clock signal to obtain a sampling signal set , the sampling signal set includes at least one sampling signal, and the clock domain channel circuit further includes a multiplexer, and the multiplexer can select from the preset mapping relationship between the clock phase difference and the write enable signal according to the clock phase difference The target mapping relationship is selected, and then the sampling signal is determined from the sampling signal set according to the target mapping relationship, and the determined sampling signal is used as the read enable signal. In this embodiment, multiple flip-flop groups can be sampled to obtain a set of sampling signals, and the mapping relationship between the clock phase difference and the read enable signal is preset, so the read enable signal determined by the change of the clock phase difference will also change. Therefore, under different clock phase difference conditions, the corresponding sampling signal can be selected from the sampling signal set as the read enable signal, so that the clock delay between the read enable signal and the write enable signal can be controlled within two clock cycles, The simultaneously obtained clock delay of the read enable signal and the write enable signal can also ensure enough time to synchronize the input data from the write clock domain to the read clock domain.
在本申请的一种可选实施方式中,跨时钟域同步电路还包括鉴相器;鉴相器,可以依据接收的写时钟信号和接收的读时钟信号确定两者的时钟相位差;鉴相器,还可以根据写时钟信号产生写使能信号,并且在时钟相位差处于稳定状态时,写使能信号才有效,否则,写使能信号无效。鉴相器输出时钟相位差和写使能信号给时钟域通道电路。在本实施例中,可以通过鉴相器产生时钟相位差和写使能信号,方案结构更加完整,有利于方案实施。In an optional implementation manner of the present application, the cross-clock domain synchronization circuit further includes a phase detector; the phase detector can determine the clock phase difference between the received write clock signal and the received read clock signal; the phase detector The device can also generate a write enable signal according to the write clock signal, and the write enable signal is only valid when the clock phase difference is in a stable state, otherwise, the write enable signal is invalid. The phase detector outputs the clock phase difference and the write enable signal to the clock domain channel circuit. In this embodiment, the clock phase difference and the write enable signal can be generated through the phase detector, and the solution structure is more complete, which is beneficial to the implementation of the solution.
在本申请的一种可选实施方式中,时钟域通道电路包括第一触发器、第二触发器、第三触发器以及第四触发器;第一触发器,接收鉴相器产生的写使能信号后,可以读时钟信号的下降沿对写使能信号采样得到第一采样信号,第二触发器,可以在读时钟信号的上升沿对第一采样信号采样得到第二采样信号;第三触发器,接收鉴相器产生的写使能信号后,可以在读时钟信号的上升沿对写使能信号采样得到第三采样信号;第四触发器,可以在读时钟信号的上升沿对第三采样信号采样得到第四采样信号,第一采样信号、第二采样信号、第三采样信号以及第四采样信号均属于采样信号集合。相对于现有技术利用寄存器进行写指针或读指针同步,寄存器需要保证数据的建立时间和保持时间,那么需要等待至少两个时钟周期,而本实施例中,用触发器对写使能信号采样得到采样信号集合,采样信号集合中的采样信号可以作为读使能信号,由于触发器在时钟信号的上升沿和下降沿均可以对信号采样,因此由写使能信号得到读使能信号可以控制在两个时钟周期内,对应的数据由写时钟域同步到读时钟域也可以控制在两个时钟周期内,相对于现有技术减小了数据同步的延时。In an optional implementation manner of the present application, the clock domain channel circuit includes a first flip-flop, a second flip-flop, a third flip-flop, and a fourth flip-flop; the first flip-flop receives the write command generated by the phase detector After enabling the signal, you can sample the write enable signal on the falling edge of the read clock signal to obtain the first sampling signal, and the second flip-flop can sample the first sampling signal on the rising edge of the read clock signal to obtain the second sampling signal; the third trigger After receiving the write enable signal generated by the phase detector, the write enable signal can be sampled on the rising edge of the read clock signal to obtain the third sampling signal; the fourth flip-flop can be used to sample the third sampling signal on the rising edge of the read clock signal The fourth sampling signal is obtained by sampling, and the first sampling signal, the second sampling signal, the third sampling signal and the fourth sampling signal all belong to the sampling signal set. Compared with the prior art using registers to synchronize write pointers or read pointers, the registers need to ensure the setup time and hold time of the data, so at least two clock cycles need to be waited, and in this embodiment, the write enable signal is sampled with a flip-flop The sampling signal set is obtained, and the sampling signal in the sampling signal set can be used as a read enable signal. Since the flip-flop can sample the signal at the rising edge and the falling edge of the clock signal, the read enable signal obtained by the write enable signal can control Within two clock cycles, the synchronization of corresponding data from the write clock domain to the read clock domain can also be controlled within two clock cycles, which reduces the delay of data synchronization compared to the prior art.
在本申请的一种可选实施方式中,时钟域通道电路还包括多路信号选择器,多路信号选择器的两个输入端分别输入采样信号集合和时钟相位差,输出读使能信号。多路信号选择器,用于当时钟相位差的取值范围在[0T,1/4T)的情况下,从采样信号集合中选择第二采样信号作为读使能信号,其中,由于写时钟的时钟周期可以与读时钟域时钟相同,T为写时钟域的时钟周期或读时钟域的时钟周期;或,多路信号选择器,用于当时钟相位差为[1/4T,1/2T)的情况下,从采样信号集合中选择第二采样信号或第四采样信号作为读使能信号,这里第二采样信号和第四采样信号相对于写使能信号延迟的时钟周期是相同的,选择第二采样信号或第四采样信号均可;或,多路信号选择器,用于当时钟相位差为[1/2T,3/4T)的情况下,从采样信号集合中选择第四采样信号作为读使能信号;或,多路信号选择器,用于当时钟相位差的取值大于或等于3/4个时钟周期T的情况下,从采样信号集合中选择第二采样信号或所述第三采样信号作为读使能信号,这里第二采样信号和第三采样信号相对于写使能信号延迟的时钟周期是相同的,选择第二采样信号或第三采样信号均可。在本实施例中,介绍了四种时钟相位差情况下选择读使能信号的具体方式,涵盖了全部可能的时钟相位差情况,有利用方案灵活实施,选择得到的读使能信号与写使能信号的时钟延迟可以控制在两个时钟周期,同时选择得到的读使能信号与写使能信号的时钟延迟也可以保证足够的时间将输入数据从写时钟域同步至读时钟域。In an optional implementation manner of the present application, the clock domain channel circuit further includes a multiplexer, and two input terminals of the multiplexer respectively input the sampling signal set and the clock phase difference, and output the read enable signal. The multiplexer is used to select the second sampling signal from the sampling signal set as the read enable signal when the value range of the clock phase difference is [0T, 1/4T), wherein, due to the write clock The clock cycle can be the same as the read clock domain clock, T is the clock cycle of the write clock domain or the clock cycle of the read clock domain; or, a multiplexer, used when the clock phase difference is [1/4T, 1/2T) In the case of , select the second sampling signal or the fourth sampling signal from the sampling signal set as the read enable signal, where the clock cycle of the second sampling signal and the fourth sampling signal relative to the write enable signal delay is the same, select Either the second sampling signal or the fourth sampling signal can be used; or, the multiplexer is used to select the fourth sampling signal from the sampling signal set when the clock phase difference is [1/2T, 3/4T). As a read enable signal; or, a multiplexer, used to select the second sampling signal or the The third sampling signal is used as the read enable signal, where the second sample signal and the third sample signal are delayed by the same clock period relative to the write enable signal, and either the second sample signal or the third sample signal can be selected. In this embodiment, the specific method of selecting the read enable signal under the four kinds of clock phase differences is introduced, covering all possible clock phase differences, and the flexible implementation of the utilization scheme. The selected read enable signal and write enable signal The clock delay of the enable signal can be controlled within two clock cycles, and the selected clock delay of the read enable signal and the write enable signal can also ensure enough time to synchronize the input data from the write clock domain to the read clock domain.
在本申请的一种可选实施方式中,跨时钟域同步电路还包括写时钟域锁相环和读时钟域锁相环,写时钟域锁相环和读时钟域锁相环连接在同一个时钟源上;写时钟域锁相环,可以根据时钟源信号得到写时钟信号,写时钟信号处于写时钟域;读时钟域锁相环,可以根据该时钟源信号得到读时钟信号,读时钟信号处于读时钟域。在本实施例中,写时钟域锁相环和读时钟域锁相环连接同一个时钟源,以保证写时钟域的时钟与读时钟域的时钟是同源时钟,可以保证这两个时钟没有频偏,那么得到的写时钟信号和读时钟信号频率相等或得到的写时钟信号和读时钟信号的分频比为整数倍的,同时这两个时钟信号之间相位差随机。In an optional implementation manner of the present application, the cross-clock domain synchronization circuit further includes a write clock domain PLL and a read clock domain PLL, and the write clock domain PLL and the read clock domain PLL are connected to the same On the clock source; the write clock domain PLL can obtain the write clock signal according to the clock source signal, and the write clock signal is in the write clock domain; the read clock domain PLL can obtain the read clock signal according to the clock source signal, and the read clock signal in the read clock domain. In this embodiment, the PLL in the write clock domain and the PLL in the read clock domain are connected to the same clock source to ensure that the clock in the write clock domain and the clock in the read clock domain are homologous clocks, and that the two clocks are not Frequency deviation, then the frequency of the obtained write clock signal and the read clock signal are equal or the frequency division ratio of the obtained write clock signal and the read clock signal is an integer multiple, and the phase difference between the two clock signals is random.
在本申请的一种可选实施方式中,数据缓存电路包括多个触发器组、输入多路数据选择器和输出多路数据选择器;输入数据选择器包括与多个触发器组的多个输入端一一对应连接的多个输出端口,输出多路数据选择器包括与多个触发器组的多个输出端一一对应连接的多个输入端口;输入多路数据选择器,用于获取输入数据后,根据写地址,从某一输出端口输出缓存数据,不断改变写地址,就可以从输入多路数据选择器的多个输出端口得到多路缓存数据;多个触发器组用于在写时钟信号的驱动下,接收多路缓存数据,并将从多个输入多路数据选择器输出端口输出的多路缓存数据分别在缓存不同的触发器组中;输出多路数据选择器,接收多个触发器组输出的多路缓存数据,并根据读地址,从多路缓存数据中选择一路缓存数据作为输出数据输出,读地址不同,选择得到的输出数据不同。在本实施例中,由于读使能信号是跟随时钟相位差变化的,读使能信号又可以得到读地址,那么不同时钟相位差条件下,读地址也不同,读地址作为携带地址信息的读地址,可见读地址有多种可能的情况,那么本申请在数据同步上通过输入多路数据选择器得到多路缓存数据,多路缓存数据缓存于多个触发器组的不同触发器组中,读地址变化时就可以选择多个触发器组中对应触发器组的缓存数据作为输出数据。可见时钟相位差变化,读地址变化,选择得到的输出数据也变化,那么本申请的方案可以满足不同时钟相位差条件下数据同步的需求。In an optional implementation manner of the present application, the data buffer circuit includes a plurality of flip-flop groups, an input multiplexer, and an output multiplexer; the input data selector includes multiple A plurality of output ports connected in one-to-one correspondence between the input terminals, the output multiplexer includes a plurality of input ports connected in one-to-one correspondence with a plurality of output terminals of a plurality of flip-flop groups; the input multiplexer is used to obtain After the data is input, according to the write address, output the cached data from a certain output port, and continuously change the write address, you can get multiple cached data from multiple output ports of the input multiplexer; multiple flip-flop groups are used in Driven by the write clock signal, the multi-channel buffer data is received, and the multi-channel buffer data output from the output ports of the multiple input multiplexers are respectively buffered in different flip-flop groups; the output multiplexer receives The multi-way cache data output by multiple flip-flop groups, and according to the read address, select one line of cache data from the multi-way cache data as the output data output, and the output data obtained by selection is different for different read addresses. In this embodiment, since the read enable signal changes with the clock phase difference, and the read enable signal can obtain the read address, then under different clock phase difference conditions, the read address is also different, and the read address is used as the read address carrying address information. address, it can be seen that the read address has multiple possible situations, so the application obtains multi-way cache data by inputting the multi-way data selector on data synchronization, and the multi-way cache data is cached in different trigger groups of multiple trigger groups, When the read address changes, the cached data corresponding to the flip-flop group in the plurality of flip-flop groups can be selected as the output data. It can be seen that the clock phase difference changes, the read address changes, and the selected output data also changes, so the solution of this application can meet the data synchronization requirements under different clock phase difference conditions.
在本申请的一种可选实施方式中,跨时钟域同步电路还包括第五D触发器;第五D触发器,用于在读时钟信号的驱动下,接收输出多路数据选择器选择的输出数据,缓存并输出该输出数据。在本实施例中,利用第五D触发器对输出多路数据选择器选择的输出数据缓存并输出,第五D触发器可以防止数据传输过程中,外来干扰对数据传输正确性的影响。In an optional implementation manner of the present application, the cross-clock domain synchronization circuit further includes a fifth D flip-flop; the fifth D flip-flop is used to receive the output selected by the output multiplexer under the drive of the read clock signal data, caches and outputs that output data. In this embodiment, the fifth D flip-flop is used to buffer and output the output data selected by the output multiplexer, and the fifth D flip-flop can prevent external interference from affecting the correctness of data transmission during data transmission.
本申请第二方面提供了一种跨时钟域同步方法,该方法包括:根据写使能信号得到写地址,写地址携带地址信息,可以根据写地址的控制来接收输入数据,并缓存该输入数据,从而完成数据的写入过程,这里的输入数据处于写时钟域,同时可以对写使能信号进行采样以得到多个采样结果,并根据时钟相位差从多个采样结果中选择一个采样结果作为读使能信号,其中,时钟相位差为处于写时钟域的写时钟信号和处于读时钟域的读时钟信号的相位差;根据读使能信号得到读地址,根据读地址的控制将缓存的输入数据输出,从而产生输出数据,以完成数据的读取过程,输出数据处于读时钟域。The second aspect of the present application provides a cross-clock domain synchronization method, which includes: obtaining a write address according to the write enable signal, the write address carries address information, and can receive input data according to the control of the write address, and cache the input data , so as to complete the data writing process. The input data here is in the write clock domain. At the same time, the write enable signal can be sampled to obtain multiple sampling results, and one sampling result is selected from the multiple sampling results according to the clock phase difference as The read enable signal, wherein the clock phase difference is the phase difference between the write clock signal in the write clock domain and the read clock signal in the read clock domain; the read address is obtained according to the read enable signal, and the buffered input is controlled according to the read address Data output, thereby generating output data to complete the data reading process, and the output data is in the read clock domain.
本实施例具有以下优点:根据写使能信号得到写地址,可以根据写地址的控制来接收并缓存输入数据,从而完成数据的写入过程。由写使能信号采样得到多个采样结果,得到的多个采样结果中存在部分或全部的采样结果相对于写使能信号的延时在两个时钟周期内,其次,写时钟域的写时钟信号与读时钟域的读时钟信号之间的具有时钟相位差,根据该时钟相位差,从多个采样结果中选择一个读使能信号,选择得到的这个读使能信号与写使能信号的延时可以控制在两个时钟周期内。随后根据读使能信号得到读地址,根据读地址的控制将缓存的输入数据输出以产生输出数据,完成数据读取过程,那么由于读使能信号与写使能信号的延时控制在两个时钟周期内,那么两时钟域之间数据的同步也在两个时钟周期内,因此相对于现有两时钟域间数据的同步有至少两个时钟周期的延时的方案,本申请可以把数据同步的延时控制在两个时钟周期内,降低了数据同步的延时,进而提升了数据跨时钟域处理的效率。This embodiment has the following advantages: the write address is obtained according to the write enable signal, and the input data can be received and buffered according to the control of the write address, thereby completing the data writing process. Multiple sampling results are obtained by sampling the write enable signal. Among the multiple sampling results obtained, the delay of some or all of the sampling results relative to the write enable signal is within two clock cycles. Secondly, the write clock in the write clock domain There is a clock phase difference between the signal and the read clock signal in the read clock domain. According to the clock phase difference, a read enable signal is selected from multiple sampling results, and the selected read enable signal and write enable signal are The delay can be controlled within two clock cycles. Then obtain the read address according to the read enable signal, output the buffered input data to generate output data according to the control of the read address, and complete the data reading process, then the delay between the read enable signal and the write enable signal is controlled within two clock cycle, the synchronization of data between the two clock domains is also within two clock cycles, so compared with the existing scheme of delaying at least two clock cycles for data synchronization between the two clock domains, this application can transfer the data The synchronization delay is controlled within two clock cycles, which reduces the data synchronization delay and improves the efficiency of data cross-clock domain processing.
在本申请的一种可选实施方式中,所述对所述写使能信号进行采样以得到多个采样结果包括:在读时钟信号的上升沿对写使能信号进行采样,同时在读时钟信号的下降沿对写使能信号进行采样,可以得到多个采样结果。在本实施例中,相对于现有技术利用寄存器进行写指针或读指针同步,寄存器需要保证数据的建立时间和保持时间,那么需要等待至少两个时钟周期,而本实施例中,在读时钟信号的上升沿和下降沿均可以对信号采样,采样得到的信号可以控制在两个时钟周期内,对应的数据由写时钟域同步到读时钟域也可以控制在两个时钟周期内,相对于现有技术减小了数据同步的延时。In an optional implementation manner of the present application, the sampling the write enable signal to obtain multiple sampling results includes: sampling the write enable signal at the rising edge of the read clock signal, and simultaneously sampling the write enable signal at the rising edge of the read clock signal The falling edge samples the write enable signal, and multiple sampling results can be obtained. In this embodiment, compared with the prior art using registers to synchronize write pointers or read pointers, the registers need to ensure the setup time and hold time of the data, so it is necessary to wait for at least two clock cycles, and in this embodiment, the read clock signal Both the rising and falling edges of the clock can sample the signal, and the sampled signal can be controlled within two clock cycles, and the corresponding data can be synchronized from the write clock domain to the read clock domain within two clock cycles. There are technologies that reduce the delay of data synchronization.
在本申请的一种可选实施方式中,在读时钟信号的上升沿和下降沿分别对写使能信号进行采样,以得到多个采样结果具体包括:在读时钟信号的下降沿对写使能信号进行采样,可以得到第一采样信号;在读时钟信号的上升沿对第一采样信号进行采样,可以得到第二采样信号;在读时钟信号的上升沿对写使能信号进行采样,可以得到第三采样信号;在读时钟信号的上升沿对第三采样信号进行采样,可以得到第四采样信号,多个采样结果具体为得到的第一采样信号、第二采样信号、第三采样信号以及第四采样信号。在本实施例中,相对于现有技术利用寄存器进行写指针或读指针同步,寄存器需要保证数据的建立时间和保持时间,那么需要等待至少两个时钟周期,而本实施例中,在读时钟信号的上升沿和下降沿均可以对信号采样,采样得到的信号可以控制在两个时钟周期内,对应的数据由写时钟域同步到读时钟域也可以控制在两个时钟周期内,相对于现有技术减小了数据同步的延时。In an optional implementation manner of the present application, sampling the write enable signal at the rising edge and the falling edge of the read clock signal respectively, so as to obtain multiple sampling results specifically includes: sampling the write enable signal at the falling edge of the read clock signal Sampling can obtain the first sampling signal; sampling the first sampling signal at the rising edge of the read clock signal can obtain the second sampling signal; sampling the write enable signal at the rising edge of the read clock signal can obtain the third sampling signal signal; the third sampling signal is sampled at the rising edge of the read clock signal to obtain the fourth sampling signal, and the multiple sampling results are specifically the obtained first sampling signal, second sampling signal, third sampling signal and fourth sampling signal . In this embodiment, compared with the prior art using registers to synchronize write pointers or read pointers, the registers need to ensure the setup time and hold time of the data, so it is necessary to wait for at least two clock cycles, and in this embodiment, the read clock signal Both the rising and falling edges of the clock can sample the signal, and the sampled signal can be controlled within two clock cycles, and the corresponding data can be synchronized from the write clock domain to the read clock domain within two clock cycles. There are technologies that reduce the delay of data synchronization.
在本申请的一种可选实施方式中,根据时钟相位差从多个采样结果中选择一个采样结果作为读使能信号包括:在时钟相位差的取值范围在[0T,1/4T)的情况下,从多个采样结果中选择第二采样信号作为读使能信号,其中,由于写时钟域的时钟信号和读时钟域的时钟信号由同一时钟源产生,写时钟域的时钟周期或读时钟域的时钟周期相同,T可以为写时钟域的时钟周期或读时钟域的时钟周期;或,在时钟相位差的取值范围在[1/4T,1/2T)的情况下,从多个采样结果中选择第二采样信号或第四采样信号作为读使能信号;或,在时钟相位差的取值范围在[1/2T,3/4T)的情况下,从多个采样结果中选择第四采样信号作为读使能信号;或,在时钟相位差的取值大于或等于3/4个时钟周期T的情况下,从多个采样结果中选择第二采样信号或第三采样信号作为读使能信号。在本实施例中,介绍了四种时钟相位差情况下选择读使能信号的具体方式,涵盖了全部可能的时钟相位差情况,有利用方案灵活实施,选择得到的读使能信号与写使能信号的时钟延迟可以控制在两个时钟周期,同时选择得到的读使能信号与写使能信号的时钟延迟也可以保证足够的时间将输入数据从写时钟域同步至读时钟域。In an optional implementation manner of the present application, selecting a sampling result from a plurality of sampling results according to the clock phase difference as the read enable signal includes: In this case, the second sampling signal is selected from multiple sampling results as the read enable signal, wherein, since the clock signal of the write clock domain and the clock signal of the read clock domain are generated by the same clock source, the clock cycle of the write clock domain or the read The clock periods of the clock domains are the same, and T can be the clock period of the write clock domain or the clock period of the read clock domain; or, when the value range of the clock phase difference is [1/4T, 1/2T), from multiple Select the second sampling signal or the fourth sampling signal as the read enable signal from one sampling result; or, when the value range of the clock phase difference is in [1/2T, 3/4T), from multiple sampling results Select the fourth sampling signal as the read enable signal; or, when the value of the clock phase difference is greater than or equal to 3/4 clock cycle T, select the second sampling signal or the third sampling signal from multiple sampling results as a read enable signal. In this embodiment, the specific method of selecting the read enable signal under the four kinds of clock phase differences is introduced, covering all possible clock phase differences, and the flexible implementation of the utilization scheme. The selected read enable signal and write enable signal The clock delay of the enable signal can be controlled within two clock cycles, and the selected clock delay of the read enable signal and the write enable signal can also ensure enough time to synchronize the input data from the write clock domain to the read clock domain.
在本申请的一种可选实施方式中,所述方法还包括:根据写时钟信号写时钟信号和读时钟域的读时钟信号确定两时钟信号之间的时钟相位差;根据写时钟信号产生写使能信号,其中,当写时钟信号与读时钟信号之间的时钟相位差处于稳定状态时,写使能信号有效,当写时钟信号与读时钟信号之间的时钟相位差不处于稳定状态时,写使能信号无效。在本实施例中,可以介绍了时钟相位差以及写使能信号的获取方式,写使能信号可以用于本申请的数据同步过程,在时钟相位差稳定时写使能信号才有效,可以避免时钟相位差不稳定时数据同步发生错误。In an optional implementation manner of the present application, the method further includes: determining the clock phase difference between the write clock signal and the read clock signal in the read clock domain according to the write clock signal; generating a write clock signal according to the write clock signal. Enable signal, wherein, when the clock phase difference between the write clock signal and the read clock signal is in a stable state, the write enable signal is valid, and when the clock phase difference between the write clock signal and the read clock signal is not in a stable state , the write enable signal is invalid. In this embodiment, the acquisition method of the clock phase difference and the write enable signal can be introduced. The write enable signal can be used in the data synchronization process of this application. The write enable signal is valid only when the clock phase difference is stable, which can avoid Data synchronization error occurs when the clock phase difference is unstable.
本申请第三方面提供了一种芯片,该芯片包括本申请第一方面以及其任一种实现方式所述的跨时钟域同步电路。The third aspect of the present application provides a chip, which includes the cross-clock domain synchronization circuit described in the first aspect of the present application and any implementation manner thereof.
本申请实施例具有以下优点:写地址产生电路根据写使能信号得到写地址,写地址用于控制数据数据缓存电路接收数据,数据缓存电路接收输入数据后将输入数据缓存,从而完成数据写入数据缓存电路的过程。时钟域通道电路可以将写使能信号采样得到多个采样结果,得到的多个采样结果中存在部分或全部的采样结果相对于写使能信号的延时在两个时钟周期内,其次,写时钟域的写时钟信号与读时钟域的读时钟信号之间的具有时钟相位差,根据该时钟相位差,从多个采样结果中选择一个读使能信号,选择得到的这个读使能信号与写使能信号的延时可以控制在两个时钟周期内。随后读地址产生电路可以根据读使能信号得到读地址,读地址用于控制数据缓存电路产生输出数据,从而完成数据的读取过程,那么由于读使能信号与写使能信号的延时控制在两个时钟周期内,那么两时钟域之间数据的同步也在两个时钟周期内,因此相对于现有两时钟域间数据的同步有至少两个时钟周期的延时的方案,本申请可以把数据同步的延时控制在两个时钟周期内,降低了数据同步的延时,进而提升了数据跨时钟域处理的效率。The embodiment of the present application has the following advantages: the write address generation circuit obtains the write address according to the write enable signal, the write address is used to control the data buffer circuit to receive data, and the data buffer circuit caches the input data after receiving the input data, thereby completing the data writing The process of data cache circuit. The clock domain channel circuit can sample the write enable signal to obtain multiple sampling results. Among the multiple sampling results obtained, some or all of the sampling results are delayed within two clock cycles relative to the write enable signal. Secondly, the write There is a clock phase difference between the write clock signal in the clock domain and the read clock signal in the read clock domain. According to the clock phase difference, a read enable signal is selected from multiple sampling results, and the selected read enable signal is the same as The delay of the write enable signal can be controlled within two clock cycles. Then the read address generation circuit can obtain the read address according to the read enable signal, and the read address is used to control the data cache circuit to generate output data, thereby completing the data read process, then due to the delay control of the read enable signal and the write enable signal Within two clock cycles, the synchronization of data between the two clock domains is also within two clock cycles. Therefore, compared with the existing scheme of delaying at least two clock cycles for data synchronization between the two clock domains, this application The data synchronization delay can be controlled within two clock cycles, which reduces the data synchronization delay and improves the efficiency of data cross-clock domain processing.
附图说明Description of drawings
图1为现有异步FIFO的结构图;Fig. 1 is the structural diagram of existing asynchronous FIFO;
图2为本申请跨时钟域同步电路的结构图;FIG. 2 is a structural diagram of the cross-clock domain synchronization circuit of the present application;
图3为本申请时钟域通道电路的结构图;Fig. 3 is the structural diagram of the clock domain channel circuit of the present application;
图4(a)为本申请读写时钟域的一种相位关系;Fig. 4 (a) is a kind of phase relationship of the read-write clock domain of the present application;
图4(b)为本申请读写时钟域的另一种相位关系;Fig. 4 (b) is another kind of phase relationship of the read-write clock domain of the present application;
图4(c)为本申请读写时钟域的另一种相位关系;Fig. 4 (c) is another kind of phase relationship of the read-write clock domain of the present application;
图4(d)为本申请读写时钟域的另一种相位关系;Fig. 4 (d) is another kind of phase relationship of the read-write clock domain of the present application;
图5(a)为本申请的一种信号采样结果;Fig. 5 (a) is a kind of signal sampling result of the present application;
图5(b)为本申请的另一种信号采样结果;Fig. 5 (b) is another kind of signal sampling result of the present application;
图5(c)为本申请的另一种信号采样结果;Fig. 5 (c) is another kind of signal sampling result of the present application;
图5(d)为本申请的另一种信号采样结果。Fig. 5(d) is another signal sampling result of the present application.
具体实施方式Detailed ways
本申请提供了一种跨时钟域同步电路,可以应用于现场可编程门阵(field-programmable gate array,FPGA),也可以应用于专用集成电路(application specificintegrated circuits,ASIC)芯片,还可以应用于其他设备,此处不作限定。The present application provides a cross-clock domain synchronization circuit, which can be applied to field-programmable gate array (field-programmable gate array, FPGA), and can also be applied to application specific integrated circuits (application specific integrated circuits, ASIC) chips, and can also be applied to Other devices are not limited here.
参照图2,本申请的跨时钟域同步电路包括写地址产生电路01、读地址产生电路02以及数据缓存电路,其中数据缓存电路包括电路多个触发器组05、输入多路数据选择器06(multiplexer,MUX)以及输出多路数据选择器07,跨时钟域同步电路还包括第五D触发器08、鉴相器03、时钟域通道电路04、写时钟域锁相环09(phase locked loop,PLL)和读时钟域锁相环010。Referring to Fig. 2, the cross-clock domain synchronous circuit of the present application comprises write
首先,写时钟域锁相环09可以产生写时钟域的写时钟信号,读时钟域锁相环010可以产生读时钟域的读时钟信号,写时钟域锁相环09的输入端和读时钟域锁相环010的输入端连接同一个时钟源,以保证写时钟域的时钟与读时钟域的时钟是同源时钟,其目的是确保这两个时钟没有频偏,产生频率相等的写时钟信号和读时钟信号,或产生分频比为整数倍的写时钟信号和读时钟信号,同时写时钟信号和读时钟信号之间时钟相位差随机。First, the write
写地址产生电路01:可以在写时钟域的写时钟信号的驱动下,当写使能信号有效时,连续产生写指针,写地址可以作为写地址,其中,写使能信号可以由鉴相器03产生。写地址产生电路01的一个输入端口与写时钟域锁相环09的输出端口连接,可以接收写时钟信号,写地址产生电路01的另一个输入端口与鉴相器03的第一输出端口连接,可以接收写使能信号,写地址产生电路01的输出端口与输入多路数据选择器06的输入端口连接,可以输出写地址。Write address generation circuit 01: driven by the write clock signal in the write clock domain, when the write enable signal is valid, the write pointer can be continuously generated, and the write address can be used as the write address, wherein the write enable signal can be generated by the
数据缓存电路包括输入多路数据选择器06、多个触发器组05以及输出多路数据选择器07,数据缓存电路可以根据写地址接收输入数据,随后缓存输入数据,数据缓存电路也可以根据读地址产生输出数据,具体过程为:The data cache circuit includes an
写地址输入至输入多路数据选择器06,输入多路数据选择器06获取输入数据后,可以根据写地址所指示的地址信息,从输入多路数据选择器06的某一输出端口输出缓存数据,从而将缓存数据写入多个触发器组05的某一触发器组中,写地址所指示的地址信息可以指示将缓存数据写入多个触发器组05的特定触发器组,某一触发器组与某一输出端口是相对应的。写地址指示的地址信息是可变的,那么输入多路数据选择器06可以根据写地址的指示,分别从输入多路数据选择器06的多个端口输出缓存数据,多个端口输出的缓存数据分别对应进入多个触发器组05。输入多路数据选择器06的两个数据端分别接收输入数据和写地址产生电路01产生的写地址,多个触发器组05的多个输入端口与输入数据多路选择06的多个输出端口一一对应连接,可以接收缓存数据,多个触发器组05的多个输出端口与输出多路数据选择器07的多个输入端口一一对应连接,可以输出缓存数据。The write address is input to the
进一步的,关于上述多个触发器组05,图2中以4组D触发器组为例,每组触发器组中D触发器的个数由输入数据的位宽决定,四组D触发器组的触发输入端口连接到写时钟信号,在写时钟信号驱动下,输入多路数据选择器06处理得到的四路缓存数据分别输入到四组D触发器组。Further, regarding the above-mentioned multiple flip-
多个触发器组05缓存多路缓存数据,随后将多路缓存数据输出至输出多路数据选择器07,输出多路数据选择器07,可以根据读指针的指示从多路缓存数据中选择一路缓存数据作为输出数据输出,具体的读指针可以作为读地址,读地址携带有地址信息,读地址所指示的地址信息可以指示输出多路数据选择器07输出从多个触发器组05的特定D触发器组中获取到的缓存数据,读地址不同,输出多路数据选择器07选择输出的缓存数据不同。输出多路数据选择器07一个输入端口与多个触发器组05的输出端口连接,可以接收缓存数据,输出多路数据选择器07的另一个输入端口与读地址产生电路02的输出端口连接,可以接收读地址。A plurality of flip-
输出多路数据选择器07产生的输出数据输入至第五D触发器08,在读时钟信号驱动下,第五D触发器08可以缓存并输出数据缓存电路产生的输出数据,第五D触发器08可以防止数据传输过程中,外来干扰对数据传输正确性的影响。The output data generated by the
鉴相器03(phase detector,PD),可以计算写时钟域的写时钟信号和读时钟域的读时钟信号之间的时钟相位差,当写时钟域和读时钟域稳定后,鉴相器03进入工作状态,经过若干个时钟周期后,鉴相器03产生稳定的时钟相位差输出至时钟域通道电路04。同时鉴相器03还可以对写时钟域的写时钟信号进行处理得到写使能信号,并将写使能信号输出至写地址产生电路01和时钟域通道电路04,写使能信号作为鉴相器03稳定输出时钟相位差的状态指示,当时钟相位差处于稳定状态时,写使能信号有效,否则写使能信号无效。鉴相器03的一个输入端连接到写时钟域锁相环09,以便接收写时钟信号,鉴相器03的另一个输入端连接到写时读时钟域锁相环010,以便接收读时钟信号,鉴相器03的第一输出端口连接到写地址产生电路01的另一个输入端口以及时钟域通道电路04的第一输入端口,可以输出写使能信号,鉴相器03的第二输出端口连接到时钟域通道电路04的第二输入端口,可以输出时钟相位差。The phase detector 03 (phase detector, PD) can calculate the clock phase difference between the write clock signal in the write clock domain and the read clock signal in the read clock domain. When the write clock domain and the read clock domain are stable, the
时钟域通道电路04电路:时钟域通道电路04可以根据时钟相位差的四种状态将写使能由写时钟域同步到读时钟域,得到读使能信号,然后读使能信号输出至读地址产生电路02,读地址产生电路02可以在读时钟域的读时钟信号的驱动下,当读使能信号有效时,连续产生读指针,作为读地址输出至多路数据选择器07。时钟域通道电路04的输出端口连接到读地址产生电路02的一个输入端口,可以输出读使能信号,读地址产生电路02的另一个输入端口连接读时钟域锁相环010的输出端口,可以接收读时钟信号,读地址产生电路02的输出端口连接到输出多路数据选择器07的另一个输入端口,可以输出读地址。Clock
基于上述结构,写地址产生电路01产生写地址,将数据写入数据缓存电路,时钟域通道电路04可以根据写使能信号和时钟相位差得到读使能信号,从而将写使能信号从写时钟域同步到了读时钟域,读地址产生电路02根据读使能信号得到读地址,将数据从数据缓存电路中读出来,从而实现了输入数据从写时钟域同步到读时钟域。Based on the above structure, the write
同时,由于读使能信号是跟随时钟相位差变化的,读使能信号又可以得到读指针,那么不同时钟相位差条件下,读指针也不同,读地址变化,输出多路数据选择器07选择得到的输出数据也变化,因此本申请的方案设置四路缓存数据可以满足不同时钟相位差条件下数据同步的需求。At the same time, since the read enable signal changes with the clock phase difference, and the read enable signal can obtain the read pointer, then under different clock phase difference conditions, the read pointer is also different, the read address changes, and the
基于上述时钟域通道电路04的功能,下面具体描述读地址的产生过程:Based on the functions of the above-mentioned clock
图3为本申请时钟域通道电路04的具体结构,时钟域通道电路04包括第一触发器041、第二触发器042、第三触发器043和第四触发器044以及多路信号选择器045,鉴相器03的第一输出端口具体与第一触发器041的输入端口连接,第一触发器041的输出端口与第二触发器042的输入端口连接,鉴相器03的第一输出端口具体还与第三触发器043的输入端口连接,第三触发器043的输出端口与第四触发器044的输入端口连接,第一触发器041的输出端口、第二触发器042的输出端口、第三触发器043的输出端口、以及第四触发器044的输出端口与多路数据选择器的另一个输入端口连接,多路信号选择器045的输出端口与读地址产生电路02的输入端口连接,参照图3,以写时钟域与读时钟域是同源同频异步时钟为例,写时钟信号与读时钟信号之间频率相同,时钟相位差随机,本申请时钟域通道电路04将写使能信号由写时钟域同步到读时钟域的具体过程为:Figure 3 is the specific structure of the clock domain channel circuit 04 of the present application, the clock domain channel circuit 04 includes a first flip-flop 041, a second flip-flop 042, a third flip-flop 043, a fourth flip-flop 044 and a multiplexer 045 , the first output port of the phase detector 03 is specifically connected to the input port of the first flip-flop 041, the output port of the first flip-flop 041 is connected to the input port of the second flip-flop 042, and the first output port of the phase detector 03 Specifically, it is also connected to the input port of the third flip-flop 043, the output port of the third flip-flop 043 is connected to the input port of the fourth flip-flop 044, the output port of the first flip-flop 041, the output port of the second flip-flop 042, The output port of the third flip-flop 043 and the output port of the fourth flip-flop 044 are connected with another input port of the multiplexer, and the output port of the multiplexer 045 is connected with the input port of the read address generation circuit 02 Referring to Figure 3, taking the write clock domain and the read clock domain as an example with the same source, same frequency and asynchronous clock, the frequency between the write clock signal and the read clock signal is the same, and the clock phase difference is random. The clock
如上所述,鉴相器03产生写使能信号,写使能信号进入写地址产生电路01,同时写使能信号也进入时钟域通道电路04,具体的:As mentioned above, the
写使能信号进入第一触发器041,以读时钟信号作为采样脉冲,第一触发器041在读时钟信号的下降沿对写使能信号进行采样,得到第一采样信号,随后,第一采样信号进入第二触发器042,同样读时钟信号作为采样脉冲,在读时钟信号的上升沿对第一采样信号进行采样,得到第二采样信号,写时钟域的写使能信号也进入第三触发器043,以读时钟信号作为采样脉冲,第三触发器043在读时钟信号的下降沿对写使能信号进行采样,得到第三采样信号,随后,第三采样信号进入第四触发器044,同样读时钟信号作为采样脉冲,在读时钟信号的上升沿对第三采样信号进行采样,得到第四采样信号。第一采样信号、第二采样信号、第三采样信号以及第四采样信号属于采样信号集合,第一采样信号、第二采样信号、第三采样信号以及第四采样信号分别输出至多路信号选择器045,鉴相器03的鉴相得到的时钟相位差也输入多路信号选择器045,多路信号选择器045根据鉴相器03的鉴相得到的时钟相位差,选择一路采样信号作为写使能信号输出至读地址产生电路02即可产生读地址。The write enable signal enters the first flip-
相对于现有技术利用寄存器进行写指针同步或读指针同步,寄存器需要保证数据的建立时间和保持时间,那么需要等待至少两个时钟周期,而本实施例中,用触发器对写使能信号采样得到采样信号集合,采样信号集合中的采样信号可以作为读使能信号,由于触发器在时钟信号的上升沿和下降沿均可以对信号采样,因此由写使能信号得到采样信号集合中全部或部分的采样信号可以控制在两个时钟周期内,对应的数据由写时钟域同步到读时钟域也可以控制在两个时钟周期内,相对于现有技术减小了数据同步的延时。Compared with the prior art using registers for write pointer synchronization or read pointer synchronization, the register needs to ensure the setup time and hold time of the data, so it needs to wait at least two clock cycles, and in this embodiment, the write enable signal is used to The sampling signal set is obtained by sampling, and the sampling signal in the sampling signal set can be used as a read enable signal. Since the flip-flop can sample the signal on both the rising edge and the falling edge of the clock signal, all the sampling signals in the sampling signal set can be obtained from the write enable signal. Or part of the sampling signal can be controlled within two clock cycles, and the corresponding data synchronization from the write clock domain to the read clock domain can also be controlled within two clock cycles, which reduces the delay of data synchronization compared with the prior art.
本申请鉴相器03的时钟相位差有四种可能的情况,选择得到的读使能信号也有四种可能的情况,选择的总体思想是确保写使能信号不会出现亚稳态,下面对四种情况进行说明:There are four possible situations for the clock phase difference of
首先时钟相位差指的是写时钟域写时钟信号和读时钟域读时钟信号之间的相位差。本申请预置有时钟相位差和读使能信号的映射关系,时钟相位差不同,读使能信号不同,具体的:First, the clock phase difference refers to the phase difference between the write clock signal in the write clock domain and the read clock signal in the read clock domain. This application presets the mapping relationship between the clock phase difference and the read enable signal. The clock phase difference is different and the read enable signal is different. Specifically:
一、鉴相器03鉴相得到的时钟相位差为:时钟相位差的属于[0T,1/4T),T为写时钟域的时钟周期,如图4(a)所示,以写时钟信号与读时钟信号之间时钟相位差为1/8T为例,对应图4(a)的时钟相位差,如图5(a)所示,利用读时钟信号按照上面所描述的方式对写使能信号采样,采样得到的第三采样信号会出现亚稳态,第四采样信号也可能会出现亚稳态,但是第一采样信号和第二采样信号不会出现亚稳态,为了保证一定的数据同步延时,从而保证有足够的时间读取数据,但是数据同步延时也不能太大,一般在2个时钟周期内,多路信号选择器045选择第二采样信号作为读使能信号并产生读地址,读地址比写地址约晚1.25个时钟周期,那么从到读时钟域到写时钟域的数据同步延时约为1.25个时钟周期。1. The clock phase difference obtained by the
二、鉴相器03鉴相得到的时钟相位差为:写时钟域与读时钟域间时钟相位差的属于[1/4T,1/2T),T为写时钟域的时钟周期,如图4(b)所示,以写时钟信号与读时钟信号间时钟相位差为3/8T为例,对应图4(b)的时钟相位差,如图5(b)所示,利用读时钟信号按照上面所描述的方式对写使能信号采样,采样得到的第一采样信号、第二采样信号、第三采样信号以及第四采样信号不会出现亚稳态,为了保证一定的数据同步延时,从而保证有足够的时间读取数据,但是数据同步延时也不能太大,一般在2个时钟周期内,多路信号选择器045选择第二采样信号或第四采样信号作为读使能信号并产生读地址,这里第二采样信号和第四采样信号相对于写使能信号延迟的时钟周期是相同的,读地址比写地址约晚1.5个时钟周期,那么从到读时钟域到写时钟域的数据同步延时约为1.5个时钟周期。2. The clock phase difference obtained by the
三、鉴相器03鉴相得到的时钟相位差为:写时钟域与读时钟域间时钟相位差的属于[1/2T,3/4T),T为写时钟域的时钟周期,如图4(c)所示,以写时钟信号与读时钟信号间时钟相位差为5/8T为例,对应图4(c)的时钟相位差,如图5(c)所示,利用读时钟信号按照上面所描述的方式对写使能信号采样,采样得到的第一采样信号以及第二采样信号出现亚稳态,第三采样信号以及第四采样信号不会出现亚稳态,为了保证一定的数据同步延时,从而保证有足够的时间读取数据,但是数据同步延时也不能太大,一般在2个时钟周期内,多路信号选择器045选择第四采样信号作为读使能信号并产生读地址,读地址比写地址约晚1.5个时钟周期,那么从到读时钟域到写时钟域的数据同步延时约为1.5个时钟周期。3. The clock phase difference obtained by the
四、鉴相器03鉴相得到的时钟相位差为:写时钟域与读时钟域间相位差的取值大于或等于3/4个时钟周期T,T为写时钟域的时钟周期,如图4(d)所示,以写时钟信号与读时钟信号间时钟相位差为7/8T为例对应图4(d)的时钟相位差,如图5(d)所示,利用读时钟信号按照上面所描述的方式对写使能信号采样,采样得到的第一采样信号、第二采样信号、第三采样信号以及第四采样信号不会出现亚稳态,为了保证一定的数据同步延时,从而保证有足够的时间读取数据,但是数据同步延时也不能太大,一般在2个时钟周期内,多路信号选择器045选择第二采样信号或第三采样信号作为读使能信号并产生读地址,这里第二采样信号和第三采样信号相对于写使能信号延迟的时钟周期是相同的,读地址比写地址约晚1个时钟周期,那么从到读时钟域到写时钟域的数据同步延时约为1个时钟周期。4. The clock phase difference obtained by
基于上述跨时钟域同步电路,时钟域通道电路04可以将写使能信号采样得到多个采样结果,得到的多个采样结果中存在部分或全部的采样结果相对于写使能信号的延时在两个时钟周期内,其次,写时钟域的写时钟信号与读时钟域的读时钟信号之间的具有时钟相位差,根据该时钟相位差,从多个采样结果中选择一个读使能信号,选择得到的这个读使能信号与写使能信号的延时可以控制在两个时钟周期内。两时钟域之间数据的同步也在两个时钟周期内,因此相对于现有两时钟域间数据的同步有至少两个时钟周期的延时的方案,本申请实现数据同步的延时较小。Based on the above cross-clock domain synchronization circuit, the clock
本申请还提供了一种跨时钟域同步方法,该方法可以应用于上述跨时钟域同步电路,以实现上述跨时钟域同步电路的功能。The present application also provides a cross-clock domain synchronization method, which can be applied to the above-mentioned cross-clock domain synchronization circuit, so as to realize the functions of the above-mentioned cross-clock domain synchronization circuit.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机或服务器等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general-purpose hardware, and of course it can also be realized by special hardware including application-specific integrated circuits, dedicated CPUs, dedicated memories, Special components, etc. to achieve. In general, all functions completed by computer programs can be easily realized by corresponding hardware, and the specific hardware structure used to realize the same function can also be varied, such as analog circuits, digital circuits or special-purpose circuit etc. However, for this application, software program implementation is a better implementation mode in most cases. Based on this understanding, the essence of the technical solution of this application or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a readable storage medium, such as a floppy disk of a computer , U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk, etc., including several instructions to make a computer device (which can be personal computer or server, etc.) to execute the methods described in the various embodiments of the present application.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server, or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be stored by a computer, or a data storage device such as a server or a data center integrated with one or more available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).
Claims (13)
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2019/079663 WO2020191611A1 (en) | 2019-03-26 | 2019-03-26 | Cross-clock domain synchronization circuit and method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN113615088A CN113615088A (en) | 2021-11-05 |
| CN113615088B true CN113615088B (en) | 2023-07-14 |
Family
ID=72610725
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201980094534.6A Active CN113615088B (en) | 2019-03-26 | 2019-03-26 | Synchronization circuit and method across clock domains |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN113615088B (en) |
| WO (1) | WO2020191611A1 (en) |
Families Citing this family (17)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114090241B (en) * | 2021-11-08 | 2025-09-09 | 曙光网络科技有限公司 | DDR2 SRAM interface circuit based on FPGA and phase adjustment method thereof |
| CN114326515A (en) * | 2021-12-30 | 2022-04-12 | 西人马(西安)测控科技有限公司 | Synchronous acquisition method, system and equipment based on FPGA and readable storage medium |
| CN114048470B (en) * | 2022-01-13 | 2022-06-24 | 浙江大学 | Defense method and device and electronic device for hardware attack based on TDC module |
| CN115589372B (en) * | 2022-01-25 | 2025-03-25 | 浙江理工大学 | A non-resident data cross-clock domain method based on co-frequency and out-of-phase clocks |
| CN114185397B (en) * | 2022-02-15 | 2022-05-17 | 深圳市爱普特微电子有限公司 | Cross-clock domain data transmission circuit and method |
| CN115035929B (en) * | 2022-06-24 | 2025-10-03 | 中国科学院微电子研究所 | A circuit, method and electronic device for efficiently implementing pseudo DDR signal cross-clock domain |
| JP7656092B2 (en) | 2022-08-16 | 2025-04-02 | チャンシン メモリー テクノロジーズ インコーポレイテッド | Write leveling circuit applied to memory, and control method and control device thereof |
| CN117636943A (en) * | 2022-08-16 | 2024-03-01 | 长鑫存储技术有限公司 | Write leveling circuit applied to memory, control method and control device thereof |
| CN116320237B (en) * | 2023-03-24 | 2025-04-25 | 中国科学院长春光学精密机械与物理研究所 | A Cache System for Multi-channel 2711 Image Data |
| CN116521604B (en) * | 2023-07-05 | 2024-03-19 | 芯耀辉科技有限公司 | Method for synchronizing data and related device |
| CN116795172B (en) * | 2023-08-29 | 2023-12-12 | 芯耀辉科技有限公司 | A cross-clock domain processing method, medium and device for high-speed digital transmission |
| CN117420342B (en) * | 2023-11-08 | 2024-04-09 | 苏州联讯仪器股份有限公司 | Multichannel acquisition method, device, system, FPGA and sampling oscilloscope |
| CN117970994B (en) * | 2024-02-04 | 2024-12-17 | 奇异摩尔(上海)集成电路设计有限公司 | Cross-clock domain processing device, processing method and core particle integrated system |
| CN118708537A (en) * | 2024-08-26 | 2024-09-27 | 爱芯元智半导体股份有限公司 | On-chip data processing device, method and equipment across clock domain and voltage domain |
| CN119847283B (en) * | 2024-12-25 | 2025-07-08 | 海光信息技术股份有限公司 | Integrated circuit, clock domain crossing data transmission method, electronic device and storage medium |
| CN120045018B (en) * | 2025-04-25 | 2025-07-18 | 北京炬玄智能科技有限公司 | A cross-clock domain communication circuit and data reading and writing method |
| CN120653065B (en) * | 2025-08-19 | 2025-11-07 | 芯耀辉科技股份有限公司 | Devices and methods for high-speed input/output |
Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5731770A (en) * | 1995-04-12 | 1998-03-24 | Sharp Kabushiki Kaisha | Digital data buffering device |
| US5963075A (en) * | 1996-08-19 | 1999-10-05 | Nec Corporation | Large scale integrated circuit having functional blocks controlled with clock signals that conduct setting operations at different times |
| US6956776B1 (en) * | 2004-05-04 | 2005-10-18 | Xilinx, Inc. | Almost full, almost empty memory system |
| US7038952B1 (en) * | 2004-05-04 | 2006-05-02 | Xilinx, Inc. | Block RAM with embedded FIFO buffer |
| CN101009487A (en) * | 2007-01-24 | 2007-08-01 | 华为技术有限公司 | Cross-clock domain asynchronous data processing, cross-clock domain method of the asynchronous data, and its device |
| CN101741372A (en) * | 2008-11-11 | 2010-06-16 | 株式会社瑞萨科技 | Semiconductor integrated circuit and control method for clock signal synchronization |
| CN106354652A (en) * | 2015-07-15 | 2017-01-25 | 上海华虹集成电路有限责任公司 | Nonvolatile memory read-write control circuit and method |
| CN107911102A (en) * | 2017-11-29 | 2018-04-13 | 长园深瑞继保自动化有限公司 | The symchronizing filter and method of cross-clock domain asynchronous data |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2993463B2 (en) * | 1997-05-08 | 1999-12-20 | 日本電気株式会社 | Synchronous circuit controller |
-
2019
- 2019-03-26 WO PCT/CN2019/079663 patent/WO2020191611A1/en not_active Ceased
- 2019-03-26 CN CN201980094534.6A patent/CN113615088B/en active Active
Patent Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5731770A (en) * | 1995-04-12 | 1998-03-24 | Sharp Kabushiki Kaisha | Digital data buffering device |
| US5963075A (en) * | 1996-08-19 | 1999-10-05 | Nec Corporation | Large scale integrated circuit having functional blocks controlled with clock signals that conduct setting operations at different times |
| US6956776B1 (en) * | 2004-05-04 | 2005-10-18 | Xilinx, Inc. | Almost full, almost empty memory system |
| US7038952B1 (en) * | 2004-05-04 | 2006-05-02 | Xilinx, Inc. | Block RAM with embedded FIFO buffer |
| CN101009487A (en) * | 2007-01-24 | 2007-08-01 | 华为技术有限公司 | Cross-clock domain asynchronous data processing, cross-clock domain method of the asynchronous data, and its device |
| CN101741372A (en) * | 2008-11-11 | 2010-06-16 | 株式会社瑞萨科技 | Semiconductor integrated circuit and control method for clock signal synchronization |
| CN106354652A (en) * | 2015-07-15 | 2017-01-25 | 上海华虹集成电路有限责任公司 | Nonvolatile memory read-write control circuit and method |
| CN107911102A (en) * | 2017-11-29 | 2018-04-13 | 长园深瑞继保自动化有限公司 | The symchronizing filter and method of cross-clock domain asynchronous data |
Also Published As
| Publication number | Publication date |
|---|---|
| WO2020191611A1 (en) | 2020-10-01 |
| CN113615088A (en) | 2021-11-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN113615088B (en) | Synchronization circuit and method across clock domains | |
| US10725950B2 (en) | Peripheral interface circuit for serial memory | |
| WO2021056965A1 (en) | High-speed spi main mode controller | |
| US11404102B2 (en) | Semiconductor device, semiconductor system, and method of operating the semiconductor device | |
| CN101645301A (en) | Temperature self-adaptive adjustment method for read data sampling and device thereof | |
| CN116521604A (en) | A method and related device for synchronizing data | |
| CN112712829B (en) | Register read-write circuit and method crossing clock domains | |
| CN110618950A (en) | Asynchronous FIFO read-write control circuit and method, readable storage medium and terminal | |
| CN105182377A (en) | Receiver board card and receiver | |
| US8904221B2 (en) | Arbitration circuitry for asynchronous memory accesses | |
| JP5221609B2 (en) | Host controller that sets the sampling phase by sharing the DLL | |
| CN209842447U (en) | Clock domain crossing signal synchronization circuit | |
| CN117908790B (en) | ONFI PHY quick switching training device based on single Channel multiple Die | |
| CN114384288B (en) | signal generator | |
| JPH09185427A (en) | Clock phase adjusting circuit and clock phase adjusting method | |
| CN110059036B (en) | Access control device and method for multiple asynchronous interfaces in memory bank | |
| CN117420342B (en) | Multichannel acquisition method, device, system, FPGA and sampling oscilloscope | |
| US12009056B2 (en) | Data transmission apparatus and method having clock gating mechanism | |
| CN120653065B (en) | Devices and methods for high-speed input/output | |
| CN119003404B (en) | A low-latency and small-area read data path for DDR hosts | |
| CN114691556B (en) | Universal physical layer for providing connection with external storage device and connection method thereof | |
| US12451174B2 (en) | Semiconductor devices capable of performing write training without read training, and memory system including the same | |
| CN110825688B (en) | Clock system | |
| CN117785792A (en) | Signal processing method and device crossing synchronous frequency asynchronous clock domain | |
| CN117971756A (en) | Clock phase determining method and device, electronic equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |