我是 cocotb 的新手,想对 SPI master 进行健全性测试。我编写了一个简单的测试,没有导入驱动程序和监视器,而是从 DUT 调用所有信号。我尝试运行一个简单的测试,报告显示没有语法或缩进错误,但测试没有被启动并发现此消息“未检测到 Python 虚拟环境。使用系统范围的 Python 解释器”如何解决这个问题?
import logging
import cocotb
from cocotb.triggers import RisingEdge, FallingEdge, Timer, ReadOnly
from cocotb.clock import Clock
from cocotb.result import TestFailure
import random
class MasterSpi(object):
INTERFRAME = (100, "ns")
def __init__(self, dut, clock, w_CPOL=0, w_CPHA=1):
self._dut = dut
self._w_CPOL = w_CPOL
self._w_CPHA = w_CPHA
if w_CPOL == 1:
raise Exception("cpol = 1 not implemented yet")
if w_CPHA == 0:
raise Exception("cpha = 0 not implemented yet")
self._clock_thread = cocotb.fork(clock.start())
spi_sigs = SPISignals(
miso=dut.i_SPI_MISO,
mosi=dut.o_SPI_MOSI,
sclk=dut.o_SPI - Clk,
)
self.spi_config = SPIConfig(
w_CPOL=False,
w_CPHA=True,
baudrate=(1, "us"),
csphase=False,
)
self.spimod = SPIModule(self.spi_config, spi_sigs, clock)
@cocotb.coroutine
def reset(self):
print("inside coroutine")
self._dut.i_Rst_L <= 0
short_per = Timer(100, units="ns")
self._dut.i_Rst_L <= 0
self.spimod.set_ss(False)
self._dut.o_SPI_MOSI <= 0
self._dut.o_SPI_Clk <= 0
yield short_per
self._dut.i_Rst_L <= 1
yield short_per