Specman list伪方法从/向特定索引弹出/推送

时间:2015-05-10 08:49:20

标签: specman

我正在寻找一种方法来实现一个新的List伪方法 从列表中的某个位置推送/弹出(不一定是索引0)。

有没有办法添加列表伪方法?

1 个答案:

答案 0 :(得分:2)

实现list伪方法可能不使用宏。 下面是一个示例fpr如何从索引伪方法实现所需的pop:

define <my_n_pop'exp> "<list'exp>[ ].[ ]pop_index[ ]\(<num'exp>\)" as {


evaluate typeof_item(<list'exp>) {
    if(<list'exp>.size()> <num'exp>) {
        value = <list'exp>[<num'exp>];
        <list'exp>.delete(<num'exp>);
    }else {
        error("error : This list is has the size of ",<list'exp>.size(),"and you requested item",<num'exp>);
    };
  };
 };

代码中的用法如下所示:

 i=l.pop_index(2); // pop the item with index 2. All greater indices will decrease by 1.