ISE的verilog编程问题

module LED(
input clk,
input res,
output reg [7:0] led
);

reg m=0;
led=8'b00000001;

always@(posedge clk or negedge res)
begin
if(!res)
begin
if(m==0) m=1;
else m=0;
end

if(m==0)
begin
case(led_r)
8'b00000001:led=8'b00000010;
8'b00000010:led=8'b00000100;
8'b00000100:led=8'b00001000;
8'b00001000:led=8'b00010000;
8'b00010000:led=8'b00100000;
8'b00100000:led=8'b01000000;
8'b01000000:led=8'b10000000;
8'b10000000:led=8'b00000001;
endcase
end
else
begin
case(led_r)
8'b00000001:led=8'b10000000;
8'b00000010:led=8'b00000001;
8'b00000100:led=8'b00000010;
8'b00001000:led=8'b00000100;
8'b00010000:led=8'b00001000;
8'b00100000:led=8'b00010000;
8'b01000000:led=8'b00100000;
8'b10000000:led=8'b01000000;
endcase
end

end
endmodule
就是一个控制8个LED某个灯亮,然后有左移和右移两种模式,我想根据当前灯亮的情况决定一下个灯,但是编译出现问题:
ERROR:HDLCompilers:26 - "LED.v" line 29 unexpected token: '='
Module <LED> compiled
ERROR:HDLCompilers:26 - "LED.v" line 29 expecting 'endmodule', found '8'
Analysis of file <"LED.prj"> failed.
module LED(
input clk,
input res,
output reg [7:0] led=8'b00000001
);
改成这样以后,会出现问题:
ERROR:Xst:899 - "LED.v" line 35: The logic for <m> does not match a known FF or Latch template. The description style you are using to describe a register or latch is not supported in the current software release.

reg m=0;
led=8'b00000001;

这两句都有语法错误:
reg只能声明 不能同时赋值
led是输出 怎么能直接赋值?

always@(posedge clk or negedge res) 这个里面对led的赋值必须使用 <=
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-10-21
阻塞语法不了解导致这样的程序出现,往往就容易编译不通过
第2个回答  2014-10-20
好好看看语法书吧
第3个回答  2014-10-20
led_r没有定义,代码最好使用非阻塞赋值,不要用那个=追问

那里改程序的时候弄错了,就是led

追答

写的真烂,看着都闹眼睛!!!led的case判断值和赋值中间加个寄存器能死啊,这么省资源干嘛...不要用阻塞赋值,你这频率多快的啊??你能看清流水灯么?

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网