verilog 学习记(如何编写assert)

来源:互联网 发布:淘宝易轩数码靠谱吗 编辑:程序博客网 时间:2024/04/28 14:26


【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】


    我们在编写c代码的时候,一般测试的时候都要用assert进行判断。那么怎么在verilog中进行assert判断呢?大家知道,system verilog是包含有assert语句的,但是raw verilog没有。既然verilog 没有,那么我们可以自己定义一个module,一样可以实现assert的功能。今天在网上看到别人的描述,自己写了一段类似的代码,和大家一起分享一下。希望对大家有所帮助。


// author : feixiaoxing// date   : 2017_01_19// history://module assert(clk, in);// input & outputinput clk;input in;// wire & reg;wire clk;wire in;// inner wire & reg/* none */// always clause defined herealways @(posedge clk)beginif(in !== 1)begin$display("assert happened in %m\n");$finish;endendendmodule


1 0