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

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_bit_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 control data bit
23
--   Description:
24
--     Delays input data by g_depth. The delay line shifts when in_val is
25
--     indicates an active clock cycle.
26
--   Remark:
27
--   . This common_bit_delay can not use common_delay.vhd because it needs a reset.
28
--   . Typically rst may be left not connected, because the internal power up
29
--     state of the shift_reg is 0.
30
--   . If dynamic restart control is needed then use in_clr for that. Otherwise
31
--     leave in_clr also not connected.
32
--   . For large g_depth Quartus infers a RAM block for this bitDelay even if
33
--     the same signal is applied to both in_bit and in_val. It does not help
34
--     to remove in_clr or to not use shift_reg(0) combinatorially.
35
 
36
library IEEE;
37
use IEEE.std_logic_1164.all;
38
 
39
entity common_bit_delay is
40
  generic (
41
    g_depth : NATURAL := 16 --Quartus infers fifo for 4 to 4096 g_depth, 8 Bits.
42
  );
43
  port (
44
    clk     : in  std_logic;
45
    rst     : in  std_logic := '0';   -- asynchronous reset for initial start
46
    in_clr  : in  std_logic := '0';   -- synchronous reset for control of dynamic restart(s)
47
    in_bit  : in  std_logic;
48
    in_val  : in  std_logic := '1';
49
    out_bit : out std_logic
50
  );
51
end entity common_bit_delay;
52
 
53
architecture rtl of common_bit_delay is
54
 
55
  -- Use index (0) as combinatorial input and index(1:g_depth) for the shift
56
  -- delay, in this way the shift_reg type can support all g_depth >= 0
57
  signal shift_reg : std_logic_vector(0 to g_depth) := (others=>'0');
58
 
59
begin
60
 
61
  shift_reg(0) <= in_bit;
62
 
63
  out_bit <= shift_reg(g_depth);
64
 
65
  gen_reg : if g_depth>0 generate
66
    p_clk : process(clk, rst)
67
    begin
68
      if rst='1' then
69
        shift_reg(1 to g_depth) <= (others=>'0');
70
      elsif rising_edge(clk) then
71
        if in_clr='1' then
72
          shift_reg(1 to g_depth) <= (others=>'0');
73
        elsif in_val='1' then
74
          shift_reg(1 to g_depth) <= shift_reg(0 to g_depth-1);
75
        end if;
76
      end if;
77
    end process;
78
  end generate;
79
 
80
end rtl;

powered by: WebSVN 2.1.0

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