コード例 #1
0
 def __init__(self, dut):
     self.dut = dut
     # TODO: See https://github.com/cocotb/cocotb/issues/2051 for Verilator freeze bug
     self.userrx = AvalonSTMonitor(dut, 'userrx', dut.rx_clk)
     self.tx_csr = AvalonMaster(dut, 'tx_mm', dut.tx_clk)
     self.rx_csr = AvalonMaster(dut, 'rx_mm', dut.rx_clk)
     self.expected_output = []
     self.scoreboard = Scoreboard(dut)
     self.scoreboard.add_interface(self.userrx, self.expected_output)
コード例 #2
0
ファイル: test_spi.py プロジェクト: javValverde/spi_master
def test_avalon(dut):
    """
    Test avalon interface
    """

    yield init_clock_reset(dut.clk, dut.reset_n)

    # ----------------------------------------------------------------------- #

    avs = AvalonMaster(dut, "avs", dut.clk)

    yield avs.write(SPI_DATA_IN_ADDR, 0xDEADBEEF)
    spi_data = yield avs.read(1)

    assert_equal(spi_data, 0xDEADBEEF, "Wrong avalon access")
コード例 #3
0
    def __init__(self, dut, debug=False):
        self.dut = dut
        self.stream_in = AvalonSTDriver(dut, "stream_in", dut.clk)
        self.backpressure = BitDriver(self.dut.stream_out_ready, self.dut.clk)
        self.stream_out = AvalonSTMonitor(
            dut,
            "stream_out",
            dut.clk,
            config={'firstSymbolInHighOrderBits': True})

        self.csr = AvalonMaster(dut, "csr", dut.clk)

        cocotb.fork(
            stream_out_config_setter(dut, self.stream_out, self.stream_in))

        # Create a scoreboard on the stream_out bus
        self.pkts_sent = 0
        self.expected_output = []
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            self.scoreboard = Scoreboard(dut)
        self.scoreboard.add_interface(self.stream_out, self.expected_output)

        # Reconstruct the input transactions from the pins
        # and send them to our 'model'
        self.stream_in_recovered = AvalonSTMonitor(dut,
                                                   "stream_in",
                                                   dut.clk,
                                                   callback=self.model)

        # Set verbosity on our various interfaces
        level = logging.DEBUG if debug else logging.WARNING
        self.stream_in.log.setLevel(level)
        self.stream_in_recovered.log.setLevel(level)
コード例 #4
0
 def __init__(self, dut):
     self.dut = dut
     self.tlp_tx_st = AvalonSTMonitor(dut, 'tlp_tx_multiplexer_out', dut.clk)
     self.tlp_tx_recovered = AvalonSTMonitor(dut, 'tlp_tx_multiplexer_out', dut.clk,
             callback=self.tx_model)
     self.csr = AvalonMaster(dut, 'csr', dut.clk)
     self.expected_output = []
     self.scoreboard = Scoreboard(dut)
     self.scoreboard.add_interface(self.tlp_tx_st, self.expected_output)
コード例 #5
0
ファイル: test_spi.py プロジェクト: javValverde/spi_master
def test_spi(dut):
    """
    Test spi
    """

    yield init_clock_reset(dut.clk, dut.reset_n)

    # ----------------------------------------------------------------------- #

    avs = AvalonMaster(dut, "avs", dut.clk)
    spi_monitor = SpiMonitor(dut)

    yield avs.write(SPI_DATA_OUT_ADDR, 0xDEADBEEF)
    yield avs.write(SLAVE_SELECT_ADDR, 0)

    spi_data_out = yield spi_monitor.wait_for_recv()

    assert_equal(spi_data_out, 0xDEADBEEF, "Wrong spi_data: %X"
                 % spi_data_out)
コード例 #6
0
ファイル: test.py プロジェクト: l-n-x/fejkon
 def __init__(self, dut):
     self.dut = dut
     self.st_in = AvalonSTDriver(dut, 'st_in', dut.clk)
     self.st_out = AvalonSTMonitor(dut, 'st_out', dut.clk)
     self.csr = AvalonMaster(dut, 'csr', dut.clk)
     self.st_in_recovered = AvalonSTMonitor(dut,
                                            'st_in',
                                            dut.clk,
                                            callback=self.model)
     self.expected_output = []
     self.scoreboard = Scoreboard(dut)
     self.scoreboard.add_interface(self.st_out, self.expected_output)
コード例 #7
0
async def initial_hal_test(dut, debug=True):
    """Example of using the software HAL against cosim testbench"""

    cocotb.fork(Clock(dut.clk, 5, units='ns').start())
    await reset(dut)

    # Create the avalon master and direct our HAL calls to that
    master = AvalonMaster(dut, "csr", dut.clk)
    if debug:
        master.log.setLevel(logging.DEBUG)

    @cocotb.function
    async def read(address):
        master.log.debug("External source: reading address 0x%08X" % address)
        value = await master.read(address)
        master.log.debug("Reading complete: got value 0x%08x" % value)
        return value

    @cocotb.function
    async def write(address, value):
        master.log.debug("Write called for 0x%08X -> %d" % (address, value))
        await master.write(address, value)
        master.log.debug("Write complete")

    io_module.set_write_function(write)
    io_module.set_read_function(read)

    dut._log.info("READ/WRITE functions set up, initialising HAL")

    state = hal.endian_swapper_init(0)

    # Check the actual value
    if dut.byteswapping.value:
        raise TestFailure("Byteswapping is enabled but haven't configured DUT")

    await cocotb.external(hal.endian_swapper_enable)(state)

    await ReadOnly()

    if not dut.byteswapping.value:
        raise TestFailure("Byteswapping wasn't enabled after calling "
                          "endian_swapper_enable")

    dut._log.info(
        "HAL call endian_swapper_enable successfully enabled the DUT")