【问题标题】:How can I wait for one event out of a list of events in specman?如何等待 Specman 事件列表中的一个事件?
【发布时间】:2009-10-07 08:15:26
【问题描述】:

我在 specman 中有一个结构:

struct foo_s {
    event foo_ev;

    // some code that will emit foo_ev sometimes
};

还有一个清单:

var foo_l: list of foo_s;  // later code will manage the list

现在我想同步列表中的任何foo_ev 事件:

first of {
    sync @foo_l[0].foo_ev;
    sync @foo_l[1].foo_ev;
    sync @foo_l[2].foo_ev;
    //etc
};

问题是在这个 sn-p 运行时我不知道foo_l 中有多少元素。我有什么方法可以等待 任何 foo_ev 事件发出?

【问题讨论】:

    标签: list events specman


    【解决方案1】:

    您可以手动级联事件:

    unit bar_u {
        foo_l: list of foo_s;  
        event any_foo_toggled_e;
    }
    
    struct foo_s {
        event foo_e;
        on foo_e {
            emit get_enclosing_unit(bar_u).any_foo_toggled_e;
        };
    
        // some code that will emit foo_ev sometimes
    };
    

    【讨论】:

    • 优雅 :-) 后面是强制性的 15 个字符扩展名!
    【解决方案2】:

    另一种解决方案是使用计算宏。计算宏的概念是编写代码以生成电子代码。使用这种方法,您可以查看foo_l 的长度并生成first of { sync ... 列表作为宏的替换。

    抱歉,我目前没有时间编写示例,但如果您有兴趣,Specman 文档应该是您的朋友。如果您还没有听说过计算宏,那么绝对值得一看。

    [更新]: 在 Specman 团队中,他们刚刚发布了 example of a computed macro。他们也有一些关于这个主题的older posts

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-31
      • 1970-01-01
      • 1970-01-01
      • 2019-08-26
      • 2011-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多