D.3. Examples of Simulator Use

This section contains several example of using the target Microprocessor simulator.

$ m1750-coff-run hello
Hello world

$ m1750-coff-run -s hello
Hello world

-----------------
Statistics Report
-----------------

CPU type:                Generic 1750A
Clock frequency:         10.0 MHz
Memory allocated:        16384 16-bit words
Instructions executed:   2049
Clock cycles:            7968
Execution time:          796.800 uSec
Average clocks per insn  3.89
M1750 execution speed    2.57 MIPS

D.3.1. Tracing Simulation

The simulator supports several options including the trace option (-t) and the statistics option (-s). Use the option --help for more information.

Example D-2. Tracing Simulation

The trace options allow you to get a trace of program execution. In most cases the -w option will more information in a wider of longer format. Tracing is triggered either immediately or according to several trigger options. You can trigger on program counter value, after a given number of microseconds, on an interrupt.

$ m1750-coff-run -t hello
-----------------------
-- Instruction trace --
-----------------------

Tracing starts at     0.000

microseconds cpznpbpsas   ft   mk   pi     ic  insn
------------+----------+----+----+----+------:-----
       0.000      0 0 0 0000 0000 0000 000000: lim    r1,32768
       0.300    n 0 0 0 0000 0000 0000 000004: lim    r3,4728
       0.600  p   0 0 0 0000 0000 0000 000008: lim    r2,33188
       0.900    n 0 0 0 0000 0000 0000 00000c: sr     r2,r1

...lots of output...

main():
/home/nettleto/xgc/play/b~hello.adb:36
 <main>
     436.700   z  0 0 0 0000 5140 0000 000596: pshm   r14,r14
     437.000   z  0 0 0 0000 5140 0000 000598: lr     r14,r15
     437.200    n 0 0 0 0000 5140 0000 00059a: lr     r11,r15
     437.400    n 0 0 0 0000 5140 0000 00059c: xorm   r11,32768
     437.700  p   0 0 0 0000 5140 0000 0005a0: c      r11,0x000103dc
     438.100  p   0 0 0 0000 5140 0000 0005a4: bge    2
/home/nettleto/xgc/play/b~hello.adb:42
     438.300  p   0 0 0 0000 5140 0000 0005a8: sjs    r15,0x0000056c
adainit():
/home/nettleto/xgc/play/b~hello.adb:8
 <adainit>
     438.700  p   0 0 0 0000 5140 0000 00056c: pshm   r14,r14
     439.000  p   0 0 0 0000 5140 0000 00056e: lr     r14,r15
     439.200    n 0 0 0 0000 5140 0000 000570: lr     r11,r15
     439.400    n 0 0 0 0000 5140 0000 000572: xorm   r11,32768
     439.700  p   0 0 0 0000 5140 0000 000576: c      r11,0x000103dc
     440.100  p   0 0 0 0000 5140 0000 00057a: bge    2

...lots of output...

D.3.2. Tasking Reports

In the following example we can clearly see how the tasking system switched among the 12 tasks that ran during the report's time window. The top line is the idle task and tasks 4 to 12 wait in the ready queue until it's their turn. The second part of the report shows the locking level of the current task in its current protected object.

The following example shows the report for the real-time demonstration program (in directory demo) on the M1750 Ada CD-ROM.

Example D-3. Tracing Tasking

$ m1750-coff-run -z demo -u 500
...
--------------
Tasking Report
--------------

  'p' PIL set here
  'i' Masked pending interrupt
  'I' Pending interrupt
  '*' Both of the above
  '.' Interrupt unmasked
  '0' The current task with no locks
  '1' The current task with one lock
  ' ' Power down is a blank column

Simulation ended at 1218635.800 uSec

There are no interrupt records
Tasks, y-axis is task number

  't' Current task
  '.' Task in ready queue
  ' ' Task blocked

ttttttttttttttttttttttttttttttttttttttt.......tttttttttttttttttttttttt|  1
                                                                      |  2
                                      ttt                             |  3
                                      ..tt                            |  4
                                      ...tt                           |  5
                                      ....t                           |  6
                                      ....tt                          |  7
                                       ....t                          |  8
                                       ....tt                         |  9
                                       .....t                         | 10
                                       .....tt                        | 11
                                        .....tt                       | 12
+---------+---------+---------+---------+---------+---------+---------0
-35000    -30000    -25000    -20000    -15000    -10000    -5000     
                                                  uSec before end time


Locks and active priority for current task (above), y-axis is priority
Note: blank rows omitted

  'b' No locks, therefore base priority
  '1' One lock, active priority inherited

                                        111111                        | 127
                                      bbbbbbbbb                       |  10
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb       bbbbbbbbbbbbbbbbbbbbbbbb|   0
+---------+---------+---------+---------+---------+---------+---------0
-35000    -30000    -25000    -20000    -15000    -10000    -5000     
                                                  uSec before end time

D.3.3. The RAM Tags Report

For each 16-bit word of simulated memory the simulator keeps a tag word that has flags to indicate if the word has been written to, read from, executed and so on. At the end of simulation the simulator can print a report on the tag words. The following example shows the report for the real-time demonstration program (in directory demo) on the M1750 Ada CD-ROM.

Example D-4. A RAM Tags Report

---------------
RAM Tags Report
---------------

  'S' stack pointer in this block, and block written to
  's' stack pointer in this block
  'X' executed code in the block
  'x' executable code in the block
  'R' read-only data block, has been read
  'r' read-only data block
  'W' block written to
  '.' block unused

This is address state 0

Byte    | Each line represents 4096 bytes
Address | Each character represents a 64 byte block
--------+-------------------------------------------------------------------
00000000 XR..XXXxXXXXXxxx XXXXXXXXXXXxxXXX XXXXXXxXXXxxXXXX XXXXXXXXXXXXXXXX
00001000 XXXXXXXXXXXXXXXX XXXXXXXXXxXXXxxx xxxxxxXXXXxxxxxx xxXXXXXXXXXXXXXX
00002000 XXXXXXXXxXXXxxxx xxxxxxXXXXXXXXXX XXXxXXXXXXXXxxxx xxxxxxxXXXxxxxxx
00003000 xxxxxxXXXxxxxxxx XXXXxxxxXXXXXXXX XXXXXXXXXXXXXxXx xxxxXXXxxXXXXXXX
00004000 XXXXXxXxxxXXXXXX xXXXxXXXXXXxXXXX XXXRRRRRRRRRRRRR RRRRRRRRRrrrrrrR
00005000 rRrrrrrrRrrrrR.. ................ ................ ................

00010000 WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWW........... ................
00011000 ..SSSW.......... ................ ....SSW......... ................
00012000 .....SSWW....... ................ ......SSSW...... ................
00013000 ........SSW..... ................ .........SSW.... ................
00014000 ..........SSW... ................ ...........SSW.. ................
00015000 ............SSSW ................ .............SSS W...............
00016000 ...............S SW.............. ................ SSW.............
00017000 ................ .SSW............ ................ ..SSWW..........
00018000 ................ ...SSSW......... ................ .....SSW........
00019000 ................ ......SSW....... ................ .....SSSS.......

0001e000 ................ ................ ................ ..............SS
0001f000 ................ ................ ................ ..............SS

--------+-------------------------------------------------------------------

The main stack, interrupt stack and task stacks are clearly visible and we can see how little they are used.