Verilog中的specify block和timing check

specify block用来描述从源点(source:input/inout port)到终点(destination:output/inout port)的路径延时(path delay),由specify开始,到endspecify结束,并且只能在模块内部声明,具有精确性(accuracy)和模块性(modularity)的特点。specify block可以用来执行以下三个任务:

一、描述横穿整个模块的各种路径及其延时。(module path delay)
二、脉冲过滤限制。(pulse filtering limit)
三、时序检查。(timing check)

specify block有一个专用的关键字specparam用来进行参数声明,用法和parameter一样,不同点是两者的作用域不同:specparam只能在specify block内部声明及使用,而parameter只能在specify block外部声明及使用。
////////////////////////////////////////////////////////////////////////////////
第一个任务:模块路径延时(module path delay)
一条模块路径可以是一条简单的路径(simple path),或者是一条边缘敏感的路径(edge sensitive path),或者是一条状态依赖的路径(state dependent path)。
//------------------------------------------------------------------------------
一、simple path,可以由以下两种格式中的任意一种来声明:
1)、并行连接(patallel connection):source => destination
2)、全连接(full connection): source *> destination
例: (a, b => q, qn) = 1; 等价于:
(a => q) = 1; (b => qn) = 1;
而(a, b *> q, qn) = 1; 等价于:
(a => q) = 1; (b => q) = 1; (a => qn) = 1; (b => qn) = 1;

//------------------------------------------------------------------------------
二、edge sensitive path,是那些源点(source)使用边沿触发的路径,并使用边缘标示符指明触发条件(posedge/negedge),如果没有指明的话,那么就是任何变化都会触发终点(destination)的变化。
例1:(posedge clk => (out +: in)) = (1,2);
在clk的上升沿,从clk到out的模块路径,其上升延时是1,下降延时是2,从in到out的数据路径是同向传输,即out = in。
例2:(negedge clk => (out -: in)) = (1,2);
在clk的下降沿,从clk到out的模块路径,其上升延时是1,下降延时是2,从in到out的数据路径是反向传输,即out = ~in。
例3:(clk => (out : in)) = (1,2);
clk的任何变化,从clk到out的模块路径,其上升延时是1,下降延时是2,从in到out的数据路径的传输是不可预知的,同向或者反向或者不变。
Note:模块路径的极性(module path polarity):未知极性(unknown polarity,无),正极性(positive polarity,+),负极性(negative polarity,-)。
//------------------------------------------------------------------------------
三、state dependent path,是那些源点(source)以来指定条件状态的路径,使用if语句(不带else)。在条件=1 or X or Z的情况下,认为条件成立。如果有一条路经,存在多个条件同时成立的情况,那么使用延时最小值的那条限制。
例1: specify
if(a) (b => out) = (1,2);
if(~a) (b => out) = (2,3);
if(b) (a => out) = (1,2);
if(~b) (a => out) = (2,3);
endspecify
例2: specify
if(rst) (posedge clk => (q +: data)) = (1,2);
if(~rst) (posedge clk => (q +: data)) = (2,3);
endspecify
需要注意的是,所有输入状态都应该说明,否则没有说明的路径使用分布延时(distributed delay),如果也没有声明分布延时(distributed delay)的话,那么使用零延时(zero delay)。如果路径延时和分布延时同时声明的话,则选择最大的延时作为路径延时。另外,也可以使用ifnone语句,在其它所有条件都不满足的情况下,说明一个缺省的状态依赖路径延时。
例3: specify
(posedge clk => (q +: data)) = (1,2);
ifnone (clk => q) = (2,3);
endspecify

////////////////////////////////////////////////////////////////////////////////
第二个任务,脉冲过滤限制(pulse filtering limit)
由于每条传播路径都具有一定的电容性和电阻性,电荷无法在一瞬间积累或消散,所以信号变化的物理特性是具有惯性的。为了更准确地描述这种能力,使用惯性延时(inertial delay),它可以抑制持续信号比传播延时短的输入信号的变化。
例1:1ns宽度的窄脉宽通过一个传输延时为2ns的BUFFER

两个脉宽限制值:e-limit(error limit)和r-limit(rejection limit),并且要求e-limit >= r-limit,否则报错。当pulse width >= e-limit时,输出相应的逻辑值;当e-limit > pulse width >= r-limit时,输出X值;当r-limit > pulse width时,输出不发生变化。默认情况下,e-limit = r-limit = module transition delay,也可以使用以下3种控制方式中的任意一种改变路径脉冲限制值:
1、使用verilog提供的PATHPULSE 仿 使 V C S + p a t h p u l s e P A T H P U L S E 参数,有些仿真器还要求同时使能相应的选项:比如VCS,添加+pathpulse选项。 PATHPULSE = (, );
PATHPULSE < p a t h s o u r c e > <path_source> <path_destination> = (, );
例: specify
(en => q) = 12;
(data => q) = 10;
(clr, pre *> q) = 4;
specparam
PATHPULSE$ = 3, PATHPULSE e n en q = (2,9), PATHPULSE c l r clr q = 1;
endspecify
en => q的路径:reject-limit = 2, error-limit =9;
clr => q和pre => q的路径:reject-limit = error-limit = 1;
data => q的路径:reject-limit = error-limit = 3;
2、使用仿真器专用的编译指导。比如VCS,+pulse_r/20(取20%)和+pulse_e/80(取80%),需要注意的是,这个选项要求放在读入RTL网表文件之后,否则设置无效。
3、使用SDF文件反标,并且SDF文件中的延时信息具有最高的优先级。SDF文件格式将在后面介绍。

脉冲过滤限制的默认格式存在两个缺点:
1、X状态的持续时间比较短。
2、在上升延时和下降延时不相等的情况下,如果脉冲过窄,那么可能出现跟随边缘(trailing edge)先于或等于导引边缘(leading edge)的现象,这时就会淹没X状态。
可以通过修改默认格式,加以改善,具体如下:
on-event vs on-detect:

negative width pulse detection:

需要注意的是,showcancelled list_path_of_outputs,必须在模块路径之前使用,才可以约束到该模块路径。

////////////////////////////////////////////////////////////////////////////////

第三个任务,时序检查(timing check)
描述设计要求的时序性能,所有的时序检查有一个参考事件(reference event)和一个数据事件(data event),它们通过一个布尔表达式相联接,还包括一个可选的notifier寄存器选项,这个寄存器用来打印错误信息或者传播X状态。
这里把时序检查分成两组来说明:
第一组,检查时序窗口的稳定性,包括:setup、hold、recovery和removal。
setup:$setup (data_event, reference_event, limit, notifier);
当reference_event time - limit < data_event time < reference_event time时,就会报告setup time violations。
hold: h o l d ( r e f e r e n c e e v e n t , d a t a e v e n t , l i m i t , n o t i f i e r ) ; r e f e r e n c e e v e n t t i m e < d a t a e v e n t t i m e < r e f e r e n c e e v e n t t i m e + l i m i t h o l d t i m e v i o l a t i o n s s e t u p / h o l d hold (reference_event, data_event, limit, notifier); 当reference_event time < data_event time < reference_event time + limit时,就会报告hold time violations。 setup/hold: setuphold (reference_event, data_event, setup_limit, hold_limit, notifier);
s e t u p h o l d setuphold是 setup和$hold两者的联合。例如:
$setuphold (posedge clk, negedge d, 2, 1, notifier); 等于
$setup (negedge d, posedge clk, 2, notifier); 和 $hold (posedge clk, negedge d, 1, notifier);
数据事件常常是数据信号,而参考事件常常是时钟信号,如下图:

recovery:$recovery (reference_event, data_event, limit, notifier);
当data_event time - limit < reference_event time < data_event time时,就会报告recovery time violations。
removal: r e m o v a l ( r e f e r e n c e e v e n t , d a t a e v e n t , l i m i t , n o t i f i e r ) ; d a t a e v e n t t i m e < r e f e r e n c e e v e n t t i m e < d a t a e v e n t t i m e + l i m i t r e m o v a l t i m e v i o l a t i o n s r e c o v e r y / r e m o v a l removal (reference_event, data_event, limit, notifier); 当data_event time < reference_event time < data_event time + limit时,就会报告removal time violations。 recovery/removal: recrem (reference_event, data_event, recovery_limit, removal_limit, notifier);
r e c r e m recrem是 recovery和$removal两者的联合。
$recrem (posedge clr, posedge clk, 2, 3, notifier); 等于
$recovery (posedge clr, posedge clk, 2, notifier); 和 $removal (posedge clr, posedge clk, 3, notifier);
数据事件常常是时钟信号,而参考事件常常是控制信号,比如清除信号或者置位信号,如下图:

s e t u p h o l d setuphold和 recrem可以接受负值,同时需要激活仿真器的负值时序检查选项(比如VCS:+neg_tchk),同时还有一个限制:
setup_limit + hold_limit > 仿真精度(simulation unit of precision),
recovery_limit + removal_limit > 仿真精度(simulation unit of precision),
否则仿真器会把负值当成0处理。

第二组,检查时钟和控制信号在指定事件之间的时间间隔,包括:skew、width、period和nochange。
skew:$skew (reference_event, data_event, limit, notifier); 限制最大偏斜
$skew (posedge clk1, posedge clk2, 1, notifier);
当data_event time - reference_event > limit,则会报告skew time violations。
s k e w e v e n t b a s e d r e f e r e n c e e v e n t d a t a e v e n t r e f e r e n c e e v e n t d a t a e v e n t r e f e r e n c e e v e n t w i d t h skew是基于事件(event-based)的,如果监测到一个reference_event,那么就开始评估脉宽,只要监测到一个data_event,就会生成相应的报告,直到监测到下一个reference_event,才重新开始新的监测。如果在监测到一个data_event之前,又监测到一个reference_event,那么就放弃本次评估,重新开始新的评估。 width: width (controlled_reference_event, limit, threshold, notifier); 限制最小脉宽
w i d t h ( p o s e d g e i n , 2 , n o t i f i e r ) ; d a t a e v e n t r e f e r e n c e e v e n t w i d t h < l i m i t w i d t h t i m e v i o l a t i o n s p e r i o d width (posedge in, 2, notifier); 这里data_event是隐含的,它等于reference_event的相反边缘,当width < limit时,就会报告width time violations。 period: period (controlled_reference_event, limit, notifier); 限制最小周期
p e r i o d ( n e g e d g e c l k , 10 , n o t i f i e r ) ; d a t a e v e n t r e f e r e n c e e v e n t p e r i o d < l i m i t p e r i o d t i m e v i o l a t i o n s n o c h a n g e period (negedge clk, 10, notifier); 这里data_event是隐含的,它等于reference_event的相同边缘,当period < limit时,就会报告period time violations。 nochange: nochange (reference_event, data_event, start_edge_offset, end_edge_offset, notifier);
当leading reference event time - start_edge_offset < data_event < trailing reference event time + end_edge_offset时,就会报告nochange time violations。例如:
$nochange (posedge clk, data, 0 , 0);
当在clk高电平期间,data发生任何变化,就会报告nochange time violations。

有时候,路径上的时序检查是在一定条件成立的前提下进行的,这就需要引入条件操作符:&&&。需要注意的是,当存在两个及以上的条件时,要求这些条件首先在specify块外部经过适当的组合逻辑产生一个新的控制信号,然后再引入到specify块内部使用。
例如:
and u1 (clr_and_set, clr, set);
specify
$setup (negedge data, posedge clk &&& clr_and_set, 3, notifier);
endspecify

////////////////////////////////////////////////////////////////////////////////

SDF文件简述:
SDF文件包含指定路径延时(specify path delay),参数值(specparam values),时序检查约束(timing check constraints),互连线延时(interconnect delay),以及一些和仿真不相关的说明信息。反标SDF文件的过程,也算是更新specify block相对应信息的过程,如果SDF文件没有包含某些信息,则参考specify block中的相应信息。
SDF时序信息在CELL内部描述,可以包含一个或多个DELAY、TIMINGCHECK和LABEL。DELAY部分包含指定路径的传播延时(specify path delay)和互连线延时(interconnect delay);TIMINGCHECK部分包含时序检查约束信息(timing check constraint);LABEL部分包含新的参数值(specparam)。

DELAY部分:

例1:SDF文件:(IOPATH in out (1.1::1.3) (1.5::1.7));
verilog specify path:(in => out) = (2, 3);
例2:SDF文件:(COND en==1’b1 (IOPATH in out (1.2) (1.6));
verilog specify path:if (en) (in => out) = (1, 2);
例3:互连线延时:(INTERCONNECT source_port load_port delay_values)
SDF文件:(INTERCONNECT u1/out u2/in (1.2::1.4) (1.4::1.6));

TIMINGCHECK部分:

例4: SDF文件: (SETUP (posedge data) (posedge clk) (3::4));
(HOLD (posedge data) (posedge clk) (1::2));
verilog timing checks: $setup (posedge data, posedge clk, 1);
$hold (posedge clk, posedge data, 2);

例5: SDF文件: (SETUP (posedge data) (COND rb1’b1 (posedge clk)) (3::4));
(HOLD (posedge data) (COND rb
1’b1 (posedge clk)) (1::2));
verilog timing checks: $setup (posedge data, posedge clk &&& rb, 1);
KaTeX parse error: Expected 'EOF', got '&' at position 21: … (posedge clk &̲&& rb, posedge …sdf_annotate)多个SDF文件时,就很可能发生的。
例7:覆盖前面的延时信息
(DELAY
(ABSOLUTE
(IOPATH A Z (1) (2))
(IOPATH A Z (2) (3))))

发布了105 篇原创文章 · 获赞 71 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/vivid117/article/details/105099662