需求: 在systemverilog 的string看是否存在某个字节或某段字符串
其实请前辈说match也不算是sv的语法了,而且只IEEE中确实也没有该function, 不过可以实现上面所需,用的时候可能会受simulator 的影响。
eg:
program string_test;
string str = "add16_rri";
initial begin
if(str.match("16")) begin
$display("match success");
end else begin
$display("not match success");
end
if(str.match("abc")) begin
$display("match success");
end else begin
$display("not match success");
end
end
endprogram
result:
match success
not match success
$finish at simulation time 0
本文介绍如何使用SystemVerilog中的match方法来判断一个字符串是否包含特定的子串。通过示例程序展示了当字符串中存在目标子串时如何输出匹配成功的信息。
1295

被折叠的 条评论
为什么被折叠?



