input SYSCLK_50M; //System clock, 50MHz.
input RST_B; //Global reset, low ac
tive.
input PUSH_SW1; //G
//input key; //G
output [5:0] LED_DATA; //LED data output.
//===========================================================================
//Wire and reg declaration
//===========================================================================
wire SYSCLK_50M;
wire RST_B;
reg [5:0] LED_DATA;
//wire key;reg [23:0] TIME_CNT; //Count the time, everyone show 1ms.
reg [5:0] LED_DATA_N; //Next value of LED_DATA.
wire [23:0] TIME_CNT_N; //Next value of TIME_CNT.
reg led_dir;always @(negedge RST_B or negedge SYSCLK_50M)
begin
if(!RST_B)
TIME_CNT <= `UD 21'b0;
else
TIME_CNT <= `UD TIME_CNT_N;
end
assign TIME_CNT_N = TIME_CNT + 21'b1;
always @(negedge RST_B or negedge SYSCLK_50M)
begin
if(!RST_B)
LED_DATA <= `UD 6'b11_1110;//这里LED同样是低电平有效,初值只允许一个LED亮
else
LED_DATA <= `UD LED_DATA_N;
end
always @(negedge RST_B or negedge SYSCLK_50M)
begin
if(!RST_B)
led_dir <=1'b0;
else
begin
if(PUSH_SW1)
led_dir <= 1'b0; //从低到高流动
else
led_dir <= 1'b1; //从高到低流动
end
endalways @ (*)
begin
if(TIME_CNT == 24'h0 )
case(led_dir)
1'b0: LED_DATA_N = {LED_DATA[5],LED_DATA[4:0]};
1'b1: LED_DATA_N = {LED_DATA[4:0],LED_DATA[5]};
default: ;
endcase
else
LED_DATA_N = LED_DATA;
end
endmodule
我想的是拨码开关led_dir 为高时流水灯正常流动,为低时反向流动,可我下载到板子上后为低能流动 为高电平时不流动为什么呢
一周热门 更多>