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. .. _using_xsim_which_tile: Which tile is my code running on? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Build and execute the example in :ref:`multi_tile`: .. code-block:: bash $ xcc -target=XCORE-200-EXPLORER mapfile.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 :option:`xsim -t` to determine which tile the system calls were generated by. Here we use :command:`grep` to simplify and reduce the trace output by capturing 1 line before each of the relevant output lines: .. code-block:: bash $ 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_xsim_fast_printf: 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 :ref:`fast_printf`. Execute the application using the :option:`xsim --xscope` option as follows: .. code-block:: bash $ 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 :file:`xscope.vcd`.