如何解决是否可以在 SystemVerilog 中不同的其他 case 语句中包含的 case 语句中使用相同的表达式?
我有一个 SystemVerilog 测试平台,我想在其中使用我程序中其他 case
语句中的 case
语句。
例如,我有:
task a(string b,string c)
case(b)
"a1": x(x1,case(c) "b1":y=1; "b2":y=2;);
"a2": x(x2,case(c) "b3":y=4; "b4":y=5;);
这是我想要实现的结构,在多个不同的 case 项中使用带有字符串 c 的 case。
解决方法
如果我猜对了,x
表示一个任务或一个函数,而您正试图将 case 语句作为参数传递。对?不可能。
但这应该有效:
task a(string b,string c)
case(c)
"b1": y = 1;
"b2": y = 2;
...
endcase
case(b)
"a1": x(x1,y);
"a2": x(x2,y);
或者对于 case 中的 case 通常使用 begin/end:
"a1": begin
x=x1;
case(c)
"b1":y=1;
"b2":y=2;
endcase
end
"a2": begin
x = x2;
case(c)
"b3": y=3;
"b4": y= 4;
endcase
end
endcase
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。