-------------------------------------------------------------------------------
-- Connects to Avalon system bus from NIOS processor.

-- Memory interface:
-- Address  Bits  Direction  Description  Valid values
-- 0        16    R/W        Camera X     0 - 511
-- 1        16    R/W        Camera Y     0 - 511
-- 2        16    R/W        Camera Z     0 - 511
--
-- The following values can fit in 8 bits but the interface is still 16 bits
-- wide and they should be written as 16 bit values. This is so all the 
-- registers are the same size and to make the transition easier if we want to
-- expand the range later.
-- 3        16    R/W        Rect 1 X1    0 - 255
-- 4        16    R/W        Rect 1 Y1    0 - 255
-- 5        16    R/W        Rect 1 Z1    0 - 255
-- 6        16    R/W        Rect 1 X2    0 - 255
-- 7        16    R/W        Rect 1 Y2    0 - 255
-- 8        16    R/W        Rect 1 Z2    0 - 255
-- 9        16    R/W        Rect 1 Color 0 - 2?
--
-- 10                        Rect 2
--
-- 17                        Rect 3

-- We needed to split the entity and architecture into 2 files because SOPC 
-- builder couldn't use the file with the architecture in it.
-------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity ray_tracer_avalon_module is

	port (
		reset : in std_logic := '0';
		clock : in std_logic := '0';
		
		-- Avalon Interface
		read       : in  std_logic := '0';
		write      : in  std_logic := '0';
		chipselect : in  std_logic := '0';
		address    : in  unsigned(6 downto 0)  := (others => '0');
		readdata   : out unsigned(15 downto 0) := (others => '0');
		writedata  : in  unsigned(15 downto 0) := (others => '0');

		-- VGA Outputs
		vga_clock,
		vga_h_sync,
		vga_v_sync,
		vga_blank,
		vga_sync : out std_logic := '0';
		vga_r,
		vga_g,
		vga_b : out unsigned(9 downto 0) := (others => '0');

		-- Debugging - access to camera and rectangle memories
		debug_address : in unsigned(6 downto 0) := (others => '0');
		debug_data : out unsigned(8 downto 0) := (others => '0')
	);

end ray_tracer_avalon_module;

