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

Subversion Repositories udp_ipv4_for_10g_ethernet

[/] [udp_ipv4_for_10g_ethernet/] [trunk/] [src/] [hdl/] [frame_throttle.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 DFC
-------------------------------------------------------------------------------
2
--
3
-- (C) Copyright 2017 DFC Design, s.r.o., Brno, Czech Republic
4
-- Author: Marek Kvas (m.kvas@dfcdesign.cz)
5
--
6
-------------------------------------------------------------------------------
7
-- This file is part of UDP/IPv4 for 10 G Ethernet core.
8
-- 
9
-- UDP/IPv4 for 10 G Ethernet core is free software: you can 
10
-- redistribute it and/or modify it under the terms of 
11
-- the GNU Lesser General Public License as published by the Free 
12
-- Software Foundation, either version 3 of the License, or
13
-- (at your option) any later version.
14
-- 
15
-- UDP/IPv4 for 10 G Ethernet core is distributed in the hope that 
16
-- it will be useful, but WITHOUT ANY WARRANTY; without even 
17
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A 
18
-- PARTICULAR PURPOSE.  See the GNU Lesser General Public License 
19
-- for more details.
20
-- 
21
-- You should have received a copy of the GNU Lesser General Public 
22
-- License along with UDP/IPv4 for 10 G Ethernet core.  If not, 
23
-- see <http://www.gnu.org/licenses/>.
24
-------------------------------------------------------------------------------
25
--
26
-- This simple core is used to slow transmission of frames down when
27
-- link speed is lower than maximum 10 Gbps. AS RXAUI runs on the same
28
-- frequency regardless of link speed and data are stored in the PHY FIFO
29
-- it is necessary to insert such IFG that average speed is equal to
30
-- link speed. Otherwise PHY FIFO overflows and frames get corrupted.
31
--
32
-- Output is combinatorial.
33
--
34
-------------------------------------------------------------------------------
35
 
36
library ieee;
37
use ieee.std_logic_1164.all;
38
use ieee.numeric_std.all;
39
 
40
 
41
entity frame_throttle is
42
   port (
43
      CLK            : in  std_logic;
44
 
45
      LINK_SPEED     : in  std_logic_vector(2 downto 0);
46
 
47
      FG_BUSY        : in  std_logic;
48
      FG_IDLE_IFG    : in  std_logic;
49
      BUSY_THROTTLED : out std_logic
50
        );
51
end entity;
52
 
53
 
54
 
55
architecture synthesis of frame_throttle is
56
 
57
   function spd_to_ratio_cnt(spd : std_logic_vector) return natural is
58
      variable ratio : natural;
59
   begin
60
      case to_integer(unsigned(spd)) is
61
         -- 10 Gbps must be handled differently
62
         when 1 => ratio := 2; -- 5 Gbps
63
         when 2 => ratio := 4; -- 2.5 Gbps
64
         when 3 => ratio := 10; -- 1 Gbps
65
         when 4 => ratio := 100; -- 100 Mbps
66
         when others => ratio := 1000; -- 10 Mbps and unsupported link speds
67
      end case;
68
      return ratio;
69
   end function;
70
 
71
   signal busy_throttle_i     : std_logic;
72
   signal throttle_cnt        : integer range 0 to 2**16-1;
73
   signal ratio_cnt           : integer range 0 to 1000 -1;
74
 
75
 
76
begin
77
 
78
   throttle_proc : process(CLK)
79
   begin
80
      if rising_edge(CLK) then
81
         if LINK_SPEED = "000" then
82
            -- 10 Gbps - maximal speed
83
            busy_throttle_i <= '0';
84
         elsif FG_BUSY = '1' or FG_IDLE_IFG = '1' then
85
            busy_throttle_i <= '1';
86
            throttle_cnt <= throttle_cnt + 1;
87
            ratio_cnt <= 0;
88
         else
89
            -- -1 for one cycle spent in cycle counting and
90
            -- -1 for counter limit as usual forms -2 altogether.
91
            if ratio_cnt < spd_to_ratio_cnt(LINK_SPEED) - 2 then
92
               ratio_cnt <= ratio_cnt + 1;
93
            else
94
               ratio_cnt <= 0;
95
               if throttle_cnt > 1 then
96
                  throttle_cnt <= throttle_cnt - 1;
97
               else
98
                  busy_throttle_i <= '0';
99
               end if;
100
            end if;
101
         end if;
102
      end if;
103
   end process;
104
 
105
 
106
   BUSY_THROTTLED <= FG_BUSY or busy_throttle_i;
107
 
108
end architecture;
109
 
110
 
111
 
112
 
113
 
114
 
115
 

powered by: WebSVN 2.1.0

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