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")
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)
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
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
def _initialize(self, platform, urn): self.v = View(self.status, self.actions) self.drv = SATADriver(platform, urn) self.refresh()
class Controller(NysaBaseController): @staticmethod def get_name(): return APP_NAME @staticmethod def get_driver(): return DRIVER def __init__(self): super (Controller, self).__init__() self.actions = SataActions() self.actions.sata_refresh.connect(self.refresh) self.actions.sata_command_layer_reset.connect (self.sata_command_layer_reset ) self.actions.en_hd_int_changed.connect (self.en_hd_int_changed ) self.actions.en_dma_activate_int_changed.connect (self.en_dma_activate_int_changed ) self.actions.en_d2h_reg_int_changed.connect (self.en_d2h_reg_int_changed ) self.actions.en_pio_setup_int_changed.connect (self.en_pio_setup_int_changed ) self.actions.en_d2h_data_int_changed.connect (self.en_d2h_data_int_changed ) self.actions.en_dma_setup_int_changed.connect (self.en_dma_setup_int_changed ) self.actions.en_set_device_bits_int_changed.connect (self.en_set_device_bits_int_changed ) self.actions.sata_reset.connect (self.sata_reset ) self.actions.send_hard_drive_command.connect (self.send_hard_drive_command ) self.actions.send_hard_drive_features.connect (self.send_hard_drive_features ) def _initialize(self, platform, urn): self.v = View(self.status, self.actions) self.drv = SATADriver(platform, urn) self.refresh() def start_tab_view(self, platform, urn, status): self.status = status self.status.Verbose( "Starting Template Application") self._initialize(platform, urn) def get_view(self): return self.v def refresh(self): self.status.Debug("Refresh") self.v.enable_sata_reset(self.drv.is_sata_reset()) self.v.enable_sata_reset_active(self.drv.is_sata_reset_active()) self.v.enable_command_layer_reset_checkbox(self.drv.is_sata_command_layer_reset()) self.v.enable_hd_int(self.drv.is_hd_interrupt()) self.v.enable_dma_activate_int(self.drv.is_dma_activate_stb()) self.v.enable_d2h_reg_int(self.drv.is_d2h_reg_stb()) self.v.enable_pio_setup_int(self.drv.is_pio_setup_stb()) self.v.enable_d2h_data_int(self.drv.is_d2h_data_stb()) self.v.enable_dma_setup_int(self.drv.is_dma_setup_stb()) self.v.enable_set_device_bits_int(self.drv.is_set_device_bits_stb()) self.v.enable_platform_ready(self.drv.is_platform_ready()) self.v.enable_platform_error(self.drv.is_platform_error()) self.v.enable_linkup(self.drv.is_linkup()) self.v.enable_sata_busy(self.drv.is_sata_busy()) self.v.enable_command_layer_ready(self.drv.is_command_layer_ready()) self.v.enable_transport_layer_ready(self.drv.is_transport_layer_ready()) self.v.enable_link_layer_ready(self.drv.is_link_layer_ready()) self.v.enable_phy_layer_ready(self.drv.is_phy_ready()) self.v.enable_hard_drive_error(self.drv.is_hard_drive_error()) self.v.enable_pio_data_ready(self.drv.is_pio_data_ready()) self.v.enable_d2h_interrupt(self.drv.is_d2h_interrupt()) self.v.enable_d2h_notification(self.drv.is_d2h_notification()) self.v.enable_d2h_pmult(self.drv.get_d2h_pmult()) self.v.enable_d2h_status(self.drv.get_d2h_status()) self.v.enable_d2h_error(self.drv.get_d2h_error()) self.v.enable_rx_comm_init_detect(self.drv.get_rx_comm_init_detect()) self.v.enable_rx_comm_wake_detect(self.drv.get_rx_comm_wake_detect()) self.v.enable_tx_oob_complete(self.drv.get_tx_oob_complete()) self.v.enable_tx_comm_reset(self.drv.get_tx_comm_reset()) self.v.enable_tx_comm_wake(self.drv.get_tx_comm_wake()) self.v.set_oob_state(self.drv.get_oob_state()) self.v.set_debug_linkup_data(self.drv.get_debug_linkup_data()) self.v.set_d2h_lba(self.drv.get_hard_drive_lba()) self.v.set_d2h_fis(self.drv.get_d2h_fis()) def sata_reset(self, enable): self.drv.enable_sata_reset(enable) def sata_command_layer_reset(self, enable): self.drv.enable_sata_command_layer_reset(enable) def en_hd_int_changed(self, enable): self.drv.enable_hd_interrupt(enable) def en_dma_activate_int_changed(self, enable): self.drv.enable_dma_activate_stb(enable) def en_d2h_reg_int_changed(self, enable): self.enable_d2h_reg_stb(enable) def en_pio_setup_int_changed(self, enable): self.enable_d2h_reg_stb(enable) def en_d2h_data_int_changed(self, enable): self.enable_d2h_data_stb(enable) def en_dma_setup_int_changed(self, enable): self.enable_dma_setup_stb(enable) def en_set_device_bits_int_changed(self, enable): self.enable_set_device_bits_set(enable) def send_hard_drive_features(self, features): self.drv.send_hard_drive_features(features) def send_hard_drive_command(self, command): self.status.Info("Sending Command: 0x%02X" % command) self.drv.send_hard_drive_command(command)
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
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()
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()