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

Subversion Repositories dp_components

[/] [dp_components/] [trunk/] [dp_latency_increase.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright (C) 2010
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/>
6
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
7
--
8
-- This program 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
 
23
LIBRARY IEEE, common_pkg_lib, dp_pkg_lib;
24
USE IEEE.std_logic_1164.ALL;
25
USE IEEE.numeric_std.ALL;
26
USE common_pkg_lib.common_pkg.ALL;
27
USE dp_pkg_lib.dp_stream_pkg.ALL;
28
 
29
-- Purpose:
30
--   Typically used in dp_latency_adapter.
31
-- Description:
32
--   Increase the output ready latency by g_incr_latency compared to the input
33
--   ready latency g_in_latency. Hence the output latency becomes g_in_latency
34
--   + g_incr_latency.
35
-- Remark:
36
-- . The SOSI data stream signals (i.e. data, empty, channel, err) are passed
37
--   on as wires.
38
-- . The out_sync, out_val, out_sop and out_eop are internally AND with the
39
--   delayed src_in.ready, this is only truely necessary if the input ready
40
--   latency is 0, but it does not harm to do it also when the input ready
41
--   latency > 0. However to easy achieving P&R timing it is better to not have
42
--   unnessary logic in the combinatorial path of out_sync, out_val, out_sop
43
--   and out_eop, therefore the AND with reg_val is only generated when
44
--   g_in_latency=0.
45
 
46
ENTITY dp_latency_increase IS
47
  GENERIC (
48
    g_in_latency   : NATURAL := 0;  -- >= 0
49
    g_incr_latency : NATURAL := 2   -- >= 0
50
  );
51
  PORT (
52
    rst          : IN  STD_LOGIC;
53
    clk          : IN  STD_LOGIC;
54
    -- ST sink
55
    snk_out      : OUT t_dp_siso;
56
    snk_in       : IN  t_dp_sosi;
57
    -- ST source
58
    src_in       : IN  t_dp_siso;
59
    src_out      : OUT t_dp_sosi
60
  );
61
END dp_latency_increase;
62
 
63
 
64
ARCHITECTURE rtl OF dp_latency_increase IS
65
 
66
  CONSTANT c_out_latency : NATURAL := g_in_latency + g_incr_latency;
67
 
68
  SIGNAL reg_ready : STD_LOGIC_VECTOR(c_out_latency DOWNTO 0);
69
  SIGNAL reg_val   : STD_LOGIC;
70
 
71
  SIGNAL i_snk_out : t_dp_siso := c_dp_siso_rdy;
72
 
73
BEGIN
74
 
75
  -- Use i_snk_out with defaults to force unused snk_out bits and fields to '0'
76
  snk_out <= i_snk_out;
77
 
78
  -- Support wires only for g_incr_latency=0
79
  no_latency : IF g_incr_latency=0 GENERATE
80
    i_snk_out <= src_in;  -- SISO
81
    src_out   <= snk_in;  -- SOSI
82
  END GENERATE no_latency;
83
 
84
  gen_latency : IF g_incr_latency>0 GENERATE
85
    -- SISO
86
    reg_ready(0) <= src_in.ready;  -- use reg_ready(0) to combinatorially store src_in.ready
87
    p_clk : PROCESS(rst, clk)
88
    BEGIN
89
      IF rst='1' THEN
90
        reg_ready(c_out_latency DOWNTO 1) <= (OTHERS=>'0');
91
      ELSIF rising_edge(clk) THEN
92
        reg_ready(c_out_latency DOWNTO 1) <= reg_ready(c_out_latency-1 DOWNTO 0);
93
      END IF;
94
    END PROCESS;
95
 
96
    i_snk_out.xon   <= src_in.xon;                 -- Pass on frame level flow control
97
    i_snk_out.ready <= reg_ready(g_incr_latency);  -- Adjust ready latency
98
 
99
    -- SOSI
100
    gen_out : IF g_in_latency/=0 GENERATE
101
      src_out <= snk_in;
102
    END GENERATE;
103
    gen_zero_out : IF g_in_latency=0 GENERATE
104
      reg_val <= reg_ready(c_out_latency);
105
 
106
      p_src_out : PROCESS(snk_in, reg_val)
107
      BEGIN
108
        src_out       <= snk_in;
109
        src_out.sync  <= snk_in.sync  AND reg_val;
110
        src_out.valid <= snk_in.valid AND reg_val;
111
        src_out.sop   <= snk_in.sop   AND reg_val;
112
        src_out.eop   <= snk_in.eop   AND reg_val;
113
      END PROCESS;
114
    END GENERATE;
115
  END GENERATE gen_latency;
116
 
117
END rtl;

powered by: WebSVN 2.1.0

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