SURF  1.0
EthMacTxBypass.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : EthMacTxBypass.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-01-04
5 -- Last update: 2016-09-14
6 -------------------------------------------------------------------------------
7 -- Description:
8 -- Mux stage to allow high priority bypass traffic to override primary path
9 -- traffic.
10 -------------------------------------------------------------------------------
11 -- This file is part of 'SLAC Firmware Standard Library'.
12 -- It is subject to the license terms in the LICENSE.txt file found in the
13 -- top-level directory of this distribution and at:
14 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
15 -- No part of 'SLAC Firmware Standard Library', including this file,
16 -- may be copied, modified, propagated, or distributed except according to
17 -- the terms contained in the LICENSE.txt file.
18 -------------------------------------------------------------------------------
19 
20 library ieee;
21 use ieee.std_logic_1164.all;
22 use ieee.std_logic_arith.all;
23 use ieee.std_logic_unsigned.all;
24 
25 use work.AxiStreamPkg.all;
26 use work.StdRtlPkg.all;
27 use work.EthMacPkg.all;
28 
29 --! @see entity
30  --! @ingroup ethernet_EthMacCore
31 entity EthMacTxBypass is
32  generic (
33  TPD_G : time := 1 ns;
34  BYP_EN_G : boolean := false);
35  port (
36  -- Clock and Reset
37  ethClk : in sl;
38  ethRst : in sl;
39  -- Incoming primary traffic
42  -- Incoming bypass traffic
45  -- Outgoing data to MAC
48 end EthMacTxBypass;
49 
50 architecture rtl of EthMacTxBypass is
51 
52  type StateType is (
53  IDLE_S,
54  PRIM_S,
55  BYP_S);
56 
57  type RegType is record
61  state : StateType;
62  end record RegType;
63 
64  constant REG_INIT_C : RegType := (
68  state => IDLE_S);
69 
70  signal r : RegType := REG_INIT_C;
71  signal rin : RegType;
72 
73  -- attribute dont_touch : string;
74  -- attribute dont_touch of r : signal is "true";
75 
76 begin
77 
78  U_BypTxEnGen : if (BYP_EN_G = true) generate
79 
80  comb : process (ethRst, mAxisSlave, r, sBypMaster, sPrimMaster) is
81  variable v : RegType;
82  begin
83  -- Latch the current value
84  v := r;
85 
86  -- Clear tValid on ready assertion
87  if mAxisSlave.tReady = '1' then
88  v.mAxisMaster.tValid := '0';
89  end if;
90 
91  -- Clear ready
92  v.sPrimSlave.tReady := '0';
93  v.sBypSlave.tReady := '0';
94 
95  -- State Machine
96  case r.state is
97  ----------------------------------------------------------------------
98  when IDLE_S =>
99  -- Check if ready to move data
100  if v.mAxisMaster.tValid = '0' then
101  -- Check for Bypass frame request
102  if (sBypMaster.tValid = '1') then
103  -- Accept the data
104  v.sBypSlave.tReady := '1';
105  -- Move data
106  v.mAxisMaster := sBypMaster;
107  -- Check for no EOF
108  if sBypMaster.tLast = '0' then
109  -- Next state
110  v.state := BYP_S;
111  end if;
112  -- Check for Primary frame request
113  elsif (sPrimMaster.tValid = '1') then
114  -- Accept the data
115  v.sPrimSlave.tReady := '1';
116  -- Move data
118  -- Check for no EOF
119  if sPrimMaster.tLast = '0' then
120  -- Next state
121  v.state := PRIM_S;
122  end if;
123  end if;
124  end if;
125  ----------------------------------------------------------------------
126  when PRIM_S =>
127  -- Check if ready to move data
128  if (v.mAxisMaster.tValid = '0') and (sPrimMaster.tValid = '1') then
129  -- Accept the data
130  v.sPrimSlave.tReady := '1';
131  -- Move the data
133  -- Check for EOF
134  if (sPrimMaster.tLast = '1') then
135  -- Next state
136  v.state := IDLE_S;
137  end if;
138  end if;
139  ----------------------------------------------------------------------
140  when BYP_S =>
141  -- Check if ready to move data
142  if (v.mAxisMaster.tValid = '0') and (sBypMaster.tValid = '1') then
143  -- Accept the data
144  v.sBypSlave.tReady := '1';
145  -- Move the data
146  v.mAxisMaster := sBypMaster;
147  -- Check for EOF
148  if (sBypMaster.tLast = '1') then
149  -- Next state
150  v.state := IDLE_S;
151  end if;
152  end if;
153  ----------------------------------------------------------------------
154  end case;
155 
156  -- Reset
157  if ethRst = '1' then
158  v := REG_INIT_C;
159  end if;
160 
161  -- Register the variable for next clock cycle
162  rin <= v;
163 
164  -- Outputs
165  sPrimSlave <= v.sPrimSlave;
166  sBypSlave <= v.sBypSlave;
168 
169  end process;
170 
171  seq : process (ethClk) is
172  begin
173  if rising_edge(ethClk) then
174  r <= rin after TPD_G;
175  end if;
176  end process seq;
177 
178  end generate;
179 
180  U_BypTxDisGen : if (BYP_EN_G = false) generate
184  end generate;
185 
186 end rtl;
in sBypMasterAxiStreamMasterType
std_logic sl
Definition: StdRtlPkg.vhd:28
AxiStreamMasterType :=(tValid => '0',tData =>( others => '0'),tStrb =>( others => '1'),tKeep =>( others => '1'),tLast => '0',tDest =>( others => '0'),tId =>( others => '0'),tUser =>( others => '0')) AXI_STREAM_MASTER_INIT_C
in sPrimMasterAxiStreamMasterType
TPD_Gtime := 1 ns
_library_ ieeeieee
Definition: EthMacTx.vhd:18
out mAxisMasterAxiStreamMasterType
BYP_EN_Gboolean := false
AxiStreamSlaveType :=(tReady => '0') AXI_STREAM_SLAVE_INIT_C
in mAxisSlaveAxiStreamSlaveType
out sPrimSlaveAxiStreamSlaveType
AxiStreamSlaveType :=(tReady => '1') AXI_STREAM_SLAVE_FORCE_C
out sBypSlaveAxiStreamSlaveType