Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

sc_signal<T>.event() behavior does not match the one described in LRM

$
0
0
SystemC LRM says:
6.4 sc_signal
6.4.9 Member functions for events
Member function event shall return the value true if and only if the value of the signal changed in
the update phase of the immediately preceding delta cycle and at the current simulation time

 

Then what about following code:

#include <systemc.h>

#include <cassert>

int sc_main(int, char *[])
{
    sc_signal<int> sig;

    sig.write(1);

    sc_start();
    assert(sig.event());
    sc_start(1, SC_NS);
    assert(sig.event());

    return 0;
}

In this example signal was changed at 0 ns, but event() function still returns true 1 ns after.

 

Considering the fact that LRM also says

 

4.5.5 Function sc_delta_count

The function sc_delta_count shall return an integer value that is incremented exactly once in each delta
cycle in which at least one process is triggered or resumed and, thus, returns a count of the absolute number
of delta cycles that have occurred during simulation, starting from zero, ignoring any delta cycles in which
there were no runnable processes
 

 

and describes delta cycle as

4.2.2 Initialization, cycles, and pauses in the scheduling algorithm
A delta cycle is a sequence of steps in the scheduling algorithm consisting of the following steps in the order given:
a) An evaluation phase
b ) An update phase
c) A delta notification phase

 

Looks like the only way to make mq_signal<T>::event() work is to compare both time and delta count of the last change with current values, but current implementation only compares delta count.

 

So my question is: is this a bug or was it made on purpose for performance reasons?


Viewing all articles
Browse latest Browse all 595

Trending Articles