Using XSIM#

In this section, we have a series of examples which show some ways of using XSIM to gain a greater insight into how programs run on XCORE devices.

Which tile is my code running on?#

Build and execute the example in Targeting multiple tiles:

$ xcc -target=XCORE-200-EXPLORER multitile.xc main.c
$ xrun --io a.xe
Hello from tile 0
Hello from tile 1

How can we convince ourselves that the output was generated by code running on the specified tiles? We can use xsim -t to determine which tile the system calls were generated by. Here we use grep to simplify and reduce the trace output by capturing 1 line before each of the relevant output lines:

$ xsim -t a.xe | grep -B 1 "Hello from"
tile[0]@0- -SI A-.----00040264 (_DoSyscall          +  0) : nop      @11057
Hello from tile 0
tile[1]@0- -SI A-.----00040234 (_DoSyscall          +  0) : nop      @11061
Hello from tile 1

This shows that the system calls were generated by the expected tiles.

Using XScope during simulation#

You can use XScope when running code on the simulator. It isn’t faster than the non-Xscope approach, but it allows debug of any XScope-related issues.

Build the example in Using XSCOPE for fast “printf debugging”. Execute the application using the xsim --xscope option as follows:

$ xsim --xscope "-offline xscope.vcd" a.xe
Tile 0: Result 0
Tile 1: Iteration 0 Accumulation: 0
Tile 1: Iteration 1 Accumulation: 1
Tile 1: Iteration 2 Accumulation: 3
Tile 1: Iteration 3 Accumulation: 6
Tile 1: Iteration 4 Accumulation: 10
Tile 1: Iteration 5 Accumulation: 15
Tile 1: Iteration 6 Accumulation: 21
Tile 1: Iteration 7 Accumulation: 28
Tile 1: Iteration 8 Accumulation: 36
Tile 1: Iteration 9 Accumulation: 45
Tile 0: Result 45

XScope trace output will be placed in xscope.vcd.