繁体   English   中英

Verilog Dataflow测试台出现问题,在不同站点上导致不同错误

[英]Problem with Verilog Dataflow testbench causing different errors on different sites

该程序在Dataflow Verilog中。 我想做的是使加法器和减法器依赖选择器。 我目前遇到一些错误,这些错误要么是第10行的“连续分配中的语法错误”(分配{cout ...}),要么是“错误启动EPWave:[无法解析文件:在标题中找不到$ timescale 。]。无法加载“ ./dataflow_hw_1.vcd””。

我在Internet上四处寻找如何解决此问题的方法,但是我一直在尝试推荐的解决方案,但无济于事。 我不知道尝试进行基准测试时出了什么问题。

这是代码:

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}});

您的代码应该针对其他所有情况。 在这段代码中,如果selectorOddselectorEven0 ,则分配{cout,out}={9{1'b0}}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM