SURF  1.0
EthMacFlowCtrl.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : EthMacFlowCtrl.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-09-21
5 -- Last update: 2016-10-20
6 -------------------------------------------------------------------------------
7 -- Description: ETH MAC Flow Control Module
8 -------------------------------------------------------------------------------
9 -- This file is part of 'SLAC Firmware Standard Library'.
10 -- It is subject to the license terms in the LICENSE.txt file found in the
11 -- top-level directory of this distribution and at:
12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
13 -- No part of 'SLAC Firmware Standard Library', including this file,
14 -- may be copied, modified, propagated, or distributed except according to
15 -- the terms contained in the LICENSE.txt file.
16 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.std_logic_arith.all;
21 use ieee.std_logic_unsigned.all;
22 
23 use work.StdRtlPkg.all;
24 use work.AxiStreamPkg.all;
25 
26 --! @see entity
27  --! @ingroup ethernet_EthMacCore
28 entity EthMacFlowCtrl is
29  generic (
30  TPD_G : time := 1 ns;
31  BYP_EN_G : boolean := false;
32  VLAN_EN_G : boolean := false;
33  VLAN_SIZE_G : positive range 1 to 8 := 1);
34  port (
35  -- Clock and Reset
36  ethClk : in sl;
37  ethRst : in sl;
38  -- Inputs
42  -- Output
44 end EthMacFlowCtrl;
45 
46 architecture rtl of EthMacFlowCtrl is
47 
48  type RegType is record
50  end record RegType;
51  constant REG_INIT_C : RegType := (
53 
54  signal r : RegType := REG_INIT_C;
55  signal rin : RegType;
56 
57 -- attribute dont_touch : string;
58 -- attribute dont_touch of r : signal is "TRUE";
59 
60 begin
61 
62  comb : process (bypCtrl, ethRst, primCtrl, r, vlanCtrl) is
63  variable v : RegType;
64  variable i : natural;
65  begin
66  -- Latch the current value
67  v := r;
68 
69  -- Sample the primary interface flow control
72  v.flowCtrl.idle := '0'; -- Unused
73 
74  -- Check if bypass interface is enabled
75  if (BYP_EN_G) then
76  -- Sample the bypass pause
77  if (bypCtrl.pause = '1') then
78  v.flowCtrl.pause := '1';
79  end if;
80  -- Sample the bypass overflow
81  if (bypCtrl.overflow = '1') then
82  v.flowCtrl.overflow := '1';
83  end if;
84  end if;
85 
86  -- Check if VLAN interface is enabled
87  if (VLAN_EN_G) then
88  -- Loop through the channels
89  for i in (VLAN_SIZE_G-1) downto 0 loop
90  -- Sample the VLAN pause
91  if (vlanCtrl(i).pause = '1') then
92  v.flowCtrl.pause := '1';
93  end if;
94  -- Sample the VLAN overflow
95  if (vlanCtrl(i).overflow = '1') then
96  v.flowCtrl.overflow := '1';
97  end if;
98  end loop;
99  end if;
100 
101  -- Reset
102  if (ethRst = '1') then
103  v := REG_INIT_C;
104  end if;
105 
106  -- Register the variable for next clock cycle
107  rin <= v;
108 
109  -- Outputs
110  flowCtrl <= r.flowCtrl;
111 
112  end process comb;
113 
114  seq : process (ethClk) is
115  begin
116  if rising_edge(ethClk) then
117  r <= rin after TPD_G;
118  end if;
119  end process seq;
120 
121 end rtl;
std_logic sl
Definition: StdRtlPkg.vhd:28
VLAN_EN_Gboolean := false
_library_ ieeeieee
VLAN_SIZE_Gpositive range 1 to 8:= 1
TPD_Gtime := 1 ns
AxiStreamCtrlType :=(pause => '1',overflow => '0',idle => '0') AXI_STREAM_CTRL_INIT_C
in vlanCtrlAxiStreamCtrlArray( VLAN_SIZE_G- 1 downto 0)
array(natural range <> ) of AxiStreamCtrlType AxiStreamCtrlArray
in bypCtrlAxiStreamCtrlType
BYP_EN_Gboolean := false
in primCtrlAxiStreamCtrlType
out flowCtrlAxiStreamCtrlType