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/eth/eth_buf.vhd,v $ *
00015 --* $Revision: 2.1.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:46 $ *
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 use ieee.numeric_std.all;
00033
00034 library unisim;
00035
00036 use unisim.vcomponents.all;
00037
00038
00039 entity eth_buf is
00040 port (
00041 CLK_WR : in ;
00042 CLK_RD : in ;
00043 RES : in ;
00044 RD : in ;
00045 WR : in ;
00046 DATA_IN : in (127 downto 0);
00047 DATA_OUT : out (7 downto 0)
00048 );
00049 end eth_buf;
00050
00051 architecture eth_buf_arc of eth_buf is
00052
00053 signal a_i : (8 downto 0) := (others => '0');
00054 signal b_i : (4 downto 0) := (others => '0');
00055
00056
00057 component ethbuf
00058 port (
00059 addra : in (8 downto 0);
00060 addrb : in (4 downto 0);
00061 clka : in ;
00062 clkb : in ;
00063 dinb : in (127 downto 0);
00064 douta : out (7 downto 0);
00065 ena : in ;
00066 enb : in ;
00067 web : in );
00068 end component;
00069
00070 begin
00071
00072
00073 wr_addr : process(CLK_WR)
00074 begin
00075 if CLK_WR'event and CLK_WR = '1' then
00076 if RES = '1' then
00077 b_i <= conv_std_logic_vector(12, 5);
00078 else
00079 if WR = '1' then
00080 if b_i = 23 then
00081 b_i <= (others => '0');
00082 else
00083 b_i <= b_i + 1;
00084 end if;
00085 else
00086 b_i <= b_i;
00087 end if;
00088 end if;
00089 end if;
00090 end process wr_addr;
00091
00092
00093 rd_addr : process(CLK_RD)
00094 begin
00095 if CLK_RD'event and CLK_RD = '1' then
00096 if RES = '1' then
00097 a_i <= (others => '0');
00098 else
00099 if RD = '1' then
00100 if a_i = 383 then
00101 a_i <= (others => '0');
00102 else
00103 a_i <= a_i + 1;
00104 end if;
00105 else
00106 a_i <= a_i;
00107 end if;
00108 end if;
00109 end if;
00110 end process rd_addr;
00111
00112 bram_buf : ethbuf
00113 port map (
00114 addra => a_i ,
00115 addrb => b_i ,
00116 clka => CLK_RD,
00117 clkb => CLK_WR,
00118 dinb => DATA_IN,
00119 douta => DATA_OUT,
00120 ena => RD ,
00121 enb => '1' ,
00122 web => WR
00123 );
00124
00125 end eth_buf_arc;
00126