Beispiel #1
0
def test_scm_extended(dut):
    """
    Read the 5 additional registers of the SCM and compares the response
    with the desired value
    """
    access = RegAccess(dut)

    yield _init_dut(dut)

    dut._log.info("Check contents of SYSTEM_VENDOR_ID")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.SCM_REG.SYSTEM_VENDOR_ID.value, 1)

    dut._log.info("Check contents of SYSTEM_DEVICE_ID")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.SCM_REG.SYSTEM_DEVICE_ID.value, 1)

    dut._log.info("Check contents of NUM_MOD")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.SCM_REG.NUM_MOD.value, 1)

    dut._log.info("Check contents of MAX_PKT_LEN")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.SCM_REG.MAX_PKT_LEN.value, 8)

    dut._log.info("Check contents of SYSRST")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.SCM_REG.SYSRST.value, 0)
Beispiel #2
0
def test_dem_uart_activation(dut):
    """
    Check if DEM_UART is handling the activation bit correctly
    """

    access = RegAccess(dut)

    yield _init_dut(dut)

    dut._log.info("Check contents of MOD_CS")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.BASE_REG.MOD_CS.value, 16, 0)

    yield _activate_module(dut)

    dut._log.info("Check contents of MOD_CS")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.BASE_REG.MOD_CS.value, 16, 1)

    _bus_to_di_fifo.clear()

    write_thread = cocotb.fork(_bus_to_di_tx(dut, num_transfers=5))

    read_thread = cocotb.fork(_bus_to_di_rx(dut, num_transfers=5))
    yield read_thread.join()

    yield access.write_register(dest=MODULE_DI_ADDRESS, src=SENDER_DI_ADDRESS,
                                word_width=16,
                                regaddr=DiPacket.BASE_REG.MOD_CS.value,
                                value=0)

    write_thread = cocotb.fork(_bus_to_di_tx(dut, num_transfers=5))

    # Wait one cycle to make sure the reader below doesn't accidentally try to
    # receive parts of the RegAccess response packet
    yield RisingEdge(dut.clk)

    # Don't confuse users of this test when they see a warning message
    dut._log.warning("The following warning 'packet receive timed out' is expected:")
    packet = yield NocDiReader(dut, dut.clk).receive_packet(set_ready=True)
    if packet:
        raise TestFailure("Received packet while module was deactivated")

    yield access.write_register(dest=MODULE_DI_ADDRESS, src=SENDER_DI_ADDRESS,
                                word_width=16,
                                regaddr=DiPacket.BASE_REG.MOD_CS.value,
                                value=1)

    read_thread = cocotb.fork(_bus_to_di_rx(dut, num_transfers=5))
    yield read_thread.join()
Beispiel #3
0
def test_stm_activation(dut):
    """
    Check if STM is handling the activation bit correctly
    """
    access = RegAccess(dut)

    yield _init_dut(dut)

    dut._log.info("Check contents of MOD_CS")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.BASE_REG.MOD_CS.value, 0)

    yield _activate_module(dut)

    dut._log.info("Check contents of MOD_CS")
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.BASE_REG.MOD_CS.value, 1)
Beispiel #4
0
def test_access_ext_registers(dut):
    """
    Check if access to external registers works properly
    """

    global _max_reg_size, _write_value, _req_addr, _req_width, _req_write

    access = RegAccess(dut)

    yield _init_dut(dut)

    # start thread that works as debug module
    debug_module = cocotb.fork(_debug_module_dummy(dut))

    # different register widths to test
    req_reg_width = [16, 32, 64, 128]

    dut._log.info("Run write/read test of external registers")
    # write and read 2000 random values to random external registers
    for _ in range(200):
        # addresses 0x0 - 0x1ff are handled internally. Test adresses 0x200 - 0xffff
        _req_addr = random.randint(2**9, 2**16 - 1)
        _req_width = req_reg_width[random.randint(0, 3)]
        # ensure required width is not larger than MAX_REG_SIZE
        _req_width = _req_width if _req_width <= _max_reg_size else _max_reg_size
        _write_value = random.randint(0, 2**_req_width - 1)

        _req_write = True

        # write to register
        yield access.write_register(dest=MODULE_DI_ADDRESS,
                                    src=SENDER_DI_ADDRESS,
                                    word_width=_req_width,
                                    regaddr=_req_addr,
                                    value=_write_value)

        # wait a short random time
        wait = random.randint(0, 10)
        for _ in range(wait):
            yield RisingEdge(dut.clk)

        _req_write = False

        # check if value was correctly written to debug module
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      _req_addr, _req_width, _write_value)
Beispiel #5
0
def test_mam_extended_registers(dut):
    """
    Check if the extended configuration registers have the expected values
    """

    access = RegAccess(dut)

    yield _init_dut(dut)
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.MAM_REG.AW.value, 16,
                                  dut.ADDR_WIDTH.value.integer)
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.MAM_REG.DW.value, 16,
                                  dut.DATA_WIDTH.value.integer)
    yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                  DiPacket.MAM_REG.REGIONS.value, 16,
                                  dut.REGIONS.value.integer)

    for region in range(0, dut.REGIONS.value.integer):
        dut._log.info("Checking conf registers for region " + str(region))
        region_basereg = 0x280 + region * 16
        region_baseaddr_basereg = region_basereg
        region_memsize_basereg = region_basereg + 4

        baseaddr_exp = getattr(dut, "BASE_ADDR%d" % region).value.integer
        memsize_exp = getattr(dut, "MEM_SIZE%d" % region).value.integer

        # REGION*_BASEADDR_*
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_baseaddr_basereg, 16,
                                      baseaddr_exp & 0xFFFF)
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_baseaddr_basereg + 1, 16,
                                      (baseaddr_exp >> 16) & 0xFFFF)
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_baseaddr_basereg + 2, 16,
                                      (baseaddr_exp >> 32) & 0xFFFF)
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_baseaddr_basereg + 3, 16,
                                      (baseaddr_exp >> 48) & 0xFFFF)

        # REGION*_MEMSIZE_*
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_memsize_basereg, 16,
                                      memsize_exp & 0xFFFF)
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_memsize_basereg + 1, 16,
                                      (memsize_exp >> 16) & 0xFFFF)
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_memsize_basereg + 2, 16,
                                      (memsize_exp >> 32) & 0xFFFF)
        yield access.assert_reg_value(MODULE_DI_ADDRESS, SENDER_DI_ADDRESS,
                                      region_memsize_basereg + 3, 16,
                                      (memsize_exp >> 48) & 0xFFFF)