AMBPEX5_v20_SX50T_CORE
|
00001 ------------------------------------------------------------------------------- 00002 -- 00003 -- Title : ctrl_blink 00004 -- Design : ambpex5_v11_lx50t_ddr2 00005 -- Author : Dmitry Smekhov 00006 -- Company : NNS 00007 -- 00008 ------------------------------------------------------------------------------- 00009 -- 00010 -- Description : Управление светодиодом состояния шины PCI-Express 00011 -- RESET=0 - светодиод горит 00012 -- pcie_link_up=1 - не прошла инициализация PCI-Express - 00013 -- - светодиод часто непрерывно мигает 00014 -- pcie_link_up=0 - число миганий соответствует ширине 00015 -- шины PCI-Express 00016 -- 00017 -- 00018 ------------------------------------------------------------------------------- 00019 00020 00021 library ieee; 00022 use ieee.std_logic_1164.all; 00023 00024 package ctrl_blink_pkg is 00025 00026 component ctrl_blink is 00027 generic( 00028 is_simulation : in integer:=0 00029 ); 00030 port( 00031 clk : in std_logic; -- тактовая частота 250 00032 reset : in std_logic; -- 0 - сброс 00033 clk30k : in std_logic; -- тактовая частота 30 кГц 00034 00035 pcie_link_up : in std_logic; -- 0 - завершена инициализация PCI-Express 00036 pcie_lstatus : in std_logic_vector( 15 downto 0 ); -- регистра LSTATUS 00037 00038 led_h1 : out std_logic -- светодиод 00039 ); 00040 end component; 00041 00042 end package; 00043 00044 00045 library ieee; 00046 use ieee.std_logic_1164.all; 00047 use ieee.std_logic_arith.all; 00048 use ieee.std_logic_unsigned.all; 00049 00050 library unisim; 00051 use unisim.vcomponents.all; 00052 00053 entity ctrl_blink is 00054 generic( 00055 is_simulation : in integer:=0 00056 ); 00057 port( 00058 clk : in std_logic; -- тактовая частота 250 00059 reset : in std_logic; -- 0 - сброс 00060 clk30k : in std_logic; -- тактовая частота 30 кГц 00061 00062 pcie_link_up : in std_logic; -- 0 - завершена инициализация PCI-Express 00063 pcie_lstatus : in std_logic_vector( 15 downto 0 ); -- регистра LSTATUS 00064 00065 led_h1 : out std_logic -- светодиод 00066 ); 00067 end ctrl_blink; 00068 00069 00070 architecture ctrl_blink of ctrl_blink is 00071 00072 00073 signal clk_blink : std_logic; 00074 signal clk_z1, clk_z2 : std_logic; 00075 signal mask : std_logic; 00076 signal cnt : std_logic_vector( 3 downto 0 ); 00077 signal cnt30k : std_logic_vector( 13 downto 0 ):=(others=>'0'); 00078 signal ncnt30k : std_logic_vector( 13 downto 0 ); 00079 00080 signal stp : std_logic; 00081 00082 begin 00083 gen_sim: if( is_simulation=1 ) generate 00084 00085 clk_blink <= cnt30k(4) when stp='1' else cnt30k(3); 00086 00087 end generate; 00088 00089 gen_syn: if( is_simulation=0 ) generate 00090 00091 00092 clk_blink <= cnt30k(13) when stp='1' else cnt30k(12); 00093 00094 end generate; 00095 00096 00097 00098 clk_z1 <= clk_blink after 1 ns when rising_edge( clk ); 00099 clk_z2 <= clk_z1 after 1 ns when rising_edge( clk ); 00100 00101 cnt30k(0) <= ncnt30k(0) when rising_edge( clk30k ); 00102 00103 gen_30k: for i in 1 to 13 generate 00104 fd30k: fd port map( q =>cnt30k(i), c =>cnt30k(i-1), d =>ncnt30k(i) ); 00105 end generate; 00106 00107 ncnt30k <= not cnt30k; 00108 00109 00110 pr_state: process( clk ) begin 00111 00112 if( rising_edge( clk ) ) then 00113 if( clk_z1='1' and clk_z2='0' ) then 00114 00115 case( stp ) is 00116 when '0' => 00117 if( pcie_link_up='0' ) then 00118 stp <= '1' after 1 ns; 00119 end if; 00120 mask <= '0' after 1 ns; 00121 cnt <= "0000" after 1 ns; 00122 00123 when '1' => 00124 if( pcie_link_up='1' ) then 00125 stp <= '0' after 1 ns; 00126 end if; 00127 if( cnt(3 downto 0 )="0000" ) then 00128 mask <= '0' after 1 ns; 00129 elsif( pcie_lstatus(6 downto 4)=cnt( 2 downto 0 ) ) then 00130 mask <= '1' after 1 ns; 00131 end if; 00132 00133 cnt <= cnt + 1 after 1 ns; 00134 00135 when others => null; 00136 end case; 00137 00138 00139 00140 end if; 00141 00142 if( reset='0' ) then 00143 mask <= '0' after 1 ns; 00144 stp <= '0' after 1 ns; 00145 end if; 00146 end if; 00147 end process; 00148 00149 led_h1 <= reset and ( clk_blink or mask ); 00150 00151 end ctrl_blink;