'='的语法错误

打字员

我有以下Verilog HDL代码。它基本上是一个两位加法器,它ab相加,并具有PG单元,进位生成单元(cg_unit)和和单元(s_unit)。ci对随身携带的两个位加法器。sel是激活特洛伊木马程序的行为,即否定的值s[1]coutminus1cout分别是进位和进位之前的进位。

module trojan
(
  input [1:0] a, b,
  input ci, sel,
  output [1:0] s,
  output cout, coutminus1
);

  wire [1:0] c, p, g;
  cla_pg_unit_2bits       pgu1(a, b, p, g);
  cla_cg_unit_2bits       cgu1(p, g, ci, c);
  cla_s_unit_2bits        su1(p, {c[0], ci}, s);
  coutminus1 = c[0];
  cout = c[1];

  always@(sel)
  begin
    if (sel == 1)
      assign s[1] = ~s[1];
    else
      assign s[1] = s[1];
  end
endmodule

由于某种原因,我收到以下语法错误:

Following Verilog source has the following syntax error: token is '=' 
coutminus1 = c[0];
           ^
Qiu

在这行中:

coutminus1 = c[0];
cout = c[1];

关键字assign缺失。您的代码还存在其他一些问题。我建议将其更改为以下内容:

module trojan
(
  input [1:0] a, b,
  input ci, sel,
  output [1:0] s,
  output cout, coutminus1
);

wire [1:0] c, p, g, tmp;

cla_pg_unit_2bits       pgu1(a, b, p, g);
cla_cg_unit_2bits       cgu1(p, g, ci, c);
cla_s_unit_2bits        su1(p, {c[0], ci}, tmp);

assign coutminus1 = c[0];
assign cout = c[1];
assign s = {(sel) ? ~tmp[1] : tmp[1], tmp[0]};

endmodule

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章