verilog - Verilog Dataflow 测试平台的问题导致不同站点上的不同错误
问题描述
该程序在 Dataflow Verilog 中。我要做的是使加法器和减法器依赖于选择器。我目前收到一些错误,这些错误是第 10 行的“连续分配中的语法错误”(assign {cout...},)或“启动 EPWave 时出错:[无法解析文件:在标题中找不到 $timescale .]. 无法加载“./dataflow_hw_1.vcd”。
我在整个互联网上寻找如何解决这个问题,但我一直在尝试推荐的解决方案,但无济于事。我不知道尝试测试它时出了什么问题。
这是代码:
module dataflow_1 (a[7:0],b[7:0],out[7:0],cout);
input a,b;
output out,cout;
//if a have odd number of 1s, output = a + b
//else if even positions have even number of 1s in total, output = a-b
assign selectorOdd = (a[1]^ a[3]^ a[5] ^ a[7]);
assign selectorEven = (~selectorOdd & ~(a[0] ^ a[2] ^ a[4] ^ a[6]));
assign {cout,out[7:0]} = (selectorOdd & ({a[7:0] + b[7:0}) | (selectorEven & ({a[7:0] - b[7:0]}));
endmodule
这是测试台代码:
// Code your testbench here
module dataflow_1();
reg [7:0] a;
reg [7:0] b;
wire [7:0] out;
dataflow_1 test(
.a(a),
.b(b),
.out(out)
);
initial begin
$dumpfile("dump.vcd");
$dumpvars(0, out);
a = 8'b01010101;
b = 8'b00000001;
#100;
end
endmodule
解决方案
问题出在这一行:
assign {cout,out[7:0]} = (selectorOdd & ({a[7:0] + b[7:0}) | (selectorEven & ({a[7:0] - b[7:0]}));
您使用了错误的{}
and []
,{}
用于连接位。它应该像这样修复:
assign {cout,out} = selectorOdd ? (a + b) : (selectorEven ? (a - b) : {9{1'b0}});
你的代码应该有更多的情况。在这段代码中 ifselectorOdd
和selectorEven
are 0
,我分配{cout,out}={9{1'b0}}
.
推荐阅读
- angular - 显示新数组的垫表
- r - 如何在R中使用多个条件进行排序
- xml - Restsharp反序列化不同的属性名称
- r - 可以在 Plotly Dash 或 R Shiny 中制作基于模板的自动化 PDF 报告吗?
- c# - 这是循环变量范围的更好方法吗?
- android - 如何避免 RecyclerView ViewHolder 中的内存泄漏?
- c# - 有没有办法使用 Flurl 库获取上传文件百分比?
- python - IndexError:列表索引超出范围。(试图用另一个 txt 文件查找和替换一个 txt 文件的元素
- javascript - 如何知道在网站或 html 页面的某些特定部分使用什么 JavaScript 或 jquery?
- vue.js - 将 main.js 中的变量暴露给 vue-cli 项目中的其他脚本