##一、任务要求
1)实现一交通十字路口处红绿灯的基本定时控制功能,要求东西方向灯色循环为绿灯45秒,黄灯5秒,左拐灯15秒,黄灯5秒,红灯40秒,黄灯5秒;南北方向灯色循环为红灯65秒,黄灯5秒,绿灯20秒,黄灯5秒,左拐灯15秒,黄灯5秒。
2)实现东西方向和南北方向各种灯的倒计时数码显示功能。
##二、BCD转码&&片选信号
module select(Clk_12M,Rst,led,sel,Indight_1,Indight_2,Indight_3,Indight_4,Indight_5,Indight_6);
input Clk_12M;
input Rst;
output reg[6:0]led;
output reg[5:0]sel;
input [3:0]Indight_1;
input [3:0]Indight_2;
input [3:0]Indight_3;
input [3:0]Indight_4;
input [3:0]Indight_5;
input [3:0]Indight_6;
reg [7:0]segout_1;
reg [7:0]segout_2;
reg [7:0]segout_3;
reg [7:0]segout_4;
reg [7:0]segout_5;
reg [7:0]segout_6;
reg [15:0]count;
parameter start=0;
parameter AN_1=1;
parameter AN_2=2;
parameter AN_3=3;
parameter AN_4=4;
parameter AN_5=5;
parameter AN_6=6;
parameter ending=7;
reg flag;
always@(posedge Clk_12M or negedge Rst)
begin
if(!Rst)
begin
count<=16'd0;
flag<=1'b0;
end
else if (count==16'd12000)
begin
count <= 16'd0;
flag<=1'b1;
end
else
begin
count<=count+16'd1;
flag<=1'b0;
end
end
always@(posedge Clk_12M or negedge Rst)
begin
if(!Rst)
segout_1<=7'b1111111;
else
begin
case(Indight_1)
4'b0000: segout_1 <= 7'b0111111;
4'b0001: segout_1 <= 7'b0000110;
4'b0010: segout_1 <= 7'b1011011;
4'b0011: segout_1 <= 7'b1001111;
4'b0100: segout_1 <= 7'b1100110;
4'b0101: segout_1 <= 7'b1101101;
4'b0110: segout_1 <= 7'b1111101;
4'b0111: segout_1 <= 7'b0000111;
4'b1000: segout_1 <= 7'b1111111;
4'b1001: segout_1 <= 7'b1101111;
default segout_1 <= 7'b0100011;
endcase
end
end
always@(posedge Clk_12M or negedge Rst)
begin
if(!Rst)
segout_2<=7'b1111111;
else
begin
case(Indight_2)
4'b0000: segout_2 <= 7'b0111111;
4'b0001: segout_2 <= 7'b0000110;
4'b0010: segout_2 <= 7'b1011011;
4'b0011: segout_2 <= 7'b1001111;
4'b0100: segout_2 <= 7'b1100110;
4'b0101: segout_2 <= 7'b1101101;
4'b0110: segout_2 <= 7'b1111101;
4'b0111: segout_2 <= 7'b0000111;
4'b1000: segout_2 <= 7'b1111111;
4'b1001: segout_2 <= 7'b1101111;
default segout_2 <= 7'b0100011;
endcase
end
end
always@(posedge Clk_12M or negedge Rst)
begin
if(!Rst)
segout_3<=7'b1111111;
else
begin
case(Indight_3)
4'b0000: segout_3 <= 7'b0111111;
4'b0001: segout_3 <= 7'b0000110;
4'b0010: segout_3 <= 7'b1011011;
4'b0011: segout_3 <= 7'b1001111;
4'b0100: segout_3 <= 7'b1100110;
4'b0101: segout_3 <= 7'b1101101;
4'b0110: segout_3 <= 7'b1111101;
4'b0111: segout_3 <= 7'b0000111;
4'b1000: segout_3 <= 7'b1111111;
4'b1001: segout_3 <= 7'b1101111;
default segout_3 <= 7'b0100011;
endcase
end
end
always@(posedge Clk_12M or negedge Rst)
begin
if(!Rst)
segout_4<=7'b1111111;
else
begin
case(Indight_4)
4'b0000: segout_4 <= 7'b0111111;
4'b0001: segout_4 <= 7'b0000110;
4'b0010: segout_4 <= 7'b1011011;
4'b0011: segout_4 <= 7'b1001111;
4'b0100: segout_4 <= 7'b1100110;
4'b0101: segout_4 <= 7'b1101101;
4'b0110: segout_4 <= 7'b1111101;
4'b0111: segout_4 <= 7'b0000111;
4'b1000: segout_4 <= 7'b1111111;
4'b1001: segout_4 <= 7'b1101111;
default segout_4 <= 7'b0100011;
endcase
end
end
always@(posedge Clk_12M or negedge Rst)
begin
if(!Rst)
segout_5<=7'b1111111;
else
begin
case(Indight_5)
4'b0000: segout_5 <= 7'b0111111;
4'b0001: segout_5 <= 7'b0000110;
4'b0010: segout_5 <= 7'b1011011;
4'b0011: segout_5 <= 7'b1001111;
4'b0100