`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
//	Tony Kim
//	6.111 Lab2
//
// Module name: StatusLEDDriver
// Description: Appropriately lights the Status LED depending on `status'. It 
//					 currently implements OFF, BLINK (0.5Hz), ON.
//
//////////////////////////////////////////////////////////////////////////////////

module StatusLEDDriver(clock_27mhz, clock_1hz, status, led_out);
    input clock_27mhz;
    input clock_1hz;
    input [1:0] status;
    output led_out;

	// Status indicator modes
	parameter I_OFF   = 2'b00;
	parameter I_BLINK = 2'b01;
	parameter I_ON    = 2'b10;

	reg blink_state = 1'b0;
	reg led_out     = 1'b0;
	
	always @ (posedge clock_27mhz)
	begin
		case(status)
			I_OFF: led_out <= 1'b0;
			I_ON:  led_out <= 1'b1;
			I_BLINK:
			begin
				if(clock_1hz) blink_state <= blink_state + 1;
				led_out <= blink_state;
			end
			default: led_out <= 1'b0;
		endcase
	end
endmodule
