/*
 * Avalon memory-mapped peripheral for the VGA LED Emulator
 *
 * Stephen A. Edwards
 * Columbia University
 */

module VGA_LED(input logic        clk,
	       input logic 	  reset,
	       input logic [7:0]  writedata,
	       input logic 	  write,
	       input 		  chipselect,
	       input logic [7:0]  address,

	       output logic [7:0] VGA_R, VGA_G, VGA_B,
	       output logic 	  VGA_CLK, VGA_HS, VGA_VS, VGA_BLANK_n,
	       output logic 	  VGA_SYNC_n);

	VGA_LED_Emulator led_emulator(.clk50(clk), .*);		 
	logic[7:0] first_sel,second_sel,third_sel,arrow_sel, score1, score2, array_value, array_address; 
	
	always_ff@(posedge clk)
		if(!reset && chipselect && write) begin
		   if (address[7] == 0) begin
				array_value <= writedata;
				array_address <= writedata;
			end
			else
			case(address[4:0])
			5'd0 : first_sel <= writedata;
			8'd1 : second_sel <= writedata;
			8'd2 : third_sel <= writedata;
			8'd3 : score1 <= writedata;
			8'd4 : score2 <= writedata;
			8'd5 : arrow_sel <= writedata;
			endcase
		end
   //assign array_index = 8'd21;
	//assign array_value = 8'd1;
	
endmodule