Specman-如何将测试更改为更通用?

时间:2018-08-01 09:00:14

标签: generics parameters verification specman

我有一个名为test_dpwm的测试。

测试包含一些代码,例如“

    event dpwm_clk_e is rise (driver.lv_top_env.smp.port_dpwm_clk$)@sim;
    event tc_e is rise (driver.lv_top_env.smp.port_tc$)@dpwm_clk_e;

    body()@driver.clock is only {

        message(LOW,"Configure Modules wait states");
        do CONFIG_WAIT_STATE seq keeping {.module=="DPWM_CNT";      .wait_state in [0..3];};
.....
......

        do EN_DPWM_CNT seq keeping {.en==1;};
        do DPWM_TEST seq keeping {.dpwm_idx==0; .hw_en==hw_en; .num_of_cycles==num_of_cycles;};

...
..};

我想为另一个名为aux_dpwm的dpwm模块创建完全相同的测试。因此,每个“ dpwm”都将为“ aux_dpwm”。 例如,上面的代码将变为:

    event aux_dpwm_clk_e is rise (driver.lv_top_env.smp.port_aux_dpwm_clk$)@sim;
    event tc_e is rise (driver.lv_top_env.smp.port_tc$)@aux_dpwm_clk_e;

    body()@driver.clock is only {

        message(LOW,"Configure Modules wait states");
        do CONFIG_WAIT_STATE seq keeping {.module=="AUX_DPWM_CNT";      .wait_state in [0..3];};
.....
......

        do EN_AUX_DPWM_CNT seq keeping {.en==1;};
        do AUX_DPWM_TEST seq keeping {.aux_dpwm_idx==0; .hw_en==hw_en; .num_of_cycles==num_of_cycles;};

...
..};

是否有通过参数或其他方式执行此操作的通用方法?

1 个答案:

答案 0 :(得分:0)

您可以使用宏轻松地做到这一点。 为简单起见,我将忽略以下事实:示例中的多个位置使用名称的大写变体,然后一个简单的define as宏就足够了。借助其他技巧(也许还涉及define as computed宏),还可以处理大写用法。

define <my_test'struct_member> "my_test <module'name>" as {
    event <module'name>_clk_e is rise (driver.lv_top_env.smp.port_<module'name>_clk$)@sim;
    event tc_e is rise (driver.lv_top_env.smp.port_tc$)@<module'name>_clk_e;

    body()@driver.clock is only {

        message(LOW,"Configure Modules wait states");
        do CONFIG_WAIT_STATE seq keeping {.module=="<module'name>_CNT";      .wait_state in [0..3];};
.....
......

        do EN_<module'name>_CNT seq keeping {.en==1;};
        do <module'name>_TEST seq keeping {.<module'name>_idx==0; .hw_en==hw_en; .num_of_cycles==num_of_cycles;};

...
    };
};

然后:

    my_test dpwm;

或:

    my_test aux_dpwm;

以此类推。