各位大哥、大姐,看本菜的程序错在那里!!??
module led_shizhong(res,clkin,on_ked,fenout,wei);//时钟input clkin,res;
input on_ked;//按键
output fenout,wei;
reg fenout;//显示出口
reg wei;//led位
reg tai,anle,anle1;//功能键按了标记,anle1保证每按一次键只加一个数
reg shan;//闪烁标记
reg con;//分频计数
reg con1;
reg miao;//秒计数
reg miaoshan;//秒点闪烁
reg weishu ;//小时和分钟寄存器
reg zibiao ;//字表寄存器组
always @ (posedge res or posedge clkin)
begin
if(res)
begin
con<=0;
//fenout<=8'hFF;
//wei=0; // 初始化字段
zibiao=8'h03;
zibiao=8'h9F;
zibiao=8'h25;
zibiao=8'h0D;
zibiao=8'h99;
zibiao=8'h49;
zibiao=8'h41;
zibiao=8'h1F;
zibiao=8'h01;
zibiao=8'h09;
weishu=0;
weishu=0;
tai=0;
shan=0;
end
else
begin
if(on_ked==3'b111)
begin
anle=0;
con1=0;
end
if(on_ked!=3'b111)
begin
if(con1<22'd2000000)
begin
con1=con1+1'b1;//防抖延时
end
if(con1==22'd2000000)
begin
if(on_ked!=3'b111)
begin//也可以con1<=22'd2000001;来保证按一次键,但较占空间
if(anle==0)//保证每按一次键只加一个数
begin
anle=1;//确认按键啦
anle1=1;//保证每按一次键只加一个数
end
end
end
end
///
if(anle1==1)
begin
anle1=0;//保证每按一次键只加一个数
if(on_ked==1'b0)//功能键按下
begin
tai=~tai;
end
if(tai==1'b1)
begin
if(on_ked==1'b0)//调分
begin
jifen;
end
if(on_ked==1'b0)//调时
begin
jishi;
end
end
end//
if(tai==1'b0)//停止闪烁
begin
shan=1'b0;
end
con=con+1'b1;
if(con==26'd40000000)//40MHz晶体,1秒分频,用于计数源
begin
con=0;
miaoshan<=~miaoshan;
if(tai==1'b1)//数字闪烁
begin
shan=~shan;
end
miao=miao+1'b1;//计秒
if(miao==6'd60)
begin
miao=0;
if(tai==1'b0)//未按功能键就走时
begin
jifen;
end
end
end
end
end
always(posedge res or posedge clkin)
begin
if(res)
begin
fenout<=8'hFF;
wei=0; // 初始化字段
end
else if(!res)
begin
case(con)//用于位扫描
2'b00:
begin
if(shan==1'b0)//第一位数字闪烁,表示进入调时
begin
wei=4'b0111;
end
else
begin
wei=4'b1111;
end
fenout=zibiao%4'd10];
end
2'b01:
begin
wei=4'b1011;
fenout=zibiao/4'd10];
end
2'b10:
begin
wei=4'b1101;
fenout=zibiao%4'd10];
fenout<=miaoshan;//秒点闪烁
end
2'b11:
begin
wei=4'b1110;
fenout=zibiao/4'd10];
end
endcase
end
end
task jifen;
weishu=weishu+1'b1;//分钟
if(weishu==6'd60)
begin
weishu=0;
if(tai==1'b0)//未按功能键就走时
begin
jishi;
end
end
endtask
task jishi;
weishu=weishu+1'b1;//小时
if(weishu==5'd24)
begin
weishu=0;
end
endtask
endmodule
综合时报错:
Error (10170): Verilog HDL syntax error at led_shizhong.v(111) near text "(";expecting "@", or an identifier, or a system task, or "{", or a sequential statement,
Error (10170): Verilog HDL syntax error at led_shizhong.v(137) near text "<=";expecting ".", or "["
Error (10112): Ignored module "led_shizhong" at led_shizhong.v(1) due to previous errors always(posedge res or posedge clkin)
你少个@啊~~太粗心
加上去编译至少通过了,有没有其他问题就不知道了 少了个@,哈哈
页:
[1]
