zinn
12-01-2008, 02:41 AM
Hi folks,
I tried to define a sequence_item with a field instruction. The instruction is of an enumerated type and my idea was to declare it as randc in order to get an even distribution.
typedef enum {ADD, SUB, AND, OR, XOR, INVA, INVB} opCode;
...
class my_sequence_item extends ovm_sequence_item;
...
randc opCode instruction;
...
endclass: my_sequence_item
Now I wanted to define a sequence that simply drives this sequence_item by means of the `ovm_do macro:
class amy_seq extends ovm_sequence;
`ovm_sequence_utils(my_seq, my_sequencer)
my_sequence_item ins;
...
task body;
forever begin
`ovm_do(ins);
end
endtask: body
endclass: my_seq
Unfortunately, I had to realize that the distribution was not even. I looked into the `ovm_do macro and found out that inside the macro a new object is created. Accordingly, each sequence_item object is randomized only once in its life which means that it does not matter at all if i declare a field as rand or randc.
Is this the intended behavior of `ovm_do or is the implementation of the macro buggy?
What do you think how the randc functionality can be used in combination with sequence_item and `ovm_do?
Best regards
Andreas
I tried to define a sequence_item with a field instruction. The instruction is of an enumerated type and my idea was to declare it as randc in order to get an even distribution.
typedef enum {ADD, SUB, AND, OR, XOR, INVA, INVB} opCode;
...
class my_sequence_item extends ovm_sequence_item;
...
randc opCode instruction;
...
endclass: my_sequence_item
Now I wanted to define a sequence that simply drives this sequence_item by means of the `ovm_do macro:
class amy_seq extends ovm_sequence;
`ovm_sequence_utils(my_seq, my_sequencer)
my_sequence_item ins;
...
task body;
forever begin
`ovm_do(ins);
end
endtask: body
endclass: my_seq
Unfortunately, I had to realize that the distribution was not even. I looked into the `ovm_do macro and found out that inside the macro a new object is created. Accordingly, each sequence_item object is randomized only once in its life which means that it does not matter at all if i declare a field as rand or randc.
Is this the intended behavior of `ovm_do or is the implementation of the macro buggy?
What do you think how the randc functionality can be used in combination with sequence_item and `ovm_do?
Best regards
Andreas