问题描述
我在 Xilinx ISE verilog 编码方面相对很新(只有几个小时)。这是我的 uni 项目中的代码。它在 count = 0 行显示语法错误。在运行检查语法时,我没有发现任何问题。我该如何解决这个问题?
module syncdown(clk,rst,count);
input clk,rst;
output reg [3:0] count = 1;
always @(posedge clk);
begin
if(rst)
count = 0; // wrong here
else
count = count-1;
end
endmodule
错误
ERROR:HDLCompiler:806 - "/home/bossman/mux/syncdown.v" Line 8: Syntax error near "=".
解决方法
去掉 always
行末尾的分号:
module syncdown(clk,rst,count);
input clk,rst;
output reg [3:0] count = 1;
always @(posedge clk)
begin
if(rst)
count = 0; // wrong here
else
count = count-1;
end
endmodule