AMBPEX5_v20_SX50T_CORE
|
00001 --------------------------------------------------------------------------------------------------- 00002 -- 00003 -- Title : cl_chn_v4 00004 -- Author : Dmitry Smekhov 00005 -- Company : Instrumental System 00006 -- 00007 -- Version : 2.4 00008 -- 00009 --------------------------------------------------------------------------------------------------- 00010 -- 00011 -- Description : Реализация общих регистров управления, 00012 -- формирование прерывания и запроса DMA 00013 -- Модификация 4. 00014 -- Для дешифрации адреса используются разряды 4..0. 00015 -- Формируются регистры: 00016 -- MODE0, MODE1, MODE2, MODE3, SFLAG_PAE, SFLAG_PAF, PRT_MODE 00017 -- STMODE, FMODE, CNT0, CNT1, CNT2 00018 -- CHAN1, FORMAT 00019 -- 00020 --------------------------------------------------------------------------------------------------- 00021 -- 00022 -- Version 2.4 05.04.2010 00023 -- Добавлены триггеры на сигналы rst, fifo_rst 00024 -- 00025 --------------------------------------------------------------------------------------------------- 00026 -- 00027 -- Version 2.3 14.04.2006 00028 -- добавлен выход регистра TL_MODE (Соколов) 00029 -- 00030 -- Version 2.2 29.10.2004 00031 -- Исправлена запись в регистр mode3 00032 -- 00033 -- Version 2.1 25.09.2004 00034 -- Разрешение запроса DMA маскируется сигналом prt_wr_start 00035 -- 00036 -- Version 2.0 03.08.2004 00037 -- Добавлены выходы SFLAG_PAE, SFLAG_PAF 00038 -- 00039 --------------------------------------------------------------------------------------------------- 00040 00041 00042 library ieee; 00043 use ieee.std_logic_1164.all; 00044 00045 use work.adm2_pkg.all; 00046 00047 package cl_chn_v4_pkg is 00048 00049 component cl_chn_v4 is 00050 generic ( 00051 -- 2 - out - для тетрады вывода 00052 -- 1 - in - для тетрады ввода 00053 chn_type : integer 00054 ); 00055 00056 port( 00057 reset : in std_logic; -- 0 - общий сброс 00058 clk : in std_logic; -- тактовая частота 00059 00060 -- Флаги 00061 cmd_rdy : in std_logic; -- 1 - готовность тетрады 00062 rdy : in std_logic; -- 1 - готовность FIFO 00063 fifo_flag : in bl_fifo_flag; -- флаги FIFO 00064 st9 : in std_logic:='0'; -- Разряды регистра STATUS 00065 st10 : in std_logic:='0'; 00066 st11 : in std_logic:='0'; 00067 st12 : in std_logic:='0'; 00068 st13 : in std_logic:='0'; 00069 st14 : in std_logic:='0'; 00070 st15 : in std_logic:='0'; 00071 00072 -- Тетрада 00073 data_in : in std_logic_vector( 15 downto 0 ); -- шина данных 00074 cmd : in bl_cmd; -- команда 00075 bx_irq : out std_logic; -- 1 - прерывание от тетрады 00076 bx_drq : out bl_drq; -- запрос DMA 00077 00078 status : out std_logic_vector( 15 downto 0 ); -- регистр STATUS 00079 00080 -- Управление 00081 mode0 : out std_logic_vector( 15 downto 0 ); -- регистры тетрады 00082 fdiv : out std_logic_vector( 15 downto 0 ); 00083 fdiv_we : out std_logic; -- 1 - в регистре FDIV новое значение 00084 fmode : out std_logic_vector( 15 downto 0 ); 00085 stmode : out std_logic_vector( 15 downto 0 ); 00086 cnt0 : out std_logic_vector( 15 downto 0 ); 00087 cnt1 : out std_logic_vector( 15 downto 0 ); 00088 cnt2 : out std_logic_vector( 15 downto 0 ); 00089 mode1 : out std_logic_vector( 15 downto 0 ); 00090 mode2 : out std_logic_vector( 15 downto 0 ); 00091 mode3 : out std_logic_vector( 15 downto 0 ); 00092 sflag_pae : out std_logic_vector( 15 downto 0 ); 00093 sflag_paf : out std_logic_vector( 15 downto 0 ); 00094 prt_mode : out std_logic_vector( 15 downto 0 ); 00095 tl_mode : out std_logic_vector( 15 downto 0 ); 00096 00097 chan1 : out std_logic_vector( 1 downto 0 ); 00098 format : out std_logic; 00099 00100 rst : out std_logic; -- 0 - сброс тетрады 00101 fifo_rst : out std_logic; -- 0 - сброс FIFO 00102 prt_wr_start: in std_logic:='1' -- 1 - наступило событие старта в режиме претриггера 00103 ); 00104 end component; 00105 00106 end package cl_chn_v4_pkg; 00107 00108 library ieee; 00109 use ieee.std_logic_1164.all; 00110 00111 use work.adm2_pkg.all; 00112 00113 entity cl_chn_v4 is 00114 generic ( 00115 -- 2 - out - для тетрады вывода 00116 -- 1 - in - для тетрады ввода 00117 chn_type : integer 00118 ); 00119 00120 port( 00121 reset : in std_logic; -- 0 - общий сброс 00122 clk : in std_logic; -- тактовая частота 00123 00124 -- Флаги 00125 cmd_rdy : in std_logic; -- 1 - готовность тетрады 00126 rdy : in std_logic; -- 1 - готовность FIFO 00127 fifo_flag : in bl_fifo_flag; -- флаги FIFO 00128 st9 : in std_logic:='0'; -- Разряды регистра STATUS 00129 st10 : in std_logic:='0'; 00130 st11 : in std_logic:='0'; 00131 st12 : in std_logic:='0'; 00132 st13 : in std_logic:='0'; 00133 st14 : in std_logic:='0'; 00134 st15 : in std_logic:='0'; 00135 00136 -- Тетрада 00137 data_in : in std_logic_vector( 15 downto 0 ); -- шина данных 00138 cmd : in bl_cmd; -- команда 00139 bx_irq : out std_logic; -- 1 - прерывание от тетрады 00140 bx_drq : out bl_drq; -- запрос DMA 00141 00142 status : out std_logic_vector( 15 downto 0 ); -- регистр STATUS 00143 00144 -- Управление 00145 mode0 : out std_logic_vector( 15 downto 0 ); -- регистры тетрады 00146 fdiv : out std_logic_vector( 15 downto 0 ); 00147 fdiv_we : out std_logic; -- 1 - в регистре FDIV новое значение 00148 fmode : out std_logic_vector( 15 downto 0 ); 00149 stmode : out std_logic_vector( 15 downto 0 ); 00150 cnt0 : out std_logic_vector( 15 downto 0 ); 00151 cnt1 : out std_logic_vector( 15 downto 0 ); 00152 cnt2 : out std_logic_vector( 15 downto 0 ); 00153 mode1 : out std_logic_vector( 15 downto 0 ); 00154 mode2 : out std_logic_vector( 15 downto 0 ); 00155 mode3 : out std_logic_vector( 15 downto 0 ); 00156 sflag_pae : out std_logic_vector( 15 downto 0 ); 00157 sflag_paf : out std_logic_vector( 15 downto 0 ); 00158 prt_mode : out std_logic_vector( 15 downto 0 ); 00159 tl_mode : out std_logic_vector( 15 downto 0 ); 00160 00161 chan1 : out std_logic_vector( 1 downto 0 ); 00162 format : out std_logic; 00163 00164 rst : out std_logic; -- 0 - сброс тетрады 00165 fifo_rst : out std_logic; -- 0 - сброс FIFO 00166 prt_wr_start: in std_logic:='1' -- 1 - наступило событие старта в режиме претриггера 00167 ); 00168 end cl_chn_v4; 00169 00170 architecture cl_chn_v4 of cl_chn_v4 is 00171 00172 signal c_mode0, c_mask, c_inv, c_mode1, c_mode2, c_flag, c_irq : std_logic_vector( 15 downto 0 ); 00173 signal c_fmode, c_fdiv, c_stmode, c_cnt0, c_cnt1, c_cnt2: std_logic_vector( 15 downto 0 ); 00174 signal c_mode3, c_sflag : std_logic_vector( 15 downto 0 ); 00175 signal c_sflag_pae, c_sflag_paf, c_prt_mode,c_tl_mode : std_logic_vector( 15 downto 0 ); 00176 signal c_status : std_logic_vector( 15 downto 0 ); 00177 signal c_drq_en : std_logic; 00178 signal c_rst : std_logic; -- 0 - сброс тетрады 00179 signal drq_req : std_logic; 00180 00181 00182 begin 00183 00184 00185 00186 mode0<=c_mode0; 00187 mode1<=c_mode1; 00188 mode2<=c_mode2; 00189 mode3<=c_mode3; 00190 status<=c_status; 00191 fmode<=c_fmode; 00192 fdiv<=c_fdiv; 00193 stmode<=c_stmode; 00194 cnt0<=c_cnt0; 00195 cnt1<=c_cnt1; 00196 cnt2<=c_cnt2; 00197 sflag_pae <= c_sflag_pae; 00198 sflag_paf <= c_sflag_paf; 00199 prt_mode <= c_prt_mode; 00200 tl_mode <= c_tl_mode; 00201 00202 pr_mode0: process( reset, clk ) begin 00203 if( reset='0' ) then 00204 c_mode0<=(others=>'0'); 00205 elsif( rising_edge( clk ) ) then 00206 if( cmd.cmd_data_we='1' ) then 00207 if( cmd.adr(9)='0' and cmd.adr(8)='0' ) then 00208 case cmd.adr( 4 downto 0 ) is 00209 when "00000" => c_mode0<=data_in; 00210 when others=>null; 00211 end case; 00212 end if; 00213 end if; 00214 end if; 00215 end process; 00216 00217 00218 pr_reg: process( c_rst, clk ) 00219 variable v: std_logic; 00220 begin 00221 if( c_rst='0' ) then 00222 c_mode1<=(others=>'0'); 00223 c_mode2<=(others=>'0'); 00224 c_mode3<=(others=>'0'); 00225 c_sflag_pae<=(others=>'0'); 00226 c_sflag_paf<=(others=>'0'); 00227 c_prt_mode<=(others=>'0'); 00228 c_tl_mode<=(others=>'0'); 00229 c_mask<=(others=>'0'); 00230 c_inv<=(others=>'0'); 00231 c_fmode<=(others=>'0'); 00232 c_fdiv <=(others=>'0'); 00233 c_stmode<=(others=>'0'); 00234 c_cnt0<=(others=>'0'); 00235 c_cnt1<=(others=>'0'); 00236 c_cnt2<=(others=>'0'); 00237 chan1<=(others=>'0'); 00238 fdiv_we<='0'; 00239 format <='0'; 00240 elsif( rising_edge( clk ) ) then 00241 v:='0'; 00242 if( cmd.cmd_data_we='1' ) then 00243 if( cmd.adr(9)='0' and cmd.adr(8)='0' ) then 00244 case cmd.adr( 4 downto 0 ) is 00245 when "00001" => c_mask<=data_in; 00246 when "00010" => c_inv<=data_in; 00247 when "00011" => c_fmode<=data_in; 00248 when "00100" => c_fdiv<=data_in; v:='1'; 00249 when "00101" => c_stmode<=data_in; 00250 when "00110" => c_cnt0<=data_in; 00251 when "00111" => c_cnt1<=data_in; 00252 when "01000" => c_cnt2<=data_in; 00253 when "01001" => c_mode1<=data_in; 00254 when "01010" => c_mode2<=data_in; 00255 when "01011" => c_mode3<=data_in; 00256 when "01100" => c_sflag_pae<=data_in; 00257 when "01101" => c_sflag_paf<=data_in; 00258 when "01110" => c_prt_mode<=data_in; 00259 when "01111" => c_tl_mode<=data_in; 00260 when "10000" => chan1 <= data_in( 1 downto 0 ); 00261 when "10010" => format <= data_in( 0 ); 00262 when others=>null; 00263 end case; 00264 end if; 00265 end if; 00266 fdiv_we<=v; 00267 end if; 00268 end process; 00269 00270 pr_status: process( clk ) begin 00271 if( rising_edge( clk ) ) then 00272 c_status(0)<=cmd_rdy; 00273 c_status(1)<=rdy and prt_wr_start; 00274 c_status(2)<=fifo_flag.ef; 00275 c_status(3)<=fifo_flag.pae; 00276 c_status(4)<=fifo_flag.hf; 00277 c_status(5)<=fifo_flag.paf; 00278 c_status(6)<=fifo_flag.ff; 00279 c_status(7)<=fifo_flag.ovr; 00280 c_status(8)<=fifo_flag.und; 00281 c_status(9)<=st9; 00282 c_status(10)<=st10; 00283 c_status(11)<=st11; 00284 c_status(12)<=st12; 00285 c_status(13)<=st13; 00286 c_status(14)<=st14; 00287 c_status(15)<=st15; 00288 end if; 00289 end process; 00290 00291 c_flag<=c_status xor c_inv; 00292 c_irq<= c_flag and c_mask; 00293 00294 pr_irq: process( c_irq, clk ) 00295 variable v: std_logic; 00296 begin 00297 v:='0'; 00298 for i in 0 to 15 loop 00299 v:=v or c_irq( i ); 00300 end loop; 00301 if( rising_edge( clk ) ) then 00302 bx_irq<=v and c_mode0(2); 00303 end if; 00304 end process; 00305 00306 00307 c_rst<=reset and ( not c_mode0(0) ); 00308 rst <= c_rst after 1 ns when rising_edge( clk ); 00309 00310 fifo_rst<=reset and ( not c_mode0(0) ) and ( not c_mode0(1) ) after 1 ns when rising_edge( clk ); 00311 00312 c_drq_en<=c_mode0( 3 ) and prt_wr_start; 00313 00314 bx_drq.en<=c_drq_en; 00315 00316 gen_out: if chn_type=2 generate 00317 00318 pr_bx_drq: process( c_mode0, fifo_flag, c_drq_en, rdy ) 00319 00320 begin 00321 case c_mode0( 13 downto 12 ) is 00322 when "00" => drq_req <= fifo_flag.paf and c_drq_en; -- PAF = 1 00323 when "01" => drq_req <= rdy and c_drq_en; -- RDY = 1 00324 when "10" => drq_req <= fifo_flag.hf and c_drq_en; -- HF = 1 00325 when others => drq_req<='0'; 00326 end case; 00327 end process; 00328 00329 bx_drq.ack <= cmd.data_we and c_drq_en; 00330 00331 end generate; 00332 00333 gen_in: if chn_type=1 generate 00334 00335 pr_bx_drq: process( c_mode0, fifo_flag, c_drq_en, rdy ) 00336 00337 begin 00338 case c_mode0( 13 downto 12 ) is 00339 when "00" => drq_req <= fifo_flag.pae and c_drq_en; -- PAE = 1 00340 when "01" => drq_req <= rdy and c_drq_en; -- RDY = 1 00341 when "10" => drq_req <= ( not fifo_flag.hf ) and c_drq_en; -- HF = 0 00342 when others => drq_req<='0'; 00343 end case; 00344 end process; 00345 00346 bx_drq.ack <= ( not cmd.data_cs ) and c_drq_en; 00347 00348 end generate; 00349 00350 bx_drq.req <= drq_req when c_prt_mode(0)='0' or c_prt_mode(1)='1' 00351 else drq_req and prt_wr_start; 00352 00353 00354 end cl_chn_v4;