Skip to content

请问在功能覆盖率中,mark_function 函数有什么作用? #16

@leesum1

Description

@leesum1

例如在 ifu/rvc_expander/toffee_version 中,功能覆盖率定义如下:

def init_rvc_expander_funcov(dut:DUTRVCExpander, g: fc.CovGroup):
    """Add watch points to the RVCExpander module to collect function coverage information"""
    
    # 1. Add point RVC_EXPAND_RET to check expander return value:
    #    - bin ERROR. The instruction is not illegal
    #    - bin SUCCE. The instruction is not expanded
    g.add_watch_point(dut, {
                                "ERROR": lambda d:  getattr(dut, "io_ill").value == False,
                                "SUCCE": lambda d:  getattr(dut, "io_ill").value == True ,
                          }, name = "RVC_EXPAND_RET")
    # 2. Add point RVC_EXPAND_16B_RANGE to check expander input range
    #   - bin RANGE[start-end]. The instruction is in the range of the compressed instruction set
    # This check point is added in case 'test_rv_decode.test_rvc_expand_16bit_full' dynamically, see the test case for details

    # 3. Add point RVC_EXPAND_32B_RANGE to check expander input range
    #   - bin RANGE[start-end]. The instruction is in the range of the 32bit instruction set
    # This check point is added in case 'test_rv_decode.test_rvc_expand_32bit_full' dynamically, see the test case for details

    # 4. Add point RVC_EXPAND_32B_BITS to check expander function coverage
    #   - bin BITS[0-31]. The instruction is expanded to the corresponding 32-bit instruction
    def _check_pos(i):
        def check(dut):
            return getattr(dut, "io_in").value & (1<<i) != 0
        return check
    g.add_watch_point(dut, {
                                  "POS_%d"%i: _check_pos(i)
                                   for i in range(32)
                                },
                      name="RVC_EXPAND_32B_BITS")

    # 5. Reverse mark function coverage to the check point
    def _M(name):
        # get the module name
        return module_name_with(name, "../test_rvc")

    #  - mark RVC_EXPAND_RET
    g.mark_function("RVC_EXPAND_RET",     _M(["test_rvc_expand_16bit_full",
                                              "test_rvc_expand_32bit_full",
                                              "test_rvc_expand_32bit_randomN"]), bin_name=["ERROR", "SUCCE"])
    #  - mark RVC_EXPAND_16B_RANGE
    g.mark_function("RVC_EXPAND_32B_BITS", _M("test_rvc_expand_32bit_randomN"), bin_name=["POS_*"], raise_error=False)

无论我是否将最后两行函数注释掉,最后生成的 html 报告结果都没有区别

    #  - mark RVC_EXPAND_RET
    g.mark_function("RVC_EXPAND_RET",     _M(["test_rvc_expand_16bit_full",
                                              "test_rvc_expand_32bit_full",
                                              "test_rvc_expand_32bit_randomN"]), bin_name=["ERROR", "SUCCE"])
    #  - mark RVC_EXPAND_16B_RANGE
    g.mark_function("RVC_EXPAND_32B_BITS", _M("test_rvc_expand_32bit_randomN"), bin_name=["POS_*"], raise_error=False)

我没有跳过任何测试,标记 TAG_LONG_TIME_RUN 我都取消标记了
Image

在我自己的测试也是如此,mark_function 没有对最后的功能覆盖率报告产生任何影响。

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions