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

5.4  CO-SIMULATION BY SOFTWARE COMPILATION                           93



                             Synchronisation  Interrupt and  Synchronisation
                                             Synchronisation
                                    Hardware simulation       Hardware simulation


                                                           Hardware
                                                           Software           Time
                              Software         Software
                              simulation       simulation



                                                                  2nd attempt
                           clra  bra  ..................       remaining simulation
                                                    2nd attempt,
                              Software                replay
                                                                     Invalid due
                              simulation
                                                                     to interrupt

                           clra  bra       ..................
                Figure 5.6  Synchronisation of software and hardware after the occurrence of an interrupt


               Programme 5.2 shows the corresponding C routine which was automatically gen-
               erated. Both the assembler instructions in question and the context of the C routine
               are compatible with the architecture and the command set of the Motorola 68HC05
               microcontroller.
               PORTA: EQU $0010 ; Declaration of PORT A as address
               PORTB: EQU $0001 ; Declaration of PORT B as address
               PORTC: EQU $0002 ; Declaration of PORT C as address
               PORTD: EQU $0003 ; Declaration of PORT D as address
                       org $100   ; Position in the memory: 0100 Hex
               START:             ; Start label
                       lda PORTA ; (load A) Load port A in accumulator
                       jsr SRX    ; (jump subroutine) Execute subroutine SRX
                       bra SRY    ; (branch) Branch to label SRY
                       ...
               SRY:               ; Label SRY
                       ...

                       org $200   ; Position in the memory: 0200 Hex
               SRX:               ; Label of the subroutine SRX
                       ...
               Programme 5.1  Excerpt from assembler programme
                 Upon its call up, the fundamental sequence of the C routine initially rests upon
               determining whether this is the first time the routine has been run. If so, a whole
   99   100   101   102   103   104   105   106   107   108   109