Verilog Dataflow 测试平台的问题在不同的站点上导致不同的错误
Problem with Verilog Dataflow testbench causing different errors on different sites
这个程序是在 Dataflow Verilog 中。我想做的是使加法器和减法器依赖于选择器。我目前收到一些错误,这些错误要么是第 10 行的 "syntax error in continuous assignment"(分配 {cout...}),要么是 "Error launching EPWave: [Could not parse file: $timescale not found in the header.]. Could not load './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]}));
你用错了{}
和[]
,{}
用来连接位。应该这样固定:
assign {cout,out} = selectorOdd ? (a + b) : (selectorEven ? (a - b) : {9{1'b0}});
你的代码应该有更多的情况。在这段代码中,如果 selectorOdd
和 selectorEven
是 0
,我分配 {cout,out}={9{1'b0}}
.
这个程序是在 Dataflow Verilog 中。我想做的是使加法器和减法器依赖于选择器。我目前收到一些错误,这些错误要么是第 10 行的 "syntax error in continuous assignment"(分配 {cout...}),要么是 "Error launching EPWave: [Could not parse file: $timescale not found in the header.]. Could not load './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]}));
你用错了{}
和[]
,{}
用来连接位。应该这样固定:
assign {cout,out} = selectorOdd ? (a + b) : (selectorEven ? (a - b) : {9{1'b0}});
你的代码应该有更多的情况。在这段代码中,如果 selectorOdd
和 selectorEven
是 0
,我分配 {cout,out}={9{1'b0}}
.