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

Subversion Repositories dp_components

[/] [dp_components/] [trunk/] [dp_xonoff.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
--
3
-- Copyright (C) 2013
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
-- This program is free software: you can redistribute it and/or modify
8
-- it under the terms of the GNU General Public License as published by
9
-- the Free Software Foundation, either version 3 of the License, or
10
-- (at your option) any later version.
11
--
12
-- This program is distributed in the hope that it will be useful,
13
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-- GNU General Public License for more details.
16
--
17
-- You should have received a copy of the GNU General Public License
18
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
-------------------------------------------------------------------------------
21
 
22
-- Purpose: Add flow XON-XOFF control by flushing frames
23
-- Description:
24
-- . The in_siso.ready = out_siso.ready so passed on unchanged, to support
25
--   detailed output to input flow control per cycle. The in_siso.xon is
26
--   always '1', because the out_siso.xon is taken care of in this
27
--   dp_xonoff.vhd by flushing any in_sosi data when out_siso.xon = '0'.
28
--
29
-- . When g_bypass=TRUE then the in and out are wired and the component is void.
30
-- . When g_bypass=FALSE then:
31
--     The output is ON when flush='0'.
32
--     The output is OFF when flush='1'.
33
--     The transition from OFF to ON occurs after an in_sosi.eop so between frames
34
--     The transition from ON to OFF occurs after an in_sosi.eop so between frames
35
--     Thanks to frm_busy it is also possible to switch between frames, so it
36
--     is not necessary that first an eop occurs, before the xon can change. 
37
--     The possibility to switch xon at an eop is needed to be able to switch
38
--     xon in case there are no gaps between the frames.
39
-- . The primary control is via out_siso.xon, however there is an option to override
40
--   the out_siso.xon control and force the output to off by using force_xoff.
41
-- Remark:
42
-- . The output controls are not registered.
43
-- . The xon timing is not cycle critical therefor register flush to ease
44
--   timing closure
45
-- . Originally based on rad_frame_onoff from LOFAR RSP firmware
46
 
47
LIBRARY IEEE, dp_pkg_lib;
48
USE IEEE.std_logic_1164.ALL;
49
USE dp_pkg_lib.dp_stream_pkg.ALL;
50
 
51
ENTITY dp_xonoff IS
52
  GENERIC (
53
    g_bypass : BOOLEAN := FALSE
54
  );
55
  PORT (
56
    rst           : IN  STD_LOGIC;
57
    clk           : IN  STD_LOGIC;
58
    -- Frame in
59
    in_siso       : OUT t_dp_siso;
60
    in_sosi       : IN  t_dp_sosi;
61
    -- Frame out
62
    out_siso      : IN  t_dp_siso;  -- flush control via out_siso.xon
63
    out_sosi      : OUT t_dp_sosi;
64
    -- Optional override to force XOFF ('1' = enable override)
65
    force_xoff    : IN  STD_LOGIC := '0'
66
  );
67
END dp_xonoff;
68
 
69
 
70
ARCHITECTURE rtl OF dp_xonoff IS
71
 
72
  SIGNAL frm_busy     : STD_LOGIC;
73
  SIGNAL frm_busy_reg : STD_LOGIC;
74
 
75
  SIGNAL flush      : STD_LOGIC;
76
  SIGNAL nxt_flush  : STD_LOGIC;
77
 
78
  SIGNAL out_en     : STD_LOGIC;
79
  SIGNAL nxt_out_en : STD_LOGIC;
80
 
81
BEGIN
82
 
83
  gen_bypass : IF g_bypass=TRUE GENERATE
84
    in_siso  <= out_siso;
85
    out_sosi <= in_sosi;
86
  END GENERATE;
87
 
88
  no_bypass : IF g_bypass=FALSE GENERATE
89
    in_siso.ready <= out_siso.ready;  -- pass on ready for detailed flow control per cycle
90
    in_siso.xon <= '1';               -- upstream can remain on, because flush will handle out_siso.xon
91
    nxt_flush <= NOT out_siso.xon OR force_xoff; -- use xon for flow control at frame level
92
 
93
    p_clk: PROCESS(clk, rst)
94
    BEGIN
95
      IF rst='1' THEN
96
        frm_busy_reg <= '0';
97
        flush        <= '0';
98
        out_en       <= '1';
99
      ELSIF rising_edge(clk) THEN
100
        frm_busy_reg <= frm_busy;
101
        flush        <= nxt_flush;     -- pipeline register flush to ease timing closure
102
        out_en       <= nxt_out_en;    -- state register out_en because it can only change between frames
103
      END IF;
104
    END PROCESS;
105
 
106
    -- Detect in_sosi frame busy, frm_busy is '1' from sop including sop, until eop excluding eop
107
    p_frm_busy : PROCESS(in_sosi, in_sosi, frm_busy_reg)
108
    BEGIN
109
      frm_busy <= frm_busy_reg;
110
      IF in_sosi.sop='1' THEN
111
        frm_busy <= '1';
112
      ELSIF in_sosi.eop='1' THEN
113
        frm_busy <= '0';
114
      END IF;
115
    END PROCESS;
116
 
117
    p_out_en : PROCESS(flush, out_en, frm_busy)
118
    BEGIN
119
      nxt_out_en <= out_en;
120
      IF frm_busy='0' THEN
121
        IF flush='1' THEN
122
          nxt_out_en <= '0';
123
        ELSE
124
          nxt_out_en <= '1';
125
        END IF;
126
      END IF;
127
    END PROCESS;
128
 
129
    p_out_sosi : PROCESS(in_sosi, out_en)
130
    BEGIN
131
      -- Pass on sosi data via wires
132
      out_sosi       <= in_sosi;
133
 
134
      -- XON/XOFF flow control via sosi control
135
      out_sosi.sync  <= in_sosi.sync  AND out_en;
136
      out_sosi.valid <= in_sosi.valid AND out_en;
137
      out_sosi.sop   <= in_sosi.sop   AND out_en;
138
      out_sosi.eop   <= in_sosi.eop   AND out_en;
139
    END PROCESS;
140
  END GENERATE;
141
 
142
END ARCHITECTURE;

powered by: WebSVN 2.1.0

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