DMI – Graduate Course in Computer Science
Copyleft
2018 Giuseppe Scollo
this tutorial deals with:
program development for dedicated systems often takes place on machines that are based on a different processor than the target one, viz. that which is meant for their execution
the cross-compilers and utilities here considered are GNU free software, that typically have names <target>–gcc for the compiler, where <target> indicates the target architecture, and <target>–<util> for the utility <util>, such as for example
a first example showcases the use of the VisUAL v. 1.27 ARM emulator, for the simulation of the execution of a program for GCD computation with Euclid's algorithm (Listing 7.11 in Schaumont, with modified main because of the different simulation target)
in this example, the assembly program is obtained from the C source by means of the arm-linux-gcc cross-compiler, for ISA ARMv4, implemented in the StrongARM processor
however, the assembly program so obtained does not meet the restrictions posed by the emulator, e.g. it contains assembly directives and other syntactic sugar that are not accepted by VisUAL
archive arm_visual_examples.tgz, available in folder crosstools of the reserved lab area, provides the C sources and the required scripts for the cross-compilation and VisUAL emulation of the GCD example and of a second example, that presents a software implementation of the Collatz delay calculation, similar in functionality to the hardware implementations considered in the previous lab experiences
a snapshot of VisUAL emulation of the delay_collatz.s ARM assembly program
the figure shows an execution snapshot of program delay_collatz.c on the DE1-SoC ARM processor
cross-compilation, loading and execution take place by means of the altera-monitor-program, under control of its GNU debugger GDB
execution snapshot of an ARM program under control of the GDB debugger within the Monitor Program
the same C source from the previous example may be cross-compiled and executed by a Nios II softcore on the FPGA of the DE1-SoC system
execution snapshot of a Nios II program under control of the GDB debugger within the Monitor Program
execution of the delay_collatz example on the ARM processor by means of the monitor program produces two files in the project directory that are relevant to low-level analysis:
in order to carry out low-level analysis even further, it helps one to know where the binary utilities are located, for the gcc cross-compiler used by the monitor program
N.B. actually, the monitor program makes use of specialized versions of some of these tools, that are placed elsewhere; however, for general use, independent of any execution in the contest of the monitor program, the aforementioned tool collection is the proper one
processing the C sources by the monitor program for execution on the Nios II processor produces the .elf executable in the project directory, but not its disassembly
hre is a simple example of use of the size utility: comparing the sizes of the executables produced by the three cross-compilers of interest here, for both of the examples proposed and with the same compilation options; in particular, optimization level O2
the following table presents the outcome of this exercise
C source | cross-compiler | text | data | bss | total |
gcd | arm-linux | 820 | 260 | 4 | 1084 |
arm-altera-eabi | 492 | 16 | 28 | 536 | |
nios2-elf | 1056 | 1068 | 0 | 2124 | |
delay_collatz | arm-linux | 864 | 260 | 4 | 1128 |
arm-altera-eabi | 628 | 16 | 28 | 672 | |
nios2-elf | 1196 | 1068 | 0 | 2264 |
run the examples provided with this tutorial, examine the files produced by their execution, find a few not well-known aspects of their contents, search the web for information about them and produce some tutorial documentation in form of a list of questions and answers
here are three examples of question and answer, one for each of the three types described above:
recommended readings:
readings for further consultation:
useful materials for the proposed lab experience: