Specman e:如何约束列表内值的分布



我有my_list(结构列表)这样定义:

struct my_struct {
    comparator[2] : list of int;
    something_else[2] : list of uint;
};
my_list[10] : list of my_struct;

我需要约束比较器 [0] 和比较器 [1] 的值分布(两者的分布相同),如下所示:

my_list[10] : list of my_struct;
keep soft for each (elem) in my_list {
   soft elem.comparator[0] select {
      30: [-1000 .. -50]; -- Big negative values
      40: [-49 ..49]; -- Medium values
      30: [50..1000]; -- Big positive values           
    };
    // Same for elem.comparator[1]
 };

我得到的编译错误:

*** Error: Unrecognized exp
    [Unrecognized expression 'elem.comparator[0] select {30:
[-1000..-50];40: [-49..49];30: [50..1000];}']
                at line
...
       soft elem.comparator[0] select {

如何约束驻留在列表列表中的值的分布?非常感谢任何帮助。

你在那里soft两次,尽管这不是问题。你忘了在select之前放一个==.我会这样写:

  keep for each (elem) in my_list {
    soft elem.comparator[0] == select {
      30: [-1000 .. -50]; -- Big negative values
      40: [-49 ..49]; -- Medium values
      30: [50..1000]; -- Big positive values           
    };
    // Same for elem.comparator[1]
  };

或者你可以做keep soft for each ...,在你的情况下可能更干净。你甚至可以把两个soft都放在那里,虽然它看起来有点丑,IMO。

最新更新