2012年10月17日 星期三

//8 LED 跑馬燈 (1-1)


//8 LED 跑馬燈
/*
LEDR[0] PIN_AE23
LEDR[1] PIN_AF23
LEDR[2] PIN_AB21
LEDR[3] PIN_AC22
LEDR[4] PIN_AD22
LEDR[5] PIN_AD23
LEDR[6] PIN_AD21
LEDR[7] PIN_AC21
CLOCK_50 PIN_N2

*/ 

module Flash_8LED2 (LED,CLK);    
    output[7:0] LED;
    input CLK;  //50MHZ
    
    reg [7:0] LED;
    reg [24:0] counter;
    reg [4:0] i;
    reg [3:0] j;

    initial     
    j=4'd7;

    
always@(posedge CLK)                                   
 begin           
     counter<=counter+1;                                     
   if(counter==25'd25_000_000)    //if counter=25_000_000
   begin 
      if(i<=5'd8)   //if i<=8  then shift Left , and reset counter  
begin
LED<=LED<<1;    
counter<=0;
i<=i+1;
end  
 else if(i>5'd8&&i<5'd16) //if 9-15 shift Right ,and reset counter   
        begin
j<=j-1;
LED<=LED+2**(j);
counter<=0;
i<=i+1;
end
 else if(i==5'd16)  //if i=16 ,reset all parameter
begin
LED<=LED+1;
i<=0;
j<=4'd7;
counter<=0;
end
    end
end
      
endmodule

沒有留言:

張貼留言

  清除項目編譯快取 執行 flutter clean 重新取得套件依賴 執行 flutter pub get 完整重新編譯並執行 flutter run 1. 新增專案套件 (pubspec.yaml) 在 Flutter 專案根目錄下的 pubspec.yaml 中,新增 ...