#INCLUDE "/home/amu5/users/georget/Phd/Simul/Defs/defs.inc"
#USE "/home/amu5/users/georget/Phd/Simul/library"


PROC Ctrl2(CHAN OF BUNDLE FromRegA,FromRegB,FromApipe,FromDatInt,
                           FromDec2,FromNGen,FromCPsrA,FromOplat,FromImm,
                           ToApipe,ToDatIntBw,ToDatIntMb,ToDec2,ToCPsr,ToOplatB,
                           ToOplatA,ToNGen,ToDec2a,ToReg,ToImm,
                           FromDec2A,Ctrl3Alx ,[]CHAN OF DEB.MESSAGE screen, VAL INT report, evaluate)--6
  ------------------------------------------------------------------------
  [MESGLEN]INT  D2,Da,Db,MLa,MLa1,MLb,MLb1,AckAp,BObW,AckDI,Rs,AckD2,Da.occ,
        Imm,Sh,Cp,Ng,AckCp,OPdata,AckNg,Acktd2,Ackop,
        Ackrb,AckImm, ALx:
  BOOL  end, DObw, first:
  INT SHop,cin,cout,sel, mla,DObwi,temp, clock0,clock1,clock2,clock3,clock4,clock5:
  [32]BOOL D2b : 
  [8]BOOL  C2b:  
  [10]BOOL SHopb :  
  [7]BOOL Imdb :
  [8]BOOL Cpb:
  [25]INT delay:

  [4][OCCT.SIZE][OCCT.COL]INT occupancy.table:  --an array of occupancy tables!!!!
                                     

  -------------------------------------------------------------------------
  PROC calculate.delays()
    SEQ
      delay[0]:=MULLERC
      delay[1]:=SELECT+XOR
      delay[2]:=SELECT
      delay[3]:=DESWAIT
      delay[4]:=SELECT
      delay[5]:=XOR
      delay[6]:=SELECT
      delay[7]:=(MULT.DELAY+XOR)+CALLR
      delay[8]:=(XOR+CALLR)+MULT.PASS
      delay[9]:=(MULLERC + XOR)+NOR
      delay[10]:=((XOR+SHIFT.DELAY)+TOGGLE)+CALLR
      delay[11]:=SELECT+XOR
      delay[12]:=MULLERC+CALLR
      delay[13]:=SELECT+CALLR
      delay[14]:=XOR
      delay[15]:=SELECT+XOR
      delay[16]:=CALLA+XOR
      delay[17]:=MULLERC
      delay[18]:=((MULLERC+CALLA)+XOR)+XOR
      delay[19]:=MULLERC + CALLR
      delay[20]:= (((((MULLERC + MULLERC) + CALLA) + XOR) + NOR) + SHIFT.DELAY)+TOGGLE
      delay[21]:=MULLERC+SELECT
      delay[22]:=CALLR
      delay[23]:=CALLR
      
  :
  -------------------------------------------------------------------------
  PROC  initialize.occup.tables()
    SEQ
      initialize.occup.table(occupancy.table[0], DEC2REGB, DEC2REGB.SIZE, REGISTER.DELAY)  
      initialize.occup.table(occupancy.table[1], NGENPIPE, NGENPIPE.SIZE,NGEN.DELAY)  
      initialize.occup.table(occupancy.table[2], RBCTRL2PIPE,RBCTRL2PIPE.SIZE ,REGISTER.DELAY)  
      initialize.occup.table(occupancy.table[3], IMMPIPE, IMMPIPE.SIZE,IMM.DELAY)  
  :
  -------------------------------------------------------------------------

  PROC  MUltiplier(VAL INT Da, Db, INT Psm, Pca)
    INT sum, carry:
    SEQ
      sum:=((Da)TIMES(Db))                    
      carry:=(sum>>1)
      sum:=sum MINUS carry
      Psm:=sum
      Pca:=(carry)   --Here I had ~carry...
  :
  ---------------------------------------
  
  PROC SHifter(VAL BOOL sel, VAL INT Db, Imm,op,cin, INT Sh, cout,CHAN OF DEB.MESSAGE screen )

    INT b0,b31,uval,val,n,m,carry,switch, sign.bit:

    SEQ 

       

      IF
        sel=TRUE
          val:=(Db)
        sel=FALSE
          val:=(Imm)

      b0:= (val/\1)
      b31:=((val>>31)/\1)
      sign.bit:= (b31<<31)           --(b31)0000000...0
      uval:=val
      -------------------------------------------------------------------- 
      --uval, val::: In the C implementation, val is signed while uval 
      -----is unsigned. The difference is that the right shift of  the unsigned
      -----guarantees that the holes will be filled with 0's; right shift of
      -----a signed could fill the holes with 0's (logical shift) or with
      -----the sign bit(arithmetic shift). Occam fills holes with 0's in all cases.
      -----*************THIS MUST BE CHECKED AGAIN**************************
      ------------------------------------------------------------------------- 


      n:=(op/\ #1F)
      --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER--- n", n )

      m:=((n MINUS 1) /\ #1F)
      --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER--- m ", m )
      carry:=((val>>m)/\1)               --carry for right shift
      --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER--- carry:=((val>>m)/\1)", carry ) 

      ----------------------------------------------------------
      switch:=((op>>5)/\3)
      CASE switch
        -------------------------------------------------------------------------
        0                                    --LSL                
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:=((op>>5)/\3) ", NULL1)

            IF
              n=0
                carry:=cin
              TRUE
                carry:=((val>>(32 MINUS n))/\1)
            val:=val<<n
        -------------------------------------------------------------------------

        1                                     --LSR                               
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:=((op>>5)/\3) ", 1 )
            IF
              n=0
                val:=0                 --uval 
              TRUE
                val:=(val>>n)          --uval 
        -------------------------------------------------------------------------

        2                                      --ASR   (arithmetic shift right)
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:=((op>>5)/\3) ", 2 )
            INT i:
            IF
              n=0
                SEQ
                  val:=(val>>31)
                  val:=val\/sign.bit       --restore sign 
                  SEQ i=1 FOR 31
                    val:=(val\/(sign.bit>>i))   --fill holes with sign bit
              
              TRUE
                SEQ
                  val:=(val>>n)
                  val:=val\/sign.bit       --restore sign 
                  SEQ i=1 FOR n
                    val:=(val\/(sign.bit>>i))   --fill holes with sign bit
              

        -------------------------------------------------------------------------

        3                                     
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:=((op>>5)/\3) ", 3 )
            IF
              n=0                                 --RRX
                SEQ
                  carry:=b0
                  val:=((cin<<31)\/(uval>>1))
              TRUE                                 --ROR
                SEQ
                  val:=((uval>>n)\/(val<<(32 MINUS n)))
      ----------------------------------------------------------
      switch:= ((op>>7) /\7)
      CASE switch
        6
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:= ((op>>7) /\7) ", 6 )
            SKIP              --carry as above
        7 
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:= ((op>>7) /\7) ", 7 )
            carry:=0
        5
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:= ((op>>7) /\7) ", 5 )
            carry:=b0
        3
          SEQ
            --debugmsg(report,screen, "DECODE2-CTRL2: SHIFTER---switch:= ((op>>7) /\7) ", 3 )
            carry:=b31
      --------------------------------------------------------
      Sh:=val
      cout:=carry

  :  

  --------------------------------------
  PROC  mkcpsr()
    BOOL temp:
    SEQ
      [Cpb FROM 0 FOR 7]:=Imdb
      IF
        cout=1
          SEQ
            temp:=TRUE
        cout=0
          SEQ
            temp:=FALSE
      Cpb[7]:=temp
      init.hex(Cp[0], Cpb)
  :
  --------------------------------------
  PROC mkopdata()
    INT temp:
    SEQ
      temp:= (Ng[0]/\#3F)  -- 111111  (Ng[5:0])
      init.hex(sel, [C2b[2]]) 
      --debugmsg(report,screen[4], "DECODE2-CTRL2: SELECTING 1=NG ", sel )     
      mux2(sel,MLa[0],temp , OPdata[0])
  :
  ---------------------------------------

  SEQ
    first:=TRUE
    cout:=0
    calculate.delays()
    initialize.occup.tables()

    ----------------------------------------------------------------
    SEQ
      debugmsg(report,screen[0], "DECODE2-CTRL2: Waiting for data from Dec2 ", NULL1 )
      FromDec2?D2
      debugmsg(report,screen[0], "DECODE2-CTRL2: Received for data from Dec2 ", D2)

      IF
        D2[0]<>FINISH  -- D2 = (c2[7:0],DObw,SHop[9:0],Imd[6:0])  --from Dec2
          SEQ
            debugmsg(report,screen[0], "DECODE2-CTRL2: Waiting for data from Reg Bank ", NULL1)
            PAR
              FromRegA? Da    --from register bank
              FromRegB? Db
            debugmsg(report,screen[0], "DECODE2-CTRL2: Received data from Regbank ", Da)
            debugmsg(report,screen[0], "DECODE2-CTRL2: Received data from Regbank ", Db)
        TRUE
          end:=TRUE
    ----------------------------------------------------------------
    WHILE end=FALSE
      SEQ
        Da.occ:=Da
        MLa[0]:=Da[0]
        MLa1[0]:=Da[0]
        MLb:=Db
        MLb1:=Db
        Sh[0]:=0    --THIS IS THE OUTPUT OF THE SHIFTER IF THE SHIFTER IS NOT ACTIVATED
        int.to.bool(D2[0], D2b)
        C2b:=[D2b FROM 0 FOR 8]  --initialize C2b
        DObw:=D2b[8]
        SHopb:=[D2b FROM 9 FOR 10]
        Imdb:=[D2b FROM 19 FOR 7]
        --*********************************************
        clock0:=max(D2[TIME.STAMP], Da[TIME.STAMP]) +delay[0]   --MULLERC
        clock1:= D2[TIME.STAMP]+delay[2]  --SELECT
        IF
          C2b[0]=TRUE
            SEQ
              clock1:=max(clock1, Da[TIME.STAMP]) + delay[3]   --DESWAIT
          C2b[0]=FALSE
            SEQ
              SKIP

        --*********************************************
        ------------------------------------------------------------
        PAR  --1
          ----------------------------------------------------------
          --------------------------------------------------------
          IF
            C2b[3]=FALSE                   --To/From Apipe(AddInt)
              SEQ
                Da[TIME.STAMP]:=clock0+delay[1]    --SELECT+XOR
                Da[STALL]:=-1
                debugmsg(report,screen[0], "DECODE2-CTRL2: Waiting to send to Apipe ", NULL1)
                ToApipe!Da
                FromApipe? AckAp
                debugmsg(report,screen[0], "DECODE2-CTRL2: sent to Apipe ", Da)

            TRUE
              SEQ
                AckAp[TIME.STAMP]:=clock0+delay[1]    --SELECT+XOR
                SKIP
          -------------------------------------------------------
          IF          
            C2b[6]=FALSE                  --To/From Dec2
              SEQ
                Rs[TIME.STAMP]:=clock0+delay[1]    --SELECT+XOR
                Rs[STALL]:=-1
                Rs[0]:=Da[0]/\#000000FF   --Rs=Da[7:0]
                debugmsg(report,screen[1], "DECODE2-CTRL2: Waiting to send to Dec2 ", NULL1)
                ToDec2!Rs
                FromDec2A? AckD2
                debugmsg(report,screen[1], "DECODE2-CTRL2: sent to Dec2 ", Rs)

            TRUE
              SEQ
                AckD2[TIME.STAMP]:=clock0+delay[1]    --SELECT+XOR
                SKIP

          --------------------------------------------------------
          IF
            C2b[4]=FALSE                 --To/From Data Interface 

              SEQ
                MLb1[TIME.STAMP]:=clock0+delay[1]    --SELECT+XOR
                MLb1[STALL]:=-1

                --DObwi:=INT DObw
                init.hex(BObW[0], [DObw])
                IF
                  (((C2b[0]=TRUE) AND (C2b[7]=TRUE)) AND (C2b[1]=FALSE))
                    SEQ
                      MUltiplier(MLa1[0], Db[0], mla, MLb1[0]) -- mla not used
                  TRUE
                    SKIP
                debugmsg(report,screen[2], "DECODE2-CTRL2: Waiting to send to DatInt", NULL1)
                PAR                                    
                  ToDatIntBw!BObW
                  ToDatIntMb!MLb1
                FromDatInt? AckDI
                debugmsg(report,screen[2], "DECODE2-CTRL2: sent to DatInt, MLb1 ", MLb1)

            TRUE
              SEQ
                AckDI[TIME.STAMP]:=clock0+delay[1]    --SELECT+XOR
                SKIP
          ---------------------------------------------------------
          SEQ  --1.2
            -------------------------------------------------------

            IF
              C2b[0]=TRUE
                SEQ
                  debugmsg(report,screen[3], "DECODE2-CTRL2: C2b is  TRUE", NULL1)
                  ---------------------------------------------------
                  clock1:=clock1+delay[4] --SELECT

                  IF
                    C2b[7]=FALSE
                      SEQ
                        clock1:=clock1+delay[5]   --XOR

                        SKIP
                    C2b[7]=TRUE
                      SEQ
                        PAR
                          ----------------------------------------
                          SEQ   --clock2
                            -------------------------------------
                            clock2:=clock1+delay[6]  --SELECT
                            IF
                              C2b[1]=FALSE
                                SEQ
                                  temp:=MLa[0]
                                  MUltiplier(temp, Db[0], MLa[0], MLb[0])
                                  clock2:=clock1+delay[7]    --MULT.DELAY+XOR+CALLR
                              TRUE
                                SEQ
                                  clock2:=clock2+delay[8]    --XOR+CALLR+MULT.PASS
                                  SKIP                            
                            init.hex(SHop, SHopb)
                            IF
                              first=TRUE
                                SEQ
                                  first:=FALSE
                                  cin:=0           --initial value of the carry
                              first=FALSE
                                SEQ
                                  debugmsg(report,screen[3], "DECODE2-CTRL2: Waiting for ALx", NULL1)
                                  Ctrl3Alx? ALx
                                  debugmsg(report,screen[3], "DECODE2-CTRL2: Received ALx", ALx)
                                  cin:=ALx[0] 
                                  clock2:= max(clock2,ALx [TIME.STAMP])+ delay[9]  --MULLERC +XOR+NOR

                      

                            debugmsg(report,screen[3], "DECODE2-CTRL2: C2b[7] TRUE--MLb[0] is ", MLb) 
                            debugmsg(report,screen[3], "DECODE2-CTRL2: C2b[7] TRUE--Imm[0] is ", Imm) 

                            debugmsg(report,screen[3], "DECODE2-CTRL2: C2b[7] TRUE--SHop is ",  [SHop,0,0,0])  

                            debugmsg(report,screen[3], "DECODE2-CTRL2: C2b[7] TRUE--cin is ",  [cin,0,0,0]) 
 
                            clock3:=clock2+delay[10]   --XOR+SHIFT.DELAY+TOGGLE

                            SHifter(C2b[0],MLb[0],Imm[0], SHop, cin, Sh[0], cout, screen[3])
                            debugmsg(report,screen[3], "DECODE2-CTRL2: C2b[7] TRUE ", NULL1)

                          ----------------------------------------
                          SEQ  --clock4
                             -----------------------------------------
                            clock4:=clock1+delay[11]  --SELECT+XOR

                            IF
                              C2b[2]=TRUE
                                SEQ
                                  debugmsg(report,screen[4], "DECODE2-CTRL2: Waiting for Ng", NULL1)
                                  FromNGen? Ng
                                  debugmsg(report,screen[4], "DECODE2-CTRL2: Received Ng", Ng)
                                  clock4:=max(clock4, Ng[TIME.STAMP])+delay[12]  --MULLERC+CALLR
                              TRUE
                                SEQ
                                  clock4:=clock4+delay[23]  --CALLR

                                  SKIP
                        ----------------------------------------------------------
                        SEQ
                          PAR
                            ------------------------------------------------------
                            SEQ
                              IF
                                C2b[5]=TRUE
                                  SEQ
                                    Cp[TIME.STAMP]:=clock3+delay[13]  --SELECT+CALLR
                                    Cp[STALL]:=-1
                                    debugmsg(report,screen[5], "DECODE2-CTRL2: waiting to send cpsr ", Cp)
                                    mkcpsr()
                                    ToCPsr!Cp
                                    FromCPsrA? AckCp
                                    AckCp [TIME.STAMP]:=AckCp[TIME.STAMP]+delay[14]  --XOR

                                    debugmsg(report,screen[5], "DECODE2-CTRL2: sent cpsr ", Cp)
                                TRUE
                                  SEQ
                                    AckCp[TIME.STAMP]:=clock3+delay[15]  --SELECT+XOR
                                    debugmsg(report,screen[5], "DECODE2-CTRL2: not sending cpsr.... ", Cp)
                                    SKIP
                            -----------------------------------------------------
                            SEQ
                              mkopdata()
                              OPdata[TIME.STAMP]:=max((clock3+delay[16]), clock4) +delay[17] --CALLA+XOR,  MULLERC 
                              OPdata[STALL]:=-1
                    
                              debugmsg(report,screen[4], "DECODE2-CTRL2: Waiting to send to OPreg Sh", Sh)
                              debugmsg(report,screen[4], "DECODE2-CTRL2: Waiting to send to OPreg OPdata",OPdata)
                              PAR
                                ToOplatB!Sh
                                ToOplatA!OPdata   --from multiplexer
         
                              FromOplat? Ackop
                              debugmsg(report,screen[4], "DECODE2-CTRL2: sent to OPreg ",Sh)
                              debugmsg(report,screen[4], "DECODE2-CTRL2: sent to OPreg ", OPdata)

                             
              ----------------------------------------------------------
              C2b[0]=FALSE
                SEQ
                  

                  ----------------------------------------------------
                  PAR
                    ------------------------------------------------
                    SEQ  
                      ----------------------------------------------
                      PAR
                        SEQ
                          debugmsg(report,screen[3], "DECODE2-CTRL2: Waiting from IMMpipe", NULL1)
                          FromImm? Imm
                          debugmsg(report,screen[3], "DECODE2-CTRL2: Received from IMMpipe", Imm)
                          clock2:= max(clock1,Imm[TIME.STAMP])+ delay[19]  --MULLERC + CALL

                        init.hex(SHop, SHopb)

                        IF
                          first=TRUE
                            SEQ
                              first:=FALSE
                              cin:=0            --initial value of the carry
                              ALx[TIME.STAMP]:=0
                          first=FALSE
                            SEQ
                              --debugmsg(report,screen[4], "DECODE2-CTRL2: Waiting for ALx", NULL1)
                              Ctrl3Alx? ALx


                              --debugmsg(report,screen[4], "DECODE2-CTRL2: Received ALx", NULL1)
                              cin:=ALx[0] 
 
                      clock2:= max(clock2,ALx[TIME.STAMP])
                      debugmsg(report,screen[4], "DECODE2-CTRL2: C2b[7] FALSE--MLb[0] is ", MLb) 
                      debugmsg(report,screen[4], "DECODE2-CTRL2: C2b[7] FALSE--Imm[0] is ", Imm) 
                      debugmsg(report,screen[4], "DECODE2-CTRL2: C2b[7] FALSE--cin is ",  [cin,0,0,0])
                      debugmsg(report,screen[4], "DECODE2-CTRL2: C2b[7] FALSE--SHop is ",  [SHop,0,0,0])                      
                      SHifter(C2b[0],MLb[0],Imm[0], SHop, cin, Sh[0], cout,screen[4])
                      clock3:= max(clock2,ALx[TIME.STAMP])+ delay[20]  -- MULLERC + MULLERC + CALL + XOR + NOR + SHIFT.DELAY+TOGGLE


                    SEQ
                      -----------------------------------------------
                      clock4:=clock1+delay[11]  --SELECT+XOR
                      IF
                        C2b[2]=TRUE
                          SEQ
                            --debugmsg(report,screen[5], "DECODE2-CTRL2: Waiting for Ng", NULL1)
                            FromNGen? Ng
                            --debugmsg(report,screen[5], "DECODE2-CTRL2: Received Ng", NULL1)
                            clock4:=max(clock4, Ng[TIME.STAMP])+delay[12]  --MULLERC+CALRL

                        TRUE
                          SEQ
                            clock4:=clock4+delay[23]  --CALRL
                            SKIP
                          ----------------------------------------------------------
                  SEQ
                    PAR
                      ------------------------------------------------------
                      SEQ
                        IF
                          C2b[5]=TRUE
                            SEQ
                              Cp[TIME.STAMP]:=clock3+delay[13]  --SELECT
                              Cp[STALL]:=-1
                              debugmsg(report,screen[5], "DECODE2-CTRL2: waiting to send cpsr ", Cp)
                              mkcpsr()
                              ToCPsr!Cp
                              FromCPsrA? AckCp
                              debugmsg(report,screen[5], "DECODE2-CTRL2: sent cpsr ", Cp)
                              AckCp [TIME.STAMP]:=AckCp[TIME.STAMP]+delay[14]  --XOR

                          TRUE
                            SEQ
                              AckCp[TIME.STAMP]:=clock3+delay[15]  --SELECT+XOR
                              debugmsg(report,screen[5], "DECODE2-CTRL2: not sending cpsr.... ", Cp)
                              SKIP
                      -----------------------------------------------------
                      SEQ
                        OPdata[TIME.STAMP]:=max((clock3+delay[16]), clock4) +delay[17]                      --CALL+XOR,  MULLERC
                        OPdata[STALL]:=-1
                        mkopdata()
                        debugmsg(report,screen[4], "DECODE2-CTRL2: Waiting to send to OPreg Sh", Sh)
                        debugmsg(report,screen[4], "DECODE2-CTRL2: Waiting to send to OPreg OPdata",OPdata)
                        PAR
                          ToOplatB!Sh
                          ToOplatA!OPdata   --from multiplexer
         
                        FromOplat? Ackop
                        debugmsg(report,screen[4], "DECODE2-CTRL2: sent to OPreg ",Sh)
                        debugmsg(report,screen[4], "DECODE2-CTRL2: sent to OPreg ", OPdata)


            ----------------------------------------------------------
        --**********************
        clock0:=max(AckDI[TIME.STAMP],AckD2[TIME.STAMP])
        clock0:=max(clock0,  AckAp[TIME.STAMP]) + delay[22]  --MULLERC

        clock5:= max(Ackop[TIME.STAMP],AckCp[TIME.STAMP])+delay[18]     --MULLERC+CALL+XOR+XOR                     
        AckNg[TIME.STAMP]:= max(Ackop[TIME.STAMP],AckCp[TIME.STAMP])+delay[18]     --MULLERC+CALL                     

        --**********************                            

        Acktd2[TIME.STAMP]:=max(clock5, clock0) +delay[20] --MULLERC
        Ackrb[TIME.STAMP]:=max(clock5, clock0) +delay[20] --MULLERC

        calculate.occupancy(evaluate, occupancy.table[0], Acktd2[TIME.STAMP],D2 )  
        calculate.occupancy(evaluate, occupancy.table[2], Ackrb[TIME.STAMP],Da.occ )  

        PAR
          ------------------------------------------------------------
          SEQ
            IF
              C2b[2]=TRUE
                SEQ
                  ToNGen!AckNg   --ok timestamp already calculated
                  calculate.occupancy(evaluate, occupancy.table[1], AckNg[TIME.STAMP],Ng )  

              TRUE
                SKIP
          -------------------------------------------------------------
          
          ToDec2a!Acktd2
          ToReg!Ackrb
          -------------------------------------------------------------
          --SEQ
           -- IF
             -- C2b[1]=FALSE
               -- SEQ
                --  TOMLa!Mla
             -- TRUE
               -- SKIP
          -----------------------------------------------------------
          SEQ
            IF
              C2b[0]=FALSE
                SEQ

                  AckImm[TIME.STAMP]:= max(Ackop[TIME.STAMP],AckCp[TIME.STAMP])+delay[21] --MULLERC+SELECT
                  calculate.occupancy(evaluate, occupancy.table[3], AckImm[TIME.STAMP],Imm )  

                  ToImm!AckImm
              TRUE
                SKIP
          ---------------------------------------------------------
       
        ----------------------------------------------------------------
        SEQ
          debugmsg(report,screen[0], "DECODE2-CTRL2: Waiting for data from Dec2 ", NULL1)
          FromDec2?D2
          debugmsg(report,screen[0], "DECODE2-CTRL2: Received data from Dec2 ", D2)

          IF
            D2[0]<>FINISH  -- D2 = (c2[7:0],DObw,SHop[9:0],Imd[6:0]) --from Dec2
              SEQ

                debugmsg(report,screen[0], "DECODE2-CTRL2: Waiting for data from RegBank ", NULL1)

                PAR
                  FromRegA? Da    --from register bank
                  FromRegB? Db
                debugmsg(report,screen[0], "DECODE2-CTRL2: Received data from RegBank ", Da)
                debugmsg(report,screen[0], "DECODE2-CTRL2: Received data from RegBank ", Db)
            TRUE
              end:=TRUE
    ----------------------------------------------------------------
    terminate(evaluate, D2[TIME.STAMP], KILL, FLUSH, occupancy.table, screen[0], [ToApipe,ToDatIntMb,ToDec2,ToCPsr,ToOplatA])
:


