Trailing-Edge
-
PDP-10 Archives
-
decuslib10-09
-
43,50466/lcap.alg
There are 2 other files named lcap.alg in the archive. Click here to see a list.
COMMENT THIS PROGRAM WAS OBTAINED FROM DECUS (NO. 10-174) AND;
COMMENT INPLEMENTED AT WESTERN MICHIGAN UNIVERSITY.;
COMMENT R LOADER LCAPA,LCAPB,USETRK,USAGE,LCAP/G 5/30/75 RRB;
COMMENT STORAGE: TOTN=INTN+NINP
NODE[0:TOTN]
NODE[J] IS:
J=0 --> +1 TIE POINT 0<J<=NINP --> INPUT
NINP<J<=TOTN --> GATE
BIT 0 1 IF TO BE PRINTED (ALWAYS 0 FOR J=0)
BITS 1-5 GATE TYPE
BITS 6-11 THRESHOLD
BITS 12-17 MAX NUMBER OF INPUTS
BIT 18 1 IF OUTPUT IS TO BE COMPLEMENTED
BIT 19 VALUE OF NODE AT TIME=0
BIT 20 1 IF GATE VALUE HAS NOT BEEN CALCULATED
(FLIP-FLOPS ONLY)
BIT 34 NODE VALUE AT TIME=T-1
BIT 35 NODE VALUE AT TIME=T;
COMMENT PATH[I,K] 0<=I<=TOTN, NINP<K<=TOTN
BIT 0 1 IF THERE IS AT LEAST ONE PATH FROM NODE[I]
TO NODE[K]
BIT 1,3,5,7,9,11
1 IF INPUT TO THE C,D,J,K,R,S CONNECTIONS RESP.
BIT 2,4,6,8,10,12
1 IF C,D,J,K,R,S RESP. IS TO BE INVERTED
BIT 13,14 0=NORMAL 1=INVERT 2=TOTAL INHIBIT
BIT 32-33 PATH VALUE AT TIME T-1
BIT 34-35 PATH VALUE AT TIME T;
BEGIN
COMMENT USETRK IS A FORTRAN SUBROUTINE THAT CALLS "USAGEB('LCAP')"
AND RETURNS. 13-JUN-74 R.BARR;
COMMENT EXTERNAL PROCEDURE USETRK;
EXTERNAL PROCEDURE SET;
EXTERNAL PROCEDURE RESET;
EXTERNAL INTEGER PROCEDURE SIZE;
EXTERNAL BOOLEAN PROCEDURE PEEK;
BOOLEAN CH; INTEGER CHAR,TERM;
INTEGER NINP,INTN,TOTN,HELP,STATUS,FFLAG,JBREL;
INTEGER I,J,K,L,M,N,J1,J2,J3,J4,SE,DY,PRES;
INTEGER CL,KI,JI,RE,COMP,FCN,THRESH,SUM,TIME,FLAG,INV,SSM;
STRING ST1,ST2,ST3,Q,BUF,SIG,VALUS;
STRING ARRAY MSG[1:60],TAB[1:20],TIPE[1:8],TAR[1:6];
SWITCH SW1:=T1,T1,T2,T2,THELP1,S6,T2,T2,T2,T2,T2,T2,T2,S14,T2,T2,SS,T2,T2;
PROCEDURE HHELP;BEGIN
WRITE("[N]THESE ARE THE SUPERVISOR COMMANDS:[N]SHORT- GIVES SHORT FORM OF MESSAGES[N]LONG- GIVES LONG FORM OF MESSAGES[N]HELP- PRINTS THIS MESSAGE[N]BEGIN- INITIAL ALLOCATION OF CORE[N]EXPAND- ALLOWS THE USER TO ALLOCATE MORE CORE[N]GATES- THIS ALLOWS THE USER TO SPECIFY THE GATE TYPES[N]WIRES- SETS UP CIRCUITRY[N]");
WRITE("REWIRE- MODIFY THE CIRCUITRY WITHOUT ERASING IT[N]INPUT- SETS THE INPUT PATTERNS AND PRESETS GATES[N]PRINT- SPECIFY WHICH GATES AND INPUTS TO PRINT VALUES OF[N]START- STARTS THE SIMULATION OF A CIRCUIT[N]RUN- CONTINUE WITH THE EXISTING CIRCUIT SIMULATION[N]SAVE- SAVES THE CIRCUIT IN A FILE FOR FUTURE USE[N]FETCH- RETRIEVES A PREVIOUSLY SAVED CIRCUIT[N]");
WRITE("DISPLAY- PRINTS CIRCUIT DESCRIPTION[N]SIZE- GIVES CURRENT NUMBER OF GATES AND INPUTS[N]CHECK- VERIFIES THAT ALL WIRES ARE CONNECTED[N]END- END EXECUTION OF THE PROGRAM[N]DUMP- TO SEE INTERNAL CONFIGURATION OF DATA [[NOT RECOMMENDED]] [2N]") END;
PROCEDURE GETSTRING(S);STRING S;
BEGIN
INTEGER I,J,K; STRING BUF;
BUF:=NEWSTRING(80,7);
I:=1;
FOR J:=1 UNTIL 80 DO
BEGIN
LOOP: IF IOCHAN(0) AND %100 THEN GOTO EX;
INSYMBOL(K);
IF K=13 THEN GOTO EX;
IF I=1 AND K=32 THEN GOTO LOOP;
BUF.[I]:=K;
I:=I+1; END;
EX: S:="0";
IF I#1 THEN S:=COPY(BUF,1,I-1);
DELETE(BUF);
NEXTSYMBOL(I);
IF I=10 THEN SKIPSYMBOL;
END;
PROCEDURE CHKTAB(TAB,ST,N,K); VALUE ST,K;
STRING ST; STRING ARRAY TAB; INTEGER N,K;
BEGIN INTEGER J; N:=0; FOR J:=1 UNTIL K DO
IF ST=TAB[J] THEN BEGIN N:=J; GOTO EX END;
EX: END;
INTEGER PROCEDURE NOCHK(ST); VALUE ST; STRING ST;
BEGIN INTEGER J,K; NOCHK:=1; J:=LENGTH(ST);
FOR K:=1 UNTIL J DO IF ST.[K]<48 OR ST.[K]>57 THEN NOCHK:=0;
END;
INTEGER PROCEDURE NUM(ST); VALUE ST; STRING ST; BEGIN INTEGER I,J,K;
I:=LENGTH(ST); K:=0; FOR J:=1 UNTIL I DO K:=10*K+ST.[J]-48;
NUM:=K; END;
Q:="* "; SET(JBREL);
MSG[1]:="[N]LOGIC CIRCUIT ANALYSIS PROGRAM VERS. 003(02)[2N]";
MSG[2]:="(TYPE ""HELP"" FOR LIST OF COMMANDS)[2N]";
MSG[3]:="ERROR: SUPERVISOR COMMAND """;
MSG[4]:=""" IS NOT VALID AT THIS TIME";
MSG[5]:="[N]WHAT IS THE NUMBER OF INPUTS TO THE CIRCUIT? ";
MSG[6]:="WHAT IS THE NUMBER OF GATES IN THE CIRCUIT? ";
MSG[7]:="[N]**CHARACTERISTICS OF GATES**[N]";
MSG[8]:=" TYPES OF GATES:[N2S]#1..NOT, #2..AND, #3..OR,[N2S]#4..NAND, #5..NOR,[N2S]#6..DO IT YOURSELF,[N2S]#7..J-K FLIP-FLOP,[N2S]#8..D FLIP-FLOP[2N]";
MSG[9]:="GATE"; MSG[10]:="INPUT"; MSG[11]:="[N2S]TYPE # ";
MSG[12]:=" ERROR: NO SUCH GATE TYPE";
MSG[13]:=" THE INPUTS WILL BE: J,K,C(LOCK),AND OPTIONALLY R(ESET)[N]";
MSG[14]:=" THIS GATE HAS ONLY 1 INPUT[N]";
MSG[15]:=" THRESHOLD OF GATE = "; MSG[16]:=" NUMBER OF INPUTS = ";
MSG[17]:=" IS OUTPUT TO BE INVERTED?[N]";
MSG[18]:=" TYPE YES OR NO... ";
MSG[19]:="[N]**WIRING DESCRIPTION**[N]";
MSG[20]:=" FOR EVERY WIRE FROM EACH INPUT AND GATE TYPE ""N,XYZ"" -- WHERE:[N2S]1) ""N"" IS THE NUMBER OF THE TERMINAL GATE OR A ""/"" (SEE #4)[N2S]2) ""X"" IS ONE OF N(ON-INVERTING), I(NVERTING), OR T(OTAL INHIBIT)[N7S]OR K TO DELETE THE WIRE[N2S]3) ""Y"" IS ONE OF J, K, C(LOCK), D, S(ET), R(ESET)[N7S]AND ONLY USED IF THE GATE IS A FLIP-FLOP[N2S]4) ""Z"" IS A ""/"" TO SIGNAL THAT NO MORE WIRES ORIGINATE[N7S]FROM THIS SOURCE[2N]";
MSG[21]:="+1 TIE POINT";MSG[22]:=" SOURCE TERMINATION[2N]";
MSG[23]:=" ERROR: NO SUCH GATE NUMBER IN THIS CIRCUIT AS";
MSG[24]:=" ERROR: INVALID TERMINATION ";
MSG[25]:=" ERROR: NO SUCH CONNECTION ON A FLIP-FLOP";
MSG[26]:="J-"; MSG[27]:="K-"; MSG[28]:="CL-"; MSG[29]:="RE ";
MSG[49]:="INPUT(S) TO GATE"; MSG[30]:=" ARE NOT WIRED[N]";
MSG[31]:=" TOO MANY INPUTS[N]"; MSG[32]:=" TOO FEW INPUTS[N]";
MSG[33]:="[N]THE CIRCUIT IS OKAY[N]";
MSG[34]:="[N]**CHARACTERISTICS OF INPUTS**[N]";
MSG[35]:=" FOR EACH INPUT, GIVE THE BIT PATTERN (<=72 BITS)[N2S]INCREASING TIME IS LEFT TO RIGHT[N]";
MSG[36]:=" ERROR: VALUES CAN BE ""0"" OR ""1"" ONLY[N]";
MSG[39]:="[2N]CIRCUIT VALUES AT TIME";MSG[40]:="VALUE";
MSG[41]:="[N]NUMBER OF TIME STEPS TO PROCESS = ";
MSG[42]:="[N]TIME INTERVAL FOR PRINTING CIRCUIT VALUES = ";
MSG[43]:="LIST THE ";
MSG[44]:="(S) TO BE PRINTED";
MSG[37]:="[N2S]TYPE ""ALL"", ""NONE"" OR SEPARATE BY COMMAS";
MSG[45]:="[N]... TRY AGAIN[N]";
MSG[46]:="[N]PLEASE SELECT THE ";
MSG[47]:="S AGAIN: ";
MSG[48]:=""" IS NOT DEFINED";
MSG[50]:="[N]DO YOU WANT TO PRESET ANY GATES?[N]";
MSG[51]:="D-"; MSG[52]:="CL-"; MSG[53]:="RE-"; MSG[54]:="S ";
TAB[1]:="SHORT";TAB[2]:="LONG";TAB[3]:="SIZE";
TAB[4]:="REWIRE";TAB[5]:="HELP";
TAB[6]:="BEGIN";
TAB[7]:="GATES";TAB[8]:="WIRES";TAB[9]:="INPUT";TAB[10]:="PRINT";
TAB[11]:="START";TAB[12]:="RUN";TAB[13]:="SAVE";
TAB[14]:="FETCH";
TAB[15]:="DISPLAY";TAB[16]:="DUMP";TAB[17]:="END";
TAB[18]:="CHECK";TAB[19]:="EXPAND";
TIPE[1]:="NOT ";TIPE[2]:="AND ";TIPE[3]:="OR ";TIPE[4]:="NAND ";
TIPE[5]:="NOR ";TIPE[6]:="*** ";TIPE[7]:="JK FF";TIPE[8]:="D FF ";
TAR[1]:="C";TAR[2]:="D";TAR[3]:="J";TAR[4]:="K";TAR[5]:="R";TAR[6]:="S";
FLAG:=0; HELP:=1; INPUT(0,"TTY"); SELECTINPUT(0); SELECTOUTPUT(0);
WRITE(MSG[1]);WRITE(MSG[2]);
COMMENT 13-JUN-74 R.BARR;
COMMENT CALL(USETRK);
T1: WRITE(Q); BREAKOUTPUT; STATUS:=0;
GETSTRING(ST1);
T0: CHKTAB(TAB,ST1,N,19); IF N=2 OR N=1 THEN HELP:=N-1;GOTO SW1[N];
T2: WRITE(MSG[3]);WRITE(ST1);
IF N#0 THEN WRITE(MSG[4]) ELSE WRITE(MSG[48]);WRITE(MSG[45]);
GOTO T1;
THELP1: HHELP; GOTO T1;
COMMENT FETCH ROUTINE;
S14: WRITE("[N]WHAT IS FILENAME.EXT = ");BREAKOUTPUT;GETSTRING(ST1);
CHKTAB(TAB,ST1,N,19); IF N#0 THEN GOTO T0;
IF LENGTH(ST1)>10 THEN BEGIN WRITE("[N]ILLEGAL NAME: ");
WRITE(ST1); GOTO S14 END;
T31: INPUT(2,"DSK");SELECTINPUT(2);
IF FLAG#2 THEN BEGIN K:=LENGTH(ST1); I:=IMIN(6,K);
J1:=J2:=0;
FOR J:=1 UNTIL I DO BEGIN
IF ST1.[J]=$/./ THEN GOTO T46;
SFIELD(J1,6*(J-1),6,ST1.[J]-INT(%40)) END;
T46: I:=J;
IF I=K THEN BEGIN J2:=0; GOTO T47 END;
K:=IMIN(K-I,3); FOR J:=1 UNTIL K DO
SFIELD(J2,6*(J-1),6,ST1.[J+I]-INT(%40));
T47: IF NOT PEEK(2,J1,J2,0) THEN BEGIN
WRITE("FILE WAS NOT FOUND[2N]");
SELECTINPUT(0); FLAG:=0; GOTO T1 END END;
IF FLAG=2 THEN ST1:="0S0R0A"; OPENFILE(2,ST1);
READ(M);READ(N); IF FLAG=2 THEN GOTO T32;
WRITE("[N]THE CIRCUIT FETCHED HAD[N]");PRINT(M,2);
WRITE(" INPUT(S) AND");PRINT(N,2);WRITE(" GATE(S)[N]");
T32: IF M#NINP OR N#INTN THEN BEGIN
NINP:= IF FLAG=2 THEN IMAX(NINP,M) ELSE M;
INTN:= IF FLAG=2 THEN IMAX(INTN,N) ELSE N;
STATUS:=INT(%004000000000) END; FLAG:=1; GOTO T30;
COMMENT BEGIN ROUTINE;
S6: STATUS:=INT(%004000000000);WRITE(MSG[5]);BREAKOUTPUT;
GETSTRING(ST1);IF NOCHK(ST1)=0 THEN GOTO T0;NINP:=NUM(ST1);
WRITE(MSG[6]);BREAKOUTPUT;GETSTRING(ST1);NEWLINE;
IF NOCHK(ST1)=0 THEN GOTO T2;INTN:=NUM(ST1);
IF FLAG=2 THEN GOTO T31;
T30: TOTN:=NINP+INTN; RESET(JBREL);
BEGIN
INTEGER ARRAY NODE[0:TOTN],PATH[0:TOTN,1+NINP:TOTN];
SWITCH SW2:=LOOP,LOOP,S3,S8,S5,SAA,S7,S8,S9,S10,S11,S12,S13,SAA,S15,S16,S17,S18,S19;
SIG:=NEWSTRING(72*NINP,1);VALUS:=NEWSTRING(72*INTN,1);
FOR J:=0 UNTIL TOTN DO BEGIN NODE[J]:=0;
FOR J1:=1+NINP UNTIL TOTN DO PATH[J,J1]:=0 END;NODE[0]:=1;
IF FLAG=1 THEN GOTO T23;
LOOP: WRITE(Q);BREAKOUTPUT;GETSTRING(ST1);
LOOPB: CHKTAB(TAB,ST1,N,19); IF N=1 OR N=2 THEN HELP:=N-1; GOTO SW2[N];
LOOPA: WRITE(MSG[3]);WRITE(ST1);
IF N#0 THEN WRITE(MSG[4]) ELSE WRITE(MSG[48]);WRITE(MSG[45]);
GOTO LOOP;
COMMENT HELP ROUTINE CALL;
S5: HHELP; GOTO LOOP;
SAA: DELETE(SIG);DELETE(VALUS);
IF N=6 THEN GOTO S6 ELSE GOTO S14;
COMMENT SIZE ROUTINE;
S3: WRITE("[N]DYNAMIC STORAGE:");PRINT(NINP,3);WRITE(" INPUT(S),");
PRINT(INTN,3); WRITE(" GATE(S)[N]");
WRITE(" ACTUAL CORE: 8 +");PRINT(SIZE-8,1);
WRITE("K[2N]"); GOTO LOOP;
COMMENT GATES ROUTINE;
S7: IF GFIELD(STATUS,6,1)#1 THEN GOTO LOOPA; WRITE(MSG[7]);
SFIELD(STATUS,7,1,1); IF HELP=1 THEN WRITE(MSG[8]) ELSE NEWLINE;
FOR J:=1 UNTIL INTN DO BEGIN
J1:=J+NINP;
T3: WRITE(MSG[9]);PRINT(J,2);WRITE(MSG[11]);BREAKOUTPUT;
GETSTRING(ST1); IF ST1="/" THEN GOTO T4;
IF ST1="EXIT" THEN BEGIN NEWLINE; GOTO LOOP END;
IF NOCHK(ST1)=0 THEN BEGIN SFIELD(STATUS,7,1,0);
GOTO LOOPB END;
J2:=NUM(ST1); IF J2>8 OR J2<1 THEN BEGIN WRITE(MSG[12]);
WRITE(MSG[45]); GOTO T3 END;
IF J2=7 THEN BEGIN
IF HELP=1 THEN WRITE(MSG[13]); SFIELD(NODE[J1],3,18,INT(%700040));
GOTO T4 END;
IF J2=8 THEN BEGIN
IF HELP=1 THEN WRITE(" THE INPUTS WILL BE R,S,D AND C(LOCK)[N]");
SFIELD(NODE[J1],0,18,INT(%100004)); GOTO T4 END;
SUM:=0; SFIELD(SUM,1,5,J2);
IF J2=1 THEN BEGIN IF HELP=1 THEN WRITE(MSG[14]);I:=1; GOTO T5 END;
IF J2=6 THEN BEGIN WRITE(MSG[15]); BREAKOUTPUT; GETSTRING(ST1);
IF NOCHK(ST1)=0 THEN GOTO T6;J3:=NUM(ST1) END;
WRITE(MSG[16]); BREAKOUTPUT;GETSTRING(ST1);
IF NOCHK(ST1)=0 THEN GOTO T6; I:=NUM(ST1);
T5: IF J2<6 THEN J3:=I; K:=J3-(J3-1)*(J2 REM 2);SFIELD(SUM,6,6,K);
IF NOT BOOL(J2) AND %02 THEN J4:=1 ELSE J4:=0;
IF J2=6 THEN BEGIN WRITE(MSG[17]); IF HELP=1 THEN WRITE(MSG[18]);BREAKOUTPUT;
GETSTRING(ST1); IF ST1="YES" THEN BEGIN J4:=1; GOTO T8 END;
IF ST1#"NO" THEN GOTO T6; END;
T8: SFIELD(SUM,12,7,2*I+J4);
SUM:=SUM/8; SFIELD(NODE[J1],0,33,SUM);
T4: NEWLINE END; GOTO LOOP;
T6: SFIELD(STATUS,7,1,0); GOTO LOOPB;
COMMENT WIRES AND REWIRE ROUTINE;
S8: IF GFIELD(STATUS,6,1)#1 THEN GOTO LOOPA;
WRITE(MSG[19]); SFIELD(STATUS,8,1,1);
IF HELP=1 THEN WRITE(MSG[20]) ELSE NEWLINE; WRITE(MSG[22]);
IF N=4 THEN BEGIN SFIELD(STATUS,4,1,1); GOTO T35 END;
FOR J:=0 UNTIL TOTN DO
FOR J1:=1+NINP UNTIL TOTN DO PATH[J,J1]:=0;
T35: FOR J:=0 UNTIL TOTN DO BEGIN
T7: IF J=0 THEN BEGIN WRITE(MSG[21]);SPACE(5);BREAKOUTPUT END;
IF J#0 THEN BEGIN SPACE(2);
IF J<=NINP THEN BEGIN WRITE(MSG[10]);K:=J END
ELSE BEGIN SPACE;WRITE(MSG[9]);K:=J-NINP END;
PRINT(K,2); SPACE(7);BREAKOUTPUT END;
J3:=0; GETSTRING(ST2); IF ST2="/" THEN GOTO T9;
IF ST2="EXIT" THEN BEGIN NEWLINE; GOTO LOOP END;
K:=LENGTH(ST2); N:=0;
FOR J4:=1 UNTIL K DO BEGIN
IF ST2.[J4]<48 OR ST2.[J4]>57 THEN GOTO T10;
N:=J4; J3:=10*J3 + ST2.[J4]-48 END;
T10: IF N=0 THEN BEGIN ST1:=ST2;GOTO LOOPB END;
IF J3<1 OR J3>INTN THEN BEGIN WRITE(MSG[23]);PRINT(J3,2);
NEWLINE; GOTO T7 END;
J3:=J3+NINP; SFIELD(PATH[J,J3],0,1,1); ST1:=COPY(ST2,N+2,K);
K:=K-N-1;TERM:=0; CHAR:=ST1.[1];
IF CHAR=$/I/ THEN BEGIN TERM:=1;
SFIELD(PATH[J,J3],13,2,1); GOTO T13 END;
IF CHAR=$/T/ THEN BEGIN SFIELD(PATH[J,J3],13,2,2); GOTO T13 END;
IF CHAR=$/K/ THEN BEGIN PATH[J,J3]:=0; GOTO T13 END;
IF CHAR#$/N/ THEN BEGIN
T12: WRITE(MSG[24]);SPACE(2);WRITE(ST1);
WRITE("[5S]THE WIRE HAS BEEN DELETED"); WRITE(MSG[45]);
PATH[J,J3]:=0; GOTO T7 END;
T13: IF K>1 THEN BEGIN CHAR:=ST1.[2];
IF CHAR=$./. THEN GOTO T9;
IF CHAR=$/C/ THEN CHAR:=1;
IF CHAR=$/D/ THEN CHAR:=3;
IF CHAR=$/J/ THEN CHAR:=5;
IF CHAR=$/K/ THEN CHAR:=7;
IF CHAR=$/R/ THEN CHAR:=9;
IF CHAR=$/S/ THEN CHAR:=11;
IF CHAR>11 OR CHAR<1 THEN BEGIN WRITE(MSG[25]);NEWLINE;GOTO T7 END;
SFIELD(PATH[J,J3],CHAR,2,2+TERM);SFIELD(PATH[J,J3],13,2,0);
IF ST1.[K]=47 AND K<4 THEN GOTO T9 END;
GOTO T7;
T9: NEWLINE; END; GOTO LOOP;
COMMENT CHECK ROUTINE;
S18: K:=0; IF GFIELD(STATUS,7,2)#3 THEN GOTO LOOPA;
SFIELD(STATUS,18,1,1);
FOR J:=1+NINP UNTIL TOTN DO BEGIN J3:=GFIELD(NODE[J],1,5);
IF J3>6 THEN BEGIN INTEGER ARRAY XX[1:4];
XX[1]:=XX[2]:=XX[3]:=XX[4]:=0;
IF J3=8 THEN GOTO T48;
FOR J1:=0 UNTIL TOTN DO BEGIN
CH:=BOOL(GFIELD(PATH[J1,J],0,12));
IF CH AND %100 THEN XX[1]:=1;
IF CH AND %20 THEN XX[2]:=1;
IF CH AND %2000 THEN XX[3]:=1;
IF CH AND %4 THEN XX[4]:=1 END;
T49: SUM:= IF J3=7 THEN 25 ELSE 50;
IF XX[1]*XX[2]*XX[3]*XX[4]=0 THEN BEGIN
FOR J2:=1 UNTIL 4 DO IF XX[J2]=0 THEN WRITE(MSG[SUM+J2]);
WRITE(MSG[49]);K:=J-NINP; PRINT(K,2); WRITE(MSG[30]) END;
GOTO T14;
T48: FOR J1:=0 UNTIL TOTN DO BEGIN
CH:=BOOL(GFIELD(PATH[J1,J],0,12));
IF CH AND %400 THEN XX[1]:=1;
IF CH AND %2000 THEN XX[2]:=1;
IF CH AND %4 THEN XX[3]:=1;
IF CH AND %1 THEN XX[4]:=1 END;
GOTO T49;
END;
J2:=0; FOR J1:=0 UNTIL TOTN DO IF PATH[J1,J]<0 THEN J2:=J2+1;
J3:=GFIELD(NODE[J],12,6);
IF J2#J3 THEN BEGIN K:=J-NINP; J3:=J2-J3;WRITE(MSG[9]);
PRINT(K,2);WRITE(" HAS");
IF J3>0 THEN BEGIN PRINT(J3,2); WRITE(MSG[31]) END
ELSE BEGIN J3:=-J3; PRINT(J3,2); WRITE(MSG[32]) END; END;
T14: END;
IF K=0 THEN WRITE(MSG[33]);NEWLINE; GOTO LOOP;
COMMENT DUMP ROUTINE;
S16: NEWLINE;WRITE("STATUS WORD = ");PRINTOCTAL(STATUS);NEWLINE(2);
WRITE("NODES[N]");
FOR J:=0 UNTIL TOTN DO BEGIN PRINT(J,5); SPACE(5);
PRINTOCTAL(NODE[J]); NEWLINE END;
NEWLINE; WRITE("WIRES[N]");
FOR J:=0 UNTIL TOTN DO
FOR J1:=1+NINP UNTIL TOTN DO
BEGIN IF PATH[J,J1]=0 THEN GOTO T17;
PRINT(J,5);PRINT(J1,5);SPACE(5);
PRINTOCTAL(PATH[J,J1]); NEWLINE;
T17: END;
NEWLINE;
GOTO LOOP;
COMMENT INPUT ROUTINE;
S9: IF GFIELD(STATUS,6,1)#1 THEN GOTO LOOPA;
WRITE(MSG[34]);SFIELD(STATUS,9,1,1);
IF HELP=1 THEN WRITE(MSG[35]);
FOR J:=1 UNTIL NINP DO BEGIN
T15: NEWLINE;WRITE(MSG[10]);PRINT(J,2);WRITE(": ");BREAKOUTPUT;
GETSTRING(ST1);IF ST1="CLOCK" THEN BEGIN
FOR J2:=1 UNTIL 72 DO SIG.[72*(J-1)+J2]:=(J2+1) REM 2;GOTO T61 END;
IF NOCHK(ST1)=0 THEN BEGIN
SFIELD(STATUS,9,1,0); GOTO LOOPB END;
J3:=LENGTH(ST1);
FOR J2:=1 UNTIL 72 DO BEGIN IF J2>J3 THEN BEGIN L:=0;GOTO T52 END;
K:=ST1.[J2];
IF K#49 AND K#48 THEN BEGIN WRITE(MSG[36]); GOTO T15 END;
L:=K-48;
T52: SIG.[72*(J-1)+J2]:=L;
IF J2=1 THEN SFIELD(NODE[J],19,1,L) END;
T61: DELETE(ST1) END;
WRITE(MSG[50]); IF HELP=1 THEN WRITE(MSG[18]);
BREAKOUTPUT; GETSTRING(ST1);
IF ST1="YES" THEN BEGIN WRITE("[N]GATE # VALUE[N]");
FOR J:=1 UNTIL INTN DO BEGIN
T16: PRINT(J,3);SPACE(9); BREAKOUTPUT;GETSTRING(ST1);
IF NOCHK(ST1)=0 THEN GOTO LOOPB;
J1:=ST1.[1]-48;
IF LENGTH(ST1)>1 OR (J1#0 AND J1#1) THEN BEGIN
WRITE(MSG[36]); GOTO T16 END;
SFIELD(NODE[J+NINP],19,1,J1) END; NEWLINE; GOTO LOOP END;
FOR J:=1+NINP UNTIL TOTN DO SFIELD(NODE[J],35,1,0);
NEWLINE;
IF ST1#"NO" THEN BEGIN SFIELD(STATUS,9,1,0); GOTO LOOPB END ELSE
BEGIN FOR J:=1+NINP UNTIL TOTN DO SFIELD(NODE[J],19,1,0);
GOTO LOOP END;
COMMENT PRINT ROUTINE;
S10: IF GFIELD(STATUS,6,1)#1 THEN GOTO LOOPA;
WRITE("[N]**OUTPUT SPECIFICATIONS**[N]");
PRES:=1;
T53: BEGIN STRING PR; INTEGER ARRAY X,Y[1:2];
PR:=NEWSTRING(TOTN,1); X[1]:=1;X[2]:=1+NINP;
Y[1]:=NINP; Y[2]:=TOTN;
FOR J:=1 UNTIL 2 DO BEGIN
NEWLINE; WRITE(MSG[43]);WRITE(MSG[11-J]);WRITE(MSG[44]);
IF HELP=1 THEN WRITE(MSG[37]); WRITE(": ");
BREAKOUTPUT; J2:=0;
T22: GETSTRING(ST1);
CHKTAB(TAB,ST1,N,19);IF N#0 THEN GOTO LOOPB;
J2:= IF ST1="ALL" THEN 1 ELSE 0;
FOR J1:=X[J] UNTIL Y[J] DO PR.[J1]:=J2;
IF J2=1 OR ST1="NONE" THEN GOTO T18; J1:=0; I:=LENGTH(ST1);
T19: SUM:=0;
T20: J1:=J1+1; IF J1>I THEN GOTO T18; J2:=ST1.[J1];
IF 47<J2 AND J2<58 THEN BEGIN SUM:=SUM*10 + J2-48;
IF J1<I THEN GOTO T20 ELSE GOTO T21 END;
IF (J2<48 OR J2>57) AND J2#32 AND SUM#0 THEN BEGIN
T21: SUM:=SUM+(J-1)*NINP;
IF SUM<X[J] OR SUM>Y[J] THEN BEGIN
WRITE(" ERROR: ");WRITE(MSG[11-J]);J3:=SUM-(J-1)*NINP;
PRINT(J3,2);WRITE(" IS NOT DEFINED IN THIS CIRCUIT");
WRITE(MSG[46]);WRITE(MSG[11-J]);WRITE(MSG[47]);BREAKOUTPUT;
GOTO T22 END; PR.[SUM]:=1; GOTO T19 END; GOTO T20;
T18: FOR J3:=X[J] UNTIL Y[J] DO SFIELD(NODE[J3],0,1,1-PR.[J3]);
END; END; NEWLINE; SFIELD(STATUS,10,1,1); GOTO LOOP;
COMMENT DISPLAY ROUTINE;
S15: IF GFIELD(STATUS,7,2)#3 THEN BEGIN
WRITE("[N] ERROR: ");FOR J:=7,8 DO IF GFIELD(STATUS,J,1)#1
THEN BEGIN WRITE(TAB[J]); SPACE(4) END;
WRITE("[N]ROUTINE(S) MUST BE CALLED FIRST[2N]");
GOTO LOOP END;
WRITE("[N]**CIRCUIT DESCRIPTION**[2N]GATE # TYPE MAX. # OF INPUTS");
FOR J:=1+NINP UNTIL TOTN DO BEGIN I:=NODE[J];
J1:=J-NINP; NEWLINE; PRINT(J1,3);SPACE(6);
J1:=GFIELD(I,1,5); WRITE(TIPE[J1]); SPACE(4);
J3:=GFIELD(I,12,6); PRINT(J3,2); BREAKOUTPUT;
IF J1=6 THEN BEGIN WRITE("[5S]THRESHOLD= ");J2:=GFIELD(I,6,6);
PRINT(J2,2); IF GFIELD(I,18,1)=1 THEN WRITE(" AND INVERTED OUTPUT");
BREAKOUTPUT END; END; WRITE("[2N]WIRES:[N] SOURCE TERMINATION[2N]");
FOR J:=0 UNTIL TOTN DO BEGIN
FOR J1:=1+NINP UNTIL TOTN DO BEGIN J2:=J1-NINP;
IF PATH[J,J1]#0 THEN BEGIN
IF J=0 THEN WRITE("+1 TIE POINT ");
IF 0<J AND J<=NINP THEN BEGIN WRITE(" INPUT");
PRINT(J,2);SPACE(5) END;
IF NINP<J THEN BEGIN J3:=J-NINP; WRITE(" GATE");
PRINT(J3,2);SPACE(5) END;
WRITE("GATE");PRINT(J2,2);
J3:=PATH[J,J1];
IF GFIELD(NODE[J1],1,5)>=7 THEN BEGIN
FOR J2:=1 STEP 2 UNTIL 11 DO BEGIN
J4:=GFIELD(J3,J2,2);IF J4=0 THEN GOTO T60;
WRITE(", ");WRITE(TAR[(J2+1)/2]);
IF J4>2 THEN OUTSYMBOL($/I/) ELSE OUTSYMBOL($/N/);
T60: END END
ELSE BEGIN
J3:=GFIELD(J3,13,2);IF J3=0 THEN OUTSYMBOL($/N/);
IF J3=1 THEN OUTSYMBOL($/I/);
IF J3=2 THEN OUTSYMBOL($/T/) END;
NEWLINE; END; END; END; NEWLINE; GOTO LOOP;
COMMENT EXPAND ROUTINE;
S19: FLAG:=2;
COMMENT SAVE ROUTINE;
S13: IF GFIELD(STATUS,6,3)#7 THEN BEGIN WRITE("[N] ERROR: ");
FOR J:=6 UNTIL 8 DO IF GFIELD(STATUS,J,1)#1 THEN BEGIN
WRITE(TAB[J]);SPACE(2) END;
WRITE("MUST BE DONE FIRST[2N]"); FLAG:=0; GOTO LOOP END;
IF FLAG=2 THEN BEGIN ST3:="0S0R0A";GOTO T33 END;
IF HELP=1 THEN WRITE("[N]WHAT NAME DO YOU WANT FOR THE FILE?[N]SPECIFY SIX OR LESS NUMBERS OR LETTERS.[N]THE FILE EXTENSION WILL BE ""LCP"" .");
WRITE(" NAME = ");
BREAKOUTPUT; GETSTRING(ST1); CHKTAB(TAB,ST1,N,18);
IF N#0 THEN GOTO LOOPB; I:=LENGTH(ST1);
FOR J:=1 UNTIL I DO IF ST1.[J]<48 THEN I:=J-1; BUF:=".LCP";
IF I>6 THEN WRITE("ONLY THE FIRST SIX CHARACTERS WILL BE USED.[N]");
IF I=0 THEN ST1:="CIRC";ST2:=COPY(ST1,1,IMIN(I,6)); ST2:=CONCAT(ST2,BUF);
ST3:=COPY(ST2,1,I+4); WRITE("FILENAME = ");WRITE(ST3);
NEWLINE;
T33: OUTPUT(1,"DSK");OPENFILE(1,ST3);SELECTOUTPUT(1);
PRINT(NINP);NEWLINE;PRINT(INTN); NEWLINE;
FOR J:= 1+NINP UNTIL TOTN DO
BEGIN PRINTOCTAL(NODE[J]);NEWLINE END;
FOR J:=0 UNTIL TOTN DO
FOR J1:=1+NINP UNTIL TOTN DO BEGIN
PRINTOCTAL(PATH[J,J1]); NEWLINE END;
SFIELD(STATUS,13,1,1); CLOSEFILE(1); SELECTOUTPUT(0);
IF FLAG=2 THEN BEGIN N:=6; GOTO SAA END; NEWLINE(2); GOTO LOOP;
T23: BEGIN INTEGER ARRAY X,Y[1:2];X[1]:=0;Y[1]:=M;
X[2]:=NINP+1;Y[2]:=N+NINP;
FOR J:=1 UNTIL N DO BEGIN READOCTAL(K);K:=K/64;
SFIELD(NODE[J+NINP],1,29,K) END;
FOR J1:=1 UNTIL 2 DO
FOR J:=X[J1] UNTIL Y[J1] DO
FOR L:=X[2] UNTIL Y[2] DO BEGIN READOCTAL(K);K:=K/64;
SFIELD(PATH[J,L],0,30,K) END;
END;
CLOSEFILE(2); RELEASE(2);SELECTINPUT(0);SFIELD(STATUS,6,9,INT(%701));
IF ST1="0S0R0A" THEN BEGIN OUTPUT(1,"DSK");OPENFILE(1,ST1);
OPENFILE(1,"");RELEASE(1) END;
FLAG:=0; NEWLINE; GOTO LOOP;
COMMENT START ROUTINE;
S11: IF GFIELD(STATUS,6,5)#INT(%37) THEN BEGIN WRITE(" ERROR: ");
FOR J:=6 UNTIL 10 DO IF GFIELD(STATUS,J,1)#1 THEN BEGIN
WRITE(TAB[J]);SPACE(4) END;
WRITE("[N]ROUTINE(S) MUST BE CALLED FIRST[2N]");GOTO LOOP END;
TIME:=K:=INV:=SSM:=0;FOR J:=1 UNTIL TOTN DO
BEGIN J1:=GFIELD(NODE[J],19,1);SFIELD(NODE[J],34,2,J1);
IF J>NINP THEN VALUS.[72*(J-1-NINP)+1]:=J1 END;
T24: FOR J:=0 UNTIL TOTN DO BEGIN J1:=GFIELD(NODE[J],35,1);
SFIELD(NODE[J],34,1,J1);
FOR J2:=1+NINP UNTIL TOTN DO IF PATH[J,J2]<0 THEN BEGIN
J3:=GFIELD(PATH[J,J2],13,2);
SUM:=GFIELD(PATH[J,J2],34,2);L:=IF J3#2 THEN ABS(J1-J3) ELSE 2*J1;
SFIELD(PATH[J,J2],32,4,4*SUM+L) END;
END;
IF TIME=0 THEN GOTO T25; FFLAG:=0;
FOR J:=1 UNTIL TOTN DO BEGIN J3:=GFIELD(NODE[J],35,1);
IF J>NINP THEN GOTO T26;
J1:=IF TIME>71 THEN 0 ELSE SIG.[72*(J-1)+TIME+1];
SFIELD(NODE[J],34,2,2*J3+J1);GOTO T45;
T26: FCN:=GFIELD(NODE[J],1,5); IF FCN>6 THEN BEGIN
CL:=RE:=SE:=-1;
FOR J1:=0 UNTIL TOTN DO BEGIN
CH:=BOOL(GFIELD(PATH[J1,J],0,12));
IF CH AND %2000 THEN CL:=J1;
IF CH AND %4 THEN RE:=J1;
IF CH AND %1 THEN SE:=J1 END;
RE:= IF RE#-1 THEN
ABS(PATH[RE,J] REM 2 - GFIELD(PATH[RE,J],10,1)) ELSE 0;
CL:= IF CL#-1 THEN
ABS(PATH[CL,J] REM 2 - GFIELD(PATH[CL,J],2,1)) ELSE 0;
SE:= IF SE#-1 THEN
ABS(PATH[SE,J] REM 2 - GFIELD(PATH[SE,J],12,1)) ELSE 0;
IF FCN=8 THEN BEGIN
IF RE=0 AND SE=0 THEN BEGIN WRITE("!!!! ERROR BOTH THE R AND S DC INPUTS TO A D FLIP-FLOP ARE ZERO[N] CHECK THE WIRING TO GATE"); PRINT(J-NINP,1); GOTO T62 END;
IF RE=0 THEN BEGIN J1:=0; GOTO T27 END;
IF SE=0 THEN BEGIN J1:=1; GOTO T27 END;
IF CL=0 THEN BEGIN SFIELD(NODE[J],20,1,1);
FFLAG:=FFLAG+1; GOTO T45 END;
J1:=J3; GOTO T27 END;
IF RE=1 THEN BEGIN J1:=0; GOTO T27 END;
IF CL=1 THEN BEGIN
SFIELD(NODE[J],20,1,1); FFLAG:=FFLAG+1; GOTO T45 END;
J1:=J3; GOTO T27 END;
IF FCN=0 THEN BEGIN J1:=0; GOTO T27 END;
THRESH:=GFIELD(NODE[J],6,6);COMP:=GFIELD(NODE[J],18,1);
SUM:=0; FOR J1:=0 UNTIL TOTN DO BEGIN J2:=GFIELD(PATH[J1,J],34,2);
SUM:=SUM+J2; IF J2=2 THEN BEGIN J1:=0; GOTO T27 END; END;
J1:=IF SUM>=THRESH THEN 1 ELSE 0;J1:=IF J1#COMP THEN 1 ELSE 0;
T27: SFIELD(NODE[J],34,2,2*J3+J1);
VALUS.[72*(J-1-NINP)+TIME+1]:=J1;
T45: END;
T40: IF FFLAG=0 THEN GOTO T25;
SUM:=FFLAG;
FOR J:=NINP +1 UNTIL TOTN DO BEGIN
IF GFIELD(NODE[J],20,1)=0 THEN GOTO T43;
CL:=JI:=KI:=DY:=-1;
FOR J2:=0 UNTIL TOTN DO BEGIN
CH:=BOOL(GFIELD(PATH[J2,J],0,12));
IF CH AND %100 THEN JI:=J2;
IF CH AND %20 THEN KI:=J2;
IF CH AND %2000 THEN CL:=J2;
IF CH AND %400 THEN DY:=J2 END;
IF GFIELD(NODE[CL],20,1)=1 THEN GOTO T43; FCN:=GFIELD(NODE[J],1,5);
J1:=GFIELD(NODE[CL],35,1); J3:=GFIELD(PATH[CL,J],2,1);
CL:=ABS(J1-J3);
J3:=GFIELD(NODE[J],35,1);
DY:= IF DY#-1 THEN
ABS(PATH[DY,J] REM 2 - GFIELD(PATH[DY,J],4,1)) ELSE 0;
IF FCN=8 THEN BEGIN J1:=IF CL>0 THEN DY ELSE J3;
GOTO T44 END;
IF CL>0 THEN BEGIN J1:=J3; GOTO T44 END;
JI:=IF JI#-1 THEN
ABS(PATH[JI,J] REM 2 - GFIELD(PATH[JI,J],6,1)) ELSE 0;
KI:= IF KI#-1 THEN
ABS(PATH[KI,J] REM 2 - GFIELD(PATH[KI,J],8,1)) ELSE 0;
J1:=JI - J3*( JI + KI -1 );
T44: SFIELD(NODE[J],34,2,2*J3+J1); SFIELD(NODE[J],20,1,0);
VALUS.[72*(J-1-NINP)+TIME+1]:=J1; FFLAG:=FFLAG-1;
IF FFLAG=0 THEN GOTO T25;
T43: END;
IF SUM=FFLAG THEN BEGIN
WRITE("[2N]!!!! ERROR IN CIRCUIT, FLIP-FLOPS WIRED IMPROPERLY[N] CHECK THE WIRING ON THESE GATE(S):[N]");
FOR J:= NINP+1 UNTIL TOTN DO
IF GFIELD(NODE[J],20,1)=1 THEN BEGIN SPACE(3);PRINT(J-NINP,1) END;
T62: WRITE("[N] AT TIME");PRINT(TIME-1,1);NEWLINE;
K:=TIME:= TIME - 1; GOTO IF K=0 THEN LOOP ELSE T51 END;
GOTO T40;
T25: IF PRES=1 AND TIME#0 THEN GOTO T51;
IF SSM=TIME OR TIME=K THEN BEGIN SSM:=SSM+INV;
WRITE("[N]CIRCUIT VALUES AT TIME");PRINT(TIME,2);
NEWLINE;M:=N:=0;
FOR J:=1 UNTIL TOTN DO BEGIN IF NODE[J]<0 THEN GOTO T28 ELSE BEGIN
IF J<=NINP AND M=0 THEN BEGIN
WRITE("[N]INPUT # VALUE[N]");M:=1 END;
IF J<=NINP THEN J2:=J;
IF J>NINP AND N=0 THEN BEGIN
WRITE("[N] GATE # VALUE[N]");N:=1 END;
IF J>NINP THEN J2:=J-NINP; J1:=GFIELD(NODE[J],35,1);
PRINT(J2,3);SPACE(6);PRINT(J1,2); NEWLINE END;
T28: END; END;
T51: TIME:=TIME+1; IF PRES = 1 THEN BEGIN
IF K#0 AND TIME=K+1 THEN BEGIN
WRITE("[N]CIRCUIT VALUES THROUGH TIME");PRINT(K,1);
FOR J1:=1 UNTIL NINP DO
IF NODE[J1]>=0 THEN BEGIN WRITE("[2N]INPUT # VALUE");
J1:=TOTN END;
FOR J:=1 UNTIL NINP DO BEGIN
IF NODE[J]<0 THEN GOTO T54; NEWLINE(2);PRINT(J,3);SPACE(6);
J3:=72*(J-1); FOR J1:=1 UNTIL K+1 DO
IF SIG.[J3+J1]=1 THEN OUTSYMBOL(INT(%130))
ELSE OUTSYMBOL(INT(%056));
T54: END;
WRITE("[2N] GATE # VALUE");
FOR J:=1 UNTIL INTN DO BEGIN
IF NODE[J+NINP]<0 THEN GOTO T55; NEWLINE(2);PRINT(J,3);
J3:=72*(J-1); SPACE(6); FOR J1:=1 UNTIL K+1 DO
IF VALUS.[J3+J1]=1 THEN OUTSYMBOL(INT(%130))
ELSE OUTSYMBOL(INT(%056));
T55: END;
NEWLINE;
END END;
IF TIME<=K THEN GOTO T24;
IF K#0 THEN BEGIN NEWLINE;GOTO LOOP END;
GOTO T34;
COMMENT RUN ROUTINE;
S12: IF GFIELD(STATUS,11,1)#1 THEN BEGIN WRITE(" ERROR: START[N]ROUTINE(S) MUST BE CALLED FIRST[2N]"); GOTO LOOP END;
T34:WRITE(MSG[41]);
BREAKOUTPUT; GETSTRING(ST1);IF NOCHK(ST1)=0 THEN GOTO LOOPB;
J3:=0;FOR L:=1 UNTIL LENGTH(ST1) DO J3:=J3*10+ST1.[L]-48;
K:=IMIN(71,K+J3); IF J3=1 THEN BEGIN INV:=1; GOTO T29 END;
IF PRES=1 THEN BEGIN INV:=0; GOTO T29 END;
WRITE(MSG[42]);
BREAKOUTPUT; GETSTRING(ST1);IF NOCHK(ST1)=0 THEN GOTO LOOPB;
INV:=0;FOR L:=1 UNTIL LENGTH(ST1) DO INV:=INV*10+ST1.[L]-48;
T29: SSM:=INV+TIME-1; SFIELD(STATUS,11,1,1); GOTO T24;
S17: END;
SS:END;