|
写了一个累加求和的程序,每32个数取一次,但是编译的时候老是出现报错:
(Error (10170): Verilog HDL syntax error at accavg.v(23) near text "else"; expecting ";", or "@", or "end", or an identifier ("else" is a reserved keyword ), or a system task, or "{", or a sequential statement
Altera官网上给出的解释是:在循环中定义了多个变量。但是我这根本就没循环啊。下面附上代码,望众位能帮忙看看,小弟是初学者。。。犯了初级错误还望大家不要见笑。谢谢各位了
module accavg(
rx_clk_100m,
rx_rst_n,
rx_data_32B,
tx_data_32B
);
parameter DATA_WIDTH=32;
parameter BIT_EXTEND=5;
input rx_clk_100m;
input rx_rst_n;
input [DATA_WIDTH-1:0] rx_data_32B;
output [DATA_WIDTH-1:0] tx_data_32B;
wire [DATA_WIDTH+BIT_EXTEND-1:0] addr_37;
reg [DATA_WIDTH+BIT_EXTEND-1:0] D_ff;
reg cnt;
assign addr_37 = {{5{rx_data_32B[DATA_WIDTH-1]}},rx_data_32B};
always @(posedge rx_clk_100m or negedge rx_rst_n)
begin
if (!rx_rst_n)
cnt <=0;
tx_data_32B <= 0;
else
begin
cnt <=0;
cnt <= cnt+1;
if(cnt===32)
begin
cnt <=0;
tx_data_32B <=D_ff[DATA_WIDTH+BIT_EXTEND-1:BIT_EXTEND];
end
else
D_ff <= D_ff+addr_37;
end
end
endmodule |
|