【发布时间】:2016-04-13 06:09:57
【问题描述】:
所以我在 verilog 中有这段代码,但我不知道问题出在哪里? 在“如果”的陈述中,在条件中,在寄存器中,我不知道请帮助我
这里是代码和错误信息:
module top(
input [31:0] din,
output [31:0] dout
);
reg [4:0] i, j;
reg [31:0] max =0;
reg [4:0] cnt;
reg [4:0] comp;
for(i=0; i<=31; i=i+1) begin
if(din[i]== 1'b0) begin
comp <= comp;
end
else if(din[i]==1 & din[i+1]==1) begin
cnt<=cnt+1;
if(cnt>comp) begin
comp<=cnt;
end else begin
comp<=comp;
end
end
end
不断出现的问题是:
INFO:HDLCompiler:1845 - 将 Verilog 文件“D:/ProiecteISE/verilog proj/teme 2016/tema1/top.v”分析到库工作中 错误:HDLCompiler:806 -“D:/Proiecte ISE/verilog proj/teme2016/tema1/top.v”第 34 行:“
如果我删除“;”在有错误的行中,它看起来像这样:
module top(
input [31:0] din,
output [31:0] dout
);
reg [4:0] i, j;
reg [31:0] max =0;
reg [4:0] cnt;
reg [4:0] comp;
for(i=0; i<=31; i=i+1) begin
if(din[i]== 0) begin
comp <= comp
end
else if(din[i]==1 & din[i+1]==1) begin
cnt<=cnt+1
if(cnt>comp) begin
comp<=cnt
end else begin
comp<=comp
end
end
end
endmodule
只得到一个错误
INFO:HDLCompiler:1845 - 将 Verilog 文件“D:/Proiecte ISE/verilog proj/teme 2016/tema1/top.v”分析到库工作中 错误:HDLCompiler:806 -“D:/Proiecte ISE/verilog proj/teme 2016/tema1/top.v”第 34 行:“
【问题讨论】:
-
请不要在未格式化的 cmets 中添加大量额外信息。相反,请edit 问题以易于阅读的方式包含额外内容。
-
感谢您的建议,这是我的第一个问题
-
自己解决了,我应该在“for”之前插入“alwasy@(*) begin”