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

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_delay.vhd] - Diff between revs 3 and 4

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 4
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--   Author: Raj Thilak Rajan : rajan at astron.nl: Nov 2009
--
--   Copyright (C) 2009-2010
-- Copyright 2020
--   ASTRON (Netherlands Institute for Radio Astronomy)
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
--   P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
--   P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
--
--
--   This file is part of the UniBoard software suite.
-- Licensed under the Apache License, Version 2.0 (the "License");
--   The file is free software: you can redistribute it and/or modify
-- you may not use this file except in compliance with the License.
--   it under the terms of the GNU General Public License as published by
-- You may obtain a copy of the License at
--   the Free Software Foundation, either version 3 of the License, or
-- 
--   (at your option) any later version.
--     http://www.apache.org/licenses/LICENSE-2.0
--
--
--   This program is distributed in the hope that it will be useful,
-- Unless required by applicable law or agreed to in writing, software
--   but WITHOUT ANY WARRANTY; without even the implied warranty of
-- distributed under the License is distributed on an "AS IS" BASIS,
--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--   GNU General Public License for more details.
-- See the License for the specific language governing permissions and
 
-- limitations under the License.
--
--
--   You should have received a copy of the GNU General Public License
 
--   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
 
 
--   Purpose: Shift register for data
--   Purpose: Shift register for data
--   Description:
--   Description:
--     Delays input data by g_depth. The delay line shifts when in_val is
--     Delays input data by g_depth. The delay line shifts when in_val is
--     indicates an active clock cycle.
--     indicates an active clock cycle.
 
 
library ieee;
library ieee;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_1164.all;
 
 
entity common_delay is
entity common_delay is
  generic (
  generic (
    g_dat_w    : NATURAL := 8;   -- need g_dat_w to be able to use (others=>'') assignments for two dimensional unconstraint vector arrays
    g_dat_w    : NATURAL := 8;   -- need g_dat_w to be able to use (others=>'') assignments for two dimensional unconstraint vector arrays
    g_depth    : NATURAL := 16
    g_depth    : NATURAL := 16
  );
  );
  port (
  port (
    clk      : in  STD_LOGIC;
    clk      : in  STD_LOGIC;
    in_val   : in  STD_LOGIC := '1';
    in_val   : in  STD_LOGIC := '1';
    in_dat   : in  STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
    in_dat   : in  STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
    out_dat  : out STD_LOGIC_VECTOR(g_dat_w-1 downto 0)
    out_dat  : out STD_LOGIC_VECTOR(g_dat_w-1 downto 0)
  );
  );
end entity common_delay;
end entity common_delay;
 
 
architecture rtl of common_delay is
architecture rtl of common_delay is
 
 
  -- Use index (0) as combinatorial input and index(1:g_depth) for the shift
  -- Use index (0) as combinatorial input and index(1:g_depth) for the shift
  -- delay, in this way the t_dly_arr type can support all g_depth >= 0
  -- delay, in this way the t_dly_arr type can support all g_depth >= 0
  type t_dly_arr is array (0 to g_depth) of STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
  type t_dly_arr is array (0 to g_depth) of STD_LOGIC_VECTOR(g_dat_w-1 downto 0);
 
 
  signal shift_reg : t_dly_arr := (others=>(others=>'0'));
  signal shift_reg : t_dly_arr := (others=>(others=>'0'));
 
 
begin
begin
 
 
  shift_reg(0) <= in_dat;
  shift_reg(0) <= in_dat;
 
 
  out_dat <= shift_reg(g_depth);
  out_dat <= shift_reg(g_depth);
 
 
  gen_reg : if g_depth>0 generate
  gen_reg : if g_depth>0 generate
    p_clk : process(clk)
    p_clk : process(clk)
    begin
    begin
      if rising_edge(clk) then
      if rising_edge(clk) then
        if in_val='1' then
        if in_val='1' then
          shift_reg(1 to g_depth) <= shift_reg(0 to g_depth-1);
          shift_reg(1 to g_depth) <= shift_reg(0 to g_depth-1);
        end if;
        end if;
      end if;
      end if;
    end process;
    end process;
  end generate;
  end generate;
 
 
end rtl;
end rtl;
 
 

powered by: WebSVN 2.1.0

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