qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] emulation cycle number implementation
@ 2017-09-07 16:30 Sergey Smolov
  2017-09-07 16:37 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Smolov @ 2017-09-07 16:30 UTC (permalink / raw)
  To: QEMU Developers

Hello, List!


I'm running MIPS assembler programs on QEMU. I need to log some events 
that happen through emulation (writes to some registers, for example). 
When an event happens, I need to print not only the event-related 
information, but an "emulation cycle number" also. This number should be 
an integer increasing value that is similar to real hardware clock.

How to implement this in QEMU? May QEMU timers be helpful in solving 
such a problem?

Thanks in advance.

-- 
Sincerely yours,
Sergey Smolov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] emulation cycle number implementation
  2017-09-07 16:30 [Qemu-devel] emulation cycle number implementation Sergey Smolov
@ 2017-09-07 16:37 ` Peter Maydell
  2017-09-08  7:41   ` Sergey Smolov
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2017-09-07 16:37 UTC (permalink / raw)
  To: Sergey Smolov; +Cc: QEMU Developers

On 7 September 2017 at 17:30, Sergey Smolov <smolov@ispras.ru> wrote:
> I'm running MIPS assembler programs on QEMU. I need to log some events that
> happen through emulation (writes to some registers, for example). When an
> event happens, I need to print not only the event-related information, but
> an "emulation cycle number" also. This number should be an integer
> increasing value that is similar to real hardware clock.
>
> How to implement this in QEMU? May QEMU timers be helpful in solving such a
> problem?

You can use cpu_get_ticks(), though if we're not in icount mode
you may find it doesn't behave quite as helpfully as you might like
(in that case it roughly tracks host hardware cycles.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] emulation cycle number implementation
  2017-09-07 16:37 ` Peter Maydell
@ 2017-09-08  7:41   ` Sergey Smolov
  2017-09-08  9:07     ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Smolov @ 2017-09-08  7:41 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers


On 07.09.2017 19:37, Peter Maydell wrote:
> On 7 September 2017 at 17:30, Sergey Smolov <smolov@ispras.ru> wrote:
>> I'm running MIPS assembler programs on QEMU. I need to log some events that
>> happen through emulation (writes to some registers, for example). When an
>> event happens, I need to print not only the event-related information, but
>> an "emulation cycle number" also. This number should be an integer
>> increasing value that is similar to real hardware clock.
>>
>> How to implement this in QEMU? May QEMU timers be helpful in solving such a
>> problem?
> You can use cpu_get_ticks(), though if we're not in icount mode
> you may find it doesn't behave quite as helpfully as you might like
> (in that case it roughly tracks host hardware cycles.)
>
> thanks
> -- PMM

Thank you, Peter!

But what if I like to track guest hardware cycles? I run the same 
program on QEMU and RTL model of MIPS microprocessor, and I want to 
compare simulation traces. I expect, that emulation will start from 0 
tick in both cases, at least.

-- 
Sincerely yours,
Sergey Smolov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] emulation cycle number implementation
  2017-09-08  7:41   ` Sergey Smolov
@ 2017-09-08  9:07     ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2017-09-08  9:07 UTC (permalink / raw)
  To: Sergey Smolov; +Cc: QEMU Developers

On 8 September 2017 at 08:41, Sergey Smolov <smolov@ispras.ru> wrote:
> But what if I like to track guest hardware cycles? I run the same program on
> QEMU and RTL model of MIPS microprocessor, and I want to compare simulation
> traces. I expect, that emulation will start from 0 tick in both cases, at
> least.

Broadly, you can't, because QEMU is not a cycle accurate emulator.
(For 21st century CPUs, cycle accurate emulation that isn't just
"run the RTL" is pretty near to impossible for practical purposes
anyway.) If you're using QEMU's icount mode then cpu_get_ticks()
will I think get you number of instructions executed; that's as
good as you're going to get, I'm afraid.

Last time I wanted to do comparison of simulation traces I just
compared the sequence of instructions executed, without worrying
about trying to compare against the other simulation's notional
clock cycle count as well.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-08  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-07 16:30 [Qemu-devel] emulation cycle number implementation Sergey Smolov
2017-09-07 16:37 ` Peter Maydell
2017-09-08  7:41   ` Sergey Smolov
2017-09-08  9:07     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).