CPU cycle count


Kindly clarify the below mentioned issues:

  1. For RV32G variant, I want to find how many CPU cycles are required for execution of each instruction

I have searched a lot to find out that how many clock is needed for operation of each instruction in ISA RV32G variant, but I couldn’t find any thing.

  1. The base timing information is for RV32G variant, for determining the CPU cycle count. Please do provide the base timing information for RV32G variant of SiFive products

Thanks in advance

(Bruce Hoult) #2

The ISA does not specify the CPU cycles for each instruction. There are many possible ways to build a CPU that executes the RISC-V instruction set, depending on what trade-off you want in core size, power, speed, cost etc. Some such as Olof Kindgren’s award-winning “SERV” bit-serial FPGA core take several dozen clock cycles per instruction. Others such as SiFive’s superscalar 7-series and 8-series cores can execute on average more than one instruction per clock cycle.

In general, SiFive’s cores execute one instruction per clock cycle per pipeline, if a suitable instruction is available for dispatch, if required inputs are available. There can be delays if loads do not hit in cache or TIM, or if branches are mispredicted. You need to read the datasheet for the core you are interested in to get information, and even then only some cores in some specially-configured deterministic configurations produce guaranteed execution times.

RISC-V provides performance counter CSRs so that you can measure the number of instructions executed and number of clock cycles actually used by your code. SiFive cores can be configured to have additional performance monitoring counters such as cache misses, pipeline interlocks, branch mispredicts and so forth.

(Jim Wilson) #3

There is a chapter in our processor docs that gives pipeline info, though it doesn’t explain all of the details. You can find the processor docs at sifive.com/documentation

You can also find some info by looking at the gcc sources, in the pipeline description files, and the RTX_COST macros, but these are approximations of the hardware. See for instance https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/riscv/generic.md;h=fcd78b990feccbdceeee70df8de2cd1341757744;hb=HEAD
This is for rocket-chip which our 3 and 5 series parts are based on. There is also a sifive-7-series.md file. There is no pipeline description file for the 2 or 8 series parts yet.


Respected sir,

I have gone through the list of SiFive’s RISCV products. And found that Freedom U54 is based on RV64GC, which is of my concern.
Could you help me in this regard, for providing the base timing information of RV32GC for U54.

Thanks and Regards

(Bruce Hoult) #5

Jim pointed you to the documentation.

The manual for the U54 is here

Section 3 has the information you want.


Thank you sir,
I have gone through the documentation of sifive u54.
But it contains the timing information of only RISCV base instructions. I want to know the number of cycles consumed for floating and compression instructions of RV32GC. Could anyone suggest me in this regard.