SURF
1.0
EthMacRxFilter.vhd
Go to the documentation of this file.
1
-------------------------------------------------------------------------------
2
-- File : EthMacRxFilter.vhd
3
-- Company : SLAC National Accelerator Laboratory
4
-- Created : 2015-09-21
5
-- Last update: 2016-09-14
6
-------------------------------------------------------------------------------
7
-- Description: Ethernet MAC's RX frame filter
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.
AxiStreamPkg
.
all
;
24
use
work.
StdRtlPkg
.
all
;
25
use
work.
EthMacPkg
.
all
;
26
27
--! @see entity
28
--! @ingroup ethernet_EthMacCore
29
entity
EthMacRxFilter
is
30
generic
(
31
TPD_G
:
time
:=
1
ns
;
32
FILT_EN_G
:
boolean
:=
false
)
;
33
port
(
34
-- Clock and Reset
35
ethClk
:
in
sl
;
36
ethRst
:
in
sl
;
37
-- Incoming data from MAC
38
sAxisMaster
:
in
AxiStreamMasterType
;
39
-- Outgoing data
40
mAxisMaster
:
out
AxiStreamMasterType
;
41
mAxisCtrl
:
in
AxiStreamCtrlType
;
42
-- Configuration
43
dropOnPause
:
in
sl
;
44
macAddress
:
in
slv
(
47
downto
0
)
;
45
filtEnable
:
in
sl
)
;
46
end
EthMacRxFilter
;
47
48
architecture
rtl
of
EthMacRxFilter
is
49
50
type
StateType
is
(
51
IDLE_S
,
52
DROP_S
,
53
PASS_S
)
;
54
55
type
RegType
is
record
56
state
:
StateType
;
57
mAxisMaster
:
AxiStreamMasterType
;
58
end
record
RegType
;
59
60
constant
REG_INIT_C
:
RegType
:=
(
61
state
=
>
IDLE_S
,
62
mAxisMaster
=
>
AXI_STREAM_MASTER_INIT_C
)
;
63
64
signal
r
:
RegType
:=
REG_INIT_C
;
65
signal
rin
:
RegType
;
66
67
-- attribute dont_touch : string;
68
-- attribute dont_touch of r : signal is "true";
69
70
begin
71
72
U_FiltEnGen
:
if
(
FILT_EN_G
=
true
)
generate
73
74
comb :
process
(
dropOnPause
,
ethRst
,
filtEnable
,
mAxisCtrl
,
macAddress
, r,
sAxisMaster
)
is
75
variable
v
:
RegType
;
76
begin
77
-- Latch the current value
78
v
:=
r
;
79
80
-- Move the data
81
v
.
mAxisMaster
:=
sAxisMaster
;
82
83
-- State Machine
84
case
r
.
state
is
85
----------------------------------------------------------------------
86
when
IDLE_S
=
>
87
-- Check for data
88
if
(
sAxisMaster
.
tValid
=
'
1
'
)
then
89
-- Drop frames when pause is asserted to avoid downstream errors
90
if
(
mAxisCtrl
.
pause
=
'
1
'
)
and
(
dropOnPause
=
'
1
'
)
then
91
-- Drop the packet
92
v
.
mAxisMaster
.
tValid
:=
'
0
'
;
93
-- Check for no EOF
94
if
(
sAxisMaster
.
tLast
=
'
0
'
)
then
95
-- Next State
96
v
.
state
:=
DROP_S
;
97
end
if
;
98
-- Local match, broadcast or multicast
99
elsif
(
filtEnable
=
'
0
'
)
or
100
(
sAxisMaster
.
tData
(
47
downto
0
)
=
macAddress
)
or
-- Local
101
(
sAxisMaster
.
tData
(
0
)
=
'
1
'
)
or
-- Multicast
102
(
sAxisMaster
.
tData
(
47
downto
0
)
=
x
"FFFFFFFFFFFF"
)
then
-- Broadcast
103
-- Check for no EOF
104
if
(
sAxisMaster
.
tLast
=
'
0
'
)
then
105
-- Next State
106
v
.
state
:=
PASS_S
;
107
end
if
;
108
-- Drop frame
109
else
110
-- Drop the packet
111
v
.
mAxisMaster
.
tValid
:=
'
0
'
;
112
-- Check for no EOF
113
if
(
sAxisMaster
.
tLast
=
'
0
'
)
then
114
-- Next State
115
v
.
state
:=
DROP_S
;
116
end
if
;
117
end
if
;
118
end
if
;
119
----------------------------------------------------------------------
120
when
DROP_S
=
>
121
-- Drop the packet
122
v
.
mAxisMaster
.
tValid
:=
'
0
'
;
123
-- Check for a valid EOF
124
if
(
sAxisMaster
.
tValid
=
'
1
'
)
and
(
sAxisMaster
.
tLast
=
'
1
'
)
then
125
-- Next State
126
v
.
state
:=
IDLE_S
;
127
end
if
;
128
----------------------------------------------------------------------
129
when
PASS_S
=
>
130
-- Check for a valid EOF
131
if
(
sAxisMaster
.
tValid
=
'
1
'
)
and
(
sAxisMaster
.
tLast
=
'
1
'
)
then
132
-- Next State
133
v
.
state
:=
IDLE_S
;
134
end
if
;
135
----------------------------------------------------------------------
136
end
case
;
137
138
-- Reset
139
if
(
ethRst
=
'
1
'
)
then
140
v
:=
REG_INIT_C
;
141
end
if
;
142
143
-- Register the variable for next clock cycle
144
rin
<=
v
;
145
146
-- Outputs
147
mAxisMaster
<=
r
.
mAxisMaster
;
148
149
end
process
;
150
151
seq :
process
(
ethClk
)
is
152
begin
153
if
rising_edge
(
ethClk
)
then
154
r
<=
rin
after
TPD_G
;
155
end
if
;
156
end
process
seq
;
157
158
end
generate
;
159
160
U_FiltDisGen
:
if
(
FILT_EN_G
=
false
)
generate
161
mAxisMaster
<=
sAxisMaster
;
162
end
generate
;
163
164
end
rtl
;
EthMacRxFifo.ieee
_library_ ieeeieee
Definition:
EthMacRxFifo.vhd:18
EthMacRxFilter.sAxisMaster
in sAxisMasterAxiStreamMasterType
Definition:
EthMacRxFilter.vhd:38
AxiStreamPkg.tValid
sl tValid
Definition:
AxiStreamPkg.vhd:30
EthMacRxFilter.macAddress
in macAddressslv( 47 downto 0)
Definition:
EthMacRxFilter.vhd:44
EthMacRxFilter.ethClk
in ethClksl
Definition:
EthMacRxFilter.vhd:35
EthMacRxFilter.FILT_EN_G
FILT_EN_Gboolean := false
Definition:
EthMacRxFilter.vhd:32
StdRtlPkg.sl
std_logic sl
Definition:
StdRtlPkg.vhd:28
EthMacRxFilter
Definition:
EthMacRxFilter.vhd:29
EthMacRxFilter.mAxisMaster
out mAxisMasterAxiStreamMasterType
Definition:
EthMacRxFilter.vhd:40
AxiStreamPkg.AXI_STREAM_MASTER_INIT_C
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
Definition:
AxiStreamPkg.vhd:40
EthMacRxFilter.dropOnPause
in dropOnPausesl
Definition:
EthMacRxFilter.vhd:43
EthMacPkg
Definition:
EthMacPkg.vhd:26
AxiStreamPkg.tLast
sl tLast
Definition:
AxiStreamPkg.vhd:34
AxiStreamPkg.tData
slv( 127 downto 0) tData
Definition:
AxiStreamPkg.vhd:31
EthMacRxFilter.ethRst
in ethRstsl
Definition:
EthMacRxFilter.vhd:36
AxiStreamPkg.AxiStreamMasterType
AxiStreamMasterType
Definition:
AxiStreamPkg.vhd:29
EthMacRxFilter.TPD_G
TPD_Gtime := 1 ns
Definition:
EthMacRxFilter.vhd:31
AxiStreamPkg.pause
sl pause
Definition:
AxiStreamPkg.vhd:105
EthMacRxFilter.filtEnable
in filtEnablesl
Definition:
EthMacRxFilter.vhd:45
AxiStreamPkg
Definition:
AxiStreamPkg.vhd:25
StdRtlPkg
Definition:
StdRtlPkg.vhd:23
EthMacRxFilter.mAxisCtrl
in mAxisCtrlAxiStreamCtrlType
Definition:
EthMacRxFilter.vhd:41
AxiStreamPkg.AxiStreamCtrlType
AxiStreamCtrlType
Definition:
AxiStreamPkg.vhd:104
StdRtlPkg.slv
std_logic_vector slv
Definition:
StdRtlPkg.vhd:29
ethernet
EthMacCore
rtl
EthMacRxFilter.vhd
Generated by
1.8.13