コード例 #1
0
 def driveDCmdReady(self):
     dut = self.dut
     dut.io_d_cmd_ready <= 1
     while True:
         yield [Edge(dut.io_d_rsp_valid), Edge(dut.io_d_rsp_ready)]
         dut.io_d_cmd_ready <= (int(dut.io_d_rsp_valid) == 0
                                or int(dut.io_d_rsp_ready) == 1)
コード例 #2
0
    def _monitor_recv(self):
        reset_edge = Edge(self.dut.i_reset)
        d_edge = Edge(self.dut.i_d)
        clk_edge = Edge(self.dut.i_clk)
        ro = ReadOnly()

        while True:
            yield [reset_edge, clk_edge, d_edge]
            yield ro

            self._recv(self.dut.o_q.value)
コード例 #3
0
    def _monitor_recv(self):
        reset_edge = Edge(self.dut.i_reset)
        d_edge = Edge(self.dut.i_d)
        clk_edge = Edge(self.dut.i_clk)
        transaction = __Proj__Transaction()
        ro = ReadOnly()

        while True:
            yield [reset_edge, clk_edge, d_edge]
            yield ro

            transaction.reset_val = self.dut.i_reset.value
            transaction.clk_val = self.dut.i_clk.value
            transaction.d_val = self.dut.i_d.value

            self._recv(transaction)
コード例 #4
0
def test_edge_identity(dut):
    """
    Test that Edge triggers returns the same object each time
    """

    re = RisingEdge(dut.clk)
    fe = FallingEdge(dut.clk)
    e = Edge(dut.clk)

    assert re is RisingEdge(dut.clk)
    assert fe is FallingEdge(dut.clk)
    assert e is Edge(dut.clk)

    # check they are all unique
    assert len({re, fe, e}) == 3
    yield Timer(1)
コード例 #5
0
 def validate_mosi_miso_stability(self, test_name):
     previous_clk = self.dut.spi_clk
     previous_mosi = self.dut.spi_mosi
     if self.wires == 4:
         previous_miso = self.dut.spi_miso
     while True:
         v = self.dut.spi_cs_n.value
         v_str = "{}".format(v)
         # self.dut._log.error("{} - CS_N value: {}  Reset value: {}".format(test_name, v_str, self.dut.reset))
         if v_str == "0" and self.dut.reset == 0:
             if self.dut.spi_clk:
                 # Clock went high, so capture value
                 if previous_clk == 0:
                     previous_mosi = self.dut.spi_mosi
                     if self.wires == 4:
                         previous_miso = self.dut.spi_miso
                 else:
                     if int(self.dut.spi_mosi) != int(previous_mosi):
                         raise TestFailure(
                             "spi.mosi changed while clk was high (was {}, now {})"
                             .format(previous_mosi, self.dut.spi_mosi))
                     if self.wires == 4:
                         if int(self.dut.spi_miso) != int(previous_miso):
                             raise TestFailure(
                                 "spi.mosi changed while clk was high (was {}, now {})"
                                 .format(previous_miso, self.dut.spi_miso))
             previous_clk = self.dut.spi_clk
         # else:
         #     self.dut._log.error("CS_N is Z")
         yield Edge(self.dut.clk48)
コード例 #6
0
async def test_singleton_isinstance(dut):
    """
    Test that the result of trigger expression have a predictable type
    """
    assert isinstance(RisingEdge(dut.clk), RisingEdge)
    assert isinstance(FallingEdge(dut.clk), FallingEdge)
    assert isinstance(Edge(dut.clk), Edge)

    await Timer(1, "ns")
コード例 #7
0
ファイル: RegisterAgent.py プロジェクト: powlib/sim
 def _wait_reset(self, active_mode=1):
     '''
     Wait until reset is in an inactive state.
     '''
     rst = self.rst
     if str(rst.value) == 'z' or str(rst.value) == 'x' or int(
             rst.value) == active_mode:
         yield Edge(rst)
     yield NullTrigger()
コード例 #8
0
 def start(self):
     r_e = RisingEdge(self.clk)
     valid_edge = Edge(self.valid)
     while True:
         yield [valid_edge, r_e]
         self.ack <= 0
         if self.valid.value.integer == 1:
             for i in range(randint(0, self.ack_rand_latency)):
                 yield r_e
             if self.valid.value.integer == 1:
                 self.ack <= 1
コード例 #9
0
ファイル: __init__.py プロジェクト: svancau/cocotb
 def _wait_for_nsignal(self, signal):
     """This method will return with the specified signal
     has hit logic 0. The state will be in the ReadOnly phase
     so sim will need to move to NextTimeStep before
     registering more callbacks can occour
     """
     yield ReadOnly()
     while signal.value.integer != 0:
         yield Edge(signal)
         yield ReadOnly()
     yield NextTimeStep()
コード例 #10
0
 def _wait_for_nsignal(self, signal):
     """This method will return when the specified signal
     has hit logic ``0``. The state will be in the 
     :class:`~cocotb.triggers.ReadOnly` phase so sim will need
     to move to :class:`~cocotb.triggers.NextTimeStep` before
     registering more callbacks can occur.
     """
     yield ReadOnly()
     while signal.value.integer != 0:
         yield Edge(signal)
         yield ReadOnly()
     yield NextTimeStep()
コード例 #11
0
def test_singleton_isinstance(dut):
    """
    Test that the result of trigger expression have a predictable type
    """
    assert isinstance(RisingEdge(dut.clk), RisingEdge)
    assert isinstance(FallingEdge(dut.clk), FallingEdge)
    assert isinstance(Edge(dut.clk), Edge)
    assert isinstance(NextTimeStep(), NextTimeStep)
    assert isinstance(ReadOnly(), ReadOnly)
    assert isinstance(ReadWrite(), ReadWrite)

    yield Timer(1)
コード例 #12
0
def test_either_edge(dut):
    """Test that either edge can be triggered on"""
    dut.clk <= 0
    yield Timer(1)
    dut.clk <= 1
    yield Edge(dut.clk)
    if dut.clk.value.integer != 1:
        raise TestError("Value should be 0")
    yield Timer(10)
    dut.clk <= 0
    yield Edge(dut.clk)
    if dut.clk.value.integer != 0:
        raise TestError("Value should be 0")
    yield Timer(10)
    dut.clk <= 1
    yield Edge(dut.clk)
    if dut.clk.value.integer != 1:
        raise TestError("Value should be 0")
    yield Timer(10)
    dut.clk <= 0
    yield Edge(dut.clk)
    if dut.clk.value.integer != 0:
        raise TestError("Value should be 0")
    yield Timer(10)
    dut.clk <= 1
    yield Edge(dut.clk)
    if dut.clk.value.integer != 1:
        raise TestError("Value should be 0")
    yield Timer(10)
    dut.clk <= 0
    yield Edge(dut.clk)
    if dut.clk.value.integer != 0:
        raise TestError("Value should be 0")
コード例 #13
0
def sequence_test(dut):
    """ Chequear que la secuencia sea:
        - Flanco de SS
        - Length flancos ascendentes del SCLK
        - Flanco de SS
    """
    cocotb.fork(Clock(dut.AXI_ACLK, period=CLK_PERIOD, units='ns').start())
    yield reset(dut)
    spi_axi, spi_slave = yield init_spi(dut, 8, 10)
    send = cocotb.fork(spi_axi.send_recv(0x55))

    ss = Edge(dut.SS)
    r_sclk = RisingEdge(dut.SCLK)
    timeout = Timer(150, units='us')

    yield send.join()
コード例 #14
0
def simulator_signal_triggers(dut):
    """Playing with the Simulator Signals Triggers"""
    cocotb.fork(Clock(dut.clk_i, 2).start())
    yield reset(dut)
    #
    for i in range(4):
        yield RisingEdge(dut.clk_i)
        print_fired(dut, "RisingEdge")
    for i in range(4):
        yield FallingEdge(dut.clk_i)
        print_fired(dut, "FallingEdge")
    for i in range(4):
        yield Edge(dut.clk_i)
        print_fired(dut, "Edge")
    for i in range(4):
        yield ClockCycles(dut.clk_i, 3)
        print_fired(dut, "ClockCycle")
コード例 #15
0
 async def peripheral_return_response(self, sdo_binstr):
     cs_n_edge = Edge(
         self.io['cs_n']) if self.io['cs_n'] is not None else None
     if self.io[
             'cs_n'] is not None:  # some 2-wire point-to-points do not have cs
         await FallingEdge(self.io['cs_n'])
     if self.lsb_first:
         sdo_binstr = sdo_binstr[::-1]  # data bits sent from left to right
     send_edge = FallingEdge(self.io['sclk'])
     if self.mode in [0, 2]:
         send_edge = RisingEdge(self.io['sclk'])
         self.io['sdo'] <= int(sdo_binstr[0], 2)  # drive before 1st clock
         sdo_binstr = sdo_binstr[1:]  # remove bit 0 (left-most bit)
     while sdo_binstr != "":
         edge = await First(cs_n_edge, send_edge)
         if edge == cs_n_edge:
             break
         self.io['sdo'] <= int(sdo_binstr[0], 2)
         sdo_binstr = sdo_binstr[1:]  # remove bit 0 (left-most bit)
コード例 #16
0
 async def peripheral_monitor(self):
     cs_n_edge = Edge(
         self.io['cs_n']) if self.io['cs_n'] is not None else None
     sdi_binstr = ""
     if self.io[
             'cs_n'] is not None:  # some 2-wire point-to-points do not have cs
         await FallingEdge(self.io['cs_n'])
     capture_edge = FallingEdge(self.io['sclk'])
     if self.mode in [0, 3]:
         capture_edge = RisingEdge(self.io['sclk'])
     while len(sdi_binstr) < self.size:
         edge = await capture_edge
         if edge == cs_n_edge:
             break
         elif edge == capture_edge:
             sdi_binstr = sdi_binstr + self.io['sdi'].value.binstr
     if self.lsb_first:
         sdi_binstr = sdi_binstr[::-1]
     return sdi_binstr
コード例 #17
0
ファイル: AhbLite3.py プロジェクト: Readon/CocotbLib
 def combEvent(self):
     while True:
         yield Edge(self.ahb.HREADYOUT)
         self.doComb()
コード例 #18
0
 def pinWatcher(self, driver):
     while True:
         yield Edge(driver)
         self.evaluate()
コード例 #19
0
ファイル: DiscreteAgent.py プロジェクト: powlib/sim
 def _synchronize(self):
     '''
     Instead of synchronzing on a control signal, wait until the data changes.
     '''
     yield [Edge(handle) for sig, handle in vars(self).items()]
コード例 #20
0
def txToRxBypass(dut):
    while True:
        dut.io_uart_uart_rxd <= int(dut.io_uart_uart_txd)
        yield Edge(dut.io_uart_uart_txd)
コード例 #21
0
ファイル: ubus_if.py プロジェクト: zfling/uvm-python
 async def drive_data(self):
     while True:
         await Combine(Edge(self.sig_data_out), Edge(self.sig_data))
         if self.slave_en == 1:
             self.sig_data <= self.sig_data_out
コード例 #22
0
 def acknowledgment(self):
     while True:
         yield Edge(self.rdy)
         self.ack <= self.rdy.value.integer
コード例 #23
0
 def loopback(self):
     self.miso <= self.mosi.value
     while True:
         yield Edge(self.mosi)
         self.miso <= self.mosi.value