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

5.4  CO-SIMULATION BY SOFTWARE COMPILATION                           97


                 The main task of synchronisation is to act as an interface between software and
               external hardware. Externally it adopts the connections of the processor. Internally
               the C routine is called up. In accordance with the preceding representation of
               the synchronisation algorithms, a formulation in a hardware description language
               will now be represented, see Hardware description 5.2. The language used here is
               MAST (Avant!) because the research work in question, see [328], was performed
               in this language.
                 The majority of the synchronisation lies in a WHEN instruction, the body of
               which is executed if its condition is true. It is thus largely comparable with a
               process in VHDL. In the body there is initially an interrogation of the interrupt line
               to determine whether a replay is necessary. This is performed if necessary, and then
               the actual execution of the software takes place. Upon return from the C routine the
               software reports that it was able to simulate until time point t_cur. Then an event
               at time t_cur is initiated upon the softsync signal. When this occurs, software
               and hardware are synchronised. Thus data can be exchanged and a new software
               operation started. This is taken into account accordingly by the WHEN instruction.

               template m6805 ...                           # Interface description
                 ...
               {
                state time t_cur               # Current software time upon return
                state time t_old          #   Start time of the last software call
                state time step       #  Desired length of the software operation
                state logic_4 softsync      #   Carries events for synchronisation
                foreign software_sim                            # External C routine
                ...
                # If simulation beginning or event at the softsynch
                # variable or active edge on the interrupt line ...

                when (time_init | event_on(softsync) |
                       (event_on(interrupt)&(interrupt==l4_0)) ) {

                  if (event_on(interrupt)&(interrupt==l4_0)) {           # Interrupt!
                     # Replay, time supplies the current time
                     (t_cur, ...) = software_sim(t_old,time,...)          # C-Routine
                     ...
                  }
                  ...
                  (t_cur, ...) = software_sim(time,time+step,...)         # C-Routine
                  schedule_event(t_cur, softsync, l4_1) )           # softsync event
                  t_old = time                                 # Save old start time
                  ...
                }
               }
               Hardware description 5.2  Simplified description of the synchronisation between hardware
               and software in the hardware description language MAST
   103   104   105   106   107   108   109   110   111   112   113