• 后仿真中的 《specify/endspecify block》之(5)使用specify进行时序仿真


    前面我们学习了specify...endspecify 具体是什么东西。今天,我们使用specify block 中定义的延时,来进行一次仿真。看看到底是背后如何运转的呢。

    一 基本例子

    一个用 specify 指定延迟的与门逻辑描述如下:

    1. module and_gate(
    2. output Z,
    3. input A, B);
    4. assign Z = A & B ;
    5. specify
    6. specparam t_rise = 1.3:1.5:1.7 ;
    7. specparam t_fall = 1.1:1.3:1.6 ;
    8. (A, B *> Z) = (t_rise, t_fall) ;
    9. endspecify
    10. endmodule

    一个用 specify 指定延迟的 D 触发器描述如下:

    1. module d_gate(
    2. output Q ,
    3. input D, CP);
    4. reg Q_r ;
    5. always @(posedge CP)
    6. Q_r <= D ;
    7. assign Q = Q_r ;
    8. specify
    9. if (D == 1'b1)
    10. (posedge CP => (Q +: D)) = (1.3:1.5:1.7, 1.1:1.4:1.9) ;
    11. if (D == 1'b0)
    12. (posedge CP => (Q +: D)) = (1.2:1.4:1.6, 1.0:1.3:1.8) ;
    13. $setup(D, posedge CP, 1);
    14. endspecify
    15. endmodule

    顶层模块描述如下,主要功能是将与逻辑的输出结果输入到 D 触发器进行缓存。

    1. module top(
    2. output and_out,
    3. input in1, in2, clk);
    4. wire res_tmp ;
    5. and_gate u_and(res_tmp, in1, in2);
    6. d_gate u_dt(and_out, res_tmp, clk);
    7. endmodule

    testbench 描述如下,仿真时设置 "+maxdelays",使用最大延迟值。

    1. `timescale 1ns/1ps
    2. module test ;
    3. wire and_out ;
    4. reg in1, in2 ;
    5. reg clk ;
    6. initial begin
    7. clk = 0 ;
    8. forever begin
    9. #(10/2) clk = ~clk ;
    10. end
    11. end
    12. initial begin
    13. in1 = 0 ; in2 = 0 ;
    14. # 32 ;
    15. in1 = 1 ; in2 = 1 ;
    16. # 13 ;
    17. in1 = 1 ; in2 = 0 ;
    18. end
    19. top u_top(
    20. .and_out (and_out),
    21. .in1 (in1),
    22. .in2 (in2),
    23. .clk (clk));
    24. initial begin
    25. forever begin
    26. #100;
    27. if ($time >= 1000) $finish ;
    28. end
    29. end
    30. endmodule // test

    仿真时序如下所示,由图可知:

    • (1) 与门输入端 A/B 到输出端 Z 的上升延迟为 33.7-32=1.7ns;
    • (2) 与门输出端 Z 到触发器输入端 D 的互联延迟为 0;
    • (3) 触发器 D 端到 CP 端时间差为 35-33.7=1.3ns,大于 setup check 时设置的 1ns,因此时序满足要求,不存在 violation 。
    • (4) 触发器 CP 端到输出端 Q 的上升延迟为 36.7-35=1.7ns;

    综上所述,仿真结果符合设计参数。

    二 拓展延伸 

    其实,我们可以做一个延伸。修改代码如下:

    1. module top(
    2. output and_out,
    3. input in1, in2, clk);
    4. wire res_tmp;
    5. wire res_tmp_tmp;
    6. assign res_tmp_tmp = res_tmp;
    7. specify
    8. ( res_tmp => res_tmp_tmp) = (2:3:4, 3:4:5);
    9. endspecfiy
    10. and_gate u_and(res_tmp, in1, in2);
    11. d_gate u_dt(and_out, res_tmp_tmp, clk);
    12. endmodule

    修改上面代码,重新进行仿真,我们会发现,Z -> D 之间,将会有 4 ns 的延时存在。 

  • 相关阅读:
    FirmAFL
    【globlal与nonlocal和闭包函数、装饰器、语法糖】
    网络安全(黑客)——自学笔记
    Argo CD入门、实战指南
    基于Echarts实现可视化数据大屏北斗车联网大数据服务平台首页面
    如何监控香港服务器的性能
    聊聊Http服务化改造实践
    Mit6.006-problemSet01
    2022-3月报
    CAMx的空气质量模拟及污染来源解析丨大气臭氧来源解析模拟与臭氧成因分析
  • 原文地址:https://blog.csdn.net/qq_16423857/article/details/139888764