This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simulation Timing vs. Timing on Target

In the simulation there are two system variables indicating the number of executed states and the time (sec) in seconds.
When I compare execution times in the simulation to the timing on the target system, the time in the simulation is about three times shorter than on the real target.
The clock settings, flash wait states, SCU settings etc. are the same. There is no external memory on the target, and no interrupts are enabled.
Has anyone an idea why the times differ that much? The code I used for tests did not use any XC16x peripherals but only arithmetic functions like MUL and DIV.

Thanks.

  • The simulator is not a real-time simulator; it does not even attempt to simulate the actual speed of execution.

    Therefore, with the performance of modern PCs, it is to be expected that the simulation will actually run faster than the actual embedded 16-bit micro!

    It should be accurate in terms of numbers of clock cycles - you can work out times from there.

  • The time the simulator displays is the number of elapsed states divided by the set cpu clock (in my case 40 MHz). Acutally, the execution of the simulation on the PC takes significantly longer than on the target but the time that is displayed is about 3.5 times shorter than the time on the target.

    Just to avoid confusion:
    Time the simulation displays (states / fcpu): 1.07 s
    Time on target: 3.7 s
    (Time the simulation takes to execute the test code: 7.2 s)

    It looks as if the simulation does not take into account some effects like ALE cycle times, pipeline effects or flash waitstates. I didn't investigate this in detail. I only made sure the system registers are set to the same values in the simulation and on the target.

  • are you executing code from on-chip Flash or off-chip memory?

  • The code is executed from on-chip flash (XC164CS-16F40) with the default WSFLASH setting (1 waitstate).