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/rod/bcm_rod_ram.vhd,v $ *
00015 --* $Revision: 1.10.2.4 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:48 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024 library ieee;
00025
00026 use ieee.std_logic_1164.all;
00027
00028 use ieee.std_logic_arith.all;
00029
00030 use ieee.std_logic_unsigned.all;
00031
00032
00033
00034 entity bcm_rod_ram is
00035 port (
00036 CLK : in ;
00037 CLK_2X : in ;
00038 SCLR : in ;
00039 data_input : in (31 downto 0);
00040 data_input_valid : in ;
00041 data_input_endoffrag : in ;
00042 stop : in ;
00043 data_output_next : in ;
00044 data_output : out (31 downto 0);
00045 data_output_vld : out ;
00046 data_output_available : out ;
00047 data_output_endoffrag : out ;
00048 busy : out ;
00049 write_error : out ;
00050 read_error : out
00051 );
00052 end bcm_rod_ram;
00053
00054
00055 architecture bcm_rod_ram_arc of bcm_rod_ram is
00056
00057
00058 component bcm_rod_dp_ram
00059 port (
00060 addra : in (8 downto 0);
00061 addrb : in (8 downto 0);
00062 clka : in ;
00063 clkb : in ;
00064 dina : in (32 downto 0);
00065 doutb : out (32 downto 0);
00066 ena : in ;
00067 enb : in ;
00068 wea : in
00069 );
00070 end component;
00071
00072
00073 component bcm_rod_dp_updown_counter
00074 port (
00075 CLK : in ;
00076 CLK_2X : in ;
00077 SCLR : in ;
00078 count_up : in ;
00079 count_down : in ;
00080 busy : out ;
00081 data_available : out ;
00082 write_error : out ;
00083 read_error : out
00084 );
00085 end component;
00086
00087 signal input_counter : (8 downto 0) := (others => '0');
00088 signal output_counter : (8 downto 0) := (others => '0');
00089 signal internal_input : (32 downto 0) := (others => '0');
00090 signal internal_output : (32 downto 0) := (others => '0');
00091 signal rd_en : := '0';
00092 signal rd_vld : := '0';
00093
00094 begin
00095
00096
00097 dp_ram : bcm_rod_dp_ram
00098 port map (
00099 addra => input_counter,
00100 addrb => output_counter,
00101 clka => CLK_2X,
00102 clkb => CLK ,
00103 dina => internal_input,
00104 doutb => internal_output,
00105 ena => '1' ,
00106 enb => rd_en,
00107 wea => data_input_valid
00108 );
00109
00110
00111 fill_counter : bcm_rod_dp_updown_counter
00112 port map(
00113 -- clocks and synchronus reset
00114 CLK => CLK,
00115 CLK_2X => CLK_2X,
00116 SCLR => SCLR,
00117 -- up/down flags
00118 count_up => data_input_valid ,
00119 count_down => data_output_next ,
00120 busy => busy,
00121 data_available => data_output_available,
00122 write_error => write_error,
00123 read_error => read_error
00124 );
00125
00126 data_output_vld <= rd_en when rising_edge(CLK);
00127 internal_input <= data_input_endoffrag & data_input;
00128 rd_en <= data_output_next;
00129 data_output <= internal_output(31 downto 0) when rd_vld = '1' else (others => '0');
00130 data_output_endoffrag <= internal_output(32) when rd_vld = '1' else '0';
00131 rd_vld <= rd_en when rising_edge(CLK);
00132
00133
00134 ram_input_address : process(CLK_2X, SCLR)
00135 begin
00136 if SCLR = '1' then
00137 input_counter <= (others => '0');
00138 else
00139 if CLK_2X'event and CLK_2X = '1' then
00140 if data_input_valid = '1' then
00141 input_counter <= (input_counter + "01");
00142 end if;
00143 end if;
00144 end if;
00145 end process ram_input_address;
00146
00147
00148 ram_output_address : process(CLK, SCLR)
00149 begin
00150 if SCLR = '1' then
00151 output_counter <= (others => '0');
00152 else
00153 if CLK'event and CLK = '1' then
00154 if data_output_next = '1' then
00155 output_counter <= (output_counter + "01");
00156 end if;
00157 end if;
00158 end if;
00159 end process ram_output_address;
00160
00161 end bcm_rod_ram_arc;
00162