------------------------------------------------------------------------------ -- Affaire : ROBOT -- Carte : Camera -- EPLD : Epld_ -- Fonction : Ball Finder v2 ! -- Author : EIRBOT 2003 ENSEIRB -- Date : 25.10.2002 ------------------------------------------------------------------------------ library IEEE, work; use IEEE.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.numeric_std.all; use work.all; entity atmel is port ( access_request : out std_logic; access_type : out std_logic_vector(1 downto 0); access_granted : in std_logic; A_mem : out std_logic_vector(18 downto 0); D_mem : inout std_logic_vector(15 downto 0); RD_L_mem : out std_logic; RD_H_mem : out std_logic; WR_L_mem : out std_logic; WR_H_mem : out std_logic; A : in std_logic_vector(15 downto 8); AD : inout std_logic_vector(7 downto 0); ALE : in std_logic; ReadN : in std_logic; WriteN : in std_logic; clk : in std_logic; q_overlay_ram : in std_logic_vector(7 downto 0); d_overlay_ram : out std_logic_vector(7 downto 0); a_overlay_ram : out std_logic_vector(12 downto 0); wren_overlay_ram : out std_logic; d_ATA_ram : in std_logic_vector(7 downto 0); q_ATA_ram : out std_logic_vector(7 downto 0); a_ATA_ram : out std_logic_vector(8 downto 0); wren_ATA_ram : out std_logic; entreeA : in std_logic_vector(7 downto 0); entreeB : in std_logic_vector(7 downto 0); entreeC : in std_logic_vector(7 downto 0); entreeD : in std_logic_vector(7 downto 0); entreeE : in std_logic_vector(7 downto 0); entreeF : in std_logic_vector(7 downto 0); entreeG : in std_logic_vector(7 downto 0); entreeH : in std_logic_vector(7 downto 0); entreeI : in std_logic_vector(7 downto 0); entreeJ : in std_logic_vector(7 downto 0); entreeAA : in std_logic_vector(7 downto 0); entreeAB : in std_logic_vector(7 downto 0); entreeAC : in std_logic_vector(7 downto 0); entreeAD : in std_logic_vector(7 downto 0); entreeAE : in std_logic_vector(7 downto 0); entreeAF : in std_logic_vector(7 downto 0); entreeAG : in std_logic_vector(7 downto 0); entreeAH : in std_logic_vector(7 downto 0); entreeAI : in std_logic_vector(7 downto 0); entreeAJ : in std_logic_vector(7 downto 0); entreeBA : in std_logic_vector(7 downto 0); entreeBB : in std_logic_vector(7 downto 0); entreeBC : in std_logic_vector(7 downto 0); entreeBD : in std_logic_vector(7 downto 0); entreeBE : in std_logic_vector(7 downto 0); entreeBF : in std_logic_vector(7 downto 0); entreeBG : in std_logic_vector(7 downto 0); entreeBH : in std_logic_vector(7 downto 0); entreeBI : in std_logic_vector(7 downto 0); entreeBJ : in std_logic_vector(7 downto 0); entreeCA : in std_logic_vector(7 downto 0); entreeCB : in std_logic_vector(7 downto 0); sortie00d : out std_logic_vector(7 downto 0); sortie01d : out std_logic_vector(7 downto 0); sortie02d : out std_logic_vector(7 downto 0); sortie03d : out std_logic_vector(7 downto 0); sortie04d : out std_logic_vector(7 downto 0); sortie05d : out std_logic_vector(7 downto 0); sortie06d : out std_logic_vector(7 downto 0); sortie07d : out std_logic_vector(7 downto 0); sortie08d : out std_logic_vector(7 downto 0); sortie09d : out std_logic_vector(7 downto 0); sortie10d : out std_logic_vector(7 downto 0); sortie11d : out std_logic_vector(7 downto 0); sortie12d : out std_logic_vector(7 downto 0); sortie13d : out std_logic_vector(7 downto 0); sortie14d : out std_logic_vector(7 downto 0); sortie15d : out std_logic_vector(7 downto 0); sortie16d : out std_logic_vector(7 downto 0); sortie17d : out std_logic_vector(7 downto 0); sortie18d : out std_logic_vector(7 downto 0); sortie19d : out std_logic_vector(7 downto 0); sortie20d : out std_logic_vector(7 downto 0); sortie21d : out std_logic_vector(7 downto 0); sortie22d : out std_logic_vector(7 downto 0); sortie23d : out std_logic_vector(7 downto 0); sortie24d : out std_logic_vector(7 downto 0); sortie25d : out std_logic_vector(7 downto 0); sortie26d : out std_logic_vector(7 downto 0); sortie27d : out std_logic_vector(7 downto 0); sortie28d : out std_logic_vector(7 downto 0); sortie29d : out std_logic_vector(7 downto 0); sortie30d : out std_logic_vector(7 downto 0); sortie31d : out std_logic_vector(7 downto 0); sortie32d : out std_logic_vector(7 downto 0); sortie33d : out std_logic_vector(7 downto 0); sortie34d : out std_logic_vector(7 downto 0); sortie35d : out std_logic_vector(7 downto 0); sortie36d : out std_logic_vector(7 downto 0); sortie37d : out std_logic_vector(7 downto 0); sortie38d : out std_logic_vector(7 downto 0); sortie39d : out std_logic_vector(7 downto 0); sortie40d : out std_logic_vector(7 downto 0); sortie41d : out std_logic_vector(7 downto 0); sortie42d : out std_logic_vector(7 downto 0); sortie43d : out std_logic_vector(7 downto 0); sortie44d : out std_logic_vector(7 downto 0); sortie45d : out std_logic_vector(7 downto 0); sortie46d : out std_logic_vector(7 downto 0); sortie47d : out std_logic_vector(7 downto 0); sortie48d : out std_logic_vector(7 downto 0); sortie49d : out std_logic_vector(7 downto 0); sortie50d : out std_logic_vector(7 downto 0); sortie51d : out std_logic_vector(7 downto 0); sortie52d : out std_logic_vector(7 downto 0); sortie53d : out std_logic_vector(7 downto 0); sortie54d : out std_logic_vector(7 downto 0); sortie55d : out std_logic_vector(7 downto 0); sortie56d : out std_logic_vector(7 downto 0); sortie57d : out std_logic_vector(7 downto 0); sortie58d : out std_logic_vector(7 downto 0); sortie59d : out std_logic_vector(7 downto 0); sortie60d : out std_logic_vector(7 downto 0); sortie61d : out std_logic_vector(7 downto 0); sortie62d : out std_logic_vector(7 downto 0); sortie63d : out std_logic_vector(7 downto 0) ); end atmel; architecture structure of atmel is signal Address : std_logic_vector(15 downto 0); signal Data_out : std_logic_vector(7 downto 0); -- sortie vers l'atmel signal Data_in : std_logic_vector(7 downto 0); -- entree dans le FPGA signal Data_mem : std_logic_vector(7 downto 0); signal enable_io, enable_mem, enable_ep_ram, enable_overlay_ram, enable_ATA_ram : std_logic; signal data_ep_ram, q_ep_ram : std_logic_vector(7 downto 0); signal wren_ep_ram : std_logic; signal choix : std_logic_vector(7 downto 0); component ram16ko PORT ( address : IN STD_LOGIC_VECTOR (13 DOWNTO 0); clock : IN STD_LOGIC ; data : IN STD_LOGIC_VECTOR (7 DOWNTO 0); wren : IN STD_LOGIC ; q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); end component; begin Address(15 downto 8) <= A(15 downto 8); ------------------------------------------------------------------------------- address_latch : process(ALE,AD) begin if ALE='1' then Address(7 downto 0) <= AD; end if; end process; write_process : process(WriteN) begin if WriteN = '0' then Data_in <= AD; end if; end process; AD <= Data_out when ReadN = '0' else "ZZZZZZZZ"; ------------------------------------------------------------------------------- -- 1100 - 1FFF : io -- 2000 - 3FFF : overlay_ram (8ko) -- 4000 - 4FFF : ep_ram (4ko) -- 6000 - 61FF : ATA_ram (512o) -- 8000 - FFFF : memory pages (32ko) fonction : process (Address) begin if (Address(15 downto 12) = "0001") then enable_io <= '1'; enable_ep_ram <= '0'; enable_mem <= '0'; enable_overlay_ram <= '0'; enable_ATA_ram <= '0'; elsif (Address(15 downto 13) = "001") then enable_io <= '0'; enable_ep_ram <= '0'; enable_mem <= '0'; enable_overlay_ram <= '1'; enable_ATA_ram <= '0'; elsif (Address(15 downto 12) = "0100") then enable_io <= '0'; enable_ep_ram <= '1'; enable_mem <= '0'; enable_overlay_ram <= '0'; enable_ATA_ram <= '0'; elsif (Address(15 downto 12) = "0110") then enable_io <= '0'; enable_ep_ram <= '0'; enable_mem <= '0'; enable_overlay_ram <= '0'; enable_ATA_ram <= '1'; elsif (Address(15) = '1') then enable_io <= '0'; enable_ep_ram <= '0'; enable_mem <= '1'; enable_overlay_ram <= '0'; enable_ATA_ram <= '0'; else enable_io <= '0'; enable_ep_ram <= '0'; enable_mem <= '0'; enable_overlay_ram <= '0'; enable_ATA_ram <= '0'; end if; end process; ------------------------------------------------------------------------------- A_mem(13 downto 0) <= Address(14 downto 1); D_mem(7 downto 0) <= Data_mem when ReadN = '1' and Address(0) = '0' else "ZZZZZZZZ"; D_mem(15 downto 8) <= Data_mem when ReadN = '1' and Address(0) = '1' else "ZZZZZZZZ"; RD_L_mem <= ReadN or not(enable_mem) or Address(0); RD_H_mem <= ReadN or not(enable_mem) or not(Address(0)); WR_L_mem <= WriteN or not(enable_mem) or Address(0); WR_H_mem <= WriteN or not(enable_mem) or not(Address(0)); ------------------------------------------------------------------------------- wren_ep_ram <= not(WriteN) and enable_ep_ram; ------------------------------------------------------------------------------- wren_overlay_ram <= not(WriteN) and enable_overlay_ram; a_overlay_ram <= Address(12 downto 0); ------------------------------------------------------------------------------- wren_ATA_ram <= not(WriteN) and enable_ATA_ram; a_ATA_ram <= Address(8 downto 0); ------------------------------------------------------------------------------- choix <= Address(7 downto 0); ------------------------------------------------------------------------------- lecture : process (choix, d_ATA_ram, enable_ATA_ram, q_overlay_ram, enable_overlay_ram, enable_io, enable_mem, enable_ep_ram, D_mem, access_granted, q_ep_ram, entreeA, entreeB, entreeC, entreeD, entreeE, entreeF, entreeG, entreeH, entreeI, entreeJ, entreeAA, entreeAB, entreeAC, entreeAD, entreeAE, entreeAF, entreeAG, entreeAH, entreeAI, entreeAJ, entreeBA, entreeBB, entreeBC, entreeBD, entreeBE, entreeBF, entreeBG, entreeBH, entreeBI, entreeBJ, entreeCA, entreeCB) begin if (enable_io = '1') then case choix is when "00000000" => Data_out <= entreeA; when "00000001" => Data_out <= entreeB; when "00000010" => Data_out <= entreeC; when "00000011" => Data_out <= entreeD; when "00000100" => Data_out <= entreeE; when "00000101" => Data_out <= entreeF; when "00000110" => Data_out <= entreeG; when "00000111" => Data_out <= entreeH; when "00001000" => Data_out <= entreeI; when "00001001" => Data_out <= entreeJ; when "00001010" => Data_out <= entreeAA; when "00001011" => Data_out <= entreeAB; when "00001100" => Data_out <= entreeAC; when "00001101" => Data_out <= entreeAD; when "00001110" => Data_out <= entreeAE; when "00001111" => Data_out <= entreeAF; when "00010000" => Data_out <= entreeAG; when "00010001" => Data_out <= entreeAH; when "00010010" => Data_out <= entreeAI; when "00010011" => Data_out <= entreeAJ; when "00010100" => Data_out <= entreeBA; when "00010101" => Data_out <= entreeBB; when "00010110" => Data_out <= entreeBC; when "00010111" => Data_out <= entreeBD; when "00011000" => Data_out <= entreeBE; when "00011001" => Data_out <= entreeBF; when "00011010" => Data_out <= entreeBG; when "00011011" => Data_out <= entreeBH; when "00011100" => Data_out <= entreeBI; when "00011101" => Data_out <= entreeBJ; when "00011110" => Data_out <= entreeCA; when "00011111" => Data_out <= entreeCB; when "11111110" => Data_out <= "1111000" & access_granted; when others => Data_out <= "01010101"; end case; elsif (enable_ep_ram = '1') then Data_out <= q_ep_ram; elsif (enable_ATA_ram = '1') then Data_out <= d_ATA_ram; elsif (enable_overlay_ram = '1') then Data_out <= q_overlay_ram; elsif (enable_mem = '1') then if choix(0) = '0' then Data_out <= D_mem(7 downto 0); else Data_out <= D_mem(15 downto 8); end if; else Data_out <= "10101010"; end if; end process; ------------------------------------------------------------------------------- ecriture : process (choix, WriteN, Data_in, enable_io, enable_mem, enable_ep_ram, enable_overlay_ram, enable_ATA_ram) begin if (enable_io = '1') and (WriteN = '0') then case choix is when "00000000" => sortie00d <= Data_in; when "00000001" => sortie01d <= Data_in; when "00000010" => sortie02d <= Data_in; when "00000011" => sortie03d <= Data_in; when "00000100" => sortie04d <= Data_in; when "00000101" => sortie05d <= Data_in; when "00000110" => sortie06d <= Data_in; when "00000111" => sortie07d <= Data_in; when "00001000" => sortie08d <= Data_in; when "00001001" => sortie09d <= Data_in; when "00001010" => sortie10d <= Data_in; when "00001011" => sortie11d <= Data_in; when "00001100" => sortie12d <= Data_in; when "00001101" => sortie13d <= Data_in; when "00001110" => sortie14d <= Data_in; when "00001111" => sortie15d <= Data_in; when "00010000" => sortie16d <= Data_in; when "00010001" => sortie17d <= Data_in; when "00010010" => sortie18d <= Data_in; when "00010011" => sortie19d <= Data_in; when "00010100" => sortie20d <= Data_in; when "00010101" => sortie21d <= Data_in; when "00010110" => sortie22d <= Data_in; when "00010111" => sortie23d <= Data_in; when "00011000" => sortie24d <= Data_in; when "00011001" => sortie25d <= Data_in; when "00011010" => sortie26d <= Data_in; when "00011011" => sortie27d <= Data_in; when "00011100" => sortie28d <= Data_in; when "00011101" => sortie29d <= Data_in; when "00011110" => sortie30d <= Data_in; when "00011111" => sortie31d <= Data_in; when "00100000" => sortie32d <= Data_in; when "00100001" => sortie33d <= Data_in; when "00100010" => sortie34d <= Data_in; when "00100011" => sortie35d <= Data_in; when "00100100" => sortie36d <= Data_in; when "00100101" => sortie37d <= Data_in; when "00100110" => sortie38d <= Data_in; when "00100111" => sortie39d <= Data_in; when "00101000" => sortie40d <= Data_in; when "00101001" => sortie41d <= Data_in; when "00101010" => sortie42d <= Data_in; when "00101011" => sortie43d <= Data_in; when "00101100" => sortie44d <= Data_in; when "00101101" => sortie45d <= Data_in; when "00101110" => sortie46d <= Data_in; when "00101111" => sortie47d <= Data_in; when "00110000" => sortie48d <= Data_in; when "00110001" => sortie49d <= Data_in; when "00110010" => sortie50d <= Data_in; when "00110011" => sortie51d <= Data_in; when "00110100" => sortie52d <= Data_in; when "00110101" => sortie53d <= Data_in; when "00110110" => sortie54d <= Data_in; when "00110111" => sortie55d <= Data_in; when "00111000" => sortie56d <= Data_in; when "00111001" => sortie57d <= Data_in; when "00111010" => sortie58d <= Data_in; when "00111011" => sortie59d <= Data_in; when "00111100" => sortie60d <= Data_in; when "00111101" => sortie61d <= Data_in; when "00111110" => sortie62d <= Data_in; when "00111111" => sortie63d <= Data_in; when "11111110" => access_request <= Data_in(0); when "11111111" => A_mem(18 downto 14) <= Data_in(4 downto 0); access_type <= Data_in(6 downto 5); when others => NULL; end case; elsif (enable_ep_ram = '1') then data_ep_ram <= Data_in; elsif (enable_ATA_ram = '1') then q_ATA_ram <= Data_in; elsif (enable_overlay_ram = '1') then d_overlay_ram <= Data_in; elsif (enable_mem = '1') then Data_mem <= Data_in; end if; end process; ------------------------------------------------------------------------------- ram16ko_inst : ram16ko PORT MAP ( address => "00"&Address(11 downto 0),--Address(13 downto 0), clock => clk, data => data_ep_ram, wren => wren_ep_ram, q => q_ep_ram ); ------------------------------------------------------------------------------- end structure;