lowRISC / ibex

Ibex is a small 32 bit RISC-V CPU core, previously known as zero-riscy.
https://www.lowrisc.org
Apache License 2.0
1.37k stars 540 forks source link

Why performance counters don’t start counting right away #17

Closed Liyang131313 closed 5 years ago

Liyang131313 commented 5 years ago

Hello, I would like to ask, why the program has been executed for a while during the simulation process, and the performance counters will start working. Instead of starting work immediately during system startup. Is it because the firmware code is being executed? Does the performance counter work require firmware? If the firmware code is not executing, what is the operation, causing the performance counters to not start working immediately?

2019-01-17 07-10-03 2019-01-17 07-19-13 @zarubaf @Razer6 @wallento

vogelpi commented 5 years ago

Hi @Liyang131313 , the behavior of the performance counters PCCR_q[0] - PCCR_q[10] are controlled by the two registers:

After a reset, all counters are disabled (PCER = '0, but PCMR = 2'h3). Your program first writes 2 to the PCER meaning the instruction counter in PCER_q[1] is enabled. In addition, your program is writing 3 to the PCMR.

Consequently, only PCER_q[1], i.e., the instruction counter, should be active, which is what you can see in the traces.

Best regards, Pirmin