verilog - 错误 (10170):Test1.sv(29) 附近文本处的 Verilog HDL 语法错误:“程序”;期待描述
问题描述
尝试通过 System Verilog 测试 Verilog 模块。我正在分析 RTL 模拟,但出现错误:
错误 (10170):Test1.sv(29) 附近文本处的 Verilog HDL 语法错误:“程序”;期待描述
谁能帮我吗?
我尝试调试它,但没有结果。在我实例化要测试的模块后,它会在此处显示错误。
interface valid_in1 (input clk);
logic din;
logic res;
logic out;
modport dut (input clk, din, res, output out);
modport tb (input out, output clk, din, res);
task monitor ();
while (1) begin
@(posedge clk);
if (din==1'b1) begin
$display ("@%0dns res %b out %b din %b clk %b",
$time, res, out, din, clk);
end
end
endtask
endinterface: valid_in1
module valid (valid_in1.dut din);
valid_in dut (.clk(din.clk),
.din(din.din),
.res(din.res),
.out(din.out));
endmodule
program validprog (valid_in1.tb tin);
default clocking cb @(posedge tin.clk);
endclocking
initial begin
fork
tin.monitor();
join_none
tin.res <= 1;
tin.din <= 0;
##10 tin.res <= 0;
##1 tin.din <= 1;
##10 tin.din <= 0;
##5 $finish;
end
endprogram
module Test1 ();
logic clk= 0;
always #1 clk++;
valid_in1 cin (clk);
valid dut (cin);
validprog tb (cin);
endmodule
这是我试图测试的 valid_in 模块:
module d_flip(din, clk, res, q, revq);
input din, clk, res;
output q, revq;
reg q;
assign revq = ~q;
always @(clk) begin
if(res == 0)
q = 0;
else
q = din;
end
endmodule
module valid_in(din, clk, res, out);
input din, clk, res;
output out;
wire q1, revq1, q2, revq2;
d_flip bl1(din, clk, res, q1, revq1);
d_flip bl2(q1, clk, res, q2, revq2);
and(out, q1, revq2);
endmodule
解决方案
这些应该在 SV 编译中工作:
来自接口的任务必须在 modport 中导入(导入到模块中)
你的接口只有一个端口(clk),不能用多个端口实例化
interface valid_in1 (input clk);
logic din;
logic res;
logic out;
modport dut (input clk, din, res, output out);
modport tb (input out, clk, output din, res, import monitor); // << import task
task monitor ();
while (1) begin
@(posedge clk);
if (din==1'b1) begin
$display ("@%0dns res %b out %b din %b clk %b",
$time, res, out, din, clk);
end
end
endtask
endinterface: valid_in1
module valid (valid_in1.dut din);
// I believe that you meant 'valid_in1', not just 'valid_in'.
// it could have caused your compilation issue. Check other errors and warnings.
valid_in1 dut (.clk(din.clk) // << only one port can be used (clk)
/*, .din(din.din),
.res(din.res),
.out(din.out)*/);
endmodule
除此之外,eda playground 的 synopsys 和导师同意 lrm 并编译它。(在大多数情况下,节奏有问题)。
推荐阅读
- java - 如何在linux中查看进程ID?
- c++ - VS2022 出错 - v143 - is_trivially_copyable_v
- reactjs - 如何控制材质ui Slider的默认valueLabelComponent的样式?
- typescript - ImageResource.ts:182 Uncaught (in promise),使用 PIXI 和 Typescript 没有使用 pixi 和 texturepacker 加载纹理
- javascript - React Styled Components:ReferenceError:在初始化之前无法访问
- xrdp - 如何配置 XRDP 服务器以默认显示会话选择
- javascript - 使用事件函数将布尔值传递给样式化组件
- c# - .Net Core DBContext 依赖注入
- javascript - 读取 GET API 响应以在一个谷歌标签管理器服务器端标签内进行第二次 POST API 调用
- python - 在特定位置后向字典添加新键 \ 值