cocotbext-eth


Namecocotbext-eth JSON
Version 0.1.20 PyPI version JSON
download
home_pagehttps://github.com/alexforencich/cocotbext-eth
SummaryEthernet interface modules for cocotb
upload_time2023-01-26 02:55:46
maintainer
docs_urlNone
authorAlex Forencich
requires_python>=3.6
licenseMIT
keywords ethernet cocotb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ethernet interface modules for Cocotb

[![Build Status](https://github.com/alexforencich/cocotbext-eth/workflows/Regression%20Tests/badge.svg?branch=master)](https://github.com/alexforencich/cocotbext-eth/actions/)
[![codecov](https://codecov.io/gh/alexforencich/cocotbext-eth/branch/master/graph/badge.svg)](https://codecov.io/gh/alexforencich/cocotbext-eth)
[![PyPI version](https://badge.fury.io/py/cocotbext-eth.svg)](https://pypi.org/project/cocotbext-eth)
[![Downloads](https://pepy.tech/badge/cocotbext-eth)](https://pepy.tech/project/cocotbext-eth)

GitHub repository: https://github.com/alexforencich/cocotbext-eth

## Introduction

Ethernet interface models for [cocotb](https://github.com/cocotb/cocotb).

Includes PHY-attach interface models for MII, GMII, RGMII, and XGMII; PHY chip interface models for MII, GMII, and RGMII; PTP clock simulation models; and a generic Ethernet MAC model that supports rate enforcement and PTP timestamping.

## Installation

Installation from pip (release version, stable):

    $ pip install cocotbext-eth

Installation from git (latest development version, potentially unstable):

    $ pip install https://github.com/alexforencich/cocotbext-eth/archive/master.zip

Installation for active development:

    $ git clone https://github.com/alexforencich/cocotbext-eth
    $ pip install -e cocotbext-eth

## Documentation and usage examples

See the `tests` directory, [verilog-ethernet](https://github.com/alexforencich/verilog-ethernet), and [corundum](https://github.com/corundum/corundum) for complete testbenches using these modules.

### GMII

The `GmiiSource` and `GmiiSink` classes can be used to drive, receive, and monitor GMII traffic.  The `GmiiSource` drives GMII traffic into a design.  The `GmiiSink` receives GMII traffic, including monitoring internal interfaces.  The `GmiiPhy` class is a wrapper around `GmiiSource` and `GmiiSink` that also provides clocking and rate-switching to emulate a GMII PHY chip.

To use these modules, import the one you need and connect it to the DUT:

    from cocotbext.eth import GmiiSource, GmiiSink

    gmii_source = GmiiSource(dut.rxd, dut.rx_er, dut.rx_en, dut.clk, dut.rst)
    gmii_sink = GmiiSink(dut.txd, dut.tx_er, dut.tx_en, dut.clk, dut.rst)

To send data into a design with a `GmiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `GmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:

    await gmii_source.send(GmiiFrame.from_payload(b'test data'))
    # wait for operation to complete (optional)
    await gmii_source.wait()

It is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `GmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:

    frame = GmiiFrame.from_payload(b'test data', tx_complete=Event())
    await gmii_source.send(frame)
    await frame.tx_complete.wait()
    print(frame.tx_complete.data.sim_time_sfd)

To receive data with a `GmiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.

    data = await gmii_sink.recv()

The `GmiiPhy` class provides a model of a GMII PHY chip.  It wraps instances of `GmiiSource` (`rx`) and `GmiiSink` (`tx`), provides the necessary clocking components, and provides the `set_speed()` method to change the link speed.  `set_speed()` changes the `tx_clk` and `rx_clk` frequencies, switches between `gtx_clk` and `tx_clk`, and selects the appropriate mode (MII or GMII) on the source and sink instances.  In general, the `GmiiPhy` class is intended to be used for integration tests where the design expects to be directly connected to an external GMII PHY chip and contains all of the necessary IO and clocking logic.  Example:

    from cocotbext.eth import GmiiFrame, GmiiPhy

    gmii_phy = GmiiPhy(dut.txd, dut.tx_er, dut.tx_en, dut.tx_clk, dut.gtx_clk,
        dut.rxd, dut.rx_er, dut.rx_en, dut.rx_clk, dut.rst, speed=1000e6)

    gmii_phy.set_speed(100e6)

    await gmii_phy.rx.send(GmiiFrame.from_payload(b'test RX data'))
    tx_data = await gmii_phy.tx.recv()

#### Signals

* `txd`, `rxd`: data
* `tx_er`, `rx_er`: error (when asserted with `tx_en` or `rx_dv`)
* `tx_en`, `rx_dv`: data valid

#### Constructor parameters:

* _data_: data signal (txd, rxd, etc.)
* _er_: error signal (tx_er, rx_er, etc.) (optional)
* _dv_: data valid signal (tx_en, rx_dv, etc.)
* _clock_: clock signal
* _reset_: reset signal (optional)
* _enable_: clock enable (optional)
* _mii_select_: MII mode select (optional)
* _reset_active_level_: reset active level (optional, default `True`)

#### Attributes:

* _queue_occupancy_bytes_: number of bytes in queue
* _queue_occupancy_frames_: number of frames in queue
* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)
* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)
* _mii_mode_: control MII mode when _mii_select_ signal is not connected

#### Methods

* `send(frame)`: send _frame_ (blocking) (source)
* `send_nowait(frame)`: send _frame_ (non-blocking) (source)
* `recv()`: receive a frame as a `GmiiFrame` (blocking) (sink)
* `recv_nowait()`: receive a frame as a `GmiiFrame` (non-blocking) (sink)
* `count()`: returns the number of items in the queue (all)
* `empty()`: returns _True_ if the queue is empty (all)
* `full()`: returns _True_ if the queue occupancy limits are met (source)
* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)
* `clear()`: drop all data in queue (all)
* `wait()`: wait for idle (source)
* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)

#### GMII timing diagram

Example transfer via GMII at 1 Gbps:

                  __    __    __    __    _       __    __    __    __
    tx_clk     __/  \__/  \__/  \__/  \__/  ... _/  \__/  \__/  \__/  \__
                        _____ _____ _____ _     _ _____ _____
    tx_d[7:0]  XXXXXXXXX_55__X_55__X_55__X_ ... _X_72__X_fb__XXXXXXXXXXXX

    tx_er      ____________________________ ... _________________________
                        ___________________     _____________
    tx_en      ________/                    ...              \___________


#### GmiiFrame object

The `GmiiFrame` object is a container for a frame to be transferred via GMII.  The `data` field contains the packet data in the form of a list of bytes.  `error` contains the `er` signal level state associated with each byte as a list of ints.

Attributes:

* `data`: bytearray
* `error`: error field, optional; list, each entry qualifies the corresponding entry in `data`.
* `sim_time_start`: simulation time of first transfer cycle of frame.
* `sim_time_sfd`: simulation time at which the SFD was transferred.
* `sim_time_end`: simulation time of last transfer cycle of frame.
* `start_lane`: byte lane in which the start control character was transferred.
* `tx_complete`: event or callable triggered when frame is transmitted.

Methods:

* `from_payload(payload, min_len=60)`: create `GmiiFrame` from payload data, inserts preamble, zero-pads frame to minimum length and computes and inserts FCS (class method)
* `from_raw_payload(payload)`: create `GmiiFrame` from payload data, inserts preamble only (class method)
* `get_preamble_len()`: locate SFD and return preamble length
* `get_preamble()`: return preamble
* `get_payload(strip_fcs=True)`: return payload, optionally strip FCS
* `get_fcs()`: return FCS
* `check_fcs()`: returns _True_ if FCS is correct
* `normalize()`: pack `error` to the same length as `data`, replicating last element if necessary, initialize to list of `0` if not specified.
* `compact()`: remove `error` if all zero

### MII

The `MiiSource` and `MiiSink` classes can be used to drive, receive, and monitor MII traffic.  The `MiiSource` drives MII traffic into a design.  The `MiiSink` receives MII traffic, including monitoring internal interfaces.  The `MiiPhy` class is a wrapper around `MiiSource` and `MiiSink` that also provides clocking and rate-switching to emulate an MII PHY chip.

To use these modules, import the one you need and connect it to the DUT:

    from cocotbext.eth import MiiSource, MiiSink

    mii_source = MiiSource(dut.rxd, dut.rx_er, dut.rx_en, dut.clk, dut.rst)
    mii_sink = MiiSink(dut.txd, dut.tx_er, dut.tx_en, dut.clk, dut.rst)

All signals must be passed separately into these classes.

To send data into a design with an `MiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `GmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:

    await mii_source.send(GmiiFrame.from_payload(b'test data'))
    # wait for operation to complete (optional)
    await mii_source.wait()

It is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `GmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:

    frame = GmiiFrame.from_payload(b'test data', tx_complete=Event())
    await mii_source.send(frame)
    await frame.tx_complete.wait()
    print(frame.tx_complete.data.sim_time_sfd)

To receive data with an `MiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.

    data = await mii_sink.recv()

The `MiiPhy` class provides a model of an MII PHY chip.  It wraps instances of `MiiSource` (`rx`) and `MiiSink` (`tx`), provides the necessary clocking components, and provides the `set_speed()` method to change the link speed.  `set_speed()` changes the `tx_clk` and `rx_clk` frequencies.  In general, the `MiiPhy` class is intended to be used for integration tests where the design expects to be directly connected to an external MII PHY chip and contains all of the necessary IO and clocking logic.  Example:

    from cocotbext.eth import GmiiFrame, MiiPhy

    mii_phy = MiiPhy(dut.txd, dut.tx_er, dut.tx_en, dut.tx_clk,
        dut.rxd, dut.rx_er, dut.rx_en, dut.rx_clk, dut.rst, speed=100e6)

    mii_phy.set_speed(10e6)

    await mii_phy.rx.send(GmiiFrame.from_payload(b'test RX data'))
    tx_data = await mii_phy.tx.recv()

#### Signals

* `txd`, `rxd`: data
* `tx_er`, `rx_er`: error (when asserted with `tx_en` or `rx_dv`)
* `tx_en`, `rx_dv`: data valid

#### Constructor parameters:

* _data_: data signal (txd, rxd, etc.)
* _er_: error signal (tx_er, rx_er, etc.) (optional)
* _dv_: data valid signal (tx_en, rx_dv, etc.)
* _clock_: clock signal
* _reset_: reset signal (optional)
* _enable_: clock enable (optional)
* _reset_active_level_: reset active level (optional, default `True`)

#### Attributes:

* _queue_occupancy_bytes_: number of bytes in queue
* _queue_occupancy_frames_: number of frames in queue
* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)
* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)

#### Methods

* `send(frame)`: send _frame_ (blocking) (source)
* `send_nowait(frame)`: send _frame_ (non-blocking) (source)
* `recv()`: receive a frame as a `GmiiFrame` (blocking) (sink)
* `recv_nowait()`: receive a frame as a `GmiiFrame` (non-blocking) (sink)
* `count()`: returns the number of items in the queue (all)
* `empty()`: returns _True_ if the queue is empty (all)
* `full()`: returns _True_ if the queue occupancy limits are met (source)
* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)
* `clear()`: drop all data in queue (all)
* `wait()`: wait for idle (source)
* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)

#### MII timing diagram

Example transfer via MII at 100 Mbps:

                 _   _   _   _   _   _       _   _   _   _
    tx_clk     _/ \_/ \_/ \_/ \_/ \_/  ... _/ \_/ \_/ \_/ \_
                     ___ ___ ___ ___ _     _ ___ ___
    tx_d[3:0]  XXXXXX_5_X_5_X_5_X_5_X_ ... _X_f_X_b_XXXXXXXX

    tx_er      _______________________ ... _________________
                     _________________     _________
    tx_en      _____/                  ...          \_______


### RGMII

The `RgmiiSource` and `RgmiiSink` classes can be used to drive, receive, and monitor RGMII traffic.  The `RgmiiSource` drives RGMII traffic into a design.  The `RgmiiSink` receives RGMII traffic, including monitoring internal interfaces.  The `RgmiiPhy` class is a wrapper around `RgmiiSource` and `RgmiiSink` that also provides clocking and rate-switching to emulate an RGMII PHY chip.

To use these modules, import the one you need and connect it to the DUT:

    from cocotbext.eth import RgmiiSource, RgmiiSink

    rgmii_source = RgmiiSource(dut.rxd, dut.rx_ctl, dut.clk, dut.rst)
    rgmii_sink = RgmiiSink(dut.txd, dut.tx_ctl, dut.clk, dut.rst)

All signals must be passed separately into these classes.

To send data into a design with an `RgmiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `GmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:

    await rgmii_source.send(GmiiFrame.from_payload(b'test data'))
    # wait for operation to complete (optional)
    await rgmii_source.wait()

It is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `GmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:

    frame = GmiiFrame.from_payload(b'test data', tx_complete=Event())
    await rgmii_source.send(frame)
    await frame.tx_complete.wait()
    print(frame.tx_complete.data.sim_time_sfd)

To receive data with an `RgmiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.

    data = await rgmii_sink.recv()

The `RgmiiPhy` class provides a model of an RGMII PHY chip.  It wraps instances of `RgmiiSource` (`rx`) and `RgmiiSink` (`tx`), provides the necessary clocking components, and provides the `set_speed()` method to change the link speed.  `set_speed()` changes the `rx_clk` frequency and selects the appropriate mode (SDR or DDR) on the source and sink instances.  In general, the `RgmiiPhy` class is intended to be used for integration tests where the design expects to be directly connected to an external RGMII PHY chip and contains all of the necessary IO and clocking logic.  Example:

    from cocotbext.eth import GmiiFrame, RgmiiPhy

    rgmii_phy = RgmiiPhy(dut.txd, dut.tx_ctl, dut.tx_clk,
        dut.rxd, dut.rx_ctl, dut.rx_clk, dut.rst, speed=1000e6)

    rgmii_phy.set_speed(100e6)

    await rgmii_phy.rx.send(GmiiFrame.from_payload(b'test RX data'))
    tx_data = await rgmii_phy.tx.recv()

#### Signals

* `txd`, `rxd`: data (DDR)
* `tx_ctl`, `rx_ctl`: control (DDR, combination of valid and error)

#### Constructor parameters:

* _data_: data signal (txd, rxd, etc.)
* _ctrl_: control
* _clock_: clock signal
* _reset_: reset signal (optional)
* _enable_: clock enable (optional)
* _mii_select_: MII mode select (optional)
* _reset_active_level_: reset active level (optional, default `True`)

#### Attributes:

* _queue_occupancy_bytes_: number of bytes in queue
* _queue_occupancy_frames_: number of frames in queue
* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)
* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)
* _mii_mode_: control MII mode when _mii_select_ signal is not connected

#### Methods

* `send(frame)`: send _frame_ (blocking) (source)
* `send_nowait(frame)`: send _frame_ (non-blocking) (source)
* `recv()`: receive a frame as a `GmiiFrame` (blocking) (sink)
* `recv_nowait()`: receive a frame as a `GmiiFrame` (non-blocking) (sink)
* `count()`: returns the number of items in the queue (all)
* `empty()`: returns _True_ if the queue is empty (all)
* `full()`: returns _True_ if the queue occupancy limits are met (source)
* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)
* `clear()`: drop all data in queue (all)
* `wait()`: wait for idle (source)
* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)

#### RGMII timing diagram

Example transfer via RGMII at 1 Gbps:

                 ___     ___     ___     _       ___     ___
    tx_clk     _/   \___/   \___/   \___/  ... _/   \___/   \___
                       ___ ___ ___ ___ ___     ___ ___
    tx_d[3:0]  XXXXXXXX_5_X_5_X_5_X_5_X_5_ ... _f_X_b_XXXXXXXXXX
                       ___________________     _______
    tx_ctl     _______/                    ...        \_________


### XGMII

The `XgmiiSource` and `XgmiiSink` classes can be used to drive, receive, and monitor XGMII traffic.  The `XgmiiSource` drives XGMII traffic into a design.  The `XgmiiSink` receives XGMII traffic, including monitoring internal interfaces.  The modules are capable of operating with XGMII interface widths of 32 or 64 bits.

To use these modules, import the one you need and connect it to the DUT:

    from cocotbext.eth import XgmiiSource, XgmiiSink

    xgmii_source = XgmiiSource(dut.rxd, dut.rxc, dut.clk, dut.rst)
    xgmii_sink = XgmiiSink(dut.txd, dut.txc, dut.clk, dut.rst)

All signals must be passed separately into these classes.

To send data into a design with an `XgmiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `XgmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:

    await xgmii_source.send(XgmiiFrame.from_payload(b'test data'))
    # wait for operation to complete (optional)
    await xgmii_source.wait()

It is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `XgmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:

    frame = XgmiiFrame.from_payload(b'test data', tx_complete=Event())
    await xgmii_source.send(frame)
    await frame.tx_complete.wait()
    print(frame.tx_complete.data.sim_time_sfd)

To receive data with an `XgmiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.

    data = await xgmii_sink.recv()

#### Signals

* `txd`, `rxd`: data
* `txc`, `rxc`: control

#### Constructor parameters:

* _data_: data signal (txd, rxd, etc.)
* _ctrl_: control signal (txc, rxc, etc.)
* _clock_: clock signal
* _reset_: reset signal (optional)
* _enable_: clock enable (optional)
* _reset_active_level_: reset active level (optional, default `True`)

#### Attributes:

* _queue_occupancy_bytes_: number of bytes in queue
* _queue_occupancy_frames_: number of frames in queue
* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)
* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)

#### Methods

* `send(frame)`: send _frame_ (blocking) (source)
* `send_nowait(frame)`: send _frame_ (non-blocking) (source)
* `recv()`: receive a frame as an `XgmiiFrame` (blocking) (sink)
* `recv_nowait()`: receive a frame as an `XgmiiFrame` (non-blocking) (sink)
* `count()`: returns the number of items in the queue (all)
* `empty()`: returns _True_ if the queue is empty (all)
* `full()`: returns _True_ if the queue occupancy limits are met (source)
* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)
* `clear()`: drop all data in queue (all)
* `wait()`: wait for idle (source)
* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)

#### XGMII timing diagram

Example transfer via 64-bit XGMII:

                  __    __    __    __    __    _       __    __
    tx_clk     __/  \__/  \__/  \__/  \__/  \__/  ... _/  \__/  \__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[63:56] __X_07__X_d5__X_51__X_01__X_09__X_ ... _X_fb__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[55:48] __X_07__X_55__X_5a__X_00__X_08__X_ ... _X_72__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[47:40] __X_07__X_55__X_d5__X_00__X_07__X_ ... _X_0d__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[39:32] __X_07__X_55__X_d4__X_80__X_06__X_ ... _X_37__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[31:24] __X_07__X_55__X_d3__X_55__X_05__X_ ... _X_2d__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[23:16] __X_07__X_55__X_d2__X_54__X_04__X_ ... _X_2c__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[15:8]  __X_07__X_55__X_d1__X_53__X_03__X_ ... _X_2b__X_07__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txd[7:0]   __X_07__X_fb__X_da__X_52__X_02__X_ ... _X_2a__X_fd__
               __ _____ _____ _____ _____ _____ _     _ _____ _____
    txc[7:0]   __X_ff__X_01__X_00__X_00__X_00__X_ ... _X_00__X_ff__


#### XgmiiFrame object

The `XgmiiFrame` object is a container for a frame to be transferred via XGMII.  The `data` field contains the packet data in the form of a list of bytes.  `ctrl` contains the control signal level state associated with each byte as a list of ints.  When `ctrl` is high, the corresponding `data` byte is interpreted as an XGMII control character.

Attributes:

* `data`: bytearray
* `ctrl`: control field, optional; list, each entry qualifies the corresponding entry in `data` as an XGMII control character.
* `sim_time_start`: simulation time of first transfer cycle of frame.
* `sim_time_sfd`: simulation time at which the SFD was transferred.
* `sim_time_end`: simulation time of last transfer cycle of frame.
* `start_lane`: byte lane in which the start control character was transferred.
* `tx_complete`: event or callable triggered when frame is transmitted.

Methods:

* `from_payload(payload, min_len=60)`: create `XgmiiFrame` from payload data, inserts preamble, zero-pads frame to minimum length and computes and inserts FCS (class method)
* `from_raw_payload(payload)`: create `XgmiiFrame` from payload data, inserts preamble only (class method)
* `get_preamble_len()`: locate SFD and return preamble length
* `get_preamble()`: return preamble
* `get_payload(strip_fcs=True)`: return payload, optionally strip FCS
* `get_fcs()`: return FCS
* `check_fcs()`: returns _True_ if FCS is correct
* `normalize()`: pack `ctrl` to the same length as `data`, replicating last element if necessary, initialize to list of `0` if not specified.
* `compact()`: remove `ctrl` if all zero

### Ethernet MAC model

The `EthMac`, `EthMacTx` and `EthMacRx` modules are models of an Ethernet MAC with an AXI stream interface.  The `EthMacRx` module drives Ethernet frames in the form of AXI stream traffic into a design.  The `EthMacTx` module accepts Ethernet frames in the form of AXI stream traffic from a design.  `EthMac` is a wrapper module containing `EthMacRx` (`rx`) and `EthMacTx` (`tx`).  The modules are capable of operating with any interface width.  The MAC models enforce the correct data rates and timings in both the receive and transmit direction, and can also collect PTP timestamps from a PTP hardware clock.

To use these modules, import the one you need and connect it to the DUT:

    from cocotbext.axi import AxiStreamBus
    from cocotbext.eth import EthMac

    mac = EthMac(
        tx_clk=dut.tx_clk,
        tx_rst=dut.tx_rst,
        tx_bus=AxiStreamBus.from_prefix(dut, "tx_axis"),
        tx_ptp_time=dut.tx_ptp_time,
        tx_ptp_ts=dut.tx_ptp_ts,
        tx_ptp_ts_tag=dut.tx_ptp_ts_tag,
        tx_ptp_ts_valid=dut.tx_ptp_ts_valid,
        rx_clk=dut.rx_clk,
        rx_rst=dut.rx_rst,
        rx_bus=AxiStreamBus.from_prefix(dut, "rx_axis"),
        rx_ptp_time=dut.rx_ptp_time,
        ifg=12, speed=speed
    )

To send data into a design, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `EthMacFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:

    await mac.tx.send(EthMacFrame.from_payload(b'test data'))
    # wait for operation to complete (optional)
    await mac.tx.wait()

It is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `EthMacFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:

    frame = EthMacFrame.from_payload(b'test data', tx_complete=Event())
    await mac.tx.send(frame)
    await frame.tx_complete.wait()
    print(frame.tx_complete.data.sim_time_sfd)

To receive data, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.

    data = await mac.tx.recv()

PTP timestamping requires free-running PTP clocks driving the PTP time inputs, synchronous with the corresponding MAC clocks.  The values of these fields are then captured when the frame SFD is transferred and returned either on tuser (for received frames) or on a separate streaming interface (for transmitted frames).  Additionally, on the transmit path, a tag value from tuser is returned along with the timestamp.

#### Signals

* `tdata`: payload data, must be a multiple of 8 bits
* `tvalid`: qualifies all other signals
* `tready`: indicates sink is ready for data (tx only)
* `tlast`: marks the last cycle of a frame
* `tkeep`: qualifies data byte, data bus width must be evenly divisible by `tkeep` signal width
* `tuser`: user data, carries frame error mark and captured receive PTP timestamp (RX) or PTP timestamp tag (TX)
* `ptp_time`: PTP time input from PHC, captured into `ptp_timestamp` field coincident with transfer of frame SFD and output on `ptp_ts` (TX) or `tuser` (RX)
* `ptp_ts`: captured transmit PTP timestamp
* `ptp_ts_tag`: captured transmit PTP timestamp tag
* `ptp_ts_valid`: qualifies captured transmit PTP timestamp

#### Constructor parameters (`EthMacRx` and `EthMacTx`):

* _bus_: `AxiStreamBus` object containing AXI stream interface signals
* _clock_: clock signal
* _reset_: reset signal (optional)
* _ptp_time_: PTP time input from PHC (optional)
* _ptp_ts_: PTP timestamp (optional) (tx)
* _ptp_ts_tag_: PTP timestamp tag (optional) (tx)
* _ptp_ts_valid_: PTP timestamp valid (optional) (tx)
* _reset_active_level_: reset active level (optional, default `True`)
* _ifg_: IFG size in byte times (optional, default `12`)
* _speed_: link speed in bits per second (optional, default `1000e6`)

#### Constructor parameters (`EthMac`):

* _tx_bus_: `AxiStreamBus` object containing transmit AXI stream interface signals
* _tx_clk_: transmit clock
* _tx_rst_: transmit reset (optional)
* _tx_ptp_time_: transmit PTP time input from PHC (optional)
* _tx_ptp_ts_: transmit PTP timestamp (optional)
* _tx_ptp_ts_tag_: transmit PTP timestamp tag (optional)
* _tx_ptp_ts_valid_: transmit PTP timestamp valid (optional)
* _rx_bus_: `AxiStreamBus` object containing receive AXI stream interface signals
* _rx_clk_: receive clock
* _rx_rst_: receive reset (optional)
* _rx_ptp_time_: receive PTP time input from PHC (optional)
* _reset_active_level_: reset active level (optional, default `True`)
* _ifg_: IFG size in byte times (optional, default `12`)
* _speed_: link speed in bits per second (optional, default `1000e6`)

#### Attributes:

* _queue_occupancy_bytes_: number of bytes in queue
* _queue_occupancy_frames_: number of frames in queue
* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (RX only)
* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (RX only)
* _ifg_: IFG size in byte times
* _speed_: link speed in bits per second

#### Methods

* `send(frame)`: send _frame_ (blocking) (rx)
* `send_nowait(frame)`: send _frame_ (non-blocking) (rx)
* `recv()`: receive a frame as an `EthMacFrame` (blocking) (tx)
* `recv_nowait()`: receive a frame as an `EthMacFrame` (non-blocking) (tx)
* `count()`: returns the number of items in the queue (all)
* `empty()`: returns _True_ if the queue is empty (all)
* `full()`: returns _True_ if the queue occupancy limits are met (rx)
* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (rx)
* `clear()`: drop all data in queue (all)
* `wait()`: wait for idle (rx)
* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (tx)

#### EthMacFrame object

The `EthMacFrame` object is a container for a frame to be transferred via XGMII.  The `data` field contains the packet data in the form of a list of bytes.

Attributes:

* `data`: bytearray
* `sim_time_start`: simulation time of first transfer cycle of frame.
* `sim_time_sfd`: simulation time at which the SFD was transferred.
* `sim_time_end`: simulation time of last transfer cycle of frame.
* `ptp_tag`: PTP timestamp tag for transmitted frames.
* `ptp_timestamp`: captured value of `ptp_time` at frame SFD
* `tx_complete`: event or callable triggered when frame is transmitted.

Methods:

* `from_payload(payload, min_len=60)`: create `EthMacFrame` from payload data, zero-pads frame to minimum length and computes and inserts FCS (class method)
* `from_raw_payload(payload)`: create `EthMacFrame` from payload data (class method)
* `get_payload(strip_fcs=True)`: return payload, optionally strip FCS
* `get_fcs()`: return FCS
* `check_fcs()`: returns _True_ if FCS is correct

### PTP clock

The `PtpClock` class implements a PTP hardware clock that produces IEEE 1588 format 96 and 64 bit PTP timestamps.

To use this module, import it and connect it to the DUT:

    from cocotbext.eth import PtpClock

    ptp_clock = PtpClock(
        ts_96=dut.ts_96,
        ts_64=dut.ts_64,
        ts_step=dut.ts_step,
        pps=dut.pps,
        clock=dut.clk,
        reset=dut.reset,
        period_ns=6.4
    )

Once the clock is instantiated, it will generate a continuous stream of monotonically increasing PTP timestamps on every clock edge.

#### Signals

* `ts_96`: 96-bit timestamp (48 bit seconds, 32 bit ns, 16 bit fractional ns)
* `ts_64`: 64-bit timestamp (48 bit ns, 16 bit fractional ns)
* `ts_step`: step output, pulsed when non-monotonic step occurs
* `pps`: pulse-per-second output, pulsed when ts_96 seconds field increments

#### Constructor parameters:

* _ts_96_: 96-bit timestamp signal (optional)
* _ts_64_: 64-bit timestamp signal (optional)
* _ts_step_: timestamp step signal (optional)
* _pps_: pulse-per-second signal (optional)
* _clock_: clock
* _reset_: reset (optional)
* _reset_active_level_: reset active level (optional, default `True`)
* _period_ns_: clock period (nanoseconds, default `6.4`)

#### Attributes:

* _ts_96_s_: current 96-bit timestamp seconds field
* _ts_96_ns_: current 96-bit timestamp ns field
* _ts_96_fns_: current 96-bit timestamp fractional ns field
* _ts_64_ns_: current 64-bit timestamp ns field
* _ts_64_fns_: current 64-bit timestamp fractional ns field

#### Methods

* `set_period(ns, fns)`: set clock period from separate fields
* `set_drift(ns, fns, rate)`: set clock drift from separate fields
* `set_period_ns(t)`: set clock period in ns (float)
* `get_period_ns()`: return current clock period in ns (float)
* `set_ts_96(ts_s, ts_ns=None, ts_fns=None)`: set 96-bit timestamp from integer or from separate fields
* `set_ts_96_ns(t)`: set 96-bit timestamp from ns (float)
* `set_ts_96_s(t)`: set 96-bit timestamp from seconds (float)
* `get_ts_96()`: return current 96-bit timestamp as an integer
* `get_ts_96_ns()`: return current 96-bit timestamp in ns (float)
* `get_ts_96_s()`: return current 96-bit timestamp in seconds (float)
* `set_ts_64(ts_ns, ts_fns=None)`: set 64-bit timestamp from integer or from separate fields
* `set_ts_64_ns(t)`: set 64-bit timestamp from ns (float)
* `set_ts_64_s(t)`: set 64-bit timestamp from seconds (float)
* `get_ts_64()`: return current 64-bit timestamp as an integer
* `get_ts_64_ns()`: return current 64-bit timestamp in ns (float)
* `get_ts_64_s()`: return current 64-bit timestamp in seconds (float)

### PTP clock (sim time)

The `PtpClockSimTime` class implements a PTP hardware clock that produces IEEE 1588 format 96 and 64 bit PTP timestamps, derived from the current simulation time.  This module can be used in place of `PtpClock` so that captured PTP timestamps can be easily compared to captured simulation time.

To use this module, import it and connect it to the DUT:

    from cocotbext.eth import PtpClockSimTime

    ptp_clock = PtpClockSimTime(
        ts_96=dut.ts_96,
        ts_64=dut.ts_64,
        pps=dut.pps,
        clock=dut.clk
    )

Once the clock is instantiated, it will generate a continuous stream of monotonically increasing PTP timestamps on every clock edge.

#### Signals

* `ts_96`: 96-bit timestamp (48 bit seconds, 32 bit ns, 16 bit fractional ns)
* `ts_64`: 64-bit timestamp (48 bit ns, 16 bit fractional ns)
* `pps`: pulse-per-second output, pulsed when ts_96 seconds field increments

#### Constructor parameters:

* _ts_96_: 96-bit timestamp signal (optional)
* _ts_64_: 64-bit timestamp signal (optional)
* _pps_: pulse-per-second signal (optional)
* _clock_: clock

#### Attributes:

* _ts_96_s_: current 96-bit timestamp seconds field
* _ts_96_ns_: current 96-bit timestamp ns field
* _ts_96_fns_: current 96-bit timestamp fractional ns field
* _ts_64_ns_: current 64-bit timestamp ns field
* _ts_64_fns_: current 64-bit timestamp fractional ns field

#### Methods

* `get_ts_96()`: return current 96-bit timestamp as an integer
* `get_ts_96_ns()`: return current 96-bit timestamp in ns (float)
* `get_ts_96_s()`: return current 96-bit timestamp in seconds (float)
* `get_ts_64()`: return current 64-bit timestamp as an integer
* `get_ts_64_ns()`: return current 64-bit timestamp in ns (float)
* `get_ts_64_s()`: return current 64-bit timestamp in seconds (float)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alexforencich/cocotbext-eth",
    "name": "cocotbext-eth",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "ethernet,cocotb",
    "author": "Alex Forencich",
    "author_email": "alex@alexforencich.com",
    "download_url": "https://files.pythonhosted.org/packages/5e/96/5086cb68fc962a66b9f232bd11aa6a67cecd1e516149f01d130f61d494c3/cocotbext-eth-0.1.20.tar.gz",
    "platform": "any",
    "description": "# Ethernet interface modules for Cocotb\n\n[![Build Status](https://github.com/alexforencich/cocotbext-eth/workflows/Regression%20Tests/badge.svg?branch=master)](https://github.com/alexforencich/cocotbext-eth/actions/)\n[![codecov](https://codecov.io/gh/alexforencich/cocotbext-eth/branch/master/graph/badge.svg)](https://codecov.io/gh/alexforencich/cocotbext-eth)\n[![PyPI version](https://badge.fury.io/py/cocotbext-eth.svg)](https://pypi.org/project/cocotbext-eth)\n[![Downloads](https://pepy.tech/badge/cocotbext-eth)](https://pepy.tech/project/cocotbext-eth)\n\nGitHub repository: https://github.com/alexforencich/cocotbext-eth\n\n## Introduction\n\nEthernet interface models for [cocotb](https://github.com/cocotb/cocotb).\n\nIncludes PHY-attach interface models for MII, GMII, RGMII, and XGMII; PHY chip interface models for MII, GMII, and RGMII; PTP clock simulation models; and a generic Ethernet MAC model that supports rate enforcement and PTP timestamping.\n\n## Installation\n\nInstallation from pip (release version, stable):\n\n    $ pip install cocotbext-eth\n\nInstallation from git (latest development version, potentially unstable):\n\n    $ pip install https://github.com/alexforencich/cocotbext-eth/archive/master.zip\n\nInstallation for active development:\n\n    $ git clone https://github.com/alexforencich/cocotbext-eth\n    $ pip install -e cocotbext-eth\n\n## Documentation and usage examples\n\nSee the `tests` directory, [verilog-ethernet](https://github.com/alexforencich/verilog-ethernet), and [corundum](https://github.com/corundum/corundum) for complete testbenches using these modules.\n\n### GMII\n\nThe `GmiiSource` and `GmiiSink` classes can be used to drive, receive, and monitor GMII traffic.  The `GmiiSource` drives GMII traffic into a design.  The `GmiiSink` receives GMII traffic, including monitoring internal interfaces.  The `GmiiPhy` class is a wrapper around `GmiiSource` and `GmiiSink` that also provides clocking and rate-switching to emulate a GMII PHY chip.\n\nTo use these modules, import the one you need and connect it to the DUT:\n\n    from cocotbext.eth import GmiiSource, GmiiSink\n\n    gmii_source = GmiiSource(dut.rxd, dut.rx_er, dut.rx_en, dut.clk, dut.rst)\n    gmii_sink = GmiiSink(dut.txd, dut.tx_er, dut.tx_en, dut.clk, dut.rst)\n\nTo send data into a design with a `GmiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `GmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:\n\n    await gmii_source.send(GmiiFrame.from_payload(b'test data'))\n    # wait for operation to complete (optional)\n    await gmii_source.wait()\n\nIt is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `GmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:\n\n    frame = GmiiFrame.from_payload(b'test data', tx_complete=Event())\n    await gmii_source.send(frame)\n    await frame.tx_complete.wait()\n    print(frame.tx_complete.data.sim_time_sfd)\n\nTo receive data with a `GmiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.\n\n    data = await gmii_sink.recv()\n\nThe `GmiiPhy` class provides a model of a GMII PHY chip.  It wraps instances of `GmiiSource` (`rx`) and `GmiiSink` (`tx`), provides the necessary clocking components, and provides the `set_speed()` method to change the link speed.  `set_speed()` changes the `tx_clk` and `rx_clk` frequencies, switches between `gtx_clk` and `tx_clk`, and selects the appropriate mode (MII or GMII) on the source and sink instances.  In general, the `GmiiPhy` class is intended to be used for integration tests where the design expects to be directly connected to an external GMII PHY chip and contains all of the necessary IO and clocking logic.  Example:\n\n    from cocotbext.eth import GmiiFrame, GmiiPhy\n\n    gmii_phy = GmiiPhy(dut.txd, dut.tx_er, dut.tx_en, dut.tx_clk, dut.gtx_clk,\n        dut.rxd, dut.rx_er, dut.rx_en, dut.rx_clk, dut.rst, speed=1000e6)\n\n    gmii_phy.set_speed(100e6)\n\n    await gmii_phy.rx.send(GmiiFrame.from_payload(b'test RX data'))\n    tx_data = await gmii_phy.tx.recv()\n\n#### Signals\n\n* `txd`, `rxd`: data\n* `tx_er`, `rx_er`: error (when asserted with `tx_en` or `rx_dv`)\n* `tx_en`, `rx_dv`: data valid\n\n#### Constructor parameters:\n\n* _data_: data signal (txd, rxd, etc.)\n* _er_: error signal (tx_er, rx_er, etc.) (optional)\n* _dv_: data valid signal (tx_en, rx_dv, etc.)\n* _clock_: clock signal\n* _reset_: reset signal (optional)\n* _enable_: clock enable (optional)\n* _mii_select_: MII mode select (optional)\n* _reset_active_level_: reset active level (optional, default `True`)\n\n#### Attributes:\n\n* _queue_occupancy_bytes_: number of bytes in queue\n* _queue_occupancy_frames_: number of frames in queue\n* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)\n* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)\n* _mii_mode_: control MII mode when _mii_select_ signal is not connected\n\n#### Methods\n\n* `send(frame)`: send _frame_ (blocking) (source)\n* `send_nowait(frame)`: send _frame_ (non-blocking) (source)\n* `recv()`: receive a frame as a `GmiiFrame` (blocking) (sink)\n* `recv_nowait()`: receive a frame as a `GmiiFrame` (non-blocking) (sink)\n* `count()`: returns the number of items in the queue (all)\n* `empty()`: returns _True_ if the queue is empty (all)\n* `full()`: returns _True_ if the queue occupancy limits are met (source)\n* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)\n* `clear()`: drop all data in queue (all)\n* `wait()`: wait for idle (source)\n* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)\n\n#### GMII timing diagram\n\nExample transfer via GMII at 1 Gbps:\n\n                  __    __    __    __    _       __    __    __    __\n    tx_clk     __/  \\__/  \\__/  \\__/  \\__/  ... _/  \\__/  \\__/  \\__/  \\__\n                        _____ _____ _____ _     _ _____ _____\n    tx_d[7:0]  XXXXXXXXX_55__X_55__X_55__X_ ... _X_72__X_fb__XXXXXXXXXXXX\n\n    tx_er      ____________________________ ... _________________________\n                        ___________________     _____________\n    tx_en      ________/                    ...              \\___________\n\n\n#### GmiiFrame object\n\nThe `GmiiFrame` object is a container for a frame to be transferred via GMII.  The `data` field contains the packet data in the form of a list of bytes.  `error` contains the `er` signal level state associated with each byte as a list of ints.\n\nAttributes:\n\n* `data`: bytearray\n* `error`: error field, optional; list, each entry qualifies the corresponding entry in `data`.\n* `sim_time_start`: simulation time of first transfer cycle of frame.\n* `sim_time_sfd`: simulation time at which the SFD was transferred.\n* `sim_time_end`: simulation time of last transfer cycle of frame.\n* `start_lane`: byte lane in which the start control character was transferred.\n* `tx_complete`: event or callable triggered when frame is transmitted.\n\nMethods:\n\n* `from_payload(payload, min_len=60)`: create `GmiiFrame` from payload data, inserts preamble, zero-pads frame to minimum length and computes and inserts FCS (class method)\n* `from_raw_payload(payload)`: create `GmiiFrame` from payload data, inserts preamble only (class method)\n* `get_preamble_len()`: locate SFD and return preamble length\n* `get_preamble()`: return preamble\n* `get_payload(strip_fcs=True)`: return payload, optionally strip FCS\n* `get_fcs()`: return FCS\n* `check_fcs()`: returns _True_ if FCS is correct\n* `normalize()`: pack `error` to the same length as `data`, replicating last element if necessary, initialize to list of `0` if not specified.\n* `compact()`: remove `error` if all zero\n\n### MII\n\nThe `MiiSource` and `MiiSink` classes can be used to drive, receive, and monitor MII traffic.  The `MiiSource` drives MII traffic into a design.  The `MiiSink` receives MII traffic, including monitoring internal interfaces.  The `MiiPhy` class is a wrapper around `MiiSource` and `MiiSink` that also provides clocking and rate-switching to emulate an MII PHY chip.\n\nTo use these modules, import the one you need and connect it to the DUT:\n\n    from cocotbext.eth import MiiSource, MiiSink\n\n    mii_source = MiiSource(dut.rxd, dut.rx_er, dut.rx_en, dut.clk, dut.rst)\n    mii_sink = MiiSink(dut.txd, dut.tx_er, dut.tx_en, dut.clk, dut.rst)\n\nAll signals must be passed separately into these classes.\n\nTo send data into a design with an `MiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `GmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:\n\n    await mii_source.send(GmiiFrame.from_payload(b'test data'))\n    # wait for operation to complete (optional)\n    await mii_source.wait()\n\nIt is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `GmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:\n\n    frame = GmiiFrame.from_payload(b'test data', tx_complete=Event())\n    await mii_source.send(frame)\n    await frame.tx_complete.wait()\n    print(frame.tx_complete.data.sim_time_sfd)\n\nTo receive data with an `MiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.\n\n    data = await mii_sink.recv()\n\nThe `MiiPhy` class provides a model of an MII PHY chip.  It wraps instances of `MiiSource` (`rx`) and `MiiSink` (`tx`), provides the necessary clocking components, and provides the `set_speed()` method to change the link speed.  `set_speed()` changes the `tx_clk` and `rx_clk` frequencies.  In general, the `MiiPhy` class is intended to be used for integration tests where the design expects to be directly connected to an external MII PHY chip and contains all of the necessary IO and clocking logic.  Example:\n\n    from cocotbext.eth import GmiiFrame, MiiPhy\n\n    mii_phy = MiiPhy(dut.txd, dut.tx_er, dut.tx_en, dut.tx_clk,\n        dut.rxd, dut.rx_er, dut.rx_en, dut.rx_clk, dut.rst, speed=100e6)\n\n    mii_phy.set_speed(10e6)\n\n    await mii_phy.rx.send(GmiiFrame.from_payload(b'test RX data'))\n    tx_data = await mii_phy.tx.recv()\n\n#### Signals\n\n* `txd`, `rxd`: data\n* `tx_er`, `rx_er`: error (when asserted with `tx_en` or `rx_dv`)\n* `tx_en`, `rx_dv`: data valid\n\n#### Constructor parameters:\n\n* _data_: data signal (txd, rxd, etc.)\n* _er_: error signal (tx_er, rx_er, etc.) (optional)\n* _dv_: data valid signal (tx_en, rx_dv, etc.)\n* _clock_: clock signal\n* _reset_: reset signal (optional)\n* _enable_: clock enable (optional)\n* _reset_active_level_: reset active level (optional, default `True`)\n\n#### Attributes:\n\n* _queue_occupancy_bytes_: number of bytes in queue\n* _queue_occupancy_frames_: number of frames in queue\n* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)\n* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)\n\n#### Methods\n\n* `send(frame)`: send _frame_ (blocking) (source)\n* `send_nowait(frame)`: send _frame_ (non-blocking) (source)\n* `recv()`: receive a frame as a `GmiiFrame` (blocking) (sink)\n* `recv_nowait()`: receive a frame as a `GmiiFrame` (non-blocking) (sink)\n* `count()`: returns the number of items in the queue (all)\n* `empty()`: returns _True_ if the queue is empty (all)\n* `full()`: returns _True_ if the queue occupancy limits are met (source)\n* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)\n* `clear()`: drop all data in queue (all)\n* `wait()`: wait for idle (source)\n* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)\n\n#### MII timing diagram\n\nExample transfer via MII at 100 Mbps:\n\n                 _   _   _   _   _   _       _   _   _   _\n    tx_clk     _/ \\_/ \\_/ \\_/ \\_/ \\_/  ... _/ \\_/ \\_/ \\_/ \\_\n                     ___ ___ ___ ___ _     _ ___ ___\n    tx_d[3:0]  XXXXXX_5_X_5_X_5_X_5_X_ ... _X_f_X_b_XXXXXXXX\n\n    tx_er      _______________________ ... _________________\n                     _________________     _________\n    tx_en      _____/                  ...          \\_______\n\n\n### RGMII\n\nThe `RgmiiSource` and `RgmiiSink` classes can be used to drive, receive, and monitor RGMII traffic.  The `RgmiiSource` drives RGMII traffic into a design.  The `RgmiiSink` receives RGMII traffic, including monitoring internal interfaces.  The `RgmiiPhy` class is a wrapper around `RgmiiSource` and `RgmiiSink` that also provides clocking and rate-switching to emulate an RGMII PHY chip.\n\nTo use these modules, import the one you need and connect it to the DUT:\n\n    from cocotbext.eth import RgmiiSource, RgmiiSink\n\n    rgmii_source = RgmiiSource(dut.rxd, dut.rx_ctl, dut.clk, dut.rst)\n    rgmii_sink = RgmiiSink(dut.txd, dut.tx_ctl, dut.clk, dut.rst)\n\nAll signals must be passed separately into these classes.\n\nTo send data into a design with an `RgmiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `GmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:\n\n    await rgmii_source.send(GmiiFrame.from_payload(b'test data'))\n    # wait for operation to complete (optional)\n    await rgmii_source.wait()\n\nIt is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `GmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:\n\n    frame = GmiiFrame.from_payload(b'test data', tx_complete=Event())\n    await rgmii_source.send(frame)\n    await frame.tx_complete.wait()\n    print(frame.tx_complete.data.sim_time_sfd)\n\nTo receive data with an `RgmiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.\n\n    data = await rgmii_sink.recv()\n\nThe `RgmiiPhy` class provides a model of an RGMII PHY chip.  It wraps instances of `RgmiiSource` (`rx`) and `RgmiiSink` (`tx`), provides the necessary clocking components, and provides the `set_speed()` method to change the link speed.  `set_speed()` changes the `rx_clk` frequency and selects the appropriate mode (SDR or DDR) on the source and sink instances.  In general, the `RgmiiPhy` class is intended to be used for integration tests where the design expects to be directly connected to an external RGMII PHY chip and contains all of the necessary IO and clocking logic.  Example:\n\n    from cocotbext.eth import GmiiFrame, RgmiiPhy\n\n    rgmii_phy = RgmiiPhy(dut.txd, dut.tx_ctl, dut.tx_clk,\n        dut.rxd, dut.rx_ctl, dut.rx_clk, dut.rst, speed=1000e6)\n\n    rgmii_phy.set_speed(100e6)\n\n    await rgmii_phy.rx.send(GmiiFrame.from_payload(b'test RX data'))\n    tx_data = await rgmii_phy.tx.recv()\n\n#### Signals\n\n* `txd`, `rxd`: data (DDR)\n* `tx_ctl`, `rx_ctl`: control (DDR, combination of valid and error)\n\n#### Constructor parameters:\n\n* _data_: data signal (txd, rxd, etc.)\n* _ctrl_: control\n* _clock_: clock signal\n* _reset_: reset signal (optional)\n* _enable_: clock enable (optional)\n* _mii_select_: MII mode select (optional)\n* _reset_active_level_: reset active level (optional, default `True`)\n\n#### Attributes:\n\n* _queue_occupancy_bytes_: number of bytes in queue\n* _queue_occupancy_frames_: number of frames in queue\n* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)\n* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)\n* _mii_mode_: control MII mode when _mii_select_ signal is not connected\n\n#### Methods\n\n* `send(frame)`: send _frame_ (blocking) (source)\n* `send_nowait(frame)`: send _frame_ (non-blocking) (source)\n* `recv()`: receive a frame as a `GmiiFrame` (blocking) (sink)\n* `recv_nowait()`: receive a frame as a `GmiiFrame` (non-blocking) (sink)\n* `count()`: returns the number of items in the queue (all)\n* `empty()`: returns _True_ if the queue is empty (all)\n* `full()`: returns _True_ if the queue occupancy limits are met (source)\n* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)\n* `clear()`: drop all data in queue (all)\n* `wait()`: wait for idle (source)\n* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)\n\n#### RGMII timing diagram\n\nExample transfer via RGMII at 1 Gbps:\n\n                 ___     ___     ___     _       ___     ___\n    tx_clk     _/   \\___/   \\___/   \\___/  ... _/   \\___/   \\___\n                       ___ ___ ___ ___ ___     ___ ___\n    tx_d[3:0]  XXXXXXXX_5_X_5_X_5_X_5_X_5_ ... _f_X_b_XXXXXXXXXX\n                       ___________________     _______\n    tx_ctl     _______/                    ...        \\_________\n\n\n### XGMII\n\nThe `XgmiiSource` and `XgmiiSink` classes can be used to drive, receive, and monitor XGMII traffic.  The `XgmiiSource` drives XGMII traffic into a design.  The `XgmiiSink` receives XGMII traffic, including monitoring internal interfaces.  The modules are capable of operating with XGMII interface widths of 32 or 64 bits.\n\nTo use these modules, import the one you need and connect it to the DUT:\n\n    from cocotbext.eth import XgmiiSource, XgmiiSink\n\n    xgmii_source = XgmiiSource(dut.rxd, dut.rxc, dut.clk, dut.rst)\n    xgmii_sink = XgmiiSink(dut.txd, dut.txc, dut.clk, dut.rst)\n\nAll signals must be passed separately into these classes.\n\nTo send data into a design with an `XgmiiSource`, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `XgmiiFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:\n\n    await xgmii_source.send(XgmiiFrame.from_payload(b'test data'))\n    # wait for operation to complete (optional)\n    await xgmii_source.wait()\n\nIt is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `XgmiiFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:\n\n    frame = XgmiiFrame.from_payload(b'test data', tx_complete=Event())\n    await xgmii_source.send(frame)\n    await frame.tx_complete.wait()\n    print(frame.tx_complete.data.sim_time_sfd)\n\nTo receive data with an `XgmiiSink`, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.\n\n    data = await xgmii_sink.recv()\n\n#### Signals\n\n* `txd`, `rxd`: data\n* `txc`, `rxc`: control\n\n#### Constructor parameters:\n\n* _data_: data signal (txd, rxd, etc.)\n* _ctrl_: control signal (txc, rxc, etc.)\n* _clock_: clock signal\n* _reset_: reset signal (optional)\n* _enable_: clock enable (optional)\n* _reset_active_level_: reset active level (optional, default `True`)\n\n#### Attributes:\n\n* _queue_occupancy_bytes_: number of bytes in queue\n* _queue_occupancy_frames_: number of frames in queue\n* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (source only)\n* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (source only)\n\n#### Methods\n\n* `send(frame)`: send _frame_ (blocking) (source)\n* `send_nowait(frame)`: send _frame_ (non-blocking) (source)\n* `recv()`: receive a frame as an `XgmiiFrame` (blocking) (sink)\n* `recv_nowait()`: receive a frame as an `XgmiiFrame` (non-blocking) (sink)\n* `count()`: returns the number of items in the queue (all)\n* `empty()`: returns _True_ if the queue is empty (all)\n* `full()`: returns _True_ if the queue occupancy limits are met (source)\n* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)\n* `clear()`: drop all data in queue (all)\n* `wait()`: wait for idle (source)\n* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)\n\n#### XGMII timing diagram\n\nExample transfer via 64-bit XGMII:\n\n                  __    __    __    __    __    _       __    __\n    tx_clk     __/  \\__/  \\__/  \\__/  \\__/  \\__/  ... _/  \\__/  \\__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[63:56] __X_07__X_d5__X_51__X_01__X_09__X_ ... _X_fb__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[55:48] __X_07__X_55__X_5a__X_00__X_08__X_ ... _X_72__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[47:40] __X_07__X_55__X_d5__X_00__X_07__X_ ... _X_0d__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[39:32] __X_07__X_55__X_d4__X_80__X_06__X_ ... _X_37__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[31:24] __X_07__X_55__X_d3__X_55__X_05__X_ ... _X_2d__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[23:16] __X_07__X_55__X_d2__X_54__X_04__X_ ... _X_2c__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[15:8]  __X_07__X_55__X_d1__X_53__X_03__X_ ... _X_2b__X_07__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txd[7:0]   __X_07__X_fb__X_da__X_52__X_02__X_ ... _X_2a__X_fd__\n               __ _____ _____ _____ _____ _____ _     _ _____ _____\n    txc[7:0]   __X_ff__X_01__X_00__X_00__X_00__X_ ... _X_00__X_ff__\n\n\n#### XgmiiFrame object\n\nThe `XgmiiFrame` object is a container for a frame to be transferred via XGMII.  The `data` field contains the packet data in the form of a list of bytes.  `ctrl` contains the control signal level state associated with each byte as a list of ints.  When `ctrl` is high, the corresponding `data` byte is interpreted as an XGMII control character.\n\nAttributes:\n\n* `data`: bytearray\n* `ctrl`: control field, optional; list, each entry qualifies the corresponding entry in `data` as an XGMII control character.\n* `sim_time_start`: simulation time of first transfer cycle of frame.\n* `sim_time_sfd`: simulation time at which the SFD was transferred.\n* `sim_time_end`: simulation time of last transfer cycle of frame.\n* `start_lane`: byte lane in which the start control character was transferred.\n* `tx_complete`: event or callable triggered when frame is transmitted.\n\nMethods:\n\n* `from_payload(payload, min_len=60)`: create `XgmiiFrame` from payload data, inserts preamble, zero-pads frame to minimum length and computes and inserts FCS (class method)\n* `from_raw_payload(payload)`: create `XgmiiFrame` from payload data, inserts preamble only (class method)\n* `get_preamble_len()`: locate SFD and return preamble length\n* `get_preamble()`: return preamble\n* `get_payload(strip_fcs=True)`: return payload, optionally strip FCS\n* `get_fcs()`: return FCS\n* `check_fcs()`: returns _True_ if FCS is correct\n* `normalize()`: pack `ctrl` to the same length as `data`, replicating last element if necessary, initialize to list of `0` if not specified.\n* `compact()`: remove `ctrl` if all zero\n\n### Ethernet MAC model\n\nThe `EthMac`, `EthMacTx` and `EthMacRx` modules are models of an Ethernet MAC with an AXI stream interface.  The `EthMacRx` module drives Ethernet frames in the form of AXI stream traffic into a design.  The `EthMacTx` module accepts Ethernet frames in the form of AXI stream traffic from a design.  `EthMac` is a wrapper module containing `EthMacRx` (`rx`) and `EthMacTx` (`tx`).  The modules are capable of operating with any interface width.  The MAC models enforce the correct data rates and timings in both the receive and transmit direction, and can also collect PTP timestamps from a PTP hardware clock.\n\nTo use these modules, import the one you need and connect it to the DUT:\n\n    from cocotbext.axi import AxiStreamBus\n    from cocotbext.eth import EthMac\n\n    mac = EthMac(\n        tx_clk=dut.tx_clk,\n        tx_rst=dut.tx_rst,\n        tx_bus=AxiStreamBus.from_prefix(dut, \"tx_axis\"),\n        tx_ptp_time=dut.tx_ptp_time,\n        tx_ptp_ts=dut.tx_ptp_ts,\n        tx_ptp_ts_tag=dut.tx_ptp_ts_tag,\n        tx_ptp_ts_valid=dut.tx_ptp_ts_valid,\n        rx_clk=dut.rx_clk,\n        rx_rst=dut.rx_rst,\n        rx_bus=AxiStreamBus.from_prefix(dut, \"rx_axis\"),\n        rx_ptp_time=dut.rx_ptp_time,\n        ifg=12, speed=speed\n    )\n\nTo send data into a design, call `send()` or `send_nowait()`.  Accepted data types are iterables that can be converted to bytearray or `EthMacFrame` objects.  Optionally, call `wait()` to wait for the transmit operation to complete.  Example:\n\n    await mac.tx.send(EthMacFrame.from_payload(b'test data'))\n    # wait for operation to complete (optional)\n    await mac.tx.wait()\n\nIt is also possible to wait for the transmission of a specific frame to complete by passing an event in the tx_complete field of the `EthMacFrame` object, and then awaiting the event.  The frame, with simulation time fields set, will be returned in the event data.  Example:\n\n    frame = EthMacFrame.from_payload(b'test data', tx_complete=Event())\n    await mac.tx.send(frame)\n    await frame.tx_complete.wait()\n    print(frame.tx_complete.data.sim_time_sfd)\n\nTo receive data, call `recv()` or `recv_nowait()`.  Optionally call `wait()` to wait for new receive data.\n\n    data = await mac.tx.recv()\n\nPTP timestamping requires free-running PTP clocks driving the PTP time inputs, synchronous with the corresponding MAC clocks.  The values of these fields are then captured when the frame SFD is transferred and returned either on tuser (for received frames) or on a separate streaming interface (for transmitted frames).  Additionally, on the transmit path, a tag value from tuser is returned along with the timestamp.\n\n#### Signals\n\n* `tdata`: payload data, must be a multiple of 8 bits\n* `tvalid`: qualifies all other signals\n* `tready`: indicates sink is ready for data (tx only)\n* `tlast`: marks the last cycle of a frame\n* `tkeep`: qualifies data byte, data bus width must be evenly divisible by `tkeep` signal width\n* `tuser`: user data, carries frame error mark and captured receive PTP timestamp (RX) or PTP timestamp tag (TX)\n* `ptp_time`: PTP time input from PHC, captured into `ptp_timestamp` field coincident with transfer of frame SFD and output on `ptp_ts` (TX) or `tuser` (RX)\n* `ptp_ts`: captured transmit PTP timestamp\n* `ptp_ts_tag`: captured transmit PTP timestamp tag\n* `ptp_ts_valid`: qualifies captured transmit PTP timestamp\n\n#### Constructor parameters (`EthMacRx` and `EthMacTx`):\n\n* _bus_: `AxiStreamBus` object containing AXI stream interface signals\n* _clock_: clock signal\n* _reset_: reset signal (optional)\n* _ptp_time_: PTP time input from PHC (optional)\n* _ptp_ts_: PTP timestamp (optional) (tx)\n* _ptp_ts_tag_: PTP timestamp tag (optional) (tx)\n* _ptp_ts_valid_: PTP timestamp valid (optional) (tx)\n* _reset_active_level_: reset active level (optional, default `True`)\n* _ifg_: IFG size in byte times (optional, default `12`)\n* _speed_: link speed in bits per second (optional, default `1000e6`)\n\n#### Constructor parameters (`EthMac`):\n\n* _tx_bus_: `AxiStreamBus` object containing transmit AXI stream interface signals\n* _tx_clk_: transmit clock\n* _tx_rst_: transmit reset (optional)\n* _tx_ptp_time_: transmit PTP time input from PHC (optional)\n* _tx_ptp_ts_: transmit PTP timestamp (optional)\n* _tx_ptp_ts_tag_: transmit PTP timestamp tag (optional)\n* _tx_ptp_ts_valid_: transmit PTP timestamp valid (optional)\n* _rx_bus_: `AxiStreamBus` object containing receive AXI stream interface signals\n* _rx_clk_: receive clock\n* _rx_rst_: receive reset (optional)\n* _rx_ptp_time_: receive PTP time input from PHC (optional)\n* _reset_active_level_: reset active level (optional, default `True`)\n* _ifg_: IFG size in byte times (optional, default `12`)\n* _speed_: link speed in bits per second (optional, default `1000e6`)\n\n#### Attributes:\n\n* _queue_occupancy_bytes_: number of bytes in queue\n* _queue_occupancy_frames_: number of frames in queue\n* _queue_occupancy_limit_bytes_: max number of bytes in queue allowed before backpressure is applied (RX only)\n* _queue_occupancy_limit_frames_: max number of frames in queue allowed before backpressure is applied (RX only)\n* _ifg_: IFG size in byte times\n* _speed_: link speed in bits per second\n\n#### Methods\n\n* `send(frame)`: send _frame_ (blocking) (rx)\n* `send_nowait(frame)`: send _frame_ (non-blocking) (rx)\n* `recv()`: receive a frame as an `EthMacFrame` (blocking) (tx)\n* `recv_nowait()`: receive a frame as an `EthMacFrame` (non-blocking) (tx)\n* `count()`: returns the number of items in the queue (all)\n* `empty()`: returns _True_ if the queue is empty (all)\n* `full()`: returns _True_ if the queue occupancy limits are met (rx)\n* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (rx)\n* `clear()`: drop all data in queue (all)\n* `wait()`: wait for idle (rx)\n* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (tx)\n\n#### EthMacFrame object\n\nThe `EthMacFrame` object is a container for a frame to be transferred via XGMII.  The `data` field contains the packet data in the form of a list of bytes.\n\nAttributes:\n\n* `data`: bytearray\n* `sim_time_start`: simulation time of first transfer cycle of frame.\n* `sim_time_sfd`: simulation time at which the SFD was transferred.\n* `sim_time_end`: simulation time of last transfer cycle of frame.\n* `ptp_tag`: PTP timestamp tag for transmitted frames.\n* `ptp_timestamp`: captured value of `ptp_time` at frame SFD\n* `tx_complete`: event or callable triggered when frame is transmitted.\n\nMethods:\n\n* `from_payload(payload, min_len=60)`: create `EthMacFrame` from payload data, zero-pads frame to minimum length and computes and inserts FCS (class method)\n* `from_raw_payload(payload)`: create `EthMacFrame` from payload data (class method)\n* `get_payload(strip_fcs=True)`: return payload, optionally strip FCS\n* `get_fcs()`: return FCS\n* `check_fcs()`: returns _True_ if FCS is correct\n\n### PTP clock\n\nThe `PtpClock` class implements a PTP hardware clock that produces IEEE 1588 format 96 and 64 bit PTP timestamps.\n\nTo use this module, import it and connect it to the DUT:\n\n    from cocotbext.eth import PtpClock\n\n    ptp_clock = PtpClock(\n        ts_96=dut.ts_96,\n        ts_64=dut.ts_64,\n        ts_step=dut.ts_step,\n        pps=dut.pps,\n        clock=dut.clk,\n        reset=dut.reset,\n        period_ns=6.4\n    )\n\nOnce the clock is instantiated, it will generate a continuous stream of monotonically increasing PTP timestamps on every clock edge.\n\n#### Signals\n\n* `ts_96`: 96-bit timestamp (48 bit seconds, 32 bit ns, 16 bit fractional ns)\n* `ts_64`: 64-bit timestamp (48 bit ns, 16 bit fractional ns)\n* `ts_step`: step output, pulsed when non-monotonic step occurs\n* `pps`: pulse-per-second output, pulsed when ts_96 seconds field increments\n\n#### Constructor parameters:\n\n* _ts_96_: 96-bit timestamp signal (optional)\n* _ts_64_: 64-bit timestamp signal (optional)\n* _ts_step_: timestamp step signal (optional)\n* _pps_: pulse-per-second signal (optional)\n* _clock_: clock\n* _reset_: reset (optional)\n* _reset_active_level_: reset active level (optional, default `True`)\n* _period_ns_: clock period (nanoseconds, default `6.4`)\n\n#### Attributes:\n\n* _ts_96_s_: current 96-bit timestamp seconds field\n* _ts_96_ns_: current 96-bit timestamp ns field\n* _ts_96_fns_: current 96-bit timestamp fractional ns field\n* _ts_64_ns_: current 64-bit timestamp ns field\n* _ts_64_fns_: current 64-bit timestamp fractional ns field\n\n#### Methods\n\n* `set_period(ns, fns)`: set clock period from separate fields\n* `set_drift(ns, fns, rate)`: set clock drift from separate fields\n* `set_period_ns(t)`: set clock period in ns (float)\n* `get_period_ns()`: return current clock period in ns (float)\n* `set_ts_96(ts_s, ts_ns=None, ts_fns=None)`: set 96-bit timestamp from integer or from separate fields\n* `set_ts_96_ns(t)`: set 96-bit timestamp from ns (float)\n* `set_ts_96_s(t)`: set 96-bit timestamp from seconds (float)\n* `get_ts_96()`: return current 96-bit timestamp as an integer\n* `get_ts_96_ns()`: return current 96-bit timestamp in ns (float)\n* `get_ts_96_s()`: return current 96-bit timestamp in seconds (float)\n* `set_ts_64(ts_ns, ts_fns=None)`: set 64-bit timestamp from integer or from separate fields\n* `set_ts_64_ns(t)`: set 64-bit timestamp from ns (float)\n* `set_ts_64_s(t)`: set 64-bit timestamp from seconds (float)\n* `get_ts_64()`: return current 64-bit timestamp as an integer\n* `get_ts_64_ns()`: return current 64-bit timestamp in ns (float)\n* `get_ts_64_s()`: return current 64-bit timestamp in seconds (float)\n\n### PTP clock (sim time)\n\nThe `PtpClockSimTime` class implements a PTP hardware clock that produces IEEE 1588 format 96 and 64 bit PTP timestamps, derived from the current simulation time.  This module can be used in place of `PtpClock` so that captured PTP timestamps can be easily compared to captured simulation time.\n\nTo use this module, import it and connect it to the DUT:\n\n    from cocotbext.eth import PtpClockSimTime\n\n    ptp_clock = PtpClockSimTime(\n        ts_96=dut.ts_96,\n        ts_64=dut.ts_64,\n        pps=dut.pps,\n        clock=dut.clk\n    )\n\nOnce the clock is instantiated, it will generate a continuous stream of monotonically increasing PTP timestamps on every clock edge.\n\n#### Signals\n\n* `ts_96`: 96-bit timestamp (48 bit seconds, 32 bit ns, 16 bit fractional ns)\n* `ts_64`: 64-bit timestamp (48 bit ns, 16 bit fractional ns)\n* `pps`: pulse-per-second output, pulsed when ts_96 seconds field increments\n\n#### Constructor parameters:\n\n* _ts_96_: 96-bit timestamp signal (optional)\n* _ts_64_: 64-bit timestamp signal (optional)\n* _pps_: pulse-per-second signal (optional)\n* _clock_: clock\n\n#### Attributes:\n\n* _ts_96_s_: current 96-bit timestamp seconds field\n* _ts_96_ns_: current 96-bit timestamp ns field\n* _ts_96_fns_: current 96-bit timestamp fractional ns field\n* _ts_64_ns_: current 64-bit timestamp ns field\n* _ts_64_fns_: current 64-bit timestamp fractional ns field\n\n#### Methods\n\n* `get_ts_96()`: return current 96-bit timestamp as an integer\n* `get_ts_96_ns()`: return current 96-bit timestamp in ns (float)\n* `get_ts_96_s()`: return current 96-bit timestamp in seconds (float)\n* `get_ts_64()`: return current 64-bit timestamp as an integer\n* `get_ts_64_ns()`: return current 64-bit timestamp in ns (float)\n* `get_ts_64_s()`: return current 64-bit timestamp in seconds (float)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ethernet interface modules for cocotb",
    "version": "0.1.20",
    "split_keywords": [
        "ethernet",
        "cocotb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d93675b01d91dd2b91ad5c64c90b1d624e2ae4388d09279f0a2c1f0170f7511",
                "md5": "c4f278806ede5171b0175e00a5147efc",
                "sha256": "076dac5b8e244dd7eb5a04c829f20d88d2bf0ab4e078ffda6afdfe26bc21fc68"
            },
            "downloads": -1,
            "filename": "cocotbext_eth-0.1.20-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c4f278806ede5171b0175e00a5147efc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 33171,
            "upload_time": "2023-01-26T02:55:44",
            "upload_time_iso_8601": "2023-01-26T02:55:44.015829Z",
            "url": "https://files.pythonhosted.org/packages/2d/93/675b01d91dd2b91ad5c64c90b1d624e2ae4388d09279f0a2c1f0170f7511/cocotbext_eth-0.1.20-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e965086cb68fc962a66b9f232bd11aa6a67cecd1e516149f01d130f61d494c3",
                "md5": "af355a6c16df75c22f0fd74e49e4427b",
                "sha256": "0a70c28855a95c391d9db872fdb3b1fd5736c5b06507146d3cdd8d673406c39d"
            },
            "downloads": -1,
            "filename": "cocotbext-eth-0.1.20.tar.gz",
            "has_sig": false,
            "md5_digest": "af355a6c16df75c22f0fd74e49e4427b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 40506,
            "upload_time": "2023-01-26T02:55:46",
            "upload_time_iso_8601": "2023-01-26T02:55:46.290579Z",
            "url": "https://files.pythonhosted.org/packages/5e/96/5086cb68fc962a66b9f232bd11aa6a67cecd1e516149f01d130f61d494c3/cocotbext-eth-0.1.20.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-26 02:55:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "alexforencich",
    "github_project": "cocotbext-eth",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cocotbext-eth"
}
        
Elapsed time: 0.03210s