FPGAのLED制御プログラムを深く理解する(ソースコード)(2/4 ページ)

» 2016年09月09日 10時00分 公開
[PR/MONOist]
PR

List2

module LED_Flash2(
	//Clock from oscillator
	input Clock,
	//Arduino I/Os
	inout Arduino_IO13
);
	reg[15:0] div_cntr1;
	reg[9:0] div_cntr2;
	reg dec_cntr;
	reg half_sec_pulse;
	
	initial begin
		div_cntr1 = 0;
		div_cntr2 = 0;
		dec_cntr  = 0;
		end
		
	
	always@(posedge Clock)
		begin
		div_cntr1 <= div_cntr1 + 1;
		if (div_cntr1 == 0) 
			if (div_cntr2 == 762) 
				begin
				div_cntr2 <= 0;
				half_sec_pulse <= 1;  
				end
			else
				div_cntr2 <= div_cntr2 + 1;
		else
			half_sec_pulse <= 0;
		
		if (half_sec_pulse == 1)	
			dec_cntr <= !dec_cntr;
			
		end	
		
		
	assign Arduino_IO13 = dec_cntr ;
endmodule
List2

Copyright © ITmedia, Inc. All Rights Reserved.


提供:日本アルテラ株式会社
アイティメディア営業企画/制作:MONOist 編集部/掲載内容有効期限:2016年10月10日