//8 LED 流水燈
超連結影片
http://www.youtube.com/embed/clpfmwGbP3A
module LED_Water8(CLOCK_50,SW, KEY, LEDR, LEDG );
input [17:0] SW; // toggle switches
input [7:0] KEY;
input CLOCK_50; //Clock 50MHZ
output [17:0] LEDR; // red LEDs
output [7:0] LEDG; // green LEDs
/*
input sys_clk,rst_n;
output [7:0] led;
*/
wire sys_clk;
wire rst_n;
reg [7:0] led;
//assign to DE2-70 hardware
assign LEDR = SW;
assign sys_clk = CLOCK_50;
assign rst_n = KEY[0];
reg [25:0] count;
reg [4:0] flag;
always @(posedge sys_clk,negedge rst_n)
if(!rst_n)
begin
flag <= 5'b0;
count <= 26'b0;
end
else
begin
if( count == 26'b00_0011_1111_1111_1111_1111_1110 )
begin
count <= 26'b0;
flag <= flag+2'b01;
if(flag == 5'b1_0000)
flag <= 5'b0;
end
else
count <= count + 1;
end
always @(posedge sys_clk)
begin
case(flag)
5'b0_0000: led <= 8'b1111_1110; //0
5'b0_0001: led <= 8'b1111_1101; //1
5'b0_0010: led <= 8'b1111_1011; //2
5'b0_0011: led <= 8'b1111_0111; //3
5'b0_0100: led <= 8'b1110_1111; //4
5'b0_0101: led <= 8'b1101_1111; //5
5'b0_0110: led <= 8'b1011_1111; //6
5'b0_0111: led <= 8'b0111_1111; //7
5'b0_1000: led <= 8'b0111_1111; //8
5'b0_1001: led <= 8'b1011_1111; //9
5'b0_1010: led <= 8'b1101_1111; //10
5'b0_1011: led <= 8'b1110_1111; //11
5'b0_1100: led <= 8'b1111_0111; //12
5'b0_1101: led <= 8'b1111_1011; //13
5'b0_1110: led <= 8'b1111_1101; //14
default:led <= 8'b1111_1110; //15
endcase
end
assign LEDG =led;
endmodule
訂閱:
張貼留言 (Atom)
WOKWI DHT22 & LED , Node-Red + SQLite database
WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
課程講義 下載 11/20 1) PPT 下載 + 程式下載 http://www.mediafire.com/file/cru4py7e8pptfda/106%E5%8B%A4%E7%9B%8A2-1.rar 11/27 2) PPT 下載...
-
• 認 識 PreFix、InFix、PostFix PreFix(前序式):* + 1 2 + 3 4 InFix(中序式): (1+2)*(3+4) PostFix(後序式):1 2 + 3 4 + * 後 序式的運算 例如: 運算時由 後序式的...
沒有留言:
張貼留言