|
这个verilog程序有何问题?
module ludeng(clk,rst,min1,min5,min10,reg_ind,major_red,major_green,minor_red,minor_green);
parameter major_0=0,major_1=1,minor=2;
input clk,rst,reg_ind;
output min1,min5,min10;
output major_red,major_green,minor_red,minor_green;
reg min1,min5,min10;
reg next_state;
reg state;
reg cnt;
always@(posedge clk or posedge rst)
begin
if(rst==1'b1)
state<=major_0;
else state<=next_state;
end
always@(state or min1 or min5 or min10 or reg_ind)
begin
case(state)
major_0:
begin
major_green=1'b1;
minor_red=1'b1;
if(min5==1'b1)
next_state=major_1;
else next_state=major_0;
end
major_1:
begin
if((min10==1'b1)||(reg_ind==1'b1))
next_state=minor;
else next_state=major_1;
end
minor:
begin
minor_green=1'b1;
major_red=1'b1;
if(min1==1'b1)
next_state=major_0;
else next_state=minor;
end
default:
next_state=major_0;
endcase
always@(posedge clk)
begin
if(rst==1'b1)
cnt=10'h000;
else
if(clr==1'b1)
cnt=10'h000;
else cnt=cnt+1'b1;
end
always@(cnt or state)
begin if((state=major_0)&&(cnt==9'd299))
min5=1'b1;
else min5=1'b0;
end
always@(cnt or state)
begin if((state=major_1)&&(cnt==9'd299))
min10=1'b1;
else min10=1'b0;
end
always@(min1 or min5 or min10)
begin if(min1||min5||min10)
clr=1;
else clr=0;
end
always@(rst or state)
begin
if(rst=1)
reg_ind<=1'b0;
else if(state==minor)
reg_ind<=1'b0;
end
endmodule |
|