/*
 * leds.v
 * 
 * "Knight Rider" effetct on leds - FPGA class project
 * 
 * 
 * Copyright 2013 damtech <damtech@HP6730S>
 * 
 * 
 * 
 * This program is free software; you can redistribute it and/or modify
 * 
 * it under the terms of the GNU General Public License as published by
 * 
 * the Free Software Foundation; either version 2 of the License, or
 * 
 * (at your option) any later version.
 * 
 * 
 * 
 * This program is distributed in the hope that it will be useful,
 * 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 
 * GNU General Public License for more details.
 * 
 * 
 * 
 * You should have received a copy of the GNU General Public License
 * 
 * along with this program; if not, write to the Free Software
 * 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * 
 * MA 02110-1301, USA.
 * 
 */

// this module drives leds with a "Knight Rider"-like effect 

module kitt(clock, reset, ledbus);

parameter 	LEDS=10;

input clock, reset;

// bidirectional shift register
output reg [LEDS-1:0] ledbus;

reg direction;

always @ (posedge clock or posedge reset)
begin
	if (reset) begin
		direction <= 1'b0;
		ledbus=1;
	
	end else begin
		ledbus <= (direction)?(ledbus>>1):(ledbus << 1);
		if (ledbus[LEDS-2]) direction <= 1;
		else if (ledbus[1]) direction <= 0;
	end

end



endmodule
