OpenCores
URL https://opencores.org/ocsvn/common_components/common_components/trunk

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_delay.vhd] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 danv
--------------------------------------------------------------------------------
2
--   Author: Raj Thilak Rajan : rajan at astron.nl: Nov 2009
3
--   Copyright (C) 2009-2010
4
--   ASTRON (Netherlands Institute for Radio Astronomy)
5
--   P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
--   This file is part of the UniBoard software suite.
8
--   The file is free software: you can redistribute it and/or modify
9
--   it under the terms of the GNU General Public License as published by
10
--   the Free Software Foundation, either version 3 of the License, or
11
--   (at your option) any later version.
12
--
13
--   This program is distributed in the hope that it will be useful,
14
--   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
--   GNU General Public License for more details.
17
--
18
--   You should have received a copy of the GNU General Public License
19
--   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
--------------------------------------------------------------------------------
21
 
22
--   Purpose: Shift register for data
23
--   Description:
24
--     Delays input data by g_depth. The delay line shifts when in_val is
25
--     indicates an active clock cycle.
26
 
27
library ieee;
28
use IEEE.STD_LOGIC_1164.all;
29
 
30
entity common_delay is
31
  generic (
32
    g_dat_w    : NATURAL := 8;   -- need g_dat_w to be able to use (others=>'') assignments for two dimensional unconstraint vector arrays
33
    g_depth    : NATURAL := 16
34
  );
35
  port (
36
    clk      : in  STD_LOGIC;
37
    in_val   : in  STD_LOGIC := '1';
38
    in_dat   : in  STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
39
    out_dat  : out STD_LOGIC_VECTOR(g_dat_w-1 downto 0)
40
  );
41
end entity common_delay;
42
 
43
architecture rtl of common_delay is
44
 
45
  -- Use index (0) as combinatorial input and index(1:g_depth) for the shift
46
  -- delay, in this way the t_dly_arr type can support all g_depth >= 0
47
  type t_dly_arr is array (0 to g_depth) of STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
48
 
49
  signal shift_reg : t_dly_arr := (others=>(others=>'0'));
50
 
51
begin
52
 
53
  shift_reg(0) <= in_dat;
54
 
55
  out_dat <= shift_reg(g_depth);
56
 
57
  gen_reg : if g_depth>0 generate
58
    p_clk : process(clk)
59
    begin
60
      if rising_edge(clk) then
61
        if in_val='1' then
62
          shift_reg(1 to g_depth) <= shift_reg(0 to g_depth-1);
63
        end if;
64
      end if;
65
    end process;
66
  end generate;
67
 
68
end rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.