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/div/Attic/generic_shift_reg.vhd,v $
00015 --* $Revision: 1.1.2.5 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:45 $ *
00019
00020
00021
00022 --* *
00023 --**************************************************************
00024
00025 library ieee;
00026
00027 use ieee.std_logic_1164.all;
00028
00029
00030
00031 entity generic_shift_reg is
00032
00033 generic (
00034 WIDTH : positive range 1 to 255 := 1;
00035 DEPTH : positive range 1 to 255 := 1
00036 );
00037 port (
00038 CLK : in ;
00039 RES : in ;
00040 DIN : in (WIDTH-1 downto 0);
00041 DOUT : out (WIDTH-1 downto 0)
00042 );
00043
00044 end generic_shift_reg;
00045
00046
00047
00048 architecture generic_shift_reg_arc of generic_shift_reg is
00049
00050
00051 type reg_arr is array (WIDTH-1 downto 0) of (DEPTH-1 downto 0);
00052 signal sreg : reg_arr := (others => (others => '0'));
00053 signal tmp : (DEPTH-1 downto 0) := (others => '0');
00054
00055 begin -- generic_shift_reg_arc
00056
00057 shift_reg_bank : for I in WIDTH-1 downto 0 generate
00058
00059 DOUT(I) <= tmp(DEPTH-1);
00060 tmp <= sreg(I);
00061
00062 -- purpose: shift register
00063 -- type : sequential
00064 -- inputs : CLK, RES, DIN
00065 -- outputs: sreg(I,DEPTH-1)
00066 shift_reg : process (CLK, RES)
00067 variable regvar : (DEPTH-1 downto 0) := (others => '0');
00068 begin -- process shift_reg
00069 if RES = '1' then -- asynchronous reset (active high)
00070 sreg(I) <= (others => '0');
00071 regvar := (others => '0');
00072 elsif CLK'event and CLK = '1' then -- rising clock edge
00073 regvar := regvar(DEPTH-2 downto 0) & DIN(I);
00074 sreg(I) <= regvar;
00075 end if;
00076 end process shift_reg;
00077
00078 end generate shift_reg_bank;
00079
00080 end generic_shift_reg_arc;