OpenCores
no use no use 1/1 no use no use
ork1sim: Profiling of C-Code
by vliw on Aug 24, 2012
vliw
Posts: 3
Joined: Aug 15, 2012
Last seen: Nov 8, 2018
Hi there,

since I am new to the project i am using the preinstalled environment provided in the virtual box image. Since yesterday I am trying to find a simple way for profiling parts of c-code. I am a bit overwhelmed by the vast amount of documentation.
Yet I haven't found a way how to enable profiling for a certain c-funktion oder code segment.
Does the OR1200 provide a clock counter that can be read out by software ?
Do I have to rebuild the ork1sim with another config ? What config should I use?

Best regards,
Marten
RE: ork1sim: Profiling of C-Code
by firefalcon on Aug 25, 2012
firefalcon
Posts: 99
Joined: Jan 10, 2011
Last seen: Mar 26, 2024
At the low level, there is the tick timer register: SPR_TTMR (mode) and SPR_TTCR (count). You will want to reference the OR1000 architecture reference manual section on the "Tick Timer Facility". You could also look at how the architecture support code for newlib or Linux gets timing information.
RE: ork1sim: Profiling of C-Code
by vliw on Aug 27, 2012
vliw
Posts: 3
Joined: Aug 15, 2012
Last seen: Nov 8, 2018
Thanks so far! I had a look into the document and found out that I am able to read out the tick register with "l.mfspr". But I am not sure how to adress the registers and how to write code for accessing via a c program. Is there a macro available which allows embedding asm code into c code ?

Kind regards
RE: ork1sim: Profiling of C-Code
by stekern on Aug 27, 2012
stekern
Posts: 84
Joined: Apr 28, 2009
Last seen: Nov 10, 2016
Easiest is to use inline asm to read/write mfspr/mtspr
Example:
http://git.openrisc.net/cgit.cgi/stefan/u-boot/tree/arch/openrisc/include/asm/system.h

If you are using newlib/libgloss, there are some helper-functions you can use
Example:
http://git.chokladfabriken.org/?p=membenchmark.git;a=blob;f=main.c;h=64b1ce8c613ca415e5b4d56a04d295a9d2e59fad;hb=HEAD
RE: ork1sim: Profiling of C-Code
by vliw on Sep 17, 2012
vliw
Posts: 3
Joined: Aug 15, 2012
Last seen: Nov 8, 2018
Maybe the tick timer does not work within the or1k-sim ? Here is the code i used for profiling a C-CodeBlock:

int timerState = 0;
int numCycles= 0;
//Enabling the Timer:
or1k_mtspr(SPR_TTMR, SPR_TTMR_CR);

//saving the timerstate:
timerState = or1k_mfspr(SPR_TTCR);

//Do some printf() and computation;

numCycles = timerState - or1k_mfspr(SPR_TTCR);


timerState always remains 0, what is wrong there? Does or1ksim not simulate the ticktimer?
no use no use 1/1 no use no use
© copyright 1999-2026 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.