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

module BALL(input logic        clk,
	       input logic 	  reset,
	       input logic [15:0]  writedata,
	       input logic 	  write,
	       input 		  chipselect,
	       input logic  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);

	 
   logic [9:0] y_coords, x_coords;

   BALL_Emulator led_emulator(.clk50(clk), .*);

   always_ff @(posedge clk)
     if (reset) begin
	x_coords <= 10'd320; // 
	y_coords <= 10'd240; //
     end else if (chipselect && write)
       case (address)
	 1'b0 : x_coords <= writedata[9:0];
	 1'b1 : y_coords <= writedata[9:0];
       endcase
	       
endmodule
