
#INCLUDE "Regbankdefs.inc"

PROC datainput(CHAN OF INPUT indata,
               CHAN OF INT WBus,
               CHAN OF BOOL Memin,
               CHAN OF ANY Ack, Valid)

  #USE "string.lib"
  #USE "debug.lib"

  [MAXDATA]BOOL Mem :
  [MAXDATA]INT Wrtdata:
  
  INT i, num.of.data,memo,wdata:
  BOOL any,more.data: 
  
  SEQ
    num.of.data:=0
    more.data:=TRUE
    WHILE more.data
      SEQ
        indata?CASE
          data;Wrtdata[num.of.data]
            SEQ
              indata?CASE data;memo
              IF
                memo = 0                
                  Mem[num.of.data]:= FALSE
                TRUE
                  Mem[num.of.data]:= TRUE
              num.of.data:=num.of.data+1
          end.of.data
            more.data:=FALSE

    SEQ i=0 FOR num.of.data
      SEQ
        PAR
          IF
            Wrtdata[i]=(-1)
              Valid!any
            TRUE
              WBus!Wrtdata[i]
          Memin!Mem[i]
        Ack?any
:

                
               
