Example #1
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """
    #Use the folowing value to find the test in the simulation (It should show up as the yellow signal at the top of the waveforms)
    dut.test_id = 0
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = axi_master_testDriver(nysa,
                                   nysa.find_device(axi_master_testDriver)[0])
    dut.log.info("Ready")

    #For a demo write a value to the control register (See the axi_master_testDriver for addresses)
    WRITE_VALUE = 0x01
    dut.log.info("Writing value: 0x%08X" % WRITE_VALUE)
    yield cocotb.external(driver.set_control)(WRITE_VALUE)
    yield (nysa.wait_clocks(100))
    dut.log.info("Reading value...")
    read_value = yield cocotb.external(driver.get_control)()
    dut.log.info("Control Register: 0x%08X" % read_value)
Example #2
0
def read_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """

    dut.test_id = 1
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = pf_hi_testerDriver(nysa, nysa.find_device(pf_hi_testerDriver)[0])
    yield (nysa.wait_clocks(100))

    DATA_IN_SIZE = 10
    yield cocotb.external(driver.read)(0x00, DATA_IN_SIZE)
    yield (nysa.wait_clocks(100))

    DATA_IN_SIZE = 20
    yield cocotb.external(driver.read)(0x00, DATA_IN_SIZE)
    yield (nysa.wait_clocks(100))
Example #3
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """


    dut.test_id = 0
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = wb_host_interface_testerDriver(nysa, nysa.find_device(wb_host_interface_testerDriver)[0])
    print "here!"
    yield cocotb.external(driver.set_control)(0x01)
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.get_control)()
    dut.log.info("V: %d" % v)
    dut.log.info("DUT Opened!")
    dut.log.info("Ready")
Example #4
0
def read_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """


    dut.test_id = 1
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = pf_hi_testerDriver(nysa, nysa.find_device(pf_hi_testerDriver)[0])
    yield (nysa.wait_clocks(100))

    DATA_IN_SIZE = 10
    yield cocotb.external(driver.read)(0x00, DATA_IN_SIZE)
    yield (nysa.wait_clocks(100))

    DATA_IN_SIZE = 20
    yield cocotb.external(driver.read)(0x00, DATA_IN_SIZE)
    yield (nysa.wait_clocks(100))
Example #5
0
def test_uart_simple(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 3

    Expected Results:
        Write to all registers
    """
    dut.test_id = 3
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    #uw = UARTCommWriter(dut, "uart", dut.clk)
    #ur = UARTCommReader(dut, "uart", dut.clk)
    uart = UART(dut, "uart", dut.clk)
    ula =UARTLogicAnalyzer(uart, sim = True, log = logging.getLogger("cocotb"), debug = True)

    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = yield cocotb.external(LogicAnalyzer)(nysa, nysa.find_device(LogicAnalyzer)[0])
    yield cocotb.external(driver.enable_uart_control)(False)
    yield (nysa.wait_clocks)(100)
    yield ula.ping()
    yield (nysa.wait_clocks)(100)
    yield ula.enable(True)
    yield (nysa.wait_clocks)(100)
    yield ula.is_enabled()
    yield (nysa.wait_clocks)(100)
    yield ula.enable(False)
    yield (nysa.wait_clocks)(100)
    yield ula.is_enabled()
    yield (nysa.wait_clocks)(100)
    yield ula.reset()
    yield (nysa.wait_clocks)(100)
    yield ula.force_trigger()
    yield (nysa.wait_clocks)(100)
    value = yield ula.get_start_pos()
    yield (nysa.wait_clocks)(100)
    value = yield ula.get_data_count()
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger(0x01234567)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger_mask(0x01234567)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger_after(0x01234567)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger_edge(0x01234567)
    yield (nysa.wait_clocks)(100)
    yield ula.set_both_edge(0x01234567)
    yield (nysa.wait_clocks)(100)
    yield ula.set_repeat_count(0x01234567)
    yield (nysa.wait_clocks)(100)
Example #6
0
def test_local_buffer(dut):
    """
    Description:
        Test to make sure that we can read/write to/from local buffer

    Test ID: 0

    Expected Results:
        Data written into the buffer is the same as the data read out of the buffer
    """

    dut.test_id = 0
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    d = nysa.find_device(ArtemisPCIEDriver)[0]
    #driver = ArtemisPCIEDriver(nysa, nysa.find_device(ArtemisPCIEDriver)[0])
    driver = yield cocotb.external(ArtemisPCIEDriver)(nysa, d)
    yield cocotb.external(driver.enable)(True)
    yield (nysa.wait_clocks(1000))
    v = yield cocotb.external(driver.get_control)()

    dut.log.info("V: %d" % v)

    dut.log.info("Write to the local buffer")
    size = yield cocotb.external(driver.get_local_buffer_size)()
    data_out = Array("B")
    for i in range(size):
        data_out.append(i % 256)

    if len(data_out) > 0:
        yield cocotb.external(driver.write_local_buffer)(data_out)

    yield (nysa.wait_clocks(1000))

    data_in = yield cocotb.external(driver.read_local_buffer)()

    error_count = 0
    for i in range(len(data_in)):
        if data_in[i] != data_out[i]:
            error_count += 1
            if error_count < 16:
                print "Data Out != Data In @ 0x%02X 0x%02X != 0x%02X" % (
                    i, data_out[i], data_in[i])

    if error_count > 0:
        print "Found Errors in the local buffer"

    yield (nysa.wait_clocks(1000))

    dut.log.info("Enable PPFIFO 2 Local Memory")
    yield cocotb.external(driver.enable_pcie_read_block)(True)
    yield (nysa.wait_clocks(1000))
Example #7
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """
    dut.test_id = 0
    #print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    #sdhost = SDHostDriver(nysa, nysa.find_device(SDHostDriver)[0])
    sdhost = yield cocotb.external(SDHostDriver)(
        nysa, nysa.find_device(SDHostDriver)[0])
    sddev = yield cocotb.external(SDIODeviceDriver)(
        nysa, nysa.find_device(SDIODeviceDriver)[0])
    yield (nysa.wait_clocks(200))
    yield cocotb.external(sddev.enable_sdio_device)(False)
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.reset_core)()
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.enable_sdio_device)(True)
    yield (nysa.wait_clocks(100))

    v = yield cocotb.external(sdhost.get_control)()
    dut.log.debug("V: %d" % v)
    dut.log.debug("DUT Opened!")
    dut.log.debug("Ready")
    test_data = [0x00, 0x01, 0x02, 0x03]
    yield cocotb.external(nysa.write_memory)(0x00, test_data)
    yield (nysa.wait_clocks(10))
    dut.log.debug("Wrote %s to memory" % (test_data))
    data = yield cocotb.external(nysa.read_memory)(0x00, 1)
    dut.log.debug("Read back %s from memory" % test_data)
    fail = False
    for i in range(len(data)):
        if data[i] != test_data[i]:
            raise TestFailure(
                "Data into memory != Data out of memory: %s != %s" %
                (print_hex_array(test_data), print_hex_array(data)))
Example #8
0
def test_uart_simple(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 3

    Expected Results:
        Write to all registers
    """
    dut.test_id = 3
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    #uw = UARTCommWriter(dut, "uart", dut.clk)
    #ur = UARTCommReader(dut, "uart", dut.clk)
    uart = UART(dut, "uart", dut.clk)
    ula = UARTLogicAnalyzer(uart,
                            sim=True,
                            log=logging.getLogger("cocotb"),
                            debug=True)

    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = yield cocotb.external(LogicAnalyzer)(
        nysa, nysa.find_device(LogicAnalyzer)[0])
    yield cocotb.external(driver.enable_uart_control)(True)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger(0x00000001)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger_mask(0x00000001)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger_after(0x00000000)
    yield (nysa.wait_clocks)(100)
    yield ula.set_trigger_edge(0x00000001)
    yield (nysa.wait_clocks)(100)
    yield ula.set_both_edge(0x00000000)
    yield (nysa.wait_clocks)(100)
    yield ula.set_repeat_count(0x00000000)
    yield (nysa.wait_clocks)(100)
    yield ula.enable(True)
    data = yield ula.read_data()
    dut.log.info("Data: %s" % str(data))
Example #9
0
def test_repeat_capture(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 1

    Expected Results:
        Write to all registers
    """
    dut.test_id = 1
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    uw = UARTCommWriter(dut, "uart", dut.clk)
    ur = UARTCommReader(dut, "uart", dut.clk)

    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = yield cocotb.external(LogicAnalyzer)(
        nysa, nysa.find_device(LogicAnalyzer)[0])
    yield cocotb.external(driver.reset)()
    yield cocotb.external(driver.enable_uart_control)(False)
    yield cocotb.external(driver.set_trigger)(0x00000002)
    yield cocotb.external(driver.set_trigger_mask)(0x00000002)
    yield cocotb.external(driver.set_trigger_edge)(0x00000002)
    yield cocotb.external(driver.set_trigger_after)(0)
    yield cocotb.external(driver.set_repeat_count)(2)
    yield cocotb.external(driver.enable_interrupts)(True)
    yield cocotb.external(driver.enable)(True)
    yield (nysa.wait_clocks)(100)
    finished = yield cocotb.external(driver.is_finished)()
    if finished:
        dut.log.info("Finished!")

    data = yield cocotb.external(driver.read_raw_data)()
    #dut.log.info("Data: %s" % str(data))
    for i in range(0, len(data), 4):
        dut.log.info("\t[%04X] 0x%08X" %
                     ((i / 4), array_to_dword(data[i:i + 4])))

    value = yield cocotb.external(driver.get_start_pos)()
    dut.log.info("Start: 0x%08X" % value)
Example #10
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """
    dut.test_id = 0
    #print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    #sdhost = SDHostDriver(nysa, nysa.find_device(SDHostDriver)[0])
    sdhost = yield cocotb.external(SDHostDriver)(nysa, nysa.find_device(SDHostDriver)[0])
    sddev = yield cocotb.external(SDIODeviceDriver)(nysa, nysa.find_device(SDIODeviceDriver)[0])
    yield (nysa.wait_clocks(200))
    yield cocotb.external(sddev.enable_sdio_device)(False)
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.reset_core)()
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.enable_sdio_device)(True)
    yield (nysa.wait_clocks(100))

    v = yield cocotb.external(sdhost.get_control)()
    dut.log.debug("V: %d" % v)
    dut.log.debug("DUT Opened!")
    dut.log.debug("Ready")
    test_data = [0x00, 0x01, 0x02, 0x03]
    yield cocotb.external(nysa.write_memory)(0x00, test_data)
    yield (nysa.wait_clocks(10))
    dut.log.debug("Wrote %s to memory" % (test_data))
    data = yield cocotb.external(nysa.read_memory)(0x00, 1)
    dut.log.debug("Read back %s from memory" % test_data)
    fail = False
    for i in range(len(data)):
        if data[i] != test_data[i]:
            raise TestFailure("Data into memory != Data out of memory: %s != %s" %
                                (print_hex_array(test_data), print_hex_array(data)))
Example #11
0
def test_trigger_after_capture(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 2

    Expected Results:
        Write to all registers
    """
    dut.test_id = 2
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    uw = UARTCommWriter(dut, "uart", dut.clk)
    ur = UARTCommReader(dut, "uart", dut.clk)

    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = yield cocotb.external(LogicAnalyzer)(nysa, nysa.find_device(LogicAnalyzer)[0])
    yield cocotb.external(driver.reset)()
    yield cocotb.external(driver.enable_uart_control)(False)
    yield cocotb.external(driver.set_trigger)           (0x00000200)
    yield cocotb.external(driver.set_trigger_mask)      (0x00000200)
    yield cocotb.external(driver.set_trigger_edge)      (0x00000200)
    yield cocotb.external(driver.set_trigger_after)(4)
    yield cocotb.external(driver.set_repeat_count)(0)
    yield cocotb.external(driver.enable_interrupts)(True)
    yield cocotb.external(driver.enable)(True)
    yield (nysa.wait_clocks)(1000)
    finished = yield cocotb.external(driver.is_finished)()
    if finished:
        dut.log.info("Finished!")

    data = yield cocotb.external(driver.read_data)()
    #dut.log.info("Data: %s" % str(data))
    for i in range (0, len(data), 1):
        #dut.log.info("\t[%04X] 0x%08X" % ((i / 4), array_to_dword(data[i: i + 4])))
        dut.log.info("\t[%04X] 0x%08X" % (i, data[i]))

    value = yield cocotb.external(driver.get_start_pos)()
    dut.log.info("Start: 0x%08X" % value)
Example #12
0
def write_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """


    dut.test_id = 0
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = pf_hi_testerDriver(nysa, nysa.find_device(pf_hi_testerDriver)[0])
    print "here!"
    yield cocotb.external(driver.set_control)(0x01)
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.get_control)()
    dut.log.info("V: %d" % v)
    dut.log.info("DUT Opened!")
    dut.log.info("Ready")
    yield (nysa.wait_clocks(100))

    DATA_OUT_SIZE = 6
    data_out = Array('B')
    for i in range (DATA_OUT_SIZE * 4):
        data_out.append(i % 256)

    print "Length: %d" % len(data_out)
    yield cocotb.external(driver.write)(0x00, data_out)
    yield (nysa.wait_clocks(100))
Example #13
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """

    dut.test_id = 0
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = wb_hs_demoDriver(nysa, nysa.find_device(wb_hs_demoDriver)[0])
    dut.log.info("Ready")
Example #14
0
def test_local_buffer_to_pcie(dut):
    """
    Description:
        Write to the local buffer and send the data out over PCIE

    Test ID: 1

    Expected Results:
        Data written into the buffer is the same as the data read out of the buffer
    """

    dut.test_id = 1
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    d = nysa.find_device(ArtemisPCIEDriver)[0]
    #driver = ArtemisPCIEDriver(nysa, nysa.find_device(ArtemisPCIEDriver)[0])
    driver = yield cocotb.external(ArtemisPCIEDriver)(nysa, d)
    yield cocotb.external(driver.enable)(True)
    yield (nysa.wait_clocks(1000))
    v = yield cocotb.external(driver.get_control)()

    dut.log.info("Write to the local buffer")
    size = yield cocotb.external(driver.get_local_buffer_size)()
    data_out = Array("B")
    for i in range(size):
        data_out.append(i % 256)

    if len(data_out) > 0:
        yield cocotb.external(driver.write_local_buffer)(data_out)

    yield (nysa.wait_clocks(1000))

    yield cocotb.external(driver.send_block_from_local_buffer)()
    yield (nysa.wait_clocks(1000))
Example #15
0
def write_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """

    dut.test_id = 0
    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = pf_hi_testerDriver(nysa, nysa.find_device(pf_hi_testerDriver)[0])
    print "here!"
    yield cocotb.external(driver.set_control)(0x01)
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.get_control)()
    dut.log.info("V: %d" % v)
    dut.log.info("DUT Opened!")
    dut.log.info("Ready")
    yield (nysa.wait_clocks(100))

    DATA_OUT_SIZE = 6
    data_out = Array('B')
    for i in range(DATA_OUT_SIZE * 4):
        data_out.append(i % 256)

    print "Length: %d" % len(data_out)
    yield cocotb.external(driver.write)(0x00, data_out)
    yield (nysa.wait_clocks(100))
Example #16
0
def send_simple_command(dut):
    """
    Description:
        Initiate an SD transaction

    Test ID: 1

    Expected Results:
        Enable an SD Transaction
    """
    dut.test_id = 1
    SDIO_PATH = get_verilog_path("sdio-device")
    sdio_config = os.path.join(SDIO_PATH, "sdio_configuration.json")
    config = None
    with open (sdio_config, "r") as f:
        dut.log.warning("Run %s before running this function" % os.path.join(SDIO_PATH, "tools", "generate_config.py"))
        config = json.load(f)

    #print "SDIO PATH: %s" % SDIO_PATH
    #print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    #sdhost = SDHostDriver(nysa, nysa.find_device(SDHostDriver)[0])
    sdhost = yield cocotb.external(SDHostDriver)(nysa, nysa.find_device(SDHostDriver)[0])
    sddev = yield cocotb.external(SDIODeviceDriver)(nysa, nysa.find_device(SDIODeviceDriver)[0])
    yield (nysa.wait_clocks(200))
    yield cocotb.external(sddev.enable_sdio_device)(False)
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.reset_core)()
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.enable_sdio_device)(True)
    yield (nysa.wait_clocks(100))


    sdhost.set_voltage_range(2.0, 3.6)

    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield (nysa.wait_clocks(100))

    yield cocotb.external(sdhost.cmd_phy_sel)()

    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = False)
    if dut.s2.sdio_device.card_controller.v1p8_sel.value.get_value() == True:
        raise TestFailure ("1.8V Switch Voltage Before Request")

    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    if dut.s2.sdio_device.card_controller.v1p8_sel.value.get_value() == False:
        raise TestFailure ("Failed to set 1.8V Switch Voltage Request")

    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 2:
        raise TestFailure ("Card Should Be In Standby State Right Now")

    yield cocotb.external(sdhost.cmd_enable_card)(True)
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 3:
        raise TestFailure ("Card Should Be In Command State Right Now")

    yield cocotb.external(sdhost.cmd_enable_card)(False)
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 2:
        raise TestFailure ("Card Should Be In Standby State Right Now")

    yield cocotb.external(sdhost.cmd_go_inactive_state)()
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 5:
        raise TestFailure ("Card Should Be In Standby State Right Now")

    yield (nysa.wait_clocks(20))
Example #17
0
def send_simple_command(dut):
    """
    Description:
        Initiate an SD transaction

    Test ID: 1

    Expected Results:
        Enable an SD Transaction
    """
    dut.test_id = 1
    SDIO_PATH = get_verilog_path("sdio-device")
    sdio_config = os.path.join(SDIO_PATH, "sdio_configuration.json")
    config = None
    with open(sdio_config, "r") as f:
        dut.log.warning("Run %s before running this function" %
                        os.path.join(SDIO_PATH, "tools", "generate_config.py"))
        config = json.load(f)

    #print "SDIO PATH: %s" % SDIO_PATH
    #print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_dut(dut)
    yield (nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    #sdhost = SDHostDriver(nysa, nysa.find_device(SDHostDriver)[0])
    sdhost = yield cocotb.external(SDHostDriver)(
        nysa, nysa.find_device(SDHostDriver)[0])
    sddev = yield cocotb.external(SDIODeviceDriver)(
        nysa, nysa.find_device(SDIODeviceDriver)[0])
    yield (nysa.wait_clocks(200))
    yield cocotb.external(sddev.enable_sdio_device)(False)
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.reset_core)()
    yield (nysa.wait_clocks(100))
    yield cocotb.external(sddev.enable_sdio_device)(True)
    yield (nysa.wait_clocks(100))

    sdhost.set_voltage_range(2.0, 3.6)

    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield (nysa.wait_clocks(100))

    yield cocotb.external(sdhost.cmd_phy_sel)()

    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=False)
    if dut.s2.sdio_device.card_controller.v1p8_sel.value.get_value() == True:
        raise TestFailure("1.8V Switch Voltage Before Request")

    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    if dut.s2.sdio_device.card_controller.v1p8_sel.value.get_value() == False:
        raise TestFailure("Failed to set 1.8V Switch Voltage Request")

    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 2:
        raise TestFailure("Card Should Be In Standby State Right Now")

    yield cocotb.external(sdhost.cmd_enable_card)(True)
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 3:
        raise TestFailure("Card Should Be In Command State Right Now")

    yield cocotb.external(sdhost.cmd_enable_card)(False)
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 2:
        raise TestFailure("Card Should Be In Standby State Right Now")

    yield cocotb.external(sdhost.cmd_go_inactive_state)()
    if dut.s2.sdio_device.card_controller.state.value.get_value() != 5:
        raise TestFailure("Card Should Be In Standby State Right Now")

    yield (nysa.wait_clocks(20))