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 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 danv
--------------------------------------------------------------------------------
2
--
3 4 danv
-- Copyright 2020
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 3 danv
--
19
--------------------------------------------------------------------------------
20
 
21
--   Purpose: Shift register for data
22
--   Description:
23
--     Delays input data by g_depth. The delay line shifts when in_val is
24
--     indicates an active clock cycle.
25
 
26
library ieee;
27
use IEEE.STD_LOGIC_1164.all;
28
 
29
entity common_delay is
30
  generic (
31
    g_dat_w    : NATURAL := 8;   -- need g_dat_w to be able to use (others=>'') assignments for two dimensional unconstraint vector arrays
32
    g_depth    : NATURAL := 16
33
  );
34
  port (
35
    clk      : in  STD_LOGIC;
36
    in_val   : in  STD_LOGIC := '1';
37
    in_dat   : in  STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
38
    out_dat  : out STD_LOGIC_VECTOR(g_dat_w-1 downto 0)
39
  );
40
end entity common_delay;
41
 
42
architecture rtl of common_delay is
43
 
44
  -- Use index (0) as combinatorial input and index(1:g_depth) for the shift
45
  -- delay, in this way the t_dly_arr type can support all g_depth >= 0
46
  type t_dly_arr is array (0 to g_depth) of STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
47
 
48
  signal shift_reg : t_dly_arr := (others=>(others=>'0'));
49
 
50
begin
51
 
52
  shift_reg(0) <= in_dat;
53
 
54
  out_dat <= shift_reg(g_depth);
55
 
56
  gen_reg : if g_depth>0 generate
57
    p_clk : process(clk)
58
    begin
59
      if rising_edge(clk) then
60
        if in_val='1' then
61
          shift_reg(1 to g_depth) <= shift_reg(0 to g_depth-1);
62
        end if;
63
      end if;
64
    end process;
65
  end generate;
66
 
67
end rtl;

powered by: WebSVN 2.1.0

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