From 79a8ec57eaf9514f4d82eb5fb701d973bfd77da0 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Thu, 26 Nov 2020 00:53:02 -0800 Subject: [PATCH] Add FCS insertion, removal, and verification to GmiiFrame and XgmiiFrame --- cocotbext/eth/gmii.py | 19 ++++++++++++++++--- cocotbext/eth/xgmii.py | 19 ++++++++++++++++--- tests/gmii/test_gmii.py | 2 +- tests/rgmii/test_rgmii.py | 3 ++- tests/xgmii/test_xgmii.py | 8 +++++--- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/cocotbext/eth/gmii.py b/cocotbext/eth/gmii.py index 940417c..a46526f 100644 --- a/cocotbext/eth/gmii.py +++ b/cocotbext/eth/gmii.py @@ -23,6 +23,8 @@ THE SOFTWARE. """ import logging +import struct +import zlib from collections import deque import cocotb @@ -48,9 +50,11 @@ class GmiiFrame(object): self.error = error @classmethod - def from_payload(cls, payload): + def from_payload(cls, payload, add_fcs=True): data = bytearray(ETH_PREAMBLE) data.extend(payload) + if add_fcs: + data.extend(struct.pack('