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/ddr/mem_interface_top_pattern_compare8.vhd,v $ *
00015 --* $Revision: 1.2.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:43 $ *
00019 --* *
00020 --**************************************************************
00021 -------------------------------------------------------------------------------
00022 -- Copyright (c) 2005 Xilinx, Inc.
00023 -- This design is confidential and proprietary of Xilinx, All Rights Reserved.
00024 -------------------------------------------------------------------------------
00025 -- ____ ____
00026 -- / /\/ /
00027 -- /___/ \ / Vendor: Xilinx
00028 -- \ \ \/ Version: 1.6
00029 -- \ \ Application : MIG
00030 -- / / Filename: mem_interface_top_pattern_compare8.vhd
00031 -- /___/ /\ Date Last Modified: Wed Jun 1 2005
00032 -- \ \ / \Date Created: Mon May 2 2005
00033 -- \___\/\___\
00034 -- Device: Virtex-4
00035 -- Design Name: DDR1_SDRAM
00036 -- Description: Compares the IOB output 8 bit data of one bank that is read data
00037 -- during the intilaization to get the delay for the data with respect
00038 -- to the command issued.
00039 -------------------------------------------------------------------------------
00040
00041
00042 library ieee;
00043
00044 use ieee.std_logic_1164.all;
00045
00046 use ieee.std_logic_unsigned.all;
00047
00048 library unisim;
00049
00050 use unisim.vcomponents.all;
00051
00052 entity mem_interface_top_pattern_compare8 is
00053 port( clk : in ;
00054 rst : in ;
00055 ctrl_rden : in ;
00056 rd_data_rise : in (7 downto 0);
00057 rd_data_fall : in (7 downto 0);
00058 comp_done : out ;
00059 first_rising : out ;
00060 rise_clk_count : out (2 downto 0);
00061 fall_clk_count : out (2 downto 0)
00062 );
00063 end mem_interface_top_pattern_compare8;
00064
00065 architecture arch of mem_interface_top_pattern_compare8 is
00066
00067 constant idle : (1 downto 0) := "00";
00068 constant first_data : (1 downto 0) := "01";
00069 constant comp_over : (1 downto 0) := "11";
00070
00071 signal state_rise : (1 downto 0);
00072 signal state_fall : (1 downto 0);
00073 signal next_state_rise : (1 downto 0);
00074 signal next_state_fall : (1 downto 0);
00075 signal rise_clk_cnt : (2 downto 0);
00076 signal fall_clk_cnt : (2 downto 0);
00077 signal ctrl_rden_r : ;
00078 signal pattern_rise : (7 downto 0);
00079 signal pattern_fall : (7 downto 0);
00080
00081 begin
00082
00083 pattern_rise <= X"AA";
00084 pattern_fall <= X"55";
00085
00086
00087 process(clk)
00088 begin
00089 if(clk'event and clk ='1') then
00090 if(rst = '1') then
00091 state_rise <= idle;
00092 else
00093 state_rise <= next_state_rise;
00094 end if;
00095 end if;
00096 end process;
00097
00098 process(clk)
00099 begin
00100 if(clk'event and clk ='1') then
00101 if(rst = '1') then
00102 state_fall <= idle;
00103 else
00104 state_fall <= next_state_fall;
00105 end if;
00106 end if;
00107 end process;
00108
00109 process(clk)
00110 begin
00111 if(clk'event and clk = '1') then
00112 if(rst = '1') then
00113 ctrl_rden_r <= '0';
00114 else
00115 ctrl_rden_r <= ctrl_rden;
00116 end if;
00117 end if;
00118 end process;
00119
00120 process(clk)
00121 begin
00122 if(clk'event and clk = '1') then
00123 if(rst = '1') then
00124 rise_clk_cnt <= "000";
00125 elsif(state_rise = first_data ) then
00126 rise_clk_cnt <= rise_clk_cnt + '1';
00127 end if;
00128 end if;
00129 end process;
00130
00131 rise_clk_count <= rise_clk_cnt when (state_rise = comp_over) else "000";
00132
00133 comp_done <= '1' when ((state_rise = comp_over) and (state_fall = comp_over)) else '0';
00134
00135 process(clk)
00136 begin
00137 if(clk'event and clk = '1') then
00138 if(rst = '1') then
00139 fall_clk_cnt <= "000";
00140 elsif(state_fall = first_data ) then
00141 fall_clk_cnt <= fall_clk_cnt + '1';
00142 end if;
00143 end if;
00144 end process;
00145
00146 fall_clk_count <= fall_clk_cnt when (state_fall = comp_over) else "000";
00147
00148
00149 process(clk)
00150 begin
00151 if (clk='1' and clk'event) then
00152 if (rst='1') then
00153 first_rising <= '0';
00154 elsif(state_rise = first_data and rd_data_rise = pattern_fall) then
00155 first_rising <= '1';
00156 end if;
00157 end if;
00158 end process;
00159
00160 process(ctrl_rden_r, state_rise, rd_data_rise, pattern_rise, pattern_fall, rst)
00161 begin
00162 if(rst = '1') then
00163 next_state_rise <= idle;
00164 else
00165 case state_rise is
00166 when idle =>
00167 if(ctrl_rden_r = '1') then
00168 next_state_rise <= first_data;
00169 else
00170 next_state_rise <= idle;
00171 end if;
00172
00173 when first_data =>
00174 if((rd_data_rise = pattern_rise) or (rd_data_rise = pattern_fall)) then
00175 next_state_rise <= comp_over;
00176 else
00177 next_state_rise <= first_data;
00178 end if;
00179
00180 when comp_over =>
00181 next_state_rise <= comp_over;
00182
00183 when others =>
00184 next_state_rise <= idle;
00185 end case;
00186 end if;
00187 end process;
00188
00189 process(ctrl_rden_r, state_fall, rd_data_fall, pattern_rise, pattern_fall, rst)
00190 begin
00191 if(rst = '1') then
00192 next_state_fall <= idle;
00193 else
00194 case state_fall is
00195 when idle =>
00196 if(ctrl_rden_r = '1') then
00197 next_state_fall <= first_data;
00198 else
00199 next_state_fall <= idle;
00200 end if;
00201
00202 when first_data =>
00203 if((rd_data_fall = pattern_rise) or (rd_data_fall = pattern_fall)) then
00204 next_state_fall <= comp_over;
00205 else
00206 next_state_fall <= first_data;
00207 end if;
00208
00209
00210 when comp_over =>
00211 next_state_fall <= comp_over;
00212
00213 when others =>
00214 next_state_fall <= idle;
00215 end case;
00216 end if;
00217 end process;
00218
00219
00220 end arch;