From afbb64023e476d9a576f8cd1f21f14ad9c074b91 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sat, 18 Feb 2023 21:38:33 -0500 Subject: [PATCH] tb: Move BIT to util This function may be useful for other testbenches. Signed-off-by: Sean Anderson --- tb/mdio_regs.py | 3 +-- tb/util.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tb/mdio_regs.py b/tb/mdio_regs.py index cff6287..b9a609a 100644 --- a/tb/mdio_regs.py +++ b/tb/mdio_regs.py @@ -6,8 +6,7 @@ from cocotb.clock import Clock from cocotb.triggers import FallingEdge, Timer from cocotb.types import LogicArray -def BIT(n): - return 1 << n +from .util import BIT BMCR = 0 BMSR = 1 diff --git a/tb/util.py b/tb/util.py index b3a3910..aec0935 100644 --- a/tb/util.py +++ b/tb/util.py @@ -16,6 +16,9 @@ async def async_iter(it): for i in it: yield i +def BIT(n): + return 1 << n + # From https://stackoverflow.com/a/7864317/5086505 class classproperty(property): def __get__(self, cls, owner):