10.9.1 Setting up the environment

This tutorial runs some example applications on the EVS_Base_Cortex-A73x1 example virtual platform to show different timing annotation features. This section describes the prerequisites for using timing annotation.


These are the prerequisites for using timing annotation:

  • A SystemC virtual platform.
  • An application that enables caches.
  • A way of calculating the execution of time of individual instructions.
  • A way of determining the total execution time of the simulation.
  • A way of calculating the average Cycles Per Instruction (CPI) value for the simulation.

Building the EVS_Base_Cortex-A73x1 example

The EVS_Base_Cortex-A73x1 example includes a single EVS that is connected to SystemC components that model a timer, and an application memory component that supports individual configuration of read and write latencies. The example is not provided pre-built in the Fast Models Portfolio installation, so you must first build it.


Timing annotation is only supported on SVPs and EVSs.

To build the example, run the following commands:

cd $PVLIB_HOME/examples/SystemCExport/EVS_Platforms/EVS_Base/Build_Cortex-A73x1/

About the example applications

This tutorial uses some bare-metal example applications to show timing annotation features. The applications are provided in the $PVLIB_HOME/images/ directory.

They are based on the DS-5 example project startup_AEMv8-FVP_AArch64_AC6. The relevant source code and the compiled binaries are provided. The binaries were compiled using ARM Compiler version 6.6.

Table 10-2 Timing annotation example applications

Application Source directory Binary file
CPI example $PVLIB_HOME/images/source/ta_cpi/ $PVLIB_HOME/images/ta_cpi.axf
Branch prediction example $PVLIB_HOME/images/source/ta_brpred/ $PVLIB_HOME/images/ta_brpred.axf

Calculating the execution time of an instruction

The INST MTI trace source displays every instruction that is executed while running a program. When used with an EVS or an SVP, it also displays the current simulation time after an instruction has completed executing.

To determine the number of ticks an instruction takes to execute, you can use the difference between the times of two consecutive instructions. The default is one tick (on the core) for each instruction. With the default clock speed of 100MHz, this gives a default execution time for an instruction of 10000 picoseconds. Any changes to latency due to branch mispredictions, memory accesses, or CPI specifications can be observed by comparison with this value.

This tutorial uses the INST trace source to measure the time it takes to execute an instruction. To generate trace, you can use the GenericTrace plugin. This plugin allows you to output any number of MTI trace sources to a text file.

Use the following extra parameters when launching the model to collect the INST trace source:

--plugin=$PVLIB_HOME/plugins/Linux64_GCC-4.8/GenericTrace.so \
-C TRACE.GenericTrace.trace-sources=INST \
-C TRACE.GenericTrace.trace-file=/path/to/trace/file.txt

In an application that uses timing annotation, the trace that is produced for the first two instructions might look like this:

INST: PC=0x0000000080000000 OPCODE=0x58001241 SIZE=0x04 MODE=EL3h ISET=AArch64 
PADDR=0x0000000080000000 NSDESC=0x00 PADDR2=0x0000000080000000 NSDESC2=0x00 NS=0x00 
ITSTATE=0x00 INST_COUNT=0x0000000000000001 LOCAL_TIME=0x0000000000001388 
CURRENT_TIME=0x0000000000001388 CORE_NUM=0x00 DISASS="LDR      x1,{pc}+0x248 ; 

INST: PC=0x0000000080000004 OPCODE=0xd518c001 SIZE=0x04 MODE=EL3h ISET=AArch64 
PADDR=0x0000000080000004 NSDESC=0x00 PADDR2=0x0000000080000004 NSDESC2=0x00 NS=0x00 
ITSTATE=0x00 INST_COUNT=0x0000000000000002 LOCAL_TIME=0x0000000000003a98 
CURRENT_TIME=0x0000000000003a98 CORE_NUM=0x00 DISASS="MSR      VBAR_EL1,x1"

The CURRENT_TIME value for the first instruction is 0x1388, or 5000ps. This value shows that the instruction took 0.5 ticks to execute. Timing annotation has halved the execution time of this instruction.

The difference between the CURRENT_TIME values of the two instructions is 0x2710, or 10000 picoseconds. This value shows that the second instruction took one tick to execute.

Displaying the total execution time of the simulation

You can use MTI trace to calculate the execution time of individual instructions. However, to determine the overall simulation time, use the command-line option --stat instead.

This option causes the model to print statistics about the simulation to the terminal on exiting. The statistics include Simulated time, which is the total simulation time in seconds. For example:

--- Base statistics: ----------------------------------------------------------
Simulated time                          : 0.001206s
User time                               : 0.276000s
System time                             : 0.136000s
Wall time                               : 0.700834s
Performance index                       : 0.00
Base.cluster0.cpu0                      : 0.42 MIPS (172289 Inst)


The MIPS value is based on the host system time, not the simulated time.

This tutorial uses the --stat option to compare the model's performance for an application with various timing annotation configurations.

Calculating the average CPI value

You can calculate the average CPI value for the simulation by using the instruction count and the simulated time value, which are displayed using the --stat option.

Use the following formula:

average_cpi = simulated_time_in_picoseconds / (10000 * instruction_count)

In this example, the average CPI value is 0.69999, which is calculated as follows:

average_cpi = (0.001206 * 10^12) / (10000 * 172289) = 0.69999
Non-ConfidentialPDF file icon PDF versionARM 100965_1101_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.