我有以下Verilog HDL代码。它基本上是一个两位加法器,它a
与b
和相加,并具有PG单元,进位生成单元(cg_unit
)和和单元(s_unit
)。在ci
对随身携带的两个位加法器。sel
是激活特洛伊木马程序的行为,即否定的值s[1]
。coutminus1
和cout
分别是进位和进位之前的进位。
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];
^
在这行中:
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] 删除。
我来说两句