Page 103 - Mechatronic Systems Modelling and Simulation with HDLs
P. 103

92                       5  SOFTWARE IN HARDWARE DESCRIPTION LANGUAGES



                  Synchronisation   Synchronisation              Synchronisation

                    Hardware simulation    Hardware simulation      Hardware simulation

                                          Hardware
                                          Software                Software        Time
                                                                  simulation

                                      Software
                                      simulation               lda  sta  bra  ..................

                   Software
                                                                          Store to
                   simulation      sta  bra      ..................  lda  main memory
                                          Store to
                                          I/O port     Load to
                clra clrx  ..................  sta     I/O port
               Figure 5.5  Synchronisation of software and hardware after the occurrence of load and store
               instructions (lda and sta) relating to the I/O ports

               interrupted. Then we again wait until the hardware has reached the current time
               of the software. At this point the appropriate values can be exchanged between
               hardware and software. Then the software is restarted.


               Synchronisation after an interrupt
               This case occurs if the software has been executed up until time point t and it is
               found during the hardware simulation that an interrupt has been triggered at time
               point t < t, that has invalidated the current progress of the software simulation,

               see Figure 5.6. The problem is solved in two stages. In the first stage the software
               has to be brought back to its state at the time of the interrupt t .Wefirst jump

               back to the old state that is stored at the start of every software operation. This
               is also called a time-warp in the literature on the general coupling of simulators,
               see the work of Jefferson [168] and [169]. Then the software is simulated up
               until the time of the interrupt. We can think of this as a type of ‘replay’ of a
               sequence that has already played out in the past. After the replay the software
               shows the precise state at time point t . A synchronisation point is then inserted

               here, which permits the interrupt to be taken into account at exactly the right time.
               Then the software simulation begins again from the instruction that refers to the
               interrupt vector.


               5.4.4    Example of software modelling

               The representation of the software shall be explained on the basis of an example
               in what follows. Programme 5.1 shows parts of an assembler programme and
   98   99   100   101   102   103   104   105   106   107   108