Beispiel #1
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))
Beispiel #2
0
def master_write_read(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 4

    Expected Results:
        Write to all registers
    """

    dut.test_id = 4
    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()

    dut.log.info("Read Master Flags")
    write_flags = yield cocotb.external(nysa.read_master_register)(0x00)
    yield (nysa.wait_clocks(100))
    dut.log.info("Writing flags: 0x%08X" % write_flags)
    write_flags = 0x001
    yield cocotb.external(nysa.write_master_register)(0x00, write_flags)
    yield (nysa.wait_clocks(100))

    write_flags = yield cocotb.external(nysa.read_master_register)(0x00)
    yield (nysa.wait_clocks(100))
    dut.log.info("Writing flags: 0x%08X" % write_flags)
    yield cocotb.external(nysa.write_master_register)(0x00, 0x00)
Beispiel #3
0
def small_write_read(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 = ft_fifo_testerDriver(nysa, nysa.find_device(ft_fifo_testerDriver)[0])
    dut.log.info("Ready")

    #For a demo write a value to the control register (See the ${SDB_NAME}Driver 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))
    read_value = yield cocotb.external(driver.get_control)()
    yield (nysa.wait_clocks(100))
    dut.log.info("Control Register: 0x%08X" % read_value)
Beispiel #4
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")
Beispiel #5
0
def memory_read_write_test(dut):

    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 = wb_master_testDriver(nysa, nysa.find_device(wb_master_testDriver)[0])
    yield (nysa.wait_clocks(10))
    dut.log.info("Ready")
    LENGTH = 100
    DATA = Array('B')
    for i in range (LENGTH):
        DATA.append(i % 256)

    while len(DATA) % 4 != 0:
        DATA.append(0)

    yield cocotb.external(nysa.write_memory)(0x00000, DATA)
    data = yield cocotb.external(nysa.read_memory)(0x00000, (len(DATA) / 4))
    for i in range (len(DATA)):
        if DATA[i] != data[i]:
            log.error("Failed at Address: %04d: 0x%02X != 0x%02X" % (i, DATA[i], data[i]))
Beispiel #6
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa
            Startup DMA Controller

    Test ID: 0

    Expected Results:
        Write to all registers
    """

    dut.test_id = 0
    nysa = NysaSim(dut)
    yield(nysa.reset())
    nysa.read_sdb()

    nysa.pretty_print_sdb()
    dma = DMA(nysa, nysa.find_device(DMA)[0])
    yield cocotb.external(dma.setup)()
    yield cocotb.external(dma.get_channel_count)()

    dut.log.info("DMA Opened!")
    dut.log.info("Ready")
Beispiel #7
0
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")
Beispiel #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)(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)
Beispiel #9
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))
Beispiel #10
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))
Beispiel #11
0
def send_byte_test(dut):
    """
    Description:
        Initiate an SD transaction

    Test ID: 2

    Expected Results:
        Single Data Write
    """
    dut.test_id = 2
    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)
    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.write_config_byte)(0x02, 0x01)
    if dut.s2.sdio_device.cia.cccr.o_func_enable.value.get_value() != 1:
        raise TestFailure ("Failed to write configuration byte to CCCR Memory Space")

    yield (nysa.wait_clocks(1000))
Beispiel #12
0
def long_write_read(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)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = ft_fifo_testerDriver(nysa, nysa.find_device(ft_fifo_testerDriver)[0])
    dut.log.info("Ready")
    memory_urns = nysa.get_memory_devices_as_urns()
    mem_addrs = []
    for m in memory_urns:
        mem_addrs.append(nysa.get_device_address(m))
    dut.log.info("Memory Size: 0x%08X" % nysa.get_total_memory_size())

    #DWORD_SIZE = nysa.get_total_memory_size()
    DWORD_SIZE = 4
    write_data = Array('B')
    for i in range (0, DWORD_SIZE * 4, 4):

        write_data.append((i + 0) % 256)
        write_data.append((i + 1) % 256)
        write_data.append((i + 2) % 256)
        write_data.append((i + 3) % 256)


    #For a demo write a value to the control register (See the ${SDB_NAME}Driver for addresses)
    yield cocotb.external(nysa.write_memory)(0x00, write_data)
    yield (nysa.wait_clocks(100))
    read_data = yield cocotb.external(nysa.read_memory)(0x00, DWORD_SIZE)
    yield (nysa.wait_clocks(100))
    #dut.log.info("Read Data: %s" % list_to_hex_string(read_data))
    fail_count = 0

    if len(write_data) != len(read_data):
        print "Length of read data is not equal to the length of write data: 0x%04X != 0x!04X" % (len(write_data), len(read_data))

    else:
        for i in range(len(write_data)):
            if write_data[i] != read_data[i]:
                if fail_count < 16:
                    print "[0x%04X] %02X != %02X" % (i, write_data[i], read_data[i])
                fail_count += 1
Beispiel #13
0
def first_test(dut):
    """
    Description:
        Very Basic Functionality
            Startup Nysa

    Test ID: 0

    Expected Results:
        Write to all registers
    """


    '''
    cocotb.fork(Clock(dut.clk, CLK_PERIOD).start())
    ingress = PPFIFOIngress(dut, "ingress", dut.clk)
    egress = PPFIFOEgress(dut, "egress", dut.clk)
    dut.test_id <= 0
    dut.rst     <= 0
    yield ClockCycles(dut.clk, 10)
    dut.rst     <= 1
    dut.log.info("Started")
    yield ClockCycles(dut.clk, 10)
    dut.rst     <= 0
    yield ClockCycles(dut.clk, 10)
    '''

    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_master_testDriver(nysa, nysa.find_device(wb_master_testDriver)[0])
    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")
    LENGTH = 100
    DATA = Array('B')
    for i in range (LENGTH):
        DATA.append(i % 256)

    while len(DATA) % 4 != 0:
        DATA.append(0)

    yield cocotb.external(nysa.write_memory)(0x00, DATA)
Beispiel #14
0
def interrupt_test(dut):
    """
    Description:
        Initiate an interrupt

    Test ID: 3

    Expected Results:
        Detect an interrupt
    """

    dut.test_id <= 3


    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_master_testDriver(nysa, nysa.find_device(wb_master_testDriver)[0])
    yield cocotb.external(driver.set_control)(0x02)

    yield (nysa.wait_clocks(1000))
Beispiel #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))
Beispiel #16
0
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")
Beispiel #17
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)))
def initial_hal_test(dut, debug=True):
    """Example of using the software HAL against cosim testbench"""

    cocotb.fork(Clock(dut.clk, 5000).start())
    yield reset(dut)

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

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

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

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

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

    state = hal.endian_swapper_init(0)

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

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

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

    dut._log.info("HAL call endian_swapper_enable successfully enabled the DUT")
Beispiel #19
0
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")
Beispiel #20
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)
Beispiel #21
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)))
Beispiel #22
0
def test_double_buffer(dut):
    """
    Description:
        Setup a channel to transfer data

    Test ID: 4

    Expected Results:
        Data is all transferred from one memory device to the next
    """
    dut.test_id = 4
    nysa = NysaSim(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield nysa.wait_clocks(10)

    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)

    #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)
Beispiel #23
0
def test_setup_dma(dut):
    """
    Description:
        Set Values Within Simulation and make sure they stimulate
        The correct places
            Read Number of Sources
            Read Number of Sinks
            Read Number of Instructions
            Source Testing:
                Enable DMA
                Source Address
                Address Increment
                Address Decrement
                Address No Change
                Set Sink Address
                Set Instruction Address
            Sink Testing:
                Sink Address
                Address Increment
                Address Decrement
                Address No Change
                Quantum
            Instruction
                Continue Testing
                Next Address
                Source Reset Address on Command
                Sink Reset Address on Command
                Egress Enable and Egress Bond Address
                Ingress Enable and Ingress Bond Address

    Test ID: 1

    Expected Results:
        Write to all registers
    """

    dut.test_id = 1
    nysa = NysaSim(dut)
    yield(nysa.reset())
    nysa.read_sdb()

    dma = DMA(nysa, nysa.find_device(DMA)[0])
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.setup)()
    yield nysa.wait_clocks(10)
    yield cocotb.external(dma.enable_dma)(True)
    yield nysa.wait_clocks(10)
    #print "Enable dma"

    SINK_ADDR = 2
    INST_ADDR = 7
    NEXT_INST_ADDR =3
    INGRESS_ADDR = 2
    EGRESS_ADDR = 4

    level = logging.INFO
    l = logging.getLogger("cocotb.gpi")
    #print "dma.channel_count: %d" % dma.channel_count

    #Source
    for i in range (0, dma.channel_count):
        #Set Channel Address Increment
        yield cocotb.external(dma.enable_source_address_increment)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_src_addr_inc[i].value.get_value():
            raise cocotb.result.TestFailure("Channel [%d] source addr increment is false when it should be true" % i)
        l.setLevel(level)
        r = yield cocotb.external(dma.is_source_address_increment)(i)
        if r != True:
            raise cocotb.result.TestFailure("Channel [%d] source Addr should be [%d] but is [%d]" % (i, INST_ADDR, r))

        yield cocotb.external(dma.enable_source_address_increment)(i, False)
        r = yield cocotb.external(dma.is_source_address_increment)(i)
        if r != False:
            raise cocotb.result.TestFailure("Channel [%d] source Addr should be [%d] but is [%d]" % (i, INST_ADDR, r))
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_src_addr_inc[i].value.get_value():
            raise cocotb.result.TestFailure("Channel [%d] source addr increment is false when it should be false" % i)
        l.setLevel(level)

        #Set Channel Address Decrement
        yield cocotb.external(dma.enable_source_address_decrement)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_src_addr_dec[i].value.get_value():
            raise cocotb.result.TestFailure("Channel [%d] source addr decrement is false when it should be true" % i)
        l.setLevel(level)
        r = yield cocotb.external(dma.is_source_address_decrement)(i)
        if r != True:
            raise cocotb.result.TestFailure("Channel [%d] source Addr should be [%d] but is [%d]" % (i, INST_ADDR, r))

        yield cocotb.external(dma.enable_source_address_decrement)(i, False)
        r = yield cocotb.external(dma.is_source_address_decrement)(i)
        if r != False:
            raise cocotb.result.TestFailure("Channel [%d] source Addr should be [%d] but is [%d]" % (i, INST_ADDR, r))
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_src_addr_dec[i].value.get_value():
            raise cocotb.result.TestFailure("Channel [%d] source addr decrement is true when it should be false" % i)
        l.setLevel(level)

        #Channel Enable
        yield cocotb.external(dma.enable_channel)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.dma_enable[i].value.get_value():
            raise cocotb.result.TestFailure("Channel [%d] source addr enable is false when it should be true" % i)
        l.setLevel(level)
        r = yield cocotb.external(dma.is_channel_enable)(i)

        if r == False:
            raise cocotb.result.TestFailure("Channel [%d] DMA Enable should be true but it is not" % (i))
        yield cocotb.external(dma.enable_channel)(i, False)
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.dma_enable[i].value.get_value():
            raise cocotb.result.TestFailure("Channel [%d] source addr enable is false when it should be true" % i)
        l.setLevel(level)
        r = yield cocotb.external(dma.is_channel_enable)(i)
        if r:
            raise cocotb.result.TestFailure("Channel [%d] DMA Enable should be false but it is not" % (i))

        #Set Channel Sink Address
        yield cocotb.external(dma.set_channel_sink_addr)(i, SINK_ADDR)
        l.setLevel(logging.ERROR)
        addr = get_register_range(dut.s1.dmacntrl.src_control[i], dmam.BIT_SINK_ADDR_TOP, dmam.BIT_SINK_ADDR_BOT)
        l.setLevel(level)
        if addr != SINK_ADDR:
            cocotb.result.TestFailure("Channel [%d] Sink Address should be [%d] but is [%d]" % (i, SINK_ADDR, addr))
        r = yield cocotb.external(dma.get_channel_sink_addr)(i)
        if SINK_ADDR != r:
            raise cocotb.result.TestFailure("Channel [%d] Sink Addr should be [%d] but is [%d]" % (i, SINK_ADDR, r))

        #Set Channel Instruction Address
        yield cocotb.external(dma.set_channel_instruction_pointer)(i, INST_ADDR)
        l.setLevel(logging.ERROR)
        inst_addr = get_register_range(dut.s1.dmacntrl.src_control[i], dmam.BIT_INST_PTR_TOP, dmam.BIT_INST_PTR_BOT)
        l.setLevel(level)
        if inst_addr != INST_ADDR:
            raise cocotb.result.TestFailure("Channel [%d] Insruction Addr should be [%d] but is [%d]" % (i, INST_ADDR, inst_addr))
        r = yield cocotb.external(dma.get_channel_instruction_pointer)(i)
        if INST_ADDR != r:
            raise cocotb.result.TestFailure("Channel [%d] Insruction Addr should be [%d] but is [%d]" % (i, INST_ADDR, r))

    #Sink
    for i in range (0, dma.sink_count):

        #Enable and Disable the dest incrementing
        yield cocotb.external(dma.enable_dest_address_increment)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_dest_addr_inc[i].value.get_value():
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Increment not enabled" % (i))
        l.setLevel(level)
        r = yield cocotb.external(dma.is_dest_address_increment)(i)
        if r != True:
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Increment not enabled" % (i))
        yield cocotb.external(dma.enable_dest_address_increment)(i, False)
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_dest_addr_inc[i].value.get_value():
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Increment not enabled" % (i))
        l.setLevel(level)
        r = yield cocotb.external(dma.is_dest_address_increment)(i)
        if r:
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Increment enabled" % (i))


        #Enable and Disable the dest decrementing
        yield cocotb.external(dma.enable_dest_address_decrement)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_dest_addr_dec[i].value.get_value():
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Decrement not enabled" % (i))
        l.setLevel(level)
        r = yield cocotb.external(dma.is_dest_address_decrement)(i)
        if r != True:
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Decrement not enabled" % (i))

        yield cocotb.external(dma.enable_dest_address_decrement)(i, False)
        if dut.s1.dmacntrl.flag_dest_addr_dec[i].value.get_value():
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Decrement not enabled" % (i))
        l.setLevel(level)
        r = yield cocotb.external(dma.is_dest_address_decrement)(i)
        if r:
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Decrement enabled" % (i))

        #Enable and Disable the sink respect quantum
        yield cocotb.external(dma.enable_dest_respect_quantum)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_dest_data_quantum[i].value.get_value():
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Respect Quantum not enabled" % (i))
        l.setLevel(level)
        r = yield cocotb.external(dma.is_dest_respect_quantum)(i)
        if r != True:
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Respect Quantum not enabled" % (i))

        yield cocotb.external(dma.enable_dest_respect_quantum)(i, False)
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_dest_data_quantum[i].value.get_value():
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Respect Quantum enabled" % (i))
        l.setLevel(level)
        r = yield cocotb.external(dma.is_dest_respect_quantum)(i)
        if r:
            raise cocotb.result.TestFailure("Sink [%d] DMA Sink Address Respect Quantum enabled" % (i))

    #Instruction
    for i in range(dma.get_instruction_count()):
        #Continue Testing
        yield cocotb.external(dma.enable_instruction_continue)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_instruction_continue[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Instruction Continue Not Enabled When it shouldn't be" % (i))
        l.setLevel(level)
        yield cocotb.external(dma.enable_instruction_continue)(i, False)
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_instruction_continue[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Instruction Continue Enabled When it shouldn't be" % (i))
        l.setLevel(level)

        #Next Address
        yield cocotb.external(dma.set_instruction_next_instruction)(i, NEXT_INST_ADDR)
        l.setLevel(logging.ERROR)
        addr = dut.s1.dmacntrl.cmd_next[i].value.get_value()
        l.setLevel(level)
        if addr != NEXT_INST_ADDR:
            raise cocotb.result.TestFailure("Instruction [%d] Next Address Should be [%d] but is [%d]" % (i, NEXT_INST_ADDR, addr))

        yield cocotb.external(dma.set_instruction_next_instruction)(i, 0)
        l.setLevel(logging.ERROR)
        addr = dut.s1.dmacntrl.cmd_next[i].value.get_value()
        l.setLevel(level)
        if addr != 0:
            raise cocotb.result.TestFailure("Instruction [%d] Next Address Should be [%d] but is [%d]" % (i, 0, addr))

        #Source Reset Address on Command
        yield cocotb.external(dma.enable_instruction_src_addr_reset_on_cmd)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_src_addr_rst_on_cmd[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Reset Source Address on command is not set" % (i))
        l.setLevel(level)
        yield cocotb.external(dma.enable_instruction_src_addr_reset_on_cmd)(i, False)
        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_src_addr_rst_on_cmd[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Reset Source Address on command is set" % (i))
        l.setLevel(level)

        #Sink Reset Address on Command
        yield cocotb.external(dma.enable_instruction_dest_addr_reset_on_cmd)(i, True)
        l.setLevel(logging.ERROR)
        if not dut.s1.dmacntrl.flag_dest_addr_rst_on_cmd[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Reset Destination Address on command is not set" % (i))
        l.setLevel(level)

        yield cocotb.external(dma.enable_instruction_dest_addr_reset_on_cmd)(i, False)
        if dut.s1.dmacntrl.flag_dest_addr_rst_on_cmd[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Reset Destination Address on command is set" % (i))
        l.setLevel(level)

        #Egress Enable and Egress Bond Address
        yield cocotb.external(dma.set_instruction_egress)(i, EGRESS_ADDR)
        yield cocotb.external(dma.enable_egress_bond)(i, True)
        l.setLevel(logging.ERROR)
        addr = dut.s1.dmacntrl.egress_bond_ip[i].value.get_value()

        if not dut.s1.dmacntrl.flag_egress_bond[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Egress is not Enabled when it should be" % (i))
        l.setLevel(level)

        if addr != EGRESS_ADDR:
            raise cocotb.result.TestFailure("Instruction [%d] Egress Address Should be [%d] but is [%d]" % (i, EGRESS_ADDR, addr))

        yield cocotb.external(dma.enable_egress_bond)(i, False)
        if dut.s1.dmacntrl.flag_egress_bond[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Egress is Enabled when it shouldn't be" % (i))

        #Ingress Enable and Ingress Bond Address
        yield cocotb.external(dma.set_instruction_ingress)(i, INGRESS_ADDR)
        yield cocotb.external(dma.enable_ingress_bond)(i, True)
        l.setLevel(logging.ERROR)
        addr = dut.s1.dmacntrl.ingress_bond_ip[i].value.get_value()
        if not dut.s1.dmacntrl.flag_ingress_bond[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Ingress is not Enabled when it should be" % (i))
        l.setLevel(level)
        if addr != INGRESS_ADDR:
            raise cocotb.result.TestFailure("Instruction [%d] Ingress Address Should be [%d] but is [%d]" % (i, EGRESS_ADDR, addr))

        yield cocotb.external(dma.enable_ingress_bond)(i, False)

        l.setLevel(logging.ERROR)
        if dut.s1.dmacntrl.flag_ingress_bond[i].value.get_value():
            raise cocotb.result.TestFailure("Instruction [%d] Ingress is Enabled when it shouldn't be" % (i))
        l.setLevel(level)


    print "Finished"


    yield nysa.wait_clocks(10)
Beispiel #24
0
def test_continuous_transfer(dut):
    """
    Description:
        Setup a channel to transfer data

    Test ID: 3

    Expected Results:
        Data is all transferred from one memory device to the next
    """
    dut.test_id = 3
    nysa = NysaSim(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield nysa.wait_clocks(2000)

    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)

    CHANNEL_ADDR = 3
    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()
Beispiel #25
0
def test_execute_single_instruction(dut):
    """
    Description:
        -Setup source and sink for 256 word transaction
        -Setup the source address to increment
        -Setup the sink address to increment
        -setup instruction

    Test ID: 2

    Expected Results:
        Data is all transferred from one memory device to the next
    """
    dut.test_id = 2
    nysa = NysaSim(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield nysa.wait_clocks(2000)

    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)

    CHANNEL_ADDR = 1
    SINK_ADDR = 0
    INST_ADDR = 7

    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,     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,     1000                )
    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(2000)
    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()
Beispiel #26
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))
Beispiel #27
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")
Beispiel #28
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)))
Beispiel #29
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))
Beispiel #30
0
def run_external(dut):
    yield cocotb.external(test_read)(dut)