- always @(posedge clk)
- begin
- if(enable) begin //如果使能端有效时就亮灯及计时
- if(!sta) begin //如果状态变量sta为0按“绿-黄-左拐-黄-红”的顺序亮灯
- sta<=1;
- case(ordera)
- 0: begin a_time<=agreen; akind<=2;ordera<=1;end
- 1: begin a_time<=ayellow;akind<=4;ordera<=2;end
- 2: begin a_time<=aleft; akind<=1;ordera<=3;end
- 3: begin a_time<=ayellow;akind<=4;ordera<=4;end
- 4: begin a_time<=ared; akind<=8;ordera<=0;end
- default: akind<=8;
- endcase
- end
-
- else begin //如果状态变量sta为1就就执行亮灯倒计时
- if(a_time>1)
- if(a_time[3:0]==0) begin
- a_time[3:0]<=4'd9;
- a_time[7:4]<=a_time[7:4]-1;
- end
- else a_time[3:0]<=a_time[3:0]-1;
- if(a_time==2) sta<=0;//
- end
- end
- else begin //如果使能端无效
- akind<=4'b1000;
- ordera<=0;
- sta<=0;
- end
- end
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>