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