Page 100 - Mechatronic Systems Modelling and Simulation with HDLs
P. 100
5.4 CO-SIMULATION BY SOFTWARE COMPILATION 89
during simulation. The better alternative is to shift the compilation cost from the
running time to a pre-simulation stage. This generally means that two versions
of the software exist. One is compiled for the simulation workstation, the other is
compiled for the processor on which it is to run in the system. Now, if the software
exists in a higher programming language and we are only interested in the function
and not in the timing, then the differences between the processors do not play a
significant role. The prerequisite for this is that the software always calculates a
certain result within a predetermined time period. A whole range of approaches
to HW/SW co-simulation are based upon this principle such as, for example, the
work of Becker et al. [21] or Thomas et al. [399].
We can expand upon this methodology so that cyclically correct timing is also
taken into account. However, to achieve this we have to make a detour in the
modelling. In a first step the assembler or machine programme is compiled into
a C routine that both reflects the functionality and correctly takes into account
the timing of the software execution on the basis of the clock cycles of the target
ˇ
processor. Zivojnovi´ c and Meyr show this in [438] for pure digital electronics, with
both software and electronics being described in C modules so that these only have
to be linked together. Pelz et al. expand upon this approach in [328] based upon a
compiled co-simulation of software, electronics and mechanics by implementing an
appropriate synchronisation between simulator and software model in a hardware
description language. Here the representation of the assembler programme in C is
automated by a compiler based upon a disassembler. Overall this method can also
be regarded as a modelling of software, see Figure 5.3.
In what follows this approach of representing system software in C routines and
linking it into a simulator on the basis of hardware description languages will be
investigated in further detail.
5.4.2 Software representation
In a first stage, the system software should be represented in a C routine that takes
into account both the function and timing on the level of machine instructions. In
main(argc,argv)
int argc;
char argv[];
{
int i, j, stat;
double v1, v2;
... Software
while (true) { model
v1 = mem[pio];
if (v1 > THRESH) {
if (!check(v1))
continue;
stat = getstat();
if (stat == 0)
putstat (HARD);
...
Figure 5.3 Execution of software by modelling at software level