Intel® Simics® Simulator for Intel® FPGAs: User Guide

ID 784383
Date 4/01/2024
Public
Document Table of Contents

5.5.2. CPU Cycles and Steps

The CPU cycle time is defined by the CPU frequency. In a single-processor system, the length (in seconds) of a clock cycle is easily defined as:

cycle=1/fcpu

where fcpu corresponds to the current CPU frequency.

The simulation of the execution of one single instruction is called a step. The step-rate corresponds to the number of steps executed each cycle (not including stalling). Similarly, the cycles per Instruction (CPI) corresponds to the number of clock cycles that are required to execute one instruction. Normally, the CPI corresponds to the reciprocal of the step-rate. The following figure describes these concepts:

Figure 8. Representation of Steps and Cycles Concepts in Intel® Simics® Simulator Timing Context

You can obtain the CPI parameter for a processor using the [processor_path].info command. You can use the [processor_path].set-step-rate command to get the step rate read as steps/cycle (can be used also to update this parameter which can be used to tweak the simulation performance, but Intel does not recommend modifying this parameter as this has not been properly verified). The following capture shows an example to retrieve the step-rate and the CPI of a processor:

# Intel Simics simulator CLI

simics> system.board.fpga.soc_inst.hps_subsys.agilex_hps.core[0].info

Information about system.board.fpga.soc_inst.hps_subsys.agilex_hps.core[0] [class arm-cortex-a55]
==============================================================================

         VMP status : Not Loaded
    JIT compilation : Enabled
    Clock frequency : 400 MHz
                CPI : 1.00
    Physical memory : system.board.fpga.soc_inst.hps_subsys.agilex_hps.cpu_mem[0]
               Cell : system.cell
simics> system.board.fpga.soc_inst.hps_subsys.agilex_hps.core[0].set-step-rate 
Current step rate is 1/1

In the above example, you can observe that for the core[0], the initial CPI value is 1.00, and the current step-rate is 1 step per 1 cycle.

Intel® Simics® allows you to inspect what the current simulation time is for a specific core using the ptime (print-time) command. This command also allows you to get the number of cycles and number of steps (instructions) that the CPU has executed. The syntax of this command is as follow:

ptime [cpu-name] [-s] [-c] [-t] [-pico-seconds] [-all]

Where:

  • -s: Indicates the number of steps executed.
  • -c: Indicates the number of cycles executed.
  • -t: Indicates the execution time.
  • -pico-seconds: Indicates the execution time in pico seconds.

This command acts over the CPU that is provided in the cpu-name argument or over the current CPU selected (indicated with psel command if this argument is not provided). If the -all argument is provided it prints the information for all the CPUs.

The following capture shows some examples that describe how the ptime command operates. For this, the run command is used to advance a specific number of cycles or steps in the simulation.

# Intel Simics simulator CLI  
# In this example, the step rate is 1/1., CPI is 1 and CPU0 frequency is 80 MHz 
simics> ptime 
----------------------------------------------------------
Processor                    Steps     Cycles     Time (s)
----------------------------------------------------------
system...agilex_hps.core[0]  82723967  82724049   1.000
----------------------------------------------------------

simics> ptime -pico-seconds 
-------------------------------------------
    Processor                 Picoseconds 
-------------------------------------------
system...agilex_hps.core[0]   999999990000
-------------------------------------------

simics> run 1000 cycles 
simics> ptime 
-----------------------------------------------------------
Processor                    Steps     Cycles      Time (s)
-----------------------------------------------------------
system...agilex_hps.core[0]  82724967  82725049    1.000
-----------------------------------------------------------

simics> ptime -pico-seconds 
--------------------------------------------
Processor                      Picoseconds 
--------------------------------------------
system...agilex_hps.core[0]    1000012490000
--------------------------------------------

simics> run 2000 steps 
simics> ptime 
-----------------------------------------------------------
Processor                    Steps     Cycles      Time (s)
-----------------------------------------------------------
system...agilex_hps.core[0]  82726967  82727049    1.000
-----------------------------------------------------------

simics> ptime -pico-seconds 
--------------------------------------------
Processor                      Picoseconds 
--------------------------------------------
system...agilex_hps.core[0]    1000037490000
--------------------------------------------

In the previous example, the cycle time is 12500 ps based on the 80 MHz CPU frequency. Initially, you are calling ptime command to determine the current time, number of cycles, and steps for the selected processor (Core 0). Here, the simulation time is obtained also in pico seconds. Next, the simulation is run for 1000 cycles. You then read the new current time/steps/cycles and observe that the number of cycles is increased exactly in 1000 cycle, which matches our expectation. Also, as the CPI is 1, then it means that the number of steps must be increased by 1000. Also, you can verify that the simulation time was increased by 12,500,000 that matches the expected value (number cycles * cycle time). The exercise is repeated but this time the simulation is run for 2000 steps. In this case, because the CPI is 1, it means that it also must advance 2000 cycles and 25,000,000 ps.

Besides the run commands that were presented earlier, there are specific commands that allow you to run a certain number of steps or cycles providing as an additional information the assembler instructions that were executed. These commands are the following:

step-instruction [count] [-r] [-q]
step-cycle [count]

The step-instruction command advances count number of instructions in the simulation. If -r argument is provided, the register changes are also printed. If -q argument is provided, the assembler instruction is not printed.

The step-cycle command advances count number of cycles in the simulation. This command also prints instructions that are being executed:

# Intel Simics simulator CLI 

# Running 5 steps using stepi command
simics> stepi 5
[system...agilex_hps.core[0]] v:0xffff800008010a84 p:0x8000000002010a84  add sp, sp, x0
[system...agilex_hps.core[0]] v:0xffff800008010a88 p:0x8000000002010a88  sub x0, sp, x0
[system...agilex_hps.core[0]] v:0xffff800008010a8c p:0x8000000002010a8c  tbnz w0, #14, 0xffff800008010a9c
[system...agilex_hps.core[0]] v:0xffff800008010a90 p:0x8000000002010a90  sub x0, sp, x0
[system...agilex_hps.core[0]] v:0xffff800008010a94 p:0x8000000002010a94  sub sp, sp, x0

# Run 3 cycles using step-cycle command
simics> step-cycle 3
[system...agilex_hps.core[0]] v:0xffff800008011334 p:0x8000000002011334  stp x28, x29, [sp, #224]
[system...agilex_hps.core[0]] v:0xffff800008011338 p:0x8000000002011338  add x21, sp, #0x150
[system...agilex_hps.core[0]] v:0xffff80000801133c p:0x800000000201133c  mrs x28, sp_el0