FPGA时序约束02——不同时序路径的分析方法

前言

分别是触发器到触发器,触发器到输出端,输入端到触发器,输入端到输出端,其中输入端到输出端是纯组合逻辑路径,没有时钟,所谓的时序其实就是延时,故此处只分析前三种路径的时序。

注意,这些时序路径中的时钟都是同源且同频的,这是分析的前提条件。

一. 触发器到触发器

触发器到触发器,reg2reg,此路径的起点为前一个触发器的时钟端,终点为后一个触发器的输入端,如下图所示。

考虑时钟延迟的情况下,信号从REG1的D端传输到REG2的D端的路径延时如下图所示。

其中,
t c l k 1 : c l k 传播到寄存器 1 的时钟延迟 t c l k 2 : c l k 传播到寄存器 2 的时钟延迟 t c o : c l o c k o u t p u t d e l a y ,寄存器数据输出延迟时间 t d a t a : d a t a d e l a y ,数据传输延迟 t s u : s t e u p t i m e ,建立时间 t h : h o l d t i m e ,保持时间 t_{clk1}: clk\text{传播到寄存器}1\text{的时钟延迟} \ t_{clk2}: clk\text{传播到寄存器}2\text{的时钟延迟} \ t_{co}: clock\,\,output\,\,delay\text{,寄存器数据输出延迟时间} \ t_{data}: data\,\,delay\text{,数据传输延迟} \ t_{su}: steup\,\,time\text{,建立时间} \ t_h: hold\,\,time\text{,保持时间}t c l k 1 ​:c l k 传播到寄存器1 的时钟延迟t c l k 2 ​:c l k 传播到寄存器2 的时钟延迟t co ​:c l oc k o u tp u t d e l a y ,寄存器数据输出延迟时间t d a t a ​:d a t a d e l a y ,数据传输延迟t s u ​:s t e u p t im e ,建立时间t h ​:h o l d t im e ,保持时间

假设总是在时钟信号的上升沿发送数据和锁存数据,下降沿分析方法是一样的,这里以最普遍的上升沿为例,绘制时钟信号与数据信号的时序图如下图所示。

其中,
c l k : 时钟源信号 c l k 1 : R E G 1 时钟端信号,延迟 c l k 信号一定时间 c l k 2 : R E G 2 时钟端信号,延迟 c l k 信号一定时间 R E G 1. Q : R E G 1 的数据输出端,在 R E G 1 的有效时钟沿到来后,延迟 t c o 时间后输出数据 R E G 2. D : R E G 2 的数据输入端,数据至少需要领先 R E G 2 的有效时钟沿 t s u 时间,才能被正确锁存 s l a c k ( s u ) : 建立时间裕量 = 数据要求时间 d a t a r e q u i r a l t i m e ( s u ) − 数据到达时间 d a t a a r r i v a l t i m e ( s u ) clk: \text{时钟源信号} \ clk1: REG1\text{时钟端信号,延迟}clk\text{信号一定时间} \ clk2: REG2\text{时钟端信号,延迟}clk\text{信号一定时间} \ REG1.Q: REG1\text{的数据输出端,在}REG1\text{的有效时钟沿到来后,延迟}t_{co}\text{时间后输出数据} \ REG2.D: REG2\text{的数据输入端,数据至少需要领先}REG2\text{的有效时钟沿}t_{su}\text{时间,才能被正确锁存} \ slack\left( su \right) : \text{建立时间裕量}=\text{数据要求时间}data\,\,requiral\,\,time\left( su \right) -\text{数据到达时间} data\,\,arrival\,\,time\left( su \right)c l k :时钟源信号c l k 1 :REG 1 时钟端信号,延迟c l k 信号一定时间c l k 2 :REG 2 时钟端信号,延迟c l k 信号一定时间REG 1.Q :REG 1 的数据输出端,在REG 1 的有效时钟沿到来后,延迟t co ​时间后输出数据REG 2.D :REG 2 的数据输入端,数据至少需要领先REG 2 的有效时钟沿t s u ​时间,才能被正确锁存s l a c k (s u ):建立时间裕量=数据要求时间d a t a re q u i r a l t im e (s u )−数据到达时间d a t a a rr i v a l t im e (s u )

d a t a a r r i v a l t i m e ( s u ) = L a u n c h E d g e ( s u ) + t c l k 1 + t c o + t d a t a data\,\,arrival\,\,time\left( su \right) =Launch\,\,Edge\left( su \right) +t_{clk1}+t_{co}+t_{data}d a t a a rr i v a l t im e (s u )=L a u n c h E d g e (s u )+t c l k 1 ​+t co ​+t d a t a ​

d a t a r e q u i r a l t i m e ( s u ) = L a t c h E d g e ( s u ) + t c l k 2 − t s u data\,\,requiral\,\,time\left( su \right) =Latch\,\,Edge\left( su \right) +t_{clk2}-t_{su}d a t a re q u i r a l t im e (s u )=L a t c h E d g e (s u )+t c l k 2 ​−t s u ​

s l a c k ( s u ) = d a t a r e q u i r a l t i m e ( s u ) − d a t a a r r i v a l t i m e ( s u ) = L a t c h E d g e + t c l k 2 − t s u − ( L a u n c h E d g e + t c l k 1 + t c o + t d a t a ) = ( L a t c h E d g e − L a u n c h E d g e ) + ( t c l k 2 − t c l k 1 ) − ( t c o + t d a t a + t s u ) = T c l k + ( t c l k 2 − t c l k 1 ) − ( t c o + t d a t a + t s u ) slack\left( su \right) =data\,\,requiral\,\,time\left( su \right) -\,\,data\,\,arrival\,\,time\left( su \right) \ =Latch\,\,Edge+t_{clk2}-t_{su}-\left( Launch\,\,Edge+t_{clk1}+t_{co}+t_{data} \right) \ =\left( Latch\,\,Edge-Launch\,\,Edge \right) +\left( t_{clk2}-t_{clk1} \right) -\left( t_{co}+t_{data}+t_{su} \right) \ =T_{clk}+\left( t_{clk2}-t_{clk1} \right) -\left( t_{co}+t_{data}+t_{su} \right)s l a c k (s u )=d a t a re q u i r a l t im e (s u )−d a t a a rr i v a l t im e (s u )=L a t c h E d g e +t c l k 2 ​−t s u ​−(L a u n c h E d g e +t c l k 1 ​+t co ​+t d a t a ​)=(L a t c h E d g e −L a u n c h E d g e )+(t c l k 2 ​−t c l k 1 ​)−(t co ​+t d a t a ​+t s u ​)=T c l k ​+(t c l k 2 ​−t c l k 1 ​)−(t co ​+t d a t a ​+t s u ​)

这就是 建立时间裕量的计算公式了,其中,

T c l k T_{clk}T c l k ​是系统运行的时钟周期, 可见时钟频率越高,建立时间裕量就越小,这使得系统运行的频率是有上限的。

t c l k 2 − t c l k 1 t_{clk2}-t_{clk1}t c l k 2 ​−t c l k 1 ​是两寄存器的时钟延时差值,一般来说,在使用全局时钟资源时,此差值是很小的。FPGA软件也会自动将前后两个寄存器布局在靠近的位置。

t c o t_{co}t co ​和t s u t_{su}t s u ​取决于寄存器的性能,当FPGA器件确定时,这两个参数其实就已经确定了, 所以分析时,这两个参数其实是固定值

t d a t a t_{data}t d a t a ​是两寄存器的之间的组合逻辑延时(包含路径延时), 组合逻辑延时是用户代码决定的,逻辑越多越复杂延时就越大,裕量就越小。所以,在编写FPGA程序时,不应在两个寄存器之间插入太复杂的组合逻辑。如果确实有逻辑变化的需求,可以考虑将组合逻辑全部或部分改为时序逻辑,相当于在这两个寄存器之间再插入了一个寄存器,这使得原本一个时钟周期能完成的工作被分到了两个时钟周期,总的信号传输延时增加了,但建立时序裕量的压力也被分担了。 插入寄存器是一种很常用的解决建立时序违例的方法

显然,触发器到触发器的建立时序分析中的所有信号,对FPGA软件来说都是已知的,可能用户需要告诉软件的唯一信息是时钟频率,但一般来说,如果使用的是时钟是PLL输出的话,时钟频率软件知道的,一般的FPGA软件会为PLL输出时钟自动添加时钟约束, 所以,大多数情况我们不需要执行任何操作,FPGA软件就会在布局布线时尽量去满足触发器到触发器的建立时序要求

与建立分析同理,绘制时钟信号与数据信号的时序图如下图所示。

其中,
L a t c h E d g e ( h ) : 旧数据读取时钟沿 L a u n c h E d g e ( h ) : 新数据写入时钟沿,在保持分析中,新数据写入与旧数据读取是同一时钟沿 保持时间裕量 s l a c k ( h ) = 新数据到达时间 d a t a a r r i v a l t i m e ( h ) − 旧数据读取要求时间 d a t a r e q u i r a l t i m e ( h ) Latch\,\,Edge\left( h \right) : \text{旧数据读取时钟沿} \ Launch\,\,Edge\left( h \right) : \text{新数据写入时钟沿,在保持分析中,新数据写入与旧数据读取是同一时钟沿} \ \text{保持时间裕量}slack\left( h \right) =\text{新数据到达时间}data\,\,arrival\,\,time\left( h \right) -\text{旧数据读取要求时间}data\,\,requiral\,\,time\left( h \right)L a t c h E d g e (h ):旧数据读取时钟沿L a u n c h E d g e (h ):新数据写入时钟沿,在保持分析中,新数据写入与旧数据读取是同一时钟沿保持时间裕量s l a c k (h )=新数据到达时间d a t a a rr i v a l t im e (h )−旧数据读取要求时间d a t a re q u i r a l t im e (h )

s l a c k ( h ) = d a t a a r r i v a l t i m e ( h ) − d a t a r e q u i r a l t i m e ( h ) = L a t c h E d g e ( h ) + t c l k 1 + t c o + t d a t a − ( L a t c h E d g e ( h ) + t c l k 2 + t h ) = ( L a t c h E d g e ( h ) − L a u n c h E d g e ( h ) ) − ( t c l k 2 − t c l k 1 ) + ( t c o + t d a t a − t h ) = − ( t c l k 2 − t c l k 1 ) + ( t c o + t d a t a − t h ) slack\left( h \right) =data\,\,arrival\,\,time\left( h \right) -data\,\,requiral\,\,time\left( h \right) \ =Latch\,\,Edge\left( h \right) +t_{clk1}+t_{co}+t_{data}-\left( Latch\,\,Edge\left( h \right) +t_{clk2}+t_h \right) \ =\left( Latch\,\,Edge\left( h \right) -Launch\,\,Edge\left( h \right) \right) -\left( t_{clk2}-t_{clk1} \right) +\left( t_{co}+t_{data}-t_h \right) \ =-\left( t_{clk2}-t_{clk1} \right) +\left( t_{co}+t_{data}-t_h \right)s l a c k (h )=d a t a a rr i v a l t im e (h )−d a t a re q u i r a l t im e (h )=L a t c h E d g e (h )+t c l k 1 ​+t co ​+t d a t a ​−(L a t c h E d g e (h )+t c l k 2 ​+t h ​)=(L a t c h E d g e (h )−L a u n c h E d g e (h ))−(t c l k 2 ​−t c l k 1 ​)+(t co ​+t d a t a ​−t h ​)=−(t c l k 2 ​−t c l k 1 ​)+(t co ​+t d a t a ​−t h ​)
这就是 保持时间裕量的计算公式了,其中,

− ( t c l k 2 − t c l k 1 ) -\left( t_{clk2}-t_{clk1} \right)−(t c l k 2 ​−t c l k 1 ​)是两寄存器的时钟延时差值,与建立时间这部分的概念是一样的,这部分差值一般很小。

t c o t_{co}t co ​和t h t_{h}t h ​取决于寄存器的性能,当FPGA器件确定时,这两个参数其实就已经确定了。

t d a t a t_{data}t d a t a ​是两寄存器的之间的组合逻辑延时(包含路径延时)。

一般来说,在触发器到触发器路径中, 保持时间裕量通常能满足要求。所以,此路径的重点在于满足建立时间裕量。

二. 触发器到输出端

触发器到输出端,reg2out,此路径起点为FPGA内触发器的输出端,终点是外部接收器件(如DAC)内部触发器的输入端,如下图所示。

考虑时钟延迟的情况下,信号从REG1的D端传输到REG2的D端的路径延时如下图所示。

其中,t c l k 1 t_{clk1}t c l k 1 ​,t c l k 2 t_{clk2}t c l k 2 ​,t c o t_{co}t co ​,t d a t a t_{data}t d a t a ​,t s u t_{su}t s u ​,t h t_h t h ​与上文含义一样。

又因为时钟和数据是从一个芯片传输到另一个芯片,中间还有一段是PCB走线,所以,上图的t d a t a t_{data}t d a t a ​和t c l k 2 t_{clk2}t c l k 2 ​可继续细分,如下图所示。

走线可分为三段,分别是FPGA内部走线,PCB走线,DAC内部走线。

此图时序图与reg2reg部分完全一致,因此不再单独绘制时序图。
数据到达时间 d a t a a r r i v a l t i m e ( s u ) = L a u n c h E d g e ( s u ) + t c l k 1 + t c o + t d a t a = L a u n c h E d g e ( s u ) + t c l k 1 + t c o + t d a t a ( f p g a ) + t d a t a ( p c b ) + t d a t a ( d a c ) \text{数据到达时间}data\,\,arrival\,\,time\left( su \right) =Launch\,\,Edge\left( su \right) +t_{clk1}+t_{co}+t_{data} \ =Launch\,\,Edge\left( su \right) +t_{clk1}+t_{co}+t_{data\left( fpga \right)}+t_{data\left( pcb \right)}+t_{data\left( dac \right)}数据到达时间d a t a a rr i v a l t im e (s u )=L a u n c h E d g e (s u )+t c l k 1 ​+t co ​+t d a t a ​=L a u n c h E d g e (s u )+t c l k 1 ​+t co ​+t d a t a (f p g a )​+t d a t a (p c b )​+t d a t a (d a c )​

数据要求时间 d a t a r e q u i r a l t i m e ( s u ) = L a t c h E d g e ( s u ) + t c l k 2 − t s u ( d a c ) = L a t c h E d g e ( s u ) + t c l k 2 ( f p g a ) + t c l k 2 ( p c b ) + t c l k 2 ( d a c ) − t s u ( d a c ) \text{数据要求时间}data\,\,requiral\,\,time\left( su \right) =Latch\,\,Edge\left( su \right) +t_{clk2}-t_{su\left( dac \right)} \ =Latch\,\,Edge\left( su \right) +t_{clk2\left( fpga \right)}+t_{clk2\left( pcb \right)}+t_{clk2\left( dac \right)}-t_{su\left( dac \right)}数据要求时间d a t a re q u i r a l t im e (s u )=L a t c h E d g e (s u )+t c l k 2 ​−t s u (d a c )​=L a t c h E d g e (s u )+t c l k 2 (f p g a )​+t c l k 2 (p c b )​+t c l k 2 (d a c )​−t s u (d a c )​

建立时间裕量 s l a c k ( s u ) = d a t a r e q u i r a l t i m e ( s u ) − d a t a a r r i v a l t i m e ( s u ) = ( L a t c h E d g e ( s u ) + t c l k 2 ( f p g a ) + t c l k 2 ( p c b ) + t c l k 2 ( d a c ) − t s u ( d a c ) ) − ( L a u n c h E d g e ( s u ) + t c l k 1 + t c o + t d a t a ( f p g a ) + t d a t a ( p c b ) + t d a t a ( d a c ) ) = ( L a t c h E d g e ( s u ) − L a u n c h E d g e ( s u ) ) − t c l k 1 − t c o − ( t d a t a ( f p g a ) − t c l k 2 ( f p g a ) ) − ( ( t d a t a ( p c b ) − t c l k 2 ( p c b ) ) + ( t d a t a ( d a c ) − t c l k 2 ( d a c ) ) + t s u ( d a c ) ) \text{建立时间裕量}slack\left( su \right) =data\,\,requiral\,\,time\left( su \right) -data\,\,arrival\,\,time\left( su \right) \ =\left( Latch\,\,Edge\left( su \right) +t_{clk2\left( fpga \right)}+t_{clk2\left( pcb \right)}+t_{clk2\left( dac \right)}-t_{su\left( dac \right)} \right) \ -\left( Launch\,\,Edge\left( su \right) +t_{clk1}+t_{co}+t_{data\left( fpga \right)}+t_{data\left( pcb \right)}+t_{data\left( dac \right)} \right) \ =\left( Latch\,\,Edge\left( su \right) -Launch\,\,Edge\left( su \right) \right) -t_{clk1}-t_{co}-\left( t_{data\left( fpga \right)}-t_{clk2\left( fpga \right)} \right) \ -\left( \left( t_{data\left( pcb \right)}-t_{clk2\left( pcb \right)} \right) +\left( t_{data\left( dac \right)}-t_{clk2\left( dac \right)} \right) +t_{su\left( dac \right)} \right)建立时间裕量s l a c k (s u )=d a t a re q u i r a l t im e (s u )−d a t a a rr i v a l t im e (s u )=(L a t c h E d g e (s u )+t c l k 2 (f p g a )​+t c l k 2 (p c b )​+t c l k 2 (d a c )​−t s u (d a c )​)−(L a u n c h E d g e (s u )+t c l k 1 ​+t co ​+t d a t a (f p g a )​+t d a t a (p c b )​+t d a t a (d a c )​)=(L a t c h E d g e (s u )−L a u n c h E d g e (s u ))−t c l k 1 ​−t co ​−(t d a t a (f p g a )​−t c l k 2 (f p g a )​)−((t d a t a (p c b )​−t c l k 2 (p c b )​)+(t d a t a (d a c )​−t c l k 2 (d a c )​)+t s u (d a c )​)

在软件中进行时序分析时,上式中的前4项( L a t c h E d g e ( s u ) − L a u n c h E d g e ( s u ) ) \left( Latch\,\,Edge\left( su \right) -Launch\,\,Edge\left( su \right) \right)(L a t c h E d g e (s u )−L a u n c h E d g e (s u )),t c l k 1 t_{clk1}t c l k 1 ​,t c o t_{co}t co ​,( t d a t a ( f p g a ) − t c l k 2 ( f p g a ) ) \left( t_{data\left( fpga \right)}-t_{clk2\left( fpga \right)} \right)(t d a t a (f p g a )​−t c l k 2 (f p g a )​)对软件来说都是已知的,而后三项$
\left( t_{data\left( pcb \right)}-t_{clk2\left( pcb \right)} \right), ,,\left( t_{data\left( dac \right)}-t_{clk2\left( dac \right)} \right), ,,t_{su\left( dac \right)}是未知的,所以,要分析输出数据的建立时间裕量,就要把后 3 项的和告诉软件,然后 ∗ ∗ 软件需要在最恶劣的情况下保证 是未知的,所以,要分析输出数据的建立时间裕量,就要把后3项的和告诉软件,然后软件需要在最恶劣的情况下保证是未知的,所以,要分析输出数据的建立时间裕量,就要把后3 项的和告诉软件,然后∗∗软件需要在最恶劣的情况下保证slack\left( su \right) \geqslant 0$

所谓的最恶劣情况,就是在前面4项已知的情况下,后3项和最大的情况,所以,此处 后三项的和被称为最大输出延迟(output delay max),即
最大输出延迟 o u t p u t d e l a y max ⁡ = ( ( t d a t a ( p c b ) − t c l k 2 ( p c b ) ) + ( t d a t a ( d a c ) − t c l k 2 ( d a c ) ) + t s u ( d a c ) ) ( max ⁡ ) \text{最大输出延迟}output\,\,delay\,\,\max =\left( \left( t_{data\left( pcb \right)}-t_{clk2\left( pcb \right)} \right) +\left( t_{data\left( dac \right)}-t_{clk2\left( dac \right)} \right) +t_{su\left( dac \right)} \right) \left( \max \right)最大输出延迟o u tp u t d e l a y max =((t d a t a (p c b )​−t c l k 2 (p c b )​)+(t d a t a (d a c )​−t c l k 2 (d a c )​)+t s u (d a c )​)(max )
一般板上走线都会进行等长处理,所以t d a t a ( p c b ) t_{data\left( pcb \right)}t d a t a (p c b )​可认为和t c l k 2 ( p c b ) t_{clk2\left( pcb \right)}t c l k 2 (p c b )​相等,又一般芯片的t d a t a ( d a c ) t_{data\left( dac \right)}t d a t a (d a c )​和t c l k 2 ( d a c ) t_{clk2\left( dac \right)}t c l k 2 (d a c )​都很小,可以忽略,所以上式可简化为:
最大输出延迟 o u t p u t d e l a y max ⁡ = t s u ( d a c ) ( max ⁡ ) \text{最大输出延迟}output\,\,delay\,\,\max =t_{su\left( dac \right)}\left( \max \right)最大输出延迟o u tp u t d e l a y max =t s u (d a c )​(max )
也就是说 外部数据接收芯片的最大建立时间就是最大输出延迟在reg2out的建立分析时,需要手动输入output delay max以供软件分析

数据到达时间 d a t a a r r i v a l t i m e ( h ) = L a u n c h E d g e ( h ) + t c l k 1 + t c o + t d a t a = L a u n c h E d g e ( h ) + t c l k 1 + t c o + t d a t a ( f p g a ) + t d a t a ( p c b ) + t d a t a ( d a c ) \text{数据到达时间}data\,\,arrival\,\,time\left( h \right) =Launch\,\,Edge\left( h \right) +t_{clk1}+t_{co}+t_{data} \ =Launch\,\,Edge\left( h \right) +t_{clk1}+t_{co}+t_{data\left( fpga \right)}+t_{data\left( pcb \right)}+t_{data\left( dac \right)}数据到达时间d a t a a rr i v a l t im e (h )=L a u n c h E d g e (h )+t c l k 1 ​+t co ​+t d a t a ​=L a u n c h E d g e (h )+t c l k 1 ​+t co ​+t d a t a (f p g a )​+t d a t a (p c b )​+t d a t a (d a c )​

数据要求时间 d a t a r e q u i r a l t i m e ( h ) = L a t c h E d g e ( h ) + t c l k 2 + t h ( d a c ) = L a t c h E d g e ( h ) + t c l k 2 ( f p g a ) + t c l k 2 ( p c b ) + t c l k 2 ( d a c ) + t h ( d a c ) \text{数据要求时间}data\,\,requiral\,\,time\left( h \right) =Latch\,\,Edge\left( h \right) +t_{clk2}+t_{h\left( dac \right)} \ =Latch\,\,Edge\left( h \right) +t_{clk2\left( fpga \right)}+t_{clk2\left( pcb \right)}+t_{clk2\left( dac \right)}+t_{h\left( dac \right)}数据要求时间d a t a re q u i r a l t im e (h )=L a t c h E d g e (h )+t c l k 2 ​+t h (d a c )​=L a t c h E d g e (h )+t c l k 2 (f p g a )​+t c l k 2 (p c b )​+t c l k 2 (d a c )​+t h (d a c )​

保持时间裕量 s l a c k ( h ) = d a t a a r r i v a l t i m e ( h ) − d a t a r e q u i r a l t i m e ( h ) = L a u n c h E d g e ( h ) + t c l k 1 + t c o + t d a t a ( f p g a ) + t d a t a ( p c b ) + t d a t a ( d a c ) − ( L a t c h E d g e ( h ) + t c l k 2 ( f p g a ) + t c l k 2 ( p c b ) + t c l k 2 ( d a c ) + t h ( d a c ) ) = ( L a t c h E d g e ( h ) − L a u n c h E d g e ( h ) ) + t c l k 1 + t c o + ( t d a t a ( f p g a ) − t c l k 2 ( f p g a ) ) + ( ( t d a t a ( p c b ) − t c l k 2 ( p c b ) ) + ( t d a t a ( d a c ) − t c l k 2 ( d a c ) ) − t h ( d a c ) ) \text{保持时间裕量}slack\left( h \right) =data\,\,arrival\,\,time\left( h \right) -data\,\,requiral\,\,time\left( h \right) \ =Launch\,\,Edge\left( h \right) +t_{clk1}+t_{co}+t_{data\left( fpga \right)}+t_{data\left( pcb \right)}+t_{data\left( dac \right)} \ -\left( Latch\,\,Edge\left( h \right) +t_{clk2\left( fpga \right)}+t_{clk2\left( pcb \right)}+t_{clk2\left( dac \right)}+t_{h\left( dac \right)} \right) \ =\left( Latch\,\,Edge\left( h \right) -Launch\,\,Edge\left( h \right) \right) +t_{clk1}+t_{co}+\left( t_{data\left( fpga \right)}-t_{clk2\left( fpga \right)} \right) \ +\left( \left( t_{data\left( pcb \right)}-t_{clk2\left( pcb \right)} \right) +\left( t_{data\left( dac \right)}-t_{clk2\left( dac \right)} \right) -t_{h\left( dac \right)} \right)保持时间裕量s l a c k (h )=d a t a a rr i v a l t im e (h )−d a t a re q u i r a l t im e (h )=L a u n c h E d g e (h )+t c l k 1 ​+t co ​+t d a t a (f p g a )​+t d a t a (p c b )​+t d a t a (d a c )​−(L a t c h E d g e (h )+t c l k 2 (f p g a )​+t c l k 2 (p c b )​+t c l k 2 (d a c )​+t h (d a c )​)=(L a t c h E d g e (h )−L a u n c h E d g e (h ))+t c l k 1 ​+t co ​+(t d a t a (f p g a )​−t c l k 2 (f p g a )​)+((t d a t a (p c b )​−t c l k 2 (p c b )​)+(t d a t a (d a c )​−t c l k 2 (d a c )​)−t h (d a c )​)

与建立分析一样,前4项对软件来说是已知的,后三项未知。所以,要分析输出数据的保持时间裕量,就要把后3项的和告诉软件,然后软件需要在最恶劣的情况下保证s l a c k ( h ) ⩾ 0 slack\left( h \right) \geqslant 0 s l a c k (h )⩾0。所谓的最恶劣情况,就是在前面4项已知的情况下,后3项和最小的情况,所以, 此处后三项的和被称为最小输出延迟output delay min,即
最小输出延迟 o u t p u t d e l a y min ⁡ = ( ( t d a t a ( p c b ) − t c l k 2 ( p c b ) ) + ( t d a t a ( d a c ) − t c l k 2 ( d a c ) ) − t h ( d a c ) ) ( min ⁡ ) \text{最小输出延迟}output\,\,delay\,\,\min =\left( \left( t_{data\left( pcb \right)}-t_{clk2\left( pcb \right)} \right) +\left( t_{data\left( dac \right)}-t_{clk2\left( dac \right)} \right) -t_{h\left( dac \right)} \right) \left( \min \right)最小输出延迟o u tp u t d e l a y min =((t d a t a (p c b )​−t c l k 2 (p c b )​)+(t d a t a (d a c )​−t c l k 2 (d a c )​)−t h (d a c )​)(min )
一般板上走线都会进行等长处理,所以t d a t a ( p c b ) t_{data\left( pcb \right)}t d a t a (p c b )​可认为和t c l k 2 ( p c b ) t_{clk2\left( pcb \right)}t c l k 2 (p c b )​相等,又一般芯片的t d a t a ( d a c ) t_{data\left( dac \right)}t d a t a (d a c )​和t c l k 2 ( d a c ) t_{clk2\left( dac \right)}t c l k 2 (d a c )​都很小,可以忽略,所以上式可简化为:
最小输出延迟 o u t p u t d e l a y min ⁡ = − ( t h ( d a c ) ( max ⁡ ) ) \text{最小输出延迟}output\,\,delay\,\,\min =-\left( t_{h\left( dac \right)}\left( \max \right) \right)最小输出延迟o u tp u t d e l a y min =−(t h (d a c )​(max ))
也就是说 外部数据接收芯片的最大保持时间的相反数就是最小输出延迟在reg2out的保持分析时,需要手动输入output delay min以供软件分析

三. 输入端到触发器

输入端到触发器,in2reg,此路径的起点为外部发送器件的时钟端,终点为FPGA内部触发器的输入端,如下图所示。

考虑时钟延迟的情况下,信号从REG1的D端传输到REG2的D端的路径延时如下图所示。

其中,t c l k 1 t_{clk1}t c l k 1 ​,t c l k 2 t_{clk2}t c l k 2 ​,t c o t_{co}t co ​,t d a t a t_{data}t d a t a ​,t s u t_{su}t s u ​,t h t_h t h ​与上文含义一样。

又因为时钟和数据是从一个芯片传输到另一个芯片,中间还有一段是PCB走线,所以,上图的t d a t a t_{data}t d a t a ​和t c l k 2 t_{clk2}t c l k 2 ​可继续细分,如下图所示。

走线可分为三段,分别是FPGA内部走线,PCB走线,DAC内部走线。

数据到达时间 d a t a a r r i v a l t i m e ( s u ) = L a u n c h E d g e ( s u ) + t c l k 1 + t c o ( a d c ) + t d a t a = L a u n c h E d g e ( s u ) + ( t c l k 1 ( f p g a ) + t c l k 1 ( p c b ) + t c l k 1 ( a d c ) ) + t c o ( a d c ) + ( t d a t a ( a d c ) + t d a t a ( p c b ) + t d a t a ( f p g a ) ) \text{数据到达时间}data\,\,arrival\,\,time\left( su \right) =Launch\,\,Edge\left( su \right) +t_{clk1}+t_{co\left( adc \right)}+t_{data} \ =Launch\,\,Edge\left( su \right) +\left( t_{clk1\left( fpga \right)}+t_{clk1\left( pcb \right)}+t_{clk1\left( adc \right)} \right) +t_{co\left( adc \right)}+\left( t_{data\left( adc \right)}+t_{data\left( pcb \right)}+t_{data\left( fpga \right)} \right)数据到达时间d a t a a rr i v a l t im e (s u )=L a u n c h E d g e (s u )+t c l k 1 ​+t co (a d c )​+t d a t a ​=L a u n c h E d g e (s u )+(t c l k 1 (f p g a )​+t c l k 1 (p c b )​+t c l k 1 (a d c )​)+t co (a d c )​+(t d a t a (a d c )​+t d a t a (p c b )​+t d a t a (f p g a )​)

数据要求时间 d a t a r e q u i r a l t i m e ( s u ) = L a t c h E d g e ( s u ) + t c l k 2 − t s u \text{数据要求时间}data\,\,requiral\,\,time\left( su \right) =Latch\,\,Edge\left( su \right) +t_{clk2}-t_{su}数据要求时间d a t a re q u i r a l t im e (s u )=L a t c h E d g e (s u )+t c l k 2 ​−t s u ​

建立时间裕量 s l a c k ( s u ) = d a t a r e q u i r a l t i m e ( s u ) − d a t a a r r i v a l t i m e ( s u ) = ( L a t c h E d g e ( s u ) + t c l k 2 − t s u ) − ( L a u n c h E d g e ( s u ) + ( t c l k 1 ( f p g a ) + t c l k 1 ( p c b ) + t c l k 1 ( a d c ) ) + t c o ( a d c ) + ( t d a t a ( a d c ) + t d a t a ( p c b ) + t d a t a ( f p g a ) ) ) = ( L a t c h E d g e ( s u ) − L a u n c h E d g e ( s u ) ) + ( t c l k 2 − t c l k 1 ( f p g a ) ) − t s u − t d a t a ( f p g a ) − ( t c l k 1 ( p c b ) + t d a t a ( p c b ) + t c l k 1 ( a d c ) + t c o ( a d c ) + t d a t a ( a d c ) ) \text{建立时间裕量}slack\left( su \right) =data\,\,requiral\,\,time\left( su \right) -data\,\,arrival\,\,time\left( su \right) \ =\left( Latch\,\,Edge\left( su \right) +t_{clk2}-t_{su} \right) \ -\left( Launch\,\,Edge\left( su \right) +\left( t_{clk1\left( fpga \right)}+t_{clk1\left( pcb \right)}+t_{clk1\left( adc \right)} \right) +t_{co\left( adc \right)}+\left( t_{data\left( adc \right)}+t_{data\left( pcb \right)}+t_{data\left( fpga \right)} \right) \right) \ =\left( Latch\,\,Edge\left( su \right) -Launch\,\,Edge\left( su \right) \right) +\left( t_{clk2}-t_{clk1\left( fpga \right)} \right) -t_{su}-t_{data\left( fpga \right)} \ -\left( t_{clk1\left( pcb \right)}+t_{data\left( pcb \right)}+t_{clk1\left( adc \right)}+t_{co\left( adc \right)}+t_{data\left( adc \right)} \right)建立时间裕量s l a c k (s u )=d a t a re q u i r a l t im e (s u )−d a t a a rr i v a l t im e (s u )=(L a t c h E d g e (s u )+t c l k 2 ​−t s u ​)−(L a u n c h E d g e (s u )+(t c l k 1 (f p g a )​+t c l k 1 (p c b )​+t c l k 1 (a d c )​)+t co (a d c )​+(t d a t a (a d c )​+t d a t a (p c b )​+t d a t a (f p g a )​))=(L a t c h E d g e (s u )−L a u n c h E d g e (s u ))+(t c l k 2 ​−t c l k 1 (f p g a )​)−t s u ​−t d a t a (f p g a )​−(t c l k 1 (p c b )​+t d a t a (p c b )​+t c l k 1 (a d c )​+t co (a d c )​+t d a t a (a d c )​)

分析同1.1与2.1,前四项已知,后三项的最大值为最恶劣情况,所以,此处 后三项的和被称为最大输入延迟input delay max,即
最大输入延迟 i n p u t d e l a y max ⁡ = ( ( t c l k 1 ( p c b ) + t d a t a ( p c b ) ) + ( t c l k 1 ( a d c ) + t c o ( a d c ) + t d a t a ( a d c ) ) ) ( max ⁡ ) \text{最大输入延迟}input\,\,delay\,\,\max =\left( \left( t_{clk1\left( pcb \right)}+t_{data\left( pcb \right)} \right) +\left( t_{clk1\left( adc \right)}+t_{co\left( adc \right)}+t_{data\left( adc \right)} \right) \right) \left( \max \right)最大输入延迟in p u t d e l a y max =((t c l k 1 (p c b )​+t d a t a (p c b )​)+(t c l k 1 (a d c )​+t co (a d c )​+t d a t a (a d c )​))(max )
可见最大输入延迟由两部分构成:

在in2out的建立分析时,需要手动输入input delay max以供软件分析

数据到达时间 d a t a a r r i v a l t i m e ( h ) = L a u n c h E d g e ( h ) + t c l k 1 + t c o ( a d c ) + t d a t a = L a u n c h E d g e ( h ) + ( t c l k 1 ( f p g a ) + t c l k 1 ( p c b ) + t c l k 1 ( a d c ) ) + t c o ( a d c ) + ( t d a t a ( a d c ) + t d a t a ( p c b ) + t d a t a ( f p g a ) ) \text{数据到达时间}data\,\,arrival\,\,time\left( h \right) =Launch\,\,Edge\left( h \right) +t_{clk1}+t_{co\left( adc \right)}+t_{data} \ =Launch\,\,Edge\left( h \right) +\left( t_{clk1\left( fpga \right)}+t_{clk1\left( pcb \right)}+t_{clk1\left( adc \right)} \right) +t_{co\left( adc \right)}+\left( t_{data\left( adc \right)}+t_{data\left( pcb \right)}+t_{data\left( fpga \right)} \right)数据到达时间d a t a a rr i v a l t im e (h )=L a u n c h E d g e (h )+t c l k 1 ​+t co (a d c )​+t d a t a ​=L a u n c h E d g e (h )+(t c l k 1 (f p g a )​+t c l k 1 (p c b )​+t c l k 1 (a d c )​)+t co (a d c )​+(t d a t a (a d c )​+t d a t a (p c b )​+t d a t a (f p g a )​)

数据要求时间 d a t a r e q u i r a l t i m e ( h ) = L a t c h E d g e ( h ) + t c l k 2 − t s u \text{数据要求时间}data\,\,requiral\,\,time\left( h \right) =Latch\,\,Edge\left( h \right) +t_{clk2}-t_{su}数据要求时间d a t a re q u i r a l t im e (h )=L a t c h E d g e (h )+t c l k 2 ​−t s u ​

保持时间裕量 s l a c k ( h ) = d a t a a r r i v a l t i m e ( h ) − d a t a r e q u i r a l t i m e ( h ) = ( L a u n c h E d g e ( h ) + ( t c l k 1 ( f p g a ) + t c l k 1 ( p c b ) + t c l k 1 ( a d c ) ) + t c o ( a d c ) + ( t d a t a ( a d c ) + t d a t a ( p c b ) + t d a t a ( f p g a ) ) ) − ( L a t c h E d g e ( h ) + t c l k 2 − t s u ) = − ( L a t c h E d g e ( h ) − L a u n c h E d g e ( h ) ) − ( t c l k 2 − t c l k 1 ( f p g a ) ) + t s u + t d a t a ( f p g a ) + ( t c l k 1 ( p c b ) + t d a t a ( p c b ) + t c l k 1 ( a d c ) + t c o ( a d c ) + t d a t a ( a d c ) ) \text{保持时间裕量}slack\left( h \right) =data\,\,arrival\,\,time\left( h \right) -data\,\,requiral\,\,time\left( h \right) \ =\left( Launch\,\,Edge\left( h \right) +\left( t_{clk1\left( fpga \right)}+t_{clk1\left( pcb \right)}+t_{clk1\left( adc \right)} \right) +t_{co\left( adc \right)}+\left( t_{data\left( adc \right)}+t_{data\left( pcb \right)}+t_{data\left( fpga \right)} \right) \right) \ -\left( Latch\,\,Edge\left( h \right) +t_{clk2}-t_{su} \right) \ =-\left( Latch\,\,Edge\left( h \right) -Launch\,\,Edge\left( h \right) \right) -\left( t_{clk2}-t_{clk1\left( fpga \right)} \right) +t_{su}+t_{data\left( fpga \right)} \ +\left( t_{clk1\left( pcb \right)}+t_{data\left( pcb \right)}+t_{clk1\left( adc \right)}+t_{co\left( adc \right)}+t_{data\left( adc \right)} \right)保持时间裕量s l a c k (h )=d a t a a rr i v a l t im e (h )−d a t a re q u i r a l t im e (h )=(L a u n c h E d g e (h )+(t c l k 1 (f p g a )​+t c l k 1 (p c b )​+t c l k 1 (a d c )​)+t co (a d c )​+(t d a t a (a d c )​+t d a t a (p c b )​+t d a t a (f p g a )​))−(L a t c h E d g e (h )+t c l k 2 ​−t s u ​)=−(L a t c h E d g e (h )−L a u n c h E d g e (h ))−(t c l k 2 ​−t c l k 1 (f p g a )​)+t s u ​+t d a t a (f p g a )​+(t c l k 1 (p c b )​+t d a t a (p c b )​+t c l k 1 (a d c )​+t co (a d c )​+t d a t a (a d c )​)

分析同1.2与2.2,前四项已知,后三项的最小值为最恶劣情况,所以,此处 后三项的和被称为最小输入延迟input delay max,即
最小输入延迟 i n p u t d e l a y min ⁡ = ( ( t c l k 1 ( p c b ) + t d a t a ( p c b ) ) + ( t c l k 1 ( a d c ) + t c o ( a d c ) + t d a t a ( a d c ) ) ) ( min ⁡ ) \text{最小输入延迟}input\,\,delay\,\,\min =\left( \left( t_{clk1\left( pcb \right)}+t_{data\left( pcb \right)} \right) +\left( t_{clk1\left( adc \right)}+t_{co\left( adc \right)}+t_{data\left( adc \right)} \right) \right) \left( \min \right)最小输入延迟in p u t d e l a y min =((t c l k 1 (p c b )​+t d a t a (p c b )​)+(t c l k 1 (a d c )​+t co (a d c )​+t d a t a (a d c )​))(min )
可见 最大输入延迟与最小输入延迟的公式是一样的,PCB延迟是固定的,所以两种延迟的区别是: ADC芯片的内部时钟延迟与数据输出延迟是变化的,有最大值和最小值,就分别对应了最大/最小输入延迟

四. 总结

通过以上分析可以看出,不同时序路径的分析方法大同小异,都是基于reg2reg,然后引入FPGA内部路径,PCB路径与外部器件路径来计算数据到达时间与数据要求时间,最后两者相减就对应了建立时间裕量与保持时间裕量。

本文介绍了最大/最小输出延迟,最大/最小输入延迟这四个新概念,它们都对应FPGA时序分析软件中的一项分析,且这些值对软件是未知的,需要手动输入。

五. 参考

徐晓康的博客持续分享高质量硬件、FPGA与嵌入式知识,软件,工具等内容,欢迎大家关注。

Original: https://blog.csdn.net/weixin_42837669/article/details/127757092
Author: 徐晓康的博客
Title: FPGA时序约束02——不同时序路径的分析方法

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/654091/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球