Skip to content

Commit 41d0035

Browse files
committed
wip
1 parent b4ba320 commit 41d0035

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

software/glasgow/applet/interface/ethernet/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Ref: IEEE Std 802.3-2018
22
# Accession: G00098
33

4-
from typing import Iterable, AsyncIterator, BinaryIO
4+
from typing import BinaryIO
5+
from collections.abc import AsyncIterator
56
import time
67
import logging
78
import asyncio
@@ -17,7 +18,7 @@
1718
from glasgow.arch.ieee802_3 import *
1819
from glasgow.gateware import cobs, ethernet
1920
from glasgow.protocol import snoop
20-
from glasgow.abstract import AbstractAssembly, GlasgowPin
21+
from glasgow.abstract import AbstractAssembly
2122
from glasgow.applet import GlasgowAppletV2
2223
from glasgow.applet.control.mdio import ControlMDIOInterface
2324

@@ -69,15 +70,16 @@ def __init__(self, logger: logging.Logger, assembly: AbstractAssembly, *,
6970
self._rx_bypass = assembly.add_rw_register(component.rx_bypass)
7071
self._tx_bypass = assembly.add_rw_register(component.tx_bypass)
7172

72-
self._snoop: snoop.SnoopWriter = None
73+
self._snoop: snoop.SnoopWriter | None = None
7374

7475
def _log(self, message: str, *args):
7576
self._logger.log(self._level, "Ethernet: " + message, *args)
7677

7778
@property
78-
def snoop_file(self) -> BinaryIO:
79+
def snoop_file(self) -> BinaryIO | None:
7980
if self._snoop is not None:
8081
return self._snoop.file
82+
return None
8183

8284
@snoop_file.setter
8385
def snoop_file(self, snoop_file):
@@ -128,6 +130,8 @@ class AbstractEthernetApplet(GlasgowAppletV2):
128130
sudo ip link set glasgow0 up
129131
"""
130132
required_revision = "C0"
133+
eth_iface: AbstractEthernetInterface
134+
mdio_iface: ControlMDIOInterface
131135

132136
@classmethod
133137
def add_setup_arguments(cls, parser):
@@ -208,7 +212,7 @@ async def forward_tx():
208212
self.logger.warning("packet bad (crc)")
209213
count_bad += 1
210214
await asyncio.sleep(args.delay)
211-
except asyncio.TimeoutError:
215+
except TimeoutError:
212216
self.logger.warning("packet lost")
213217
count_lost += 1
214218
finally:

software/glasgow/applet/interface/ethernet/rgmii/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
# Accession: G00099
55

66
import logging
7-
import asyncio
87

98
from amaranth import *
10-
from amaranth.lib import enum, wiring, io, cdc
11-
from amaranth.lib.wiring import In, Out
9+
from amaranth.lib import io
1210

1311
from glasgow.arch.ieee802_3 import *
1412
from glasgow.gateware.ethernet import AbstractDriver
1513
from glasgow.gateware.iostream import StreamIOBuffer
1614
from glasgow.gateware.ports import PortGroup
17-
from glasgow.gateware.pll import PLL
1815
from glasgow.gateware.iodelay import IODelay
1916
from glasgow.abstract import AbstractAssembly, GlasgowPin
2017
from glasgow.applet.interface.ethernet import AbstractEthernetInterface, AbstractEthernetApplet

software/glasgow/gateware/ethernet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from amaranth import *
2-
from amaranth.lib import enum, data, wiring, stream, io, cdc
2+
from amaranth.lib import data, wiring, stream
33
from amaranth.lib.wiring import In, Out
44
from amaranth.lib.crc.catalog import CRC32_ETHERNET
55

software/glasgow/support/os_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def send(self, packets: list[Buffer]):
4545
except BlockingIOError: # write until the buffer is full
4646
pass
4747

48-
async def recv(self, *, length=65536) -> list[Buffer]:
48+
async def recv(self, *, length=65536) -> list[bytes]:
4949
""""Receive packets.
5050
5151
To improve throughput, :meth:`recv` dequeues all available packets. Packets longer than

0 commit comments

Comments
 (0)