andous 发表于 2014-7-4 17:17 
可以设置来解决这个问题,估计是不是这个问题,需要你看下逻辑。
逻辑很简单 就是流水灯
//===========================================================================
// File Name : STREAM_LED.v
// Module Name : STREAM_LED
/* ��վ�� www.sopc51.com(о���Ƽ�) *
* ���䣺 SOPC51@126.com ���룺��������Ҫ *
* �汾�� V1.1 *
* ���ߣ� δ� *
* ���ڣ�2012-5-1 *
*****************************************************************************/
//===========================================================================
module test_led
(
//Input ports.
SYSCLK,
RST_B,
//Output ports.
LED_DATA
);
//===========================================================================
//Input and output declaration
//===========================================================================
input SYSCLK; //System clock, 50MHz.
input RST_B; //Global reset, low active.
// output [9:0] LED_DATA; //LED data output.
output [3:0] LED_DATA;
//===========================================================================
//Wire and reg declaration
//===========================================================================
wire SYSCLK;
wire RST_B;
//reg [9:0] LED_DATA;
reg [3:0] LED_DATA;
//===========================================================================
//Wire and reg in the module
//===========================================================================
reg [23:0] TIME_CNT; //Count the time, everyone show 1ms.
//reg [9:0] LED_DATA_N; //Next value of LED_DATA.
reg [9:0] LED_DATA_N;
wire [21:0] TIME_CNT_N; //Next value of TIME_CNT.
//===========================================================================
//Logic
//===========================================================================
//Count the time, let the every led show 50ms.
always @(negedge RST_B or negedge SYSCLK)
begin
if(!RST_B)
TIME_CNT <= 22'b0;// 2^21=1024*1024*2 50MHZ
else
TIME_CNT <= TIME_CNT_N;
end
assign TIME_CNT_N = TIME_CNT + 22'b1;
//LED light output control.
always @(negedge RST_B or negedge SYSCLK)
begin
if(!RST_B)
// LED_DATA <= `UD 10'b11_1111_1110;
LED_DATA <= 4'b1110;
else
LED_DATA <= LED_DATA_N;
end
always @ (*)
begin
//if((LED_DATA == 10'b01_1111_1111) && (TIME_CNT == 21'b0))
// LED_DATA_N = 10'b11_1111_1110;
if((LED_DATA == 4'b0111) && (TIME_CNT == 22'b0))
LED_DATA_N = 4'b1110;
else if(TIME_CNT == 21'b0)
//LED_DATA_N = {LED_DATA[8:0] , 1'h1};
LED_DATA_N = {LED_DATA[2:0] , 1'h1};
else
LED_DATA_N = LED_DATA;
end
endmodule
|