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

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...