コード例 #1
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def interrupt_test(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)
    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))
    yield cocotb.external(driver.write)(0x001000, [0x00, 0x00, 0x00, 0x01])
    yield (nysa.wait_clocks(100))
コード例 #2
0
ファイル: test_dut.py プロジェクト: nagchil/nysa-verilog
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)
コード例 #3
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa
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 = ${SDB_NAME}Driver(nysa, nysa.find_device(${SDB_NAME}Driver)[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")
コード例 #4
0
ファイル: test_dut.py プロジェクト: zhuyh128/nysa-verilog
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")
コード例 #5
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def dma_first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa
            Startup DMA Controller

    Test ID: 4

    Expected Results:
        Write to all registers
    """

    dut.test_id = 4
    #nysa = NysaSim(dut)
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    yield (nysa.reset())
    nysa.read_sdb()

    dma = DMA(nysa, nysa.find_device(DMA)[0])
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])
    yield cocotb.external(dma.setup)()
    setup_sata(dut)
    yield cocotb.external(sata.enable_sata_reset)(False)

    count = yield cocotb.external(dma.get_channel_count)()
    dut.log.info("DMA Channel Count: %d" % count)

    dut.log.info("SATA Opened!")
    dut.log.info("DMA Opened!")
    dut.log.info("Ready")
    yield nysa.wait_clocks(100)
コード例 #6
0
ファイル: test_dut.py プロジェクト: younew/nysa-verilog
def stream_read_write_bram(dut):
    """
    Description:
        Read and write data to the block ram

    Test ID: 2

    Expected Results:
        Write Data the Block RAM through Wishbone interface
        Read Same data from the block RAM through wishbone interface
    """
    dut.test_id = 2
    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))
    driver = wb_hs_demoDriver(nysa, nysa.find_device(wb_hs_demoDriver)[0])
    data = Array('B')
    SIZE =1024
    for i in range(SIZE):
        data.append(i % 256)

    yield cocotb.external(driver.write_data)(0x00, data)
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.read_data)(0x00, (SIZE / 4))

    if len(v) != len(data):
        raise cocotb.result.TestFailure("Test %d: Length of incomming data and outgoing data is equal %d = %d" % (dut.test_id, len(v), len(data)))

    for i in range(len(data)):
        if v[i] != data[i]:
            raise cocotb.result.TestFailure("Test %d: Address 0x%02X 0x%02X != 0x%02X" % (dut.test_id, i, v[i], data[i]))

    dut.log.info("Success")
コード例 #7
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
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)
コード例 #8
0
ファイル: test_dut.py プロジェクト: zhuyh128/nysa-verilog
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))
コード例 #9
0
ファイル: test_dut.py プロジェクト: zhuyh128/nysa-verilog
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)
コード例 #10
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa
            Startup Sata Stack

    Test ID: 0

    Expected Results:
        Write to all registers
    """

    dut.test_id = 0
    #nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_sata(dut)

    yield (nysa.reset())
    nysa.read_sdb()
    #nysa.pretty_print_sdb()

    #Get the driver
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])

    #Reset the hard drive
    yield cocotb.external(sata.enable_sata_reset)(False)
    #Wait for SATA to Startup
    yield (wait_for_sata_ready)(nysa, dut)

    dut.log.info("SATA Opened!")
    dut.log.info("Ready")
コード例 #11
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def write_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa
            Startup Sata Stack

    Test ID: 1

    Expected Results:
        Write to all registers
    """

    dut.test_id = 1
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_sata(dut)

    yield (nysa.reset())
    nysa.read_sdb()
    #nysa.pretty_print_sdb()
    enable_hd_read(nysa, dut)

    #Get the driver
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])

    #Reset the hard drive
    yield cocotb.external(sata.enable_sata_reset)(False)
    #Wait for SATA to Startup
    yield (wait_for_sata_ready)(nysa, dut)
    values = Array('B')
    clear_values = Array('B')
    #for i in range (0, 2048 * 4):
    for i in range(0, 2048):
        v = Array('B', [(i >> 24) & 0xFF, (i >> 16) & 0xFF,
                        (i >> 8) & 0xFF, i & 0xFF])
        #values.append(i % 256)
        values.extend(v)
        clear_values.append(0)
        clear_values.extend(Array('B', [0, 0, 0, 0]))

    #yield cocotb.external(sata.set_local_buffer_write_size)(100)
    yield cocotb.external(sata.write_local_buffer)(values)
    yield cocotb.external(sata.load_local_buffer)()

    dut.log.info("SATA Opened!")
    dut.log.info("Ready")
    dut.u2h_write_enable = 1
    dut.u2h_write_count = 2048
    yield cocotb.external(sata.hard_drive_write)(0x01000, 1)
    yield (nysa.wait_clocks(10000))
    dut.u2h_write_enable = 0
コード例 #12
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
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)
コード例 #13
0
ファイル: test_dut.py プロジェクト: younew/nysa-verilog
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")
コード例 #14
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def read_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa
            Startup Sata Stack

    Test ID: 1

    Expected Results:
        Write to all registers
    """

    dut.test_id = 2
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    setup_sata(dut)

    yield (nysa.reset())
    nysa.read_sdb()
    #nysa.pretty_print_sdb()
    enable_hd_read(nysa, dut)

    #Get the driver
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])

    #Reset the hard drive
    yield cocotb.external(sata.enable_sata_reset)(False)
    #Wait for SATA to Startup
    yield (wait_for_sata_ready)(nysa, dut)
    values = Array('B')
    clear_values = Array('B')

    dut.h2u_read_enable = 1
    yield (nysa.wait_clocks(3000))
    yield cocotb.external(sata.hard_drive_read)(0x01000, 1)
    yield (nysa.wait_clocks(7000))
    data = yield (cocotb.external(sata.read_local_buffer))()
    dut.h2u_read_enable = 0
コード例 #15
0
ファイル: test_dut.py プロジェクト: younew/nysa-verilog
def simple_read_write_bram(dut):
    """
    Description:
        Read and write data to the block ram

    Test ID: 1

    Expected Results:
        Write Data the Block RAM through Wishbone interface
        Read Same data from the block RAM through wishbone interface
    """
    dut.test_id = 1
    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))
    driver = wb_hs_demoDriver(nysa, nysa.find_device(wb_hs_demoDriver)[0])
    yield cocotb.external(driver.write_data)(0x00, [0x00, 0x01, 0x02, 0x03])
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.read_data)(0x00, 1)
    dut.log.info("V: %s" % v)
    dut.log.info("Ready")
コード例 #16
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
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))
コード例 #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))
コード例 #18
0
def small_multi_byte_data_read(dut):
    """
    Description:
        Perform a small read on the data bus

    Test ID: 5

    Expected Results:
        Multi byte data transfer, this will use the data bus, not CMC mode
    """
    dut.test_id = 5
    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)

    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))
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    data = yield cocotb.external(sdhost.read_sd_data)(function_id=0,
                                                      address=0x00,
                                                      byte_count=8,
                                                      fifo_mode=False)

    #print "data: %s" % print_hex_array(data)
    fail = False
    test_data = Array('B', [0x43, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
    for i in range(len(data)):
        if data[i] != test_data[i]:
            fail = True
            break

    if fail:
        raise TestFailure("Multi-Byte Read incorrect: %s != %s" %
                          (print_hex_array(test_data), print_hex_array(data)))

    yield (nysa.wait_clocks(1000))
コード例 #19
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def test_single_instruction_from_sata(dut):
    """
    Description:
        -Setup source and sink for 0x200 word transaction
        -Setup the source address to increment
        -Setup the sink address to increment
        -setup instruction

    Test ID: 5

    Expected Results:
        Data is all transferred from one memory device to the next
    """
    dut.test_id = 8
    #nysa = NysaSim(dut)
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    yield (nysa.reset())
    nysa.read_sdb()
    yield nysa.wait_clocks(2000)

    dma = DMA(nysa, nysa.find_device(DMA)[0])
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])
    setup_sata(dut)

    yield cocotb.external(sata.enable_sata_reset)(False)
    yield cocotb.external(dma.setup)()
    yield cocotb.external(dma.enable_dma)(True)
    yield nysa.wait_clocks(10)
    yield cocotb.external(sata.enable_dma_control)(True)
    dut.h2u_read_enable = 1

    #WORD_COUNT = 0x880
    WORD_COUNT = 0x800
    CHANNEL_ADDR = 3
    SINK_ADDR = 0
    INST_ADDR = 0

    SOURCE_ADDRESS = 0x0000000000000000
    DEST_ADDRESS = 0x0000000000000200

    source_error = get_source_error_signal(dut, CHANNEL_ADDR)
    sink_error = get_sink_error_signal(dut, SINK_ADDR)
    source_error_monitor = ErrorMonitor(dut, source_error)
    sink_error_monitor = ErrorMonitor(dut, sink_error)

    yield cocotb.external(dma.set_channel_sink_addr)(CHANNEL_ADDR, SINK_ADDR)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)(CHANNEL_ADDR,
                                                               INST_ADDR)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_source_address_increment)(CHANNEL_ADDR,
                                                               True)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_address_increment)(SINK_ADDR, True)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_respect_quantum)(SINK_ADDR, False)
    #yield cocotb.external(dma.enable_dest_respect_quantum)      (SINK_ADDR,     True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_source_address)(INST_ADDR,
                                                              SOURCE_ADDRESS)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_dest_address)(INST_ADDR,
                                                            DEST_ADDRESS)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_data_count)(INST_ADDR,
                                                          WORD_COUNT)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)(CHANNEL_ADDR,
                                                               INST_ADDR)
    yield nysa.wait_clocks(10)
    #Start
    yield cocotb.external(dma.enable_channel)(CHANNEL_ADDR, True)

    yield nysa.wait_clocks(10000)
    yield cocotb.external(dma.enable_channel)(CHANNEL_ADDR, False)
    yield cocotb.external(dma.enable_dma)(False)
    yield nysa.wait_clocks(10)
    #dut.tdm0.m2f_data_error <= 1
    #yield nysa.wait_clocks(10)

    if len(source_error_monitor) > 0:
        raise cocotb.result.TestFailure(
            "Test %d Error on source %d write detected %d errors" %
            (dut.test_id, CHANNEL_ADDR, len(source_error_monitor)))

    if len(sink_error_monitor) > 0:
        raise cocotb.result.TestFailure(
            "Test %d Error on source %d read detected %d errors" %
            (dut.test_id, SINK_ADDR, len(sink_error_monitor)))

    source_error_monitor.kill()
    sink_error_monitor.kill()
コード例 #20
0
def data_block_read(dut):
    """
    Description:
        Perform a block read

    Test ID: 7

    Expected Results:
        Block Transfer (Read)
    """
    dut.test_id = 7
    BLOCK_SIZE = 0x08
    SIZE = 0x10
    FUNCTION = 0
    ADDRESS = 0x00

    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)

    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))
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)
    yield cocotb.external(sdhost.set_function_block_size)(FUNCTION, BLOCK_SIZE)

    data = yield cocotb.external(sdhost.read_sd_data)(FUNCTION,
                                                      ADDRESS,
                                                      SIZE,
                                                      fifo_mode=False)
    print "Data: %s" % print_hex_array(data)
    yield (nysa.wait_clocks(2000))
コード例 #21
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)))
コード例 #22
0
def small_multi_byte_data_write(dut):
    """
    Description:
        Perform a small write on the data bus

    Test ID: 4

    Expected Results:
        Multi byte data transfer, this will use the data bus, not FIFO mode
    """
    dut.test_id = 4
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #data = Array ('B', [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
    data = Array('B')
    for i in range(8):
        value = i % 256
        data.append(value)
    yield cocotb.external(sdhost.write_sd_data)(0,
                                                0x00,
                                                data,
                                                fifo_mode=False,
                                                read_after_write=False)
    value = dut.s2.sdio_device.cia.cccr.o_func_enable.value.get_value()
    if value != 0x02:
        raise TestFailure(
            "Failed to write configuration byte to CCCR Memory Space: Should be 0x02 is: 0x%02X"
            % value)
    value = dut.s2.sdio_device.cia.cccr.o_func_int_enable.value.get_value()
    if value != 0x04:
        raise TestFailure(
            "Failed to write configuration byte to CCCR Memory Space: Should be 0x04 is: 0x%02X"
            % value)
    yield (nysa.wait_clocks(1000))
コード例 #23
0
def data_async_block_read_write_long_transfer(dut):
    """
    Description:
        Perform a block read using asynchronous transfer

    Test ID: 11

    Expected Results:
        Block Transfer (Read)
    """
    dut.test_id = 11
    ADDRESS = 0x00
    FUNCTION = 1
    BLOCK_SIZE = 0x08
    SIZE = 0x18

    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)

    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))
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #Enable Function
    yield cocotb.external(sdhost.enable_function)(FUNCTION)
    yield cocotb.external(sdhost.set_function_block_size)(FUNCTION, BLOCK_SIZE)

    write_data = Array('B')
    for i in range(SIZE):
        value = i % 256
        write_data.append(value)
    yield cocotb.external(sdhost.write_sd_data)(FUNCTION,
                                                ADDRESS,
                                                write_data,
                                                fifo_mode=False,
                                                read_after_write=False)
    yield cocotb.external(
        sdhost.set_async_dma_reader_callback)(dma_read_callback)
    yield cocotb.external(sdhost.enable_async_dma_reader)(True)
    yield cocotb.external(sdhost.read_sd_data)(FUNCTION,
                                               ADDRESS,
                                               SIZE,
                                               fifo_mode=False)
    dut.log.debug("Waiting for function to finish...")
    yield (nysa.wait_clocks(4000))
    if not data_is_ready:
        raise TestFailure("Async Read Never Finished!")

    read_data = sdhost.read_async_data()
    dut.log.debug("Async Data: %s" % print_hex_array(read_data))
    fail = False
    for i in range(len(write_data)):
        if write_data[i] != read_data[i]:
            fail = True
    if fail:
        raise TestFailure(
            "Async Block Read Transfer Failed, %s != %s" %
            (print_hex_array(write_data), print_hex_array(read_data)))
コード例 #24
0
ファイル: test_dut.py プロジェクト: zhuyh128/nysa-verilog
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))
コード例 #25
0
def small_multi_byte_data_write_to_func1(dut):
    """
    Description:
        Perform a small write on the data bus

    Test ID: 12

    Expected Results:
        Multi byte data transfer, this will use the data bus, not FIFO mode
    """
    dut.test_id = 12
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #data = Array ('B', [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
    data = Array('B')
    for i in range(16):
        value = i % 256
        data.append(value)
    data = [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF]
    yield cocotb.external(sdhost.write_sd_data)(1,
                                                0x00,
                                                data,
                                                fifo_mode=False,
                                                read_after_write=False)
    yield (nysa.wait_clocks(100))
    read_data = yield cocotb.external(sddev.read_local_buffer)(0,
                                                               len(data) / 4)
    print "Read data: %s" % print_hex_array(read_data)
    yield (nysa.wait_clocks(1000))
コード例 #26
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def receive_byte_test(dut):
    """
    Description:
        Initiate an SD transaction

    Test ID: 3

    Expected Results:
        Single Data Read
    """
    dut.test_id = 3
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    value = yield cocotb.external(sdhost.read_config_byte)(0x00)
    if value != 0x43:
        raise TestFailure("Failed to Read Configuration Byte at Address 0: bad value: 0x%02X" % value)
    dut.log.debug("Read value: 0x%02X" % value)
    value = yield cocotb.external(sdhost.read_config_byte)(0x01)
    if value != 0x03:
        raise TestFailure("Failed to Read Configuration Byte at Address 1: bad value: 0x%02X" % value)
    dut.log.debug("Read value: 0x%02X" % value)
    value = yield cocotb.external(sdhost.read_config_byte)(0x02)
    if value != 0x00:
        raise TestFailure("Failed to Read Configuration Byte at Address 2: bad value: 0x%02X" % value)
    dut.log.debug("Read value: 0x%02X" % value)

    yield (nysa.wait_clocks(1000))
コード例 #27
0
ファイル: test_dut.py プロジェクト: zhuyh128/nysa-verilog
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))
コード例 #28
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def test_double_buffer(dut):
    """
    Description:
        Setup a channel to transfer data

    Test ID: 7

    Expected Results:
        Data is all transferred from one memory device to the next
    """
    dut.test_id = 7
    #nysa = NysaSim(dut)
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    yield (nysa.reset())
    nysa.read_sdb()
    yield nysa.wait_clocks(10)

    dma = DMA(nysa, nysa.find_device(DMA)[0])
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])
    setup_sata(dut)

    yield cocotb.external(sata.enable_sata_reset)(False)

    yield cocotb.external(dma.setup)()
    yield cocotb.external(dma.enable_dma)(True)
    #yield nysa.wait_clocks(10)

    #Enable the hard drive data generator
    dut.h2u_read_enable = 1

    #Instructions
    INST_START_ADDR = 0

    #Channels
    SOURCE_CHANNEL = 0

    MEM_SINK_CHANNEL = 2
    MEM_SOURCE_CHANNEL = 2

    SINK_CHANNEL = 1

    #Addresses
    SOURCE_ADDR = 0x0000

    MEM_ADDR0 = 0x0000
    MEM_ADDR1 = 0x0000

    SINK_ADDR = 0x0000

    #Count
    COUNT = 0x0080

    print "Setup double buffer"

    source_error = get_source_error_signal(dut, SOURCE_CHANNEL)
    sink_error = get_sink_error_signal(dut, SINK_CHANNEL)

    source_error_monitor = ErrorMonitor(dut, source_error)
    sink_error_monitor = ErrorMonitor(dut, sink_error)

    #Setup Address Increments for all sinks and sources
    yield cocotb.external(dma.enable_source_address_increment)(SOURCE_CHANNEL,
                                                               True)
    yield cocotb.external(dma.enable_dest_address_increment)(SINK_CHANNEL,
                                                             True)
    yield cocotb.external(dma.enable_dest_respect_quantum)(MEM_SINK_CHANNEL,
                                                           True)

    yield cocotb.external(dma.enable_source_address_increment)(
        MEM_SOURCE_CHANNEL, True)
    yield cocotb.external(dma.enable_dest_respect_quantum)(MEM_SINK_CHANNEL,
                                                           False)
    yield cocotb.external(dma.enable_dest_address_increment)(MEM_SINK_CHANNEL,
                                                             True)

    yield cocotb.external(dma.set_channel_sink_addr)(SOURCE_CHANNEL,
                                                     MEM_SINK_CHANNEL)
    yield cocotb.external(dma.set_channel_sink_addr)(MEM_SOURCE_CHANNEL,
                                                     SINK_CHANNEL)


    yield cocotb.external(dma.setup_double_buffer)                      \
                        (    start_inst_addr =   INST_START_ADDR,       \
                             source          =   SOURCE_CHANNEL,        \
                             sink            =   SINK_CHANNEL,          \
                             mem_sink        =   MEM_SINK_CHANNEL,      \
                             mem_source      =   MEM_SOURCE_CHANNEL,    \
                             source_addr     =   SOURCE_ADDR,           \
                             sink_addr       =   SINK_ADDR,             \
                             mem_addr0       =   MEM_ADDR0,             \
                             mem_addr1       =   MEM_ADDR1,             \
                             count           =   COUNT  )

    yield cocotb.external(dma.enable_channel)(SOURCE_CHANNEL, True)
    yield cocotb.external(dma.enable_channel)(MEM_SOURCE_CHANNEL, True)

    yield nysa.wait_clocks(4000)

    yield cocotb.external(dma.enable_channel)(SOURCE_CHANNEL, False)
    yield cocotb.external(dma.enable_channel)(MEM_SOURCE_CHANNEL, False)

    if len(source_error_monitor) > 0:
        raise cocotb.result.TestFailure(
            "Test %d Error on source %d read detected %d errors" %
            (dut.test_id, SOURCE_CHANNEL, len(source_error_monitor)))

    if len(sink_error_monitor) > 0:
        raise cocotb.result.TestFailure(
            "Test %d Error on sink %d read detected %d errors" %
            (dut.test_id, SINK_CHANNEL, len(sink_error_monitor)))

    source_error_monitor.kill()
    sink_error_monitor.kill()
    yield nysa.wait_clocks(100)
    dut.h2u_read_enable = 0
コード例 #29
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))
コード例 #30
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def data_block_write(dut):
    """
    Description:
        Perform a block write

    Test ID: 6

    Expected Results:
        Block Transfer (Write)
    """
    dut.test_id = 6
    FUNCTION = 1
    ADDRESS = 0x00
    BLOCK_SIZE = 0x08
    SIZE = 0x10

    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)

    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))
    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))


    #Enable SDIO

    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #Enable Function
    yield cocotb.external(sdhost.enable_function)(FUNCTION)
    yield cocotb.external(sdhost.set_function_block_size)(FUNCTION, BLOCK_SIZE)

    write_data = Array ('B')
    for i in range (SIZE):
        value = i % 256
        write_data.append(value)
    yield cocotb.external(sdhost.write_sd_data)(FUNCTION, ADDRESS, write_data, fifo_mode = False, read_after_write = False)
    yield (nysa.wait_clocks(2000))
    read_data = yield cocotb.external(sdhost.read_sd_data)( function_id = FUNCTION,
                                                            address     = ADDRESS,
                                                            byte_count  = len(write_data),
                                                            fifo_mode   = False)
    yield (nysa.wait_clocks(2000))
    fail = False
    for i in range(len(write_data)):
        if write_data[i] != read_data[i]:
            fail = True

    if fail:
        raise TestFailure("Block Write Transfer Failed, %s != %s" % (print_hex_array(write_data), print_hex_array(read_data)))
コード例 #31
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))
コード例 #32
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def data_block_read(dut):
    """
    Description:
        Perform a block read

    Test ID: 7

    Expected Results:
        Block Transfer (Read)
    """
    dut.test_id = 7
    BLOCK_SIZE = 0x08
    SIZE = 0x10
    FUNCTION = 0
    ADDRESS = 0x00

    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)

    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))
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)
    yield cocotb.external(sdhost.set_function_block_size)(FUNCTION, BLOCK_SIZE)

    data = yield cocotb.external(sdhost.read_sd_data)(FUNCTION, ADDRESS, SIZE, fifo_mode = False)
    print "Data: %s" % print_hex_array(data)
    yield (nysa.wait_clocks(2000))
コード例 #33
0
def detect_interrupt(dut):
    """
    Description:
        Detect an interrupt

    Test ID: 10

    Expected Results:
        Block Transfer (Read)
    """
    dut.test_id = 10

    FUNCTION = 1
    BLOCK_SIZE = 0x08
    READ_SIZE = 0x18

    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)

    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))
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #Configure an interrupt callback
    sdhost.set_interrupt_callback(interrupt_callback)

    #Enable Function
    yield cocotb.external(sdhost.enable_function)(FUNCTION)
    #Enable Interrupts on Device
    yield cocotb.external(sdhost.enable_function_interrupt)(FUNCTION)
    pending = yield cocotb.external(sdhost.is_interrupt_pending)(FUNCTION)
    dut.log.debug("Is Interrupt Pending? %s" % pending)

    #Enable Interrupt on controller
    yield cocotb.external(sdhost.enable_interrupt)(True)
    yield (nysa.wait_clocks(100))
    #Generate an interrupt
    dut.request_interrupt = 1
    #Detect an interrupt from the device
    pending = yield cocotb.external(sdhost.is_interrupt_pending)(FUNCTION)
    dut.log.debug("Is Interrupt Pending? %s" % pending)

    yield (nysa.wait_clocks(3000))
    if not interrupt_called:
        raise TestFailure("Interrupt was not detected")
コード例 #34
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def detect_interrupt(dut):
    """
    Description:
        Detect an interrupt

    Test ID: 10

    Expected Results:
        Block Transfer (Read)
    """
    dut.test_id = 10

    FUNCTION = 1
    BLOCK_SIZE = 0x08
    READ_SIZE = 0x18

    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)

    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))
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #Configure an interrupt callback
    sdhost.set_interrupt_callback(interrupt_callback)

    #Enable Function
    yield cocotb.external(sdhost.enable_function)(FUNCTION)
    #Enable Interrupts on Device
    yield cocotb.external(sdhost.enable_function_interrupt)(FUNCTION)
    pending = yield cocotb.external(sdhost.is_interrupt_pending)(FUNCTION)
    dut.log.debug("Is Interrupt Pending? %s" % pending)

    #Enable Interrupt on controller
    yield cocotb.external(sdhost.enable_interrupt)(True)
    yield (nysa.wait_clocks(100))
    #Generate an interrupt
    dut.request_interrupt = 1
    #Detect an interrupt from the device
    pending = yield cocotb.external(sdhost.is_interrupt_pending)(FUNCTION)
    dut.log.debug("Is Interrupt Pending? %s" % pending)

    yield (nysa.wait_clocks(3000))
    if not interrupt_called:
        raise TestFailure("Interrupt was not detected")
コード例 #35
0
def data_block_write(dut):
    """
    Description:
        Perform a block write

    Test ID: 6

    Expected Results:
        Block Transfer (Write)
    """
    dut.test_id = 6
    FUNCTION = 1
    ADDRESS = 0x00
    BLOCK_SIZE = 0x08
    SIZE = 0x10

    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)

    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))
    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))

    #Enable SDIO

    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #Enable Function
    yield cocotb.external(sdhost.enable_function)(FUNCTION)
    yield cocotb.external(sdhost.set_function_block_size)(FUNCTION, BLOCK_SIZE)

    write_data = Array('B')
    for i in range(SIZE):
        value = i % 256
        write_data.append(value)
    yield cocotb.external(sdhost.write_sd_data)(FUNCTION,
                                                ADDRESS,
                                                write_data,
                                                fifo_mode=False,
                                                read_after_write=False)
    yield (nysa.wait_clocks(2000))
    read_data = yield cocotb.external(sdhost.read_sd_data)(
        function_id=FUNCTION,
        address=ADDRESS,
        byte_count=len(write_data),
        fifo_mode=False)
    yield (nysa.wait_clocks(2000))
    fail = False
    for i in range(len(write_data)):
        if write_data[i] != read_data[i]:
            fail = True

    if fail:
        raise TestFailure(
            "Block Write Transfer Failed, %s != %s" %
            (print_hex_array(write_data), print_hex_array(read_data)))
コード例 #36
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def data_async_block_read_write_long_transfer(dut):
    """
    Description:
        Perform a block read using asynchronous transfer

    Test ID: 11

    Expected Results:
        Block Transfer (Read)
    """
    dut.test_id = 11
    ADDRESS = 0x00
    FUNCTION = 1
    BLOCK_SIZE = 0x08
    SIZE = 0x18

    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)

    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))
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #Enable Function
    yield cocotb.external(sdhost.enable_function)(FUNCTION)
    yield cocotb.external(sdhost.set_function_block_size)(FUNCTION, BLOCK_SIZE)

    write_data = Array ('B')
    for i in range (SIZE):
        value = i % 256
        write_data.append(value)
    yield cocotb.external(sdhost.write_sd_data)(FUNCTION, ADDRESS, write_data, fifo_mode = False, read_after_write = False)
    yield cocotb.external(sdhost.set_async_dma_reader_callback)(dma_read_callback)
    yield cocotb.external(sdhost.enable_async_dma_reader)(True)
    yield cocotb.external(sdhost.read_sd_data)(FUNCTION, ADDRESS, SIZE, fifo_mode = False)
    dut.log.debug("Waiting for function to finish...")
    yield (nysa.wait_clocks(4000))
    if not data_is_ready:
        raise TestFailure("Async Read Never Finished!")

    read_data = sdhost.read_async_data()
    dut.log.debug("Async Data: %s" % print_hex_array(read_data))
    fail = False
    for i in range(len(write_data)):
        if write_data[i] != read_data[i]:
            fail = True
    if fail:
        raise TestFailure("Async Block Read Transfer Failed, %s != %s" % (print_hex_array(write_data), print_hex_array(read_data)))
コード例 #37
0
ファイル: test_dut.py プロジェクト: younew/nysa-verilog
def test_dma_read_write_transfer(dut):
    """
    Description:
        Simple DMA Transfer

    Test ID: 3

    Expected Results:
    """
    dut.test_id = 3
    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))
    driver = wb_hs_demoDriver(nysa, nysa.find_device(wb_hs_demoDriver)[0])
    dma = DMA(nysa, nysa.find_device(DMA)[0])
    yield cocotb.external(dma.setup)()
    yield cocotb.external(dma.enable_dma)(True)
    yield(nysa.wait_clocks(10))

    count = yield cocotb.external(dma.get_channel_count)()
    dut.log.info("DMA Channel Count: %d" % count)

    #WORD_COUNT = 0x880
    #WORD_COUNT = 0x1000
    #WORD_COUNT = 0x0800
    #WORD_COUNT = 0x400
    WORD_COUNT = 0x400
    #WORD_COUNT = 0x800000
    CHANNEL_ADDR = 1
    SINK_ADDR = 3
    INST_ADDR = 7

    SOURCE_ADDRESS  = 0x0000000000000000
    DEST_ADDRESS    = 0x0000000000000000


    yield cocotb.external(dma.set_channel_sink_addr)            (CHANNEL_ADDR,  SINK_ADDR           )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)  (CHANNEL_ADDR,  INST_ADDR           )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_source_address_increment)  (CHANNEL_ADDR,  True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_address_increment)    (SINK_ADDR,     True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_respect_quantum)      (SINK_ADDR,     False              )
    #yield cocotb.external(dma.enable_dest_respect_quantum)      (SINK_ADDR,     True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_source_address)   (INST_ADDR,     SOURCE_ADDRESS      )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_dest_address)     (INST_ADDR,     DEST_ADDRESS        )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_data_count)       (INST_ADDR,     WORD_COUNT          )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)  (CHANNEL_ADDR,  INST_ADDR           )
    yield nysa.wait_clocks(10)
    #Start
    yield cocotb.external(dma.enable_channel)                   (CHANNEL_ADDR,  True                )

    yield nysa.wait_clocks(10000)
    yield cocotb.external(dma.enable_channel)                   (CHANNEL_ADDR,  False               )
    yield cocotb.external(dma.enable_dma)(False)
    yield nysa.wait_clocks(10)



    WORD_COUNT = 0x400
    CHANNEL_ADDR = 3
    SINK_ADDR = 0
    INST_ADDR = 0

    SOURCE_ADDRESS  = 0x0000000000000000
    DEST_ADDRESS    = 0x0000000000000000

    yield cocotb.external(dma.set_channel_sink_addr)            (CHANNEL_ADDR,  SINK_ADDR           )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)  (CHANNEL_ADDR,  INST_ADDR           )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_source_address_increment)  (CHANNEL_ADDR,  True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_address_increment)    (SINK_ADDR,     True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_respect_quantum)      (SINK_ADDR,     False              )
    #yield cocotb.external(dma.enable_dest_respect_quantum)      (SINK_ADDR,     True                )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_source_address)   (INST_ADDR,     SOURCE_ADDRESS      )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_dest_address)     (INST_ADDR,     DEST_ADDRESS        )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_data_count)       (INST_ADDR,     WORD_COUNT          )
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)  (CHANNEL_ADDR,  INST_ADDR           )
    yield nysa.wait_clocks(10)
    #Start
    yield cocotb.external(dma.enable_channel)                   (CHANNEL_ADDR,  True                )

    yield nysa.wait_clocks(10000)
    yield cocotb.external(dma.enable_channel)                   (CHANNEL_ADDR,  False               )
    yield cocotb.external(dma.enable_dma)(False)
    yield nysa.wait_clocks(10)


    '''
    data = Array('B')
    SIZE =1024
    for i in range(SIZE):
        data.append(i % 256)

    yield cocotb.external(driver.write_data)(0x00, data)
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.read_data)(0x00, (SIZE / 4))

    if len(v) != len(data):
        raise cocotb.result.TestFailure("Test %d: Length of incomming data and outgoing data is equal %d = %d" % (dut.test_id, len(v), len(data)))

    for i in range(len(data)):
        if v[i] != data[i]:
            raise cocotb.result.TestFailure("Test %d: Address 0x%02X 0x%02X != 0x%02X" % (dut.test_id, i, v[i], data[i]))

    '''
    dut.log.info("Success")
コード例 #38
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def small_multi_byte_data_write_to_func1(dut):
    """
    Description:
        Perform a small write on the data bus

    Test ID: 12

    Expected Results:
        Multi byte data transfer, this will use the data bus, not FIFO mode
    """
    dut.test_id = 12
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #data = Array ('B', [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
    data = Array ('B')
    for i in range (16):
        value = i % 256
        data.append(value)
    data = [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF]
    yield cocotb.external(sdhost.write_sd_data)(1, 0x00, data, fifo_mode = False, read_after_write = False)
    yield (nysa.wait_clocks(100))
    read_data = yield cocotb.external(sddev.read_local_buffer)(0, len(data) / 4)
    print "Read data: %s" % print_hex_array(read_data)
    yield (nysa.wait_clocks(1000))
コード例 #39
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def small_multi_byte_data_write(dut):
    """
    Description:
        Perform a small write on the data bus

    Test ID: 4

    Expected Results:
        Multi byte data transfer, this will use the data bus, not FIFO mode
    """
    dut.test_id = 4
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    #data = Array ('B', [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
    data = Array ('B')
    for i in range (8):
        value = i % 256
        data.append(value)
    yield cocotb.external(sdhost.write_sd_data)(0, 0x00, data, fifo_mode = False, read_after_write = False)
    value = dut.s2.sdio_device.cia.cccr.o_func_enable.value.get_value()
    if value != 0x02:
        raise TestFailure ("Failed to write configuration byte to CCCR Memory Space: Should be 0x02 is: 0x%02X" % value)
    value = dut.s2.sdio_device.cia.cccr.o_func_int_enable.value.get_value()
    if value != 0x04:
        raise TestFailure ("Failed to write configuration byte to CCCR Memory Space: Should be 0x04 is: 0x%02X" % value)
    yield (nysa.wait_clocks(1000))
コード例 #40
0
ファイル: test_sata.py プロジェクト: zhuyh128/nysa-verilog
def test_continuous_transfer(dut):
    """
    Description:
        Setup a channel to transfer data

    Test ID: 6

    Expected Results:
        Data is all transferred from one memory device to the next
    """
    dut.test_id = 6
    #nysa = NysaSim(dut)
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths=[MODULE_PATH])
    yield (nysa.reset())
    nysa.read_sdb()
    yield nysa.wait_clocks(2000)

    dma = DMA(nysa, nysa.find_device(DMA)[0])
    sata = SATADriver(nysa, nysa.find_device(SATADriver)[0])
    setup_sata(dut)

    yield cocotb.external(sata.enable_sata_reset)(False)

    yield cocotb.external(dma.setup)()
    yield cocotb.external(dma.enable_dma)(True)
    #yield nysa.wait_clocks(10)

    CHANNEL_ADDR = 0
    SINK_ADDR = 2
    INST_ADDR = 2

    source_error = get_source_error_signal(dut, CHANNEL_ADDR)
    sink_error = get_sink_error_signal(dut, SINK_ADDR)
    source_error_monitor = ErrorMonitor(dut, source_error)
    sink_error_monitor = ErrorMonitor(dut, sink_error)
    #yield cocotb.external(dma.enable_channel)                   (CHANNEL_ADDR,  False               )

    yield cocotb.external(dma.set_channel_sink_addr)(CHANNEL_ADDR, SINK_ADDR)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_channel_instruction_pointer)(CHANNEL_ADDR,
                                                               INST_ADDR)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_source_address_increment)(CHANNEL_ADDR,
                                                               True)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_address_increment)(SINK_ADDR, True)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dest_respect_quantum)(SINK_ADDR, False)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_instruction_continue)(INST_ADDR, True)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_source_address)(
        INST_ADDR, 0x0000000000000000)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_dest_address)(INST_ADDR,
                                                            0x0000000000000010)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_data_count)(INST_ADDR, 0x0100)
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.set_instruction_next_instruction)(INST_ADDR,
                                                                INST_ADDR)
    yield nysa.wait_clocks(10)

    #Start
    yield cocotb.external(dma.set_channel_instruction_pointer)(CHANNEL_ADDR,
                                                               INST_ADDR)
    yield cocotb.external(dma.enable_channel)(CHANNEL_ADDR, True)

    yield nysa.wait_clocks(2000)
    yield cocotb.external(dma.enable_channel)(CHANNEL_ADDR, False)
    yield cocotb.external(dma.enable_dma)(False)
    yield nysa.wait_clocks(10)

    if len(source_error_monitor) > 0:
        raise cocotb.result.TestFailure(
            "Test %d Error on source %d read detected %d errors" %
            (dut.test_id, CHANNEL_ADDR, len(source_error_monitor)))

    if len(sink_error_monitor) > 0:
        raise cocotb.result.TestFailure(
            "Test %d Error on sink %d write detected %d errors" %
            (dut.test_id, SINK_ADDR, len(sink_error_monitor)))

    source_error_monitor.kill()
    sink_error_monitor.kill()
コード例 #41
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
def small_multi_byte_data_read(dut):
    """
    Description:
        Perform a small read on the data bus

    Test ID: 5

    Expected Results:
        Multi byte data transfer, this will use the data bus, not CMC mode
    """
    dut.test_id = 5
    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)

    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))
    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))


    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v = True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    data = yield cocotb.external(sdhost.read_sd_data)(  function_id = 0,
                                                        address     = 0x00,
                                                        byte_count  = 8,
                                                        fifo_mode   = False)

    #print "data: %s" % print_hex_array(data)
    fail = False
    test_data = Array('B', [0x43, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
    for i in range (len(data)):
        if data[i] != test_data[i]:
            fail = True
            break

    if fail:
        raise TestFailure("Multi-Byte Read incorrect: %s != %s" % (print_hex_array(test_data), print_hex_array(data)))

    yield (nysa.wait_clocks(1000))
コード例 #42
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
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)))
コード例 #43
0
ファイル: test_dut.py プロジェクト: CospanDesign/nysa-verilog
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))
コード例 #44
0
def receive_byte_test(dut):
    """
    Description:
        Initiate an SD transaction

    Test ID: 3

    Expected Results:
        Single Data Read
    """
    dut.test_id = 3
    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))

    #Enable SDIO
    yield cocotb.external(sdhost.enable_sd_host)(True)
    yield cocotb.external(sdhost.cmd_io_send_op_cond)(enable_1p8v=True)
    yield cocotb.external(sdhost.cmd_get_relative_card_address)()
    yield cocotb.external(sdhost.cmd_enable_card)(True)

    value = yield cocotb.external(sdhost.read_config_byte)(0x00)
    if value != 0x43:
        raise TestFailure(
            "Failed to Read Configuration Byte at Address 0: bad value: 0x%02X"
            % value)
    dut.log.debug("Read value: 0x%02X" % value)
    value = yield cocotb.external(sdhost.read_config_byte)(0x01)
    if value != 0x03:
        raise TestFailure(
            "Failed to Read Configuration Byte at Address 1: bad value: 0x%02X"
            % value)
    dut.log.debug("Read value: 0x%02X" % value)
    value = yield cocotb.external(sdhost.read_config_byte)(0x02)
    if value != 0x00:
        raise TestFailure(
            "Failed to Read Configuration Byte at Address 2: bad value: 0x%02X"
            % value)
    dut.log.debug("Read value: 0x%02X" % value)

    yield (nysa.wait_clocks(1000))