"""Common utilities for cocotb testbenches.""" from __future__ import annotations import re from collections import defaultdict from pathlib import Path from typing import Any from systemrdl import RDLCompiler from systemrdl.node import AddressableNode, AddrmapNode, RegNode from peakrdl_busdecoder.cpuif.base_cpuif import BaseCpuif from peakrdl_busdecoder.exporter import BusDecoderExporter RESET = "\x1b[0m" DIM = "\x1b[2m" LEVEL_COLORS = { "DEBUG": "\x1b[35m", # magenta "INFO": "\x1b[36m", # cyan "WARNING": "\x1b[33m", # yellow "ERROR": "\x1b[31m", # red "CRITICAL": "\x1b[1;31m", # bold red } # Matches lines like: # " 0.00ns INFO cocotb ..." or "-.--ns INFO gpi ..." LINE_RE = re.compile( r"^(?P\s*)" # leading spaces r"(?P