  -----------------------------------------------------------------------------
  PROC  check.limits()
    INT i,j: 
    SEQ
      limit.exists:=FALSE  
  
      IF
        lookahead.table.empty=FALSE   

          SEQ
            --------------------check if LDM/STM limit has been reached -------------------------------

            i:=instruction.buffer.base
            WHILE (i <> instruction.buffer.top)
              SEQ
                --------------------------------------------------------------------------------------------
                -- When an LDM/STM arrives at Dec1, Dec1 starts producing messages to
                --AddC without sending an Ack back to PCpipe. A limit has been reached
                --if an LDM/STM is in IB and no.of.pcs for this instruction is 3. 
                --------------------------------------------------------------------------------------------

                IF
                  ((instruction.buffer[i][INTRUCTION.TYPE]=LDM.STM) AND (instruction.buffer[i][NO.OF.PCS]>=LDM.STM.LIMIT))  
                    SEQ
                      limit.reached:=TRUE
                      debugmsg(report,screen, "ADDINT-AddC: CHECK LIMITS  limit reached LDRM.STM", [instruction.buffer[i][INSTRUCT],0,0,0])

                  TRUE
                    SEQ
                      SKIP

                i:= (i+1) 
                IF
                  (i >instruction.buffer.size)
                    SEQ
                      i:=0
                  TRUE
                    SEQ
                      SKIP

            --------------------check if limit due to the blocking of Reg Bank has been reached---------------

            i:=instruction.buffer.base
            WHILE (i <> instruction.buffer.top)
              SEQ
                -----------------------------------------------------------------------------------
                -- If there is an instruction A that writes to Rd, and there is an instruction B
                --following this that attempts to read Rd:
                --   *if B is a single cycle instruction, then limit has been reached if no.of.pcs for
                --    this instruction is >=4.
                --   *if B is a multi cycle instruction, then limit has been reached if no.of.pcs for
                --    this instruction is >=3.
                --------------------------------------------------------------------------------------------

                IF
                  ((instruction.buffer[i][WRITE.REGISTER] <> (-1 )) AND (instruction.buffer[i][NO.OF.PCS] >= 3)) AND (lookahead. table[i][INTRUCTION.TYPE]<> LDM.STM)

                    SEQ    --this is an instruction that locks a register and has started executing...
                      j:= (i+1)   --check the rest of the instruction buffer for a read register instruction....
                      IF
                        (j >instruction.buffer.size)
                          SEQ
                            j:=0
                        TRUE
                          SEQ
                            SKIP
                      WHILE (j <> instruction.buffer.top)
                        SEQ
                          IF
                            (((instruction.buffer[j][REGISTER.READ]) <> (-1)) AND (((instruction.buffer[j][READ.REGISTER1]) = (instruction.buffer[i][WRITE.REGISTER])) OR ((instruction.buffer[j][READ.REGISTER2]) = (instruction.buffer[i][WRITE.REGISTER]))))  AND  (lookahead. table[j][INTRUCTION.TYPE]<> LDM.STM)   --match found
                              SEQ
                                IF
                                  (((instruction.buffer[j][CYCLES]) = 1)  AND ((instruction.buffer[j][NO.OF.PCS]) >=4)) OR  (((instruction.buffer[j][CYCLES]) > 1)  AND ((instruction.buffer[j][NO.OF.PCS]) >=3))
                                    SEQ
                                      debugmsg(report,screen, "ADDINT-AddC: CHECK LIMITS  limit reached due to Reg Bank  write instr.", [instruction.buffer[i][INSTRUCT],0,0,0])
                                      debugmsg(report,screen, "ADDINT-AddC: CHECK LIMITS  limit reached due to Reg Bank  read instr.", [instruction.buffer[j][INSTRUCT],0,0,0])

                                      limit.reached:=TRUE
                                  TRUE
                                    SEQ
                                      SKIP
                          j:=j+1
                          IF
                            (j >instruction.buffer.size)
                              SEQ
                                j:=0
                            TRUE
                              SEQ
                                SKIP

                i:= (i+1) 
                IF
                  (i >instruction.buffer.size)
                    SEQ
                      i:=0
                  TRUE
                    SEQ
                      SKIP

            --------------------check if limit due to cycles filling the pipeline has been reached---------------
            i:=instruction.buffer.base
            total.cycles:=0
            WHILE ((i <> instruction.buffer.top) AND (limit.reached=FALSE))
              SEQ
                -----------------------------------------------------------------------------------
                total.cycles:=total.cycles+(instruction.buffer[i][CYCLES])
                IF
                  total.cycles < max.cycles
                    SEQ
                      SKIP
                  total.cycles = max.cycles
                    SEQ
                      IF
                        (instruction.buffer[i][NO.OF.PCS]) > = 4
                          SEQ
                            limit.reached:=TRUE
                            debugmsg(report,screen, "ADDINT-AddC: CHECK LIMITS  total.cycles = max.cycles limit reached ", [instruction.buffer[i][INSTRUCT],0,0,0])

                        TRUE
                          SEQ
                            SKIP
                  total.cycles > max.cycles
                    SEQ
                      IF
                        (instruction.buffer[i][NO.OF.PCS]) > = 3
                          SEQ
                            limit.reached:=TRUE
                            debugmsg(report,screen, "ADDINT-AddC: CHECK LIMITS total.cycles > max.cycles  limit reached ", [instruction.buffer[i][INSTRUCT],0,0,0])

                        TRUE
                          SEQ
                            SKIP
                i:= (i+1) 
                IF
                  (i >instruction.buffer.size)
                    SEQ
                      i:=0
                  TRUE
                    SEQ
                      SKIP
 
        lookahead.table.empty=TRUE
          SEQ
            debugmsg(report,screen, "ADDINT-AddC: PRMPT OFF lookahead table empty  ",NULL1)
            limit.exists:=FALSE

            SKIP


  :
  -----------------------------------------------------------------------------
  
