APB_MULTI_DIODE.vhd
105 lines
| 2.9 KiB
| text/x-vhdl
|
VhdlLexer
|
r19 | ------------------------------------------------------------------------------ | ||
-- This file is a part of the LPP VHDL IP LIBRARY | ||||
-- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS | ||||
-- | ||||
-- This program is free software; you can redistribute it and/or modify | ||||
-- it under the terms of the GNU General Public License as published by | ||||
-- the Free Software Foundation; either version 3 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program is distributed in the hope that it will be useful, | ||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
-- GNU General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
------------------------------------------------------------------------------- | ||||
library ieee; | ||||
use ieee.std_logic_1164.all; | ||||
--use ieee.numeric_std.all; | ||||
library grlib; | ||||
use grlib.amba.all; | ||||
use grlib.stdlib.all; | ||||
use grlib.devices.all; | ||||
library lpp; | ||||
use lpp.lpp_amba.all; | ||||
entity APB_MULTI_DIODE is | ||||
generic ( | ||||
pindex : integer := 0; | ||||
paddr : integer := 0; | ||||
pmask : integer := 16#fff#; | ||||
pirq : integer := 0; | ||||
abits : integer := 8); | ||||
port ( | ||||
rst : in std_ulogic; | ||||
clk : in std_ulogic; | ||||
apbi : in apb_slv_in_type; | ||||
apbo : out apb_slv_out_type; | ||||
LED : out std_logic_vector(2 downto 0) | ||||
); | ||||
end; | ||||
architecture AR_APB_MULTI_DIODE of APB_MULTI_DIODE is | ||||
constant REVISION : integer := 1; | ||||
constant pconfig : apb_config_type := ( | ||||
0 => ahb_device_reg (VENDOR_LPP, LPP_MULTI_DIODE, 0, REVISION, 0), | ||||
1 => apb_iobar(paddr, pmask)); | ||||
type LEDregs is record | ||||
DATAin : std_logic_vector(31 downto 0); | ||||
DATAout : std_logic_vector(31 downto 0); | ||||
end record; | ||||
signal r : LEDregs; | ||||
|
r29 | signal Rdata : std_logic_vector(31 downto 0); | ||
|
r19 | |||
begin | ||||
r.DATAout <= r.DATAin xor X"FFFFFFFF"; | ||||
process(rst,clk) | ||||
begin | ||||
if rst = '0' then | ||||
LED <= "000"; | ||||
r.DATAin <= (others => '0'); | ||||
|
r29 | |||
|
r19 | elsif clk'event and clk = '1' then | ||
LED <= r.DATAin(2 downto 0); | ||||
--APB Write OP | ||||
if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then | ||||
case apbi.paddr(abits-1 downto 2) is | ||||
when "000000" => | ||||
r.DATAin <= apbi.pwdata; | ||||
when others => | ||||
null; | ||||
end case; | ||||
end if; | ||||
--APB READ OP | ||||
|
r29 | if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then | ||
|
r19 | case apbi.paddr(abits-1 downto 2) is | ||
when "000000" => | ||||
|
r29 | Rdata <= r.DATAin; | ||
|
r19 | when others => | ||
|
r29 | Rdata <= r.DATAout; | ||
|
r19 | end case; | ||
end if; | ||||
end if; | ||||
apbo.pconfig <= pconfig; | ||||
end process; | ||||
|
r29 | apbo.prdata <= Rdata when apbi.penable = '1'; | ||
|
r19 | end ar_APB_MULTI_DIODE; | ||