觉得这篇文章很好,因此在这里翻译一下——或者也可以说是按我的理解加中文注释。
Mul TI ple, independent clocks are ubiquitous in system-on-chip (SoC) design. Most SoC devices have mul TI ple interfaces, some following standards that use very different clock frequencies.
在一个SOC设计中,存在多个、独立的时钟,这已经是一件很平常的事情了。大多数的SOC器件都具有很多个接口,各个接口标准都可能会使用完全不同的时钟频率。
Many modern serial interfaces are inherently asynchronous from the rest of the chip; some actually derive their clocks directly from the incoming data streams. There is also a trend toward designing major sub-blocks of SoCs to run on independent clocks to ease the problem of clock skew across large chips.
例如对于现代的串行通信接口而言,它们自然而然地就与芯片的其余部分是不同步的,因为它们的时钟有时候就是直接从数据流中恢复出来的。而且,现在还有一个趋势,就是有时候为了在避免大芯片中令人头痛的所谓"clocl skew"问题,索性让各个子模块都具有独立的时钟。
For all of these reasons, designers working on SoC projects are virtually certain to encounter mul TI ple clocks and to be faced with the design of logic interconnec TI ng two portions of the chip running on independent clocks. Each such portion is known as a clock domain. The interface between logic on different clocks is called a clock domain crossing or clock domain boundary. The proper handing of signals across clock domain boundaries is critical for successful SoC design.
因为以上原因,进行SOC设计时,常常要考虑工作在不同时钟下的两个部分逻辑之间的互连问题,而每个部分,都可称之为“时钟域”,连接它们之间的那部分数字逻辑可称为“时钟边界”或所谓“跨时钟域”。合理地处理跨时钟的问题,对于一个成功的SOC设计来说非常关键。
Problem #1: Meta-stability
The first multi-clock problem that designers must consider is that of meta-stability as signals pass from one clock domain to another. Most designers understand that meta-stability is a real problem in real circuits; the modern abstractions of RTL design and static timing analysis can't entirely shield designers from having to worry about the underlying physics.
1) 亚稳态
多时钟域设计的第一个问题,便是信号从一个时钟域传输到另一个时钟域的时候,可能会出现亚稳态。 许多设计者都知道,在真实的电路中的确会存在所谓亚稳态的问题。但是,在现代的FPGA设计中,即使设计者面对的是RTL级抽象和静态时序分析,却仍然不能完全将这个问题拒之门外,因为抽象的掩盖之下,我们仍然避免不了真实的物理规律。
Whenever a signal enters a clocked circuit element, such as a flip-flop, too close to the clock, there is the potential for meta-stability. When this happens, the flip-flop may not immediately settle to a known value. It is critical that the output signal from the flip-flop not be used until it has settled.
任何时候,一个信号输入到一个时钟触发的电路——例如一个D触发器,当信号(跳变)过于靠近时钟前沿,便会存在所谓亚稳态问题。这个时候,DFF的输出端不会马上产生一个可预知的值,也就是说,在这段时间内,输出信号是无效的。
On a truly asynchronous clock boundary, the receiving domain's clock is used to capture each signal from the driving domain in a flip-flop. Because there is no defined temporal relationship between the clock and the signal, it is entirely possible that they could transition at the same time. Whenever this happens, there is a possibility of meta-stability in the receiving clock domain.
在设计中,常常会用一个触发器接收来自于另一个时钟域的输出信号(即用本地时钟的前沿来锁存另一个时钟域的信号)。由于触发器的时钟和数据输入信号不存在确定的相位关系,因此完全有可能出现数据和时钟同时跳变的情况。这样,就在接收端所在的时钟域中造成了亚稳态。
This is not just a theoretical potential. GHz-rate chips with clocking design errors can exhibit the effects of meta-stability quite quickly when running in real systems. These effects typically include loss of critical handshake signals between clocks domains, and corruption of multi-bit data"serious problems that are highly likely to require a chip re-spin.
亚稳态的风险,并不仅仅是理论上的。对于GHz数据率的芯片,如果时钟设计考虑不当,一旦把它放到实际系统中运行,亚稳态的效果所造成的危害很快就会表现出来。最典型的比如说,跨时钟域的关键握手信号丢失,以及并行数据出错。然后这个芯片的设计很可能就泡汤,于是你不得不推倒重来。(所谓 re-spin,按我的理解,是重新开始的意思)
Most designers also know that the textbook solution to meta-stability is using two levels of flip-flops on each signal crossing a clock domain boundary. Even if the first flip-flop does become meta-stable, there is an extremely high likelihood that the signal will settle by the time that it passes through the second level. The double-level flip-flop structure is often called a synchronizer, and designers commonly speak of synchronizing signals across clock domains.
多数设计者都已经知道,对于亚稳态,教科书上经典的解决办法,就是在凡时钟边界的地方,都用两级(D)触发器对信号进行同步。这样的话,哪怕第一级D触发器进入了亚稳态,后一级也极有可能把它克服掉。这种两级触发器结构,通常称为“synchronizer”,这个过程也称为跨时钟域信号同步。
Problem #2: Reset synchronization 复位的同步问题
Improper synchronization of reset signals is a related problem in multi-clock designs. Designers sometimes forget that reset signals are subject to meta-stability and must be protected by synchronizers. Generally, the entire SoC can be reset by a single signal, which therefore must propagate to all clocked elements in all clock domains.
复位信号的不同步,也是一个与多时钟设计相关的问题。设计者有时候会忘了一个事实,那就是复位信号也可能引起亚稳态问题,而且必须用synchronizers来对它进行同步。通常来说,每个SOC都会有一个reset信号,这个信号被送到各个时钟域的各个同步逻辑单元,来对整个芯片/系统进行复位。
There is no need for synchronization on the activation edge of reset, since by definition all state elements are reset to initial values, and the reset signal will generally be held active for enough cycles to allow any meta-stability to settle out.