Skip to content

Commit 9d3697c

Browse files
author
whitequark
committedOct 30, 2017
liteeth: add CRC error and dropped packet counters.
1 parent 362de1a commit 9d3697c

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
 

Diff for: ‎misoc/cores/liteeth_mini/mac/core.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from migen import *
2+
from migen.genlib.cdc import PulseSynchronizer
23

34
from misoc.interconnect.csr import *
45
from misoc.interconnect import stream
@@ -28,6 +29,8 @@ def __init__(self, phy, dw, endianness="big",
2829
# Preamble / CRC
2930
if with_preamble_crc:
3031
self._preamble_crc = CSRStatus(reset=1)
32+
self.crc_errors = CSRStatus(32)
33+
3134
# Preamble insert/check
3235
preamble_inserter = preamble.LiteEthMACPreambleInserter(phy.dw)
3336
preamble_checker = preamble.LiteEthMACPreambleChecker(phy.dw)
@@ -43,6 +46,14 @@ def __init__(self, phy, dw, endianness="big",
4346
tx_pipeline += [preamble_inserter, crc32_inserter]
4447
rx_pipeline += [preamble_checker, crc32_checker]
4548

49+
# CRC error counter
50+
self.submodules.ps_crc_error = PulseSynchronizer("eth_rx", "sys")
51+
52+
self.comb += self.ps_crc_error.i.eq(crc32_checker.crc_error)
53+
self.sync += [
54+
If(self.ps_crc_error.o,
55+
self.crc_errors.status.eq(self.crc_errors.status + 1))]
56+
4657
# Padding
4758
if with_padding:
4859
padding_inserter = padding.LiteEthMACPaddingInserter(phy.dw, 60)

Diff for: ‎misoc/cores/liteeth_mini/mac/crc.py

+9
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,15 @@ class LiteEthMACCRCChecker(Module):
216216
source : out
217217
Packets output without CRC and "error" set to 0
218218
on eop when CRC OK / set to 1 when CRC KO.
219+
crc_error : out
220+
Pulses every time a CRC error is detected.
219221
"""
220222
def __init__(self, crc_class, layout):
221223
self.sink = sink = stream.Endpoint(layout)
222224
self.source = source = stream.Endpoint(layout)
223225

226+
self.crc_error = Signal()
227+
224228
# # #
225229

226230
dw = len(sink.data)
@@ -255,6 +259,11 @@ def __init__(self, crc_class, layout):
255259
source.error.eq(sink.error | crc.error),
256260
]
257261

262+
crc_error_r = Signal()
263+
264+
self.comb += self.crc_error.eq(crc.error & ~crc_error_r)
265+
self.sync += crc_error_r.eq(crc.error)
266+
258267
fsm.act("RESET",
259268
crc.reset.eq(1),
260269
fifo.reset.eq(1),

Diff for: ‎misoc/cores/liteeth_mini/mac/sram.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def __init__(self, dw, depth, nslots=2):
1717
self._slot = CSRStatus(slotbits)
1818
self._length = CSRStatus(lengthbits)
1919

20+
self.errors = CSRStatus(32)
21+
2022
self.submodules.ev = EventManager()
2123
self.ev.available = EventSourceLevel()
2224
self.ev.finalize()
@@ -69,6 +71,9 @@ def __init__(self, dw, depth, nslots=2):
6971
ongoing.eq(1),
7072
counter_ce.eq(1),
7173
NextState("WRITE")
74+
).Else(
75+
NextValue(self.errors.status, self.errors.status + 1),
76+
NextState("DISCARD_REMAINING")
7277
)
7378
)
7479
)

0 commit comments

Comments
 (0)
Please sign in to comment.