I still don't understand the timer cuestion, qtimer is suposed to call
simulator::step() every 1 ms and then a number of calculated steps are
"looped" to reach the non-linear rate (1e4) and logic rate (1e6).
But when i drag&drop an ecclock-input to the circuit it should go at 1 Hz,
but i goes at 0.25 Hz.. it takes 4S for a complete cicle... in diferent PCs
i have diferents timings.. not big diferences.. may be +- 10%.... but 4S for
an 1 Hz ecclock-input is a very big error.
I had a look to qtimer at trolltech docs and it doesn't look a very accurate
"Note that QTimer's accuracy depends on the underlying operating system and
hardware. Most platforms support an accuracy of 20ms; some provide more..."
...An accuracy of 20ms !!!!!!
I think something should be done to improve this.
I have no idea, but looks like C++ doesn't have high-resolution timers...
but what about some POSIX functions?, for example gethrtime() looks
interesting: it gives the nunber of nanosecods since last boot:
With a granularity of nanoseconds is possible to do something accurate.
Is possible there are some posix interfaces in some C or C++ library... i
have no idea, but perhaps there are some better solution than using qtimer.
Just a thought...
Going on with the timer stuff.
I had been playing with the ktl qtimer and i see that qtimer does not call
simulator step every 1ms... indeed it does every aprox. 4ms, and not very
accurate or regular; that's why i have a 4s period for a 1Hz ecclock-input.
The only way i found to have regular and accurate periods is sarting qtimer
at 10ms and setting maxSteps according to this:
const unsigned maxSteps = unsigned(LINEAR_UPDATE_RATE / 100);
This way i have clock input and pic running at real time.