00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/ddr2/ddr2_mem_pattern_compare8.vhd,v $
00015 --* $Revision: 1.2.2.4 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:44 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023 -------------------------------------------------------------------------------
00024 -- Copyright (c) 2005 Xilinx, Inc.
00025 -- This design is confidential and proprietary of Xilinx, All Rights Reserved.
00026 -------------------------------------------------------------------------------
00027 -- ____ ____
00028 -- / /\/ /
00029 -- /___/ \ / Vendor: Xilinx
00030 -- \ \ \/ Version: 1.6
00031 -- \ \ Application : MIG
00032 -- / / Filename: ddr2_mem_pattern_compare8.vhd
00033 -- /___/ /\ Date Last Modified: Wed Jun 1 2005
00034 -- \ \ / \Date Created: Mon May 2 2005
00035 -- \___\/\___\
00036 -- Device: Virtex-4
00037 -- Design Name: DDR2_SDRAM
00038 -------------------------------------------------------------------------------
00039
00040
00041 library ieee;
00042
00043 use ieee.std_logic_1164.all;
00044
00045 use ieee.std_logic_unsigned.all;
00046
00047 use ieee.numeric_std.all;
00048
00049
00050
00051
00052
00053 entity ddr2_mem_pattern_compare8 is
00054 port(
00055 clk : in ;
00056 rst : in ;
00057 ctrl_rden : in ;
00058 rd_data_rise : in (7 downto 0);
00059 rd_data_fall : in (7 downto 0);
00060 comp_done : out ;
00061 first_rising : out ;
00062 rd_en_rise : out ;
00063 rd_en_fall : out
00064 );
00065 end entity;
00066
00067
00068
00069
00070
00071 architecture arc_pattern_compare of ddr2_mem_pattern_compare8 is
00072
00073 signal rise_state, rise_next_state : STATE_MACHINE1;
00074 signal fall_state, fall_next_state : STATE_MACHINE2;
00075 signal clk_cnt_rise : (3 downto 0);
00076 signal clk_cnt_fall : (3 downto 0);
00077 signal clk_count_rise : (3 downto 0);
00078 signal clk_count_fall : (3 downto 0);
00079 signal cntrl_rden_r : ;
00080 signal rd_data_rise_r : (7 downto 0);
00081 signal rd_data_fall_r : (7 downto 0);
00082 signal rd_en_r1 : ;
00083 signal rd_en_r2 : ;
00084 signal rd_en_r3 : ;
00085 signal rd_en_r4 : ;
00086 signal rd_en_r5 : ;
00087 signal rd_en_r6 : ;
00088 signal rd_en_r7 : ;
00089 signal rd_en_r8 : ;
00090 signal rd_en_r9 : ;
00091 signal rd_en_r10 : ;
00092 signal comp_done0 : ;
00093 signal comp_done_r : ;
00094
00095 begin
00096
00097 comp_done <= comp_done_r;
00098
00099
00100 process(clk)
00101 begin
00102 if (clk = '1' and clk'event) then
00103 if (rst = '1') then
00104 rd_en_r1 <= '0';
00105 rd_en_r2 <= '0';
00106 rd_en_r3 <= '0';
00107 rd_en_r4 <= '0';
00108 rd_en_r5 <= '0';
00109 rd_en_r6 <= '0';
00110 rd_en_r7 <= '0';
00111 rd_en_r8 <= '0';
00112 rd_en_r9 <= '0';
00113 rd_en_r10 <= '0';
00114 else
00115 rd_en_r1 <= ctrl_rden;
00116 rd_en_r2 <= rd_en_r1;
00117 rd_en_r3 <= rd_en_r2;
00118 rd_en_r4 <= rd_en_r3;
00119 rd_en_r5 <= rd_en_r4;
00120 rd_en_r6 <= rd_en_r5;
00121 rd_en_r7 <= rd_en_r6;
00122 rd_en_r8 <= rd_en_r7;
00123 rd_en_r9 <= rd_en_r8;
00124 rd_en_r10 <= rd_en_r9;
00125 end if;
00126 end if;
00127 end process;
00128
00129
00130 process(clk)
00131 begin
00132 if (clk = '1' and clk'event) then
00133 if (rst = '1') then
00134 comp_done_r <= '0';
00135 else
00136 comp_done_r <= comp_done0;
00137 end if;
00138 end if;
00139 end process;
00140
00141
00142 process(clk)
00143 begin
00144 if (clk = '1' and clk'event) then
00145 if (rst = '1') then
00146 rd_en_rise <= '0';
00147 elsif(comp_done_r = '1') then
00148 case clk_count_rise is
00149 when "0011" => rd_en_rise <= rd_en_r2;
00150 when "0100" => rd_en_rise <= rd_en_r3;
00151 when "0101" => rd_en_rise <= rd_en_r4;
00152 when "0110" => rd_en_rise <= rd_en_r5;
00153 when "0111" => rd_en_rise <= rd_en_r6;
00154 when "1000" => rd_en_rise <= rd_en_r7;
00155 when "1001" => rd_en_rise <= rd_en_r8;
00156 when others => rd_en_rise <= '0';
00157 end case;
00158 end if;
00159 end if;
00160 end process;
00161
00162
00163 process(clk)
00164 begin
00165 if (clk = '1' and clk'event) then
00166 if (rst = '1') then
00167 rd_en_fall <= '0';
00168 elsif(comp_done_r = '1') then
00169 case (clk_count_fall) is
00170 when "0011" => rd_en_fall <= rd_en_r2;
00171 when "0100" => rd_en_fall <= rd_en_r3;
00172 when "0101" => rd_en_fall <= rd_en_r4;
00173 when "0110" => rd_en_fall <= rd_en_r5;
00174 when "0111" => rd_en_fall <= rd_en_r6;
00175 when "1000" => rd_en_fall <= rd_en_r7;
00176 when "1001" => rd_en_fall <= rd_en_r8;
00177 when others => rd_en_fall <= '0';
00178 end case;
00179 end if;
00180 end if;
00181 end process;
00182
00183 comp_done0 <= '1' when (rise_state = rise_comp_over and fall_state = fall_comp_over) else '0';
00184
00185
00186 process(clk)
00187 begin
00188 if (clk = '1' and clk'event) then
00189 if (rst = '1') then
00190 rd_data_rise_r <= (others => '0');
00191 rd_data_fall_r <= (others => '0');
00192 else
00193 rd_data_rise_r <= rd_data_rise;
00194 rd_data_fall_r <= rd_data_fall;
00195 end if;
00196 end if;
00197 end process;
00198
00199
00200 process(clk)
00201 begin
00202 if (clk = '1' and clk'event) then
00203 if (rst = '1') then
00204 cntrl_rden_r <= '0';
00205 else
00206 cntrl_rden_r <= ctrl_rden;
00207 end if;
00208 end if;
00209 end process;
00210
00211
00212 process(clk)
00213 begin
00214 if (clk = '1' and clk'event) then
00215 if (rst = '1') then
00216 first_rising <= '0';
00217 elsif(rise_state = rise_first_data and rd_data_rise_r = X"55") then
00218 first_rising <= '1';
00219 end if;
00220 end if;
00221 end process;
00222
00223 clk_count_rise <= clk_cnt_rise when (rise_state = rise_comp_over) else "0000";
00224
00225
00226 process(clk)
00227 begin
00228 if (clk = '1' and clk'event) then
00229 if (rst = '1') then
00230 clk_cnt_rise <= (others => '0');
00231 elsif(rise_state = rise_first_data) then
00232 clk_cnt_rise <= clk_cnt_rise + "0001";
00233 else
00234 clk_cnt_rise <= clk_cnt_rise;
00235 end if;
00236 end if;
00237 end process;
00238
00239
00240 process(clk)
00241 begin
00242 if (clk = '1' and clk'event) then
00243 if (rst = '1') then
00244 rise_state <= rise_idle;
00245 else
00246 rise_state <= rise_next_state;
00247 end if;
00248 end if;
00249 end process;
00250
00251
00252 process(cntrl_rden_r, rise_state, rd_data_rise_r, rst)
00253 begin
00254 if (rst = '1') then
00255 rise_next_state <= rise_idle;
00256 else
00257 case (rise_state) is
00258 when rise_idle =>
00259 if(cntrl_rden_r = '1') then
00260 rise_next_state <= rise_first_data;
00261 else
00262 rise_next_state <= rise_idle;
00263 end if;
00264
00265 when rise_first_data =>
00266 if((rd_data_rise_r = X"AA") or (rd_data_rise_r = X"55")) then
00267 rise_next_state <= rise_comp_over; --second_data
00268 else
00269 rise_next_state <= rise_first_data;
00270 end if;
00271
00272 when rise_second_data =>
00273 if((rd_data_rise_r = X"99") or (rd_data_rise_r = X"66")) then
00274 rise_next_state <= rise_comp_over;
00275 else
00276 rise_next_state <= rise_first_data;
00277 end if;
00278
00279 when rise_comp_over =>
00280 rise_next_state <= rise_comp_over;
00281
00282 when others =>
00283 rise_next_state <= rise_idle;
00284
00285 end case;
00286 end if;
00287 end process;
00288
00289 clk_count_fall <= clk_cnt_fall when (fall_state = fall_comp_over) else "0000";
00290
00291
00292 process(clk)
00293 begin
00294 if (clk = '1' and clk'event) then
00295 if (rst = '1') then
00296 clk_cnt_fall <= "0000";
00297 elsif(fall_state = fall_first_data) then
00298 clk_cnt_fall <= clk_cnt_fall + "0001";
00299 else
00300 clk_cnt_fall <= clk_cnt_fall;
00301 end if;
00302 end if;
00303 end process;
00304
00305
00306 process(clk)
00307 begin
00308 if (clk = '1' and clk'event) then
00309 if (rst = '1') then
00310 fall_state <= fall_idle;
00311 else
00312 fall_state <= fall_next_state;
00313 end if;
00314 end if;
00315 end process;
00316
00317
00318 process(cntrl_rden_r, fall_state, rd_data_fall_r, rst)
00319 begin
00320 if(rst = '1') then
00321 fall_next_state <= fall_idle;
00322 else
00323 case (fall_state) is
00324 when fall_idle =>
00325 if(cntrl_rden_r = '1') then
00326 fall_next_state <= fall_first_data;
00327 else
00328 fall_next_state <= fall_idle;
00329 end if;
00330
00331
00332 when fall_first_data =>
00333 if((rd_data_fall_r = X"55") or (rd_data_fall_r = X"AA")) then
00334 fall_next_state <= fall_comp_over; --second_data
00335 else
00336 fall_next_state <= fall_first_data;
00337 end if;
00338
00339 when fall_second_data =>
00340 if((rd_data_fall_r = X"66") or (rd_data_fall_r = X"99")) then
00341 fall_next_state <= fall_comp_over;
00342 else
00343 fall_next_state <= fall_first_data;
00344 end if;
00345
00346 when fall_comp_over =>
00347 fall_next_state <= fall_comp_over;
00348
00349 when others =>
00350 fall_next_state <= fall_idle;
00351
00352 end case;
00353 end if;
00354 end process;
00355
00356 end arc_pattern_compare;