G
Guenter Dannoritzer
Guest
Hello,
I have a question about the correct cbValueChange behavior for a
callback at simulation time 0.
I use the $my_monitor system task from the Sutherland PLI handbook. The
system task is called at simulation time 0 in the following way:
addbit i1 (a, b, ci, sum, co);
initial
$my_monitor(i1);
So there is an instance of the addbit module that is passed to the
$my_monitor system task and what the system task does is it iterates
over all nets of the passed instance and registers a cbValueChange call
back for each.
Now the Verilog code is running some stimulus to this instance that
looks like this:
initial
begin
#2 a = 0; b = 0; ci = 0;
#10 a = 1;
#10 a = 0;
#10 b = 1;
#10 a = 1;
#10 $finish;
end
The interesting part about this is that the first assignment is done at
time #2, so at time 0 there is no assignment from the Verilog code.
However, the simulator will assign the value 'x' to the nets at time 0.
My question is now, how should the cbValueChange callbacks behave, when
'x' is assigned to nets at time 0?
I tested this with Cver and Aldec Riviera and both have the first
callback happen at time #2.
Here the output from Riviera:
VPI: Adding monitors to all nets in module addbit:
VPI:
VPI: At time 2.00: my_monitor_test.i1.ci = 0
VPI: At time 2.00: my_monitor_test.i1.b = 0
VPI: At time 2.00: my_monitor_test.i1.a = 0
VPI: At time 2.00: my_monitor_test.i1.n3 = 0
VPI: At time 2.00: my_monitor_test.i1.n1 = 0
VPI: At time 2.00: my_monitor_test.i1.n2 = 0
VPI: At time 2.00: my_monitor_test.i1.co = 0
VPI: At time 2.00: my_monitor_test.i1.sum = 0
VPI: At time 12.00: my_monitor_test.i1.a = 1
VPI: At time 12.00: my_monitor_test.i1.n1 = 1
VPI: At time 12.00: my_monitor_test.i1.sum = 1
Now when I add a $monitor system task and monitor the signals, I get a
signal change to 'x' shown at time 0.
I also ran a similar PLI example with the latest development snapshot of
Icarus Verilog and it did cause a cbValueChange callback to happen at
time 0.
Now my question is, in respect to Cver and Riviera, they must register
the cbValueChange callbacks after the net assignment happened in the
current time step, so they will not cause a callback when a value
changes in the time step when the registration happened.
In the Sutherland book I did not really find any information how this
callback behavior should be in the time step the callback got registered.
Does anyone know what the exact behavior should be? Specific at time 0?
Thanks for your help.
Cheers,
Guenter
I have a question about the correct cbValueChange behavior for a
callback at simulation time 0.
I use the $my_monitor system task from the Sutherland PLI handbook. The
system task is called at simulation time 0 in the following way:
addbit i1 (a, b, ci, sum, co);
initial
$my_monitor(i1);
So there is an instance of the addbit module that is passed to the
$my_monitor system task and what the system task does is it iterates
over all nets of the passed instance and registers a cbValueChange call
back for each.
Now the Verilog code is running some stimulus to this instance that
looks like this:
initial
begin
#2 a = 0; b = 0; ci = 0;
#10 a = 1;
#10 a = 0;
#10 b = 1;
#10 a = 1;
#10 $finish;
end
The interesting part about this is that the first assignment is done at
time #2, so at time 0 there is no assignment from the Verilog code.
However, the simulator will assign the value 'x' to the nets at time 0.
My question is now, how should the cbValueChange callbacks behave, when
'x' is assigned to nets at time 0?
I tested this with Cver and Aldec Riviera and both have the first
callback happen at time #2.
Here the output from Riviera:
VPI: Adding monitors to all nets in module addbit:
VPI:
VPI: At time 2.00: my_monitor_test.i1.ci = 0
VPI: At time 2.00: my_monitor_test.i1.b = 0
VPI: At time 2.00: my_monitor_test.i1.a = 0
VPI: At time 2.00: my_monitor_test.i1.n3 = 0
VPI: At time 2.00: my_monitor_test.i1.n1 = 0
VPI: At time 2.00: my_monitor_test.i1.n2 = 0
VPI: At time 2.00: my_monitor_test.i1.co = 0
VPI: At time 2.00: my_monitor_test.i1.sum = 0
VPI: At time 12.00: my_monitor_test.i1.a = 1
VPI: At time 12.00: my_monitor_test.i1.n1 = 1
VPI: At time 12.00: my_monitor_test.i1.sum = 1
Now when I add a $monitor system task and monitor the signals, I get a
signal change to 'x' shown at time 0.
I also ran a similar PLI example with the latest development snapshot of
Icarus Verilog and it did cause a cbValueChange callback to happen at
time 0.
Now my question is, in respect to Cver and Riviera, they must register
the cbValueChange callbacks after the net assignment happened in the
current time step, so they will not cause a callback when a value
changes in the time step when the registration happened.
In the Sutherland book I did not really find any information how this
callback behavior should be in the time step the callback got registered.
Does anyone know what the exact behavior should be? Specific at time 0?
Thanks for your help.
Cheers,
Guenter