【system verilog】并发断言SVA bind RTL module的几种方式

前言

数字前端的功能验证利器——SVA断言学习笔记_moon9999的博客-CSDN博客_sva断言

学会了写断言还要学会将断言bind到环境中,因此总结归纳下bind sva_module到RTL上的方式;

正文开启

并发断言SVA的组织形式一般是,把断言组织在一个module中,之后将这个sva_module bind在对应的rtl_module上;

bind module_name sva_name sva_inst;

第一种方式,断言会关联到module_name的所有例化示例,在VCS中bind之后sva_inst路径位于rtl_inst下一层;

例如:

module test_sva #(parameter DATA_WIDTH = 4)(
    input clk   ,
    input rst_n ,
    input                   data_out_vld    ,
    input                   data_out_sop    ,
    input                   data_out_eop    ,
    input [DATA_WIDTH-1:0]  data_out
);

    logic before_rst = 1'b1;
    always @(*)begin
        if(~rst_n) begin
            #1ps;
                before_rst = 1'b0;
        end
    end


    property onehot_chk;
        @(posedge clk) disable iff(before_rst)
            $onehot(top.U_flow_proc.data_out);
    endproperty

endmodule

bind flow_proc test_sva U_test_sva(.*);

bind module_inst sva_name sva_inst(.*);

断言会关联到特定的rtl_inst上,module_inst一般需要完整路径;

例如:

module test_sva #(parameter DATA_WIDTH = 4)(
    input clk   ,
    input rst_n ,
    input                   data_out_vld    ,
    input                   data_out_sop    ,
    input                   data_out_eop    ,
    input [DATA_WIDTH-1:0]  data_out
);

    logic before_rst = 1'b1;
    always @(*)begin
        if(~rst_n) begin
            #1ps;
                before_rst = 1'b0;
        end
    end


    property onehot_chk;
        @(posedge clk) disable iff(before_rst)
            $onehot(top.U_flow_proc.data_out);
    endproperty

endmodule

bind top.U_flow_proc test_sva U_test_sva(.*);

bind module_name: inst1, inst2 sva_name sva_inst(.*);

断言会关联到module_name的某些例化实例下;

例如:

module test_sva #(parameter DATA_WIDTH = 4)(
    input clk   ,
    input rst_n ,
    input                   data_out_vld    ,
    input                   data_out_sop    ,
    input                   data_out_eop    ,
    input [DATA_WIDTH-1:0]  data_out
);

    logic before_rst = 1'b1;
    always @(*)begin
        if(~rst_n) begin
            #1ps;
                before_rst = 1'b0;
        end
    end


    property onehot_chk;
        @(posedge clk) disable iff(before_rst)
            $onehot(top.U_flow_proc.data_out);
    endproperty

endmodule

bind flow_proc: top.U_flow_proc test_sva U_test_sva(.*);

直接例化sva_module sva_inst(.*);

如果不采用bind方式,也可以把sva_module作为一个rtl_module直接例化在环境中,或者例化在module中。

test_sva #(.DATA_WIDTH(8)) U_test_sva(clk, rst_n);

不考虑继承性的话,断言也中可以直接使用全局路径信号进行检查。

property onehot_chk;
    @(posedge clk) disable iff(before_rst)
        $onehot(top.U_flow_proc.data_out);
endproperty

接口连接

连接时使用.*可以自动连接名称相同、类型匹配的接口信号,其他信号可以使用.sig1(rtl.sig2)显示的写出,两种方式在连接中可以混用。

  • 19
    点赞
  • 110
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
There are some simple tricks that every design engineer should know to facilitate the usage of SystemVerilog Assertions. Although this paper is not intended to be a comprehensive tutorial on SystemVerilog Assertions, it is worthwhile to give a simplified definition of a property and the concurrent assertion of a property. 1.1 What is an assertion? An assertion is basically a "statement of fact" or "claim of truth" made about a design by a design or verification engineer. An engineer will assert or "claim" that certain conditions are always true or never true about a design. If that claim can ever be proven false, then the assertion fails (the "claim" was false). Assertions essentially become active design comments, and one important methodology treats them exactly like active design comments. More on this in Section 2. A trusted colleague and formal analysis expert[1] reports that for formal analysis, describing what should never happen using "not sequence" assertions is even more important than using assertions to describe always true conditions. 1.2 What is a property? A property is basically a rule that will be asserted (enabled) to passively test a design. The property can be a simple Boolean test regarding conditions that should always hold true about the design, or it can be a sampled sequence of signals that should follow a legal and prescribed protocol. For formal analysis, a property describes the environment of the block under verification, i.e. what is legal behavior of the inputs. 1.3 Two types of SystemVerilog assertions SystemVerilog has two types of assertions: (1) Immediate assertions (2) Concurrent assertions Immediate assertions execute once and are placed inline with the code. Immediate assertions are not exceptionally useful except in a few places, which are detailed in Section 3.
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尼德兰的喵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值