/* ----------------------------------------------------------------P. S. O---
 *  FIRST UPDATE : Dec. 17. 1990	normal array ok! check pr_oe
 *  LIB Ver      : 1.00
 * --------------------------------------------------------------------------
 * Fuse_su		      : 3553     [74 * others 1]
 * -------------------------------------------------------------------------- */
declaration
  dataunit : bit
  ;
  functions
    Read
    Program
    Verify
    Blank_Check
    Auto
  ;
  Manufacturers
    SIGNETICS
  ;
  Devices
    PLS104
    PLS104A    
    PLS105 	/* 20 MHZ */   
    PLS105A     /* 25 MHZ */
  ;
		/*  ΥΝΝΝΝΈΥΝΝΝΝΈ        */
  chips = CLK,  /* [³ 1     28 ³] VCC   */
           R0,  /* [³ 2     27 ³] R1    */
	  NC0,  /* [³ 3     26 ³] R2    */
	   C5,  /* [³ 4     25 ³] R3    */
	   C4,  /* [³ 5     24 ³] R4    */
           C3,  /* [³ 6     23 ³] R5    */
	   C2,  /* [³ 7     22 ³] R6    */
	   C1,  /* [³ 8     21 ³] PV    */
	   C0,  /* [³ 9     20 ³] STORBE*/
	  NC1,  /* [³ 10    19 ³] PR_OE */
	  NC2,  /* [³ 11    18 ³] FN    */
          NC3,  /* [³ 12    17 ³] NC7   */
      	  NC4,  /* [³ 13    16 ³] NC6   */
	  GND,  /* [³ 14    15 ³] NC5   */
		/*  ΤΝΝΝΝΝΝΝΝΝΝΎ        */
	NC5, NC6, NC7, FN, PR_OE, STROBE, PV, R6, R5, R4, R3, R2, R1, VCC;
  $v2 = CLK;
  $v3 = VCC;
endd

/* -----------------------------------------------------------------------
 * init() ---> inital processing
 * ----------------------------------------------------------------------- */
int init(vol2, vol3)
voltage vol2, vol3;
{
  @Vout 1,     5.00;	/*      */
  @Vout 2,     vol2;    /* Vp   */
  @Vout 3,     vol3;    /* Vccp */
  @Out  GND,  	 @G;
  @Delay 10, @Ms;  

  @Out VCC,      @W;
  @Out NC[0..7], @W;  
  @Out C[0..5],  @W;
  @Out R[0..6],  @W; 
  @Out CLK,      @W;
  @Out STROBE,   @W;
  @Out FN,       @Z;
  @Out PV,       @W;
  @Out PR_OE,    @W;

  @Out VCC,      @L;
  @Out NC[0..7], @L;  
  @Out C[0..5],  @L;
  @Out R[0..6],  @L; 
  @Out CLK,      @L;
  @Out STROBE,   @H;
  @Out PV,       @L;
  @Out PR_OE,    @L;

  @Delay 1, @Ms;
}
/* -----------------------------------------------------------------------
 * Read data from device
 * Blank check
 * Verify
 * ----------------------------------------------------------------------- */
int verifyf(address, data, option)
int address, data, option;
{
   int	tmp;

@Display 35, 14, address;
@Display 35, 15, option;

   if     (option == 'r') @Load data;		/* Read data	   */
   else if(option == 'b') {			/* Blank check     */
     if(data & 1 != 0)  @Exit;
   }
   else if(option == 'v') {			/* Verify check    */
     @Store tmp;
     if ((tmp&1) != (data&1)) @Exit;
   }
   else if(option == 'p') {			/* Program verify check    */
     @Store tmp;
     if ((tmp&1) != (data&1)) @Exit;
   }   
}
/* -----------------------------------------------------------------------
 * 1 bit(s) data process
 * ----------------------------------------------------------------------- */
int sub(i, j, option, address)
int  i,       					/* Column addressing	   */
     j,       					/* Row addressing	   */
     option,   					/* Read, Program.. or more */
     address;
{
  int pgm_d,					/* Program data     */
      read_d;					/* Read data        */
      
  pgm_d = read_d = 0;     
      
  @Set 0, address;
  @Store pgm_d;
         
  @Out C[0..5], i;
  @Out R[0..6], j;

  @Out VCC, @O; 
  if(option == 'p') {				/* Program bit 	*/
    if(pgm_d == 1) {
    @Out PV,   @H;
    @Out CLK,  @O;
    @PinDelay STROBE, @L, @H, 10;
    @Out CLK,  @F; 
    @Out PV,   @L;
    }
  }
  @Out STROBE, @L; 
  @In FN, read_d;
  @Out STROBE, @H;
  @Out VCC,    @F;
  verifyf(address, read_d, option);
}
/* -----------------------------------------------------------------------
 * PR_OE 1 bit(s) data process
 * ----------------------------------------------------------------------- */
int pr_oe_sub(option)
int  option;   					/* Read, Program.. or more */
{
  int pgm_d,					/* Program data     */
      read_d;					/* Read data        */
      
  pgm_d = read_d = 0;     
      
  @Set 0, 3552;
  @Store pgm_d;
         
  init(10.0, 8.5);

  @Out VCC, @O; 
  if(option == 'p') {				/* Program bit 	*/
    if(pgm_d == 1) {
    @PinDelay PR_OE, @O, @F, 10;
    }
  }
  @Out VCC, @F;
  
  init(10.0, 5.0);

  @Out VCC,   @O;
  @Out PR_OE, @O;
  @Out PR_OE, @F;  
  @Out PR_OE, @H;
  @Out PR_OE, @L;  
  @In FN, read_d;
  @Out VCC,   @F;
  verifyf(3552, read_d, option);
}
/* -----------------------------------------------------------------------
 * Top program
 * ----------------------------------------------------------------------- */
int top(option)
int option;
{
  int i, j, k;

  init(17.5, 8.5);

  k = 0;
             
  for(i=0; i<48; i++) {					/* AND, OR array */
    for(j=0; j<74; j++) {
      if     (j < 45) sub(i, 64+j, option, k++);
      else if(j ==45) sub(i, 28,   option, k++);
      else            sub(i, j-46, option, k++);
    }
  }
  
  pr_oe_sub(option);
}
/* -----------------------------------------------------------------------
 * MAIN Program
 * ----------------------------------------------------------------------- */
int main()
{
int tmp;

tmp = 0x00;
@Display 78, 20, tmp;

  if     (FUNCTION == Program) {
    top('p');					/* Program device     */
    top('v');					/* Verify device      */
  }
  else if(FUNCTION == Read)        top('r');	/* Read device        */
  else if(FUNCTION == Blank_Check) top('b');	/* Blank check device */
  else if(FUNCTION == Verify)      top('v');	/* Verify device      */
  else if(FUNCTION == Auto) {
    top('b');					/* Blank check device */
    top('p');					/* Program device     */
    top('v');					/* Verify device      */
  }
tmp = 0xff;
@Display 78, 20, tmp;  
}
/* ------------------------------- End of program ------------------------ */
 