systemverilog操作符
Posted 薛定谔的猫冫
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了systemverilog操作符相关的知识,希望对你有一定的参考价值。
== / != / === / !===
1 program main ; 2 reg a_1,a_0,a_x,a_z; 3 reg b_1,b_0,b_x,b_z; 4 initial 5 begin 6 a_1 = \'b1;a_0 = \'b0;a_x = \'bx;a_z = \'bz; 7 b_1 = \'b1;b_0 = \'b0;b_x = \'bx;b_z = \'bz; 8 $display("--------------------------"); 9 $display (" == 0 1 x z "); 10 $display("--------------------------"); 11 $display (" 0 %b %b %b %b ",a_0 == b_0,a_0 == b_1,a_0 == b_x,a_0 == b_z); 12 $display (" 1 %b %b %b %b ",a_1 == b_0,a_1 == b_1,a_1 == b_x,a_1 == b_z); 13 $display (" x %b %b %b %b ",a_x == b_0,a_x == b_1,a_x == b_x,a_x == b_z); 14 $display (" z %b %b %b %b ",a_z == b_0,a_z == b_1,a_z == b_x,a_z == b_z); 15 $display("--------------------------"); 16 $display("--------------------------"); 17 $display (" === 0 1 x z "); 18 $display("--------------------------"); 19 $display (" 0 %b %b %b %b ",a_0 === b_0,a_0 === b_1,a_0 === b_x,a_0 === b_z); 20 $display (" 1 %b %b %b %b ",a_1 === b_0,a_1 === b_1,a_1 === b_x,a_1 === b_z); 21 $display (" x %b %b %b %b ",a_x === b_0,a_x === b_1,a_x === b_x,a_x === b_z); 22 $display (" z %b %b %b %b ",a_z === b_0,a_z === b_1,a_z === b_x,a_z === b_z); 23 $display("--------------------------"); 24 $display("--------------------------"); 25 $display (" =?= 0 1 x z "); 26 $display("--------------------------"); 27 $display (" 0 %b %b %b %b ",a_0 =?= b_0,a_0 =?= b_1,a_0 =?= b_x,a_0 =?= b_z); 28 $display (" 1 %b %b %b %b ",a_1 =?= b_0,a_1 =?= b_1,a_1 =?= b_x,a_1 =?= b_z); 29 $display (" x %b %b %b %b ",a_x =?= b_0,a_x =?= b_1,a_x =?= b_x,a_x =?= b_z); 30 $display (" z %b %b %b %b ",a_z =?= b_0,a_z =?= b_1,a_z =?= b_x,a_z =?= b_z); 31 $display("--------------------------"); 32 $display("--------------------------"); 33 $display (" != 0 1 x z "); 34 $display("--------------------------"); 35 $display (" 0 %b %b %b %b ",a_0 != b_0,a_0 != b_1,a_0 != b_x,a_0 != b_z); 36 $display (" 1 %b %b %b %b ",a_1 != b_0,a_1 != b_1,a_1 != b_x,a_1 != b_z); 37 $display (" x %b %b %b %b ",a_x != b_0,a_x != b_1,a_x != b_x,a_x != b_z); 38 $display (" z %b %b %b %b ",a_z != b_0,a_z != b_1,a_z != b_x,a_z != b_z); 39 $display("--------------------------"); 40 $display("--------------------------"); 41 $display (" !== 0 1 x z "); 42 $display("--------------------------"); 43 $display (" 0 %b %b %b %b ",a_0 !== b_0,a_0 !== b_1,a_0 !== b_x,a_0 !== b_z); 44 $display (" 1 %b %b %b %b ",a_1 !== b_0,a_1 !== b_1,a_1 !== b_x,a_1 !== b_z); 45 $display (" x %b %b %b %b ",a_x !== b_0,a_x !== b_1,a_x !== b_x,a_x !== b_z); 46 $display (" z %b %b %b %b ",a_z !== b_0,a_z !== b_1,a_z !== b_x,a_z !== b_z); 47 $display("--------------------------"); 48 $display("--------------------------"); 49 $display (" !?= 0 1 x z "); 50 $display("--------------------------"); 51 $display (" 0 %b %b %b %b ",a_0 !?= b_0,a_0 !?= b_1,a_0 !?= b_x,a_0 !?= b_z); 52 $display (" 1 %b %b %b %b ",a_1 !?= b_0,a_1 !?= b_1,a_1 !?= b_x,a_1 !?= b_z); 53 $display (" x %b %b %b %b ",a_x !?= b_0,a_x !?= b_1,a_x !?= b_x,a_x !?= b_z); 54 $display (" z %b %b %b %b ",a_z !?= b_0,a_z !?= b_1,a_z !?= b_x,a_z !?= b_z); 55 $display("--------------------------"); 56 end 57 endprogram
Result:
-------------------------- == 0 1 x z -------------------------- 0 1 0 x x 1 0 1 x x x x x x x z x x x x -------------------------- -------------------------- === 0 1 x z -------------------------- 0 1 0 0 0 1 0 1 0 0 x 0 0 1 0 z 0 0 0 1 -------------------------- -------------------------- =?= 0 1 x z -------------------------- 0 1 0 1 1 1 0 1 1 1 x 1 1 1 1 z 1 1 1 1 -------------------------- -------------------------- != 0 1 x z -------------------------- 0 0 1 x x 1 1 0 x x x x x x x z x x x x -------------------------- -------------------------- !== 0 1 x z -------------------------- 0 0 1 1 1 1 1 0 1 1 x 1 1 0 1 z 1 1 1 0 -------------------------- -------------------------- !?= 0 1 x z -------------------------- 0 0 1 0 0 1 1 0 0 0 x 0 0 0 0 z 0 0 0 0 --------------------------
以上是关于systemverilog操作符的主要内容,如果未能解决你的问题,请参考以下文章
求systemverilog vimrc 高亮方法(要代码)