--------------------------------------------------------------------------------
-- Create Date:     12:06:07 03/01/06
-- File Name:       pmc_cpld.vhd 
-- Module Name:     pmc
-- Target Device:   Xilinx XC2C64A CoolRunner-II CPLD
-- Description:     pmc_cpld 
-- Dependencies:    none
---------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_arith.ALL;
use ieee.std_logic_unsigned.ALL;

entity pmc_cpld is
port( 
    linkspd1_b          :    in std_logic_vector(1 downto 0);
    linkspd2_b          :    in std_logic_vector(1 downto 0);
    lnkf_b              :   out std_logic_vector(1 downto 0);
    lnkb_b              :   out std_logic_vector(1 downto 0);
    tpci_rst_b          :   out std_logic;
    monarch_b           :    in std_logic;
    pci_rst_b           :    in std_logic;
    mrst_b              :    in std_logic;
    pci_rstdir          :   out std_logic;
    ocn_rst_b           :   out std_logic;
    memrst_b            :   out std_logic;
    phyrst_b            :   out std_logic;
    eready              :    in std_logic;
    pwrup_pci_host      :   out std_logic;
    activity_b          :    in std_logic_vector(1 downto 0);
    activity_ledb_b     :   out std_logic_vector(1 downto 0);
    activity_ledf_b     :   out std_logic_vector(1 downto 0);
    pb_qack0_b          :    in std_logic;
    sreset_b            :    in std_logic;
    pb_rst_b            :    in std_logic;
    copsreset_b         :    in std_logic;
    cophreset_b         :    in std_logic;
    copqack_b           :    in std_logic;
    coptrst_b           :    in std_logic;
    cpusreset_b         :   out std_logic;
    cpuhreset_b         :   out std_logic;
    cputrst_b           :   out std_logic;
    cpu_qack_b          :   out std_logic
);
end pmc_cpld;

architecture behavioral of pmc_cpld is

begin
    
    -- Assign Outputs
    lnkb_b(0)           <= not(linkspd1_b(0)) and linkspd2_b(0);
    lnkb_b(1)           <= not(linkspd1_b(1)) and linkspd2_b(1);
    
    tpci_rst_b          <= pci_rst_b and mrst_b;

    pci_rstdir          <= '0';

    ocn_rst_b           <= pci_rst_b and mrst_b;

    memrst_b            <= pci_rst_b and mrst_b;

    phyrst_b            <= pci_rst_b and mrst_b;

    pwrup_pci_host      <= monarch_b; 
    
    activity_ledb_b(0)  <= activity_b(0);
    activity_ledb_b(1)  <= activity_b(1);

    cpusreset_b         <= pci_rst_b and mrst_b and pb_rst_b and copsreset_b;

    cpuhreset_b         <= pb_rst_b and cophreset_b;

    cputrst_b           <= pci_rst_b and mrst_b and pb_rst_b and coptrst_b;

    cpu_qack_b          <= pb_qack0_b and copqack_b;

    activity_ledf_b(0)  <= activity_b(0);
    activity_ledf_b(1)  <= activity_b(1);

    lnkf_b(0)           <= not(linkspd1_b(0)) and linkspd2_b(0);
    lnkf_b(1)           <= not(linkspd1_b(1)) and linkspd2_b(1);

end behavioral;
