-- a program to run within Chipmonk -- last modified by Petit, October 8, 1981 2:20 PM -- written by Petit, October 5, 1981 6:45 PM DIRECTORY ppddefs, ppdefs, rldefs, ppdddefs, StringDefs; rlgate: PROGRAM IMPORTS ppddefs, ppdefs, ppdddefs, StringDefs EXPORTS rldefs = BEGIN OPEN ppddefs, rldefs, ppdefs, ppdddefs, StringDefs; -- gate creation routines: parma:ARRAY parmaCnt OF POINTER TO gateTypeRecord _ [@gtr1,@gtr2,@gtr3,@gtr4,@gtr5]; currentParameters:POINTER TO gateTypeRecord; currentParamNumber:parmaCnt; gtr1:gateTypeRecord _ [ wWid:4, mwWid:8, norWireOff:2, standWidth:16, strtY:30, invOff:10, putWid:4, putLen:4, makAnd:mAnd1, makPu:mPu1, makConts:mCont1, makTopWire:mTW1, calcMaxy:mCalc1 ]; gtr2:gateTypeRecord _ [ wWid:4, mwWid:8, norWireOff:2, standWidth:32, strtY:30, invOff:10, putWid:8, putLen:4, makAnd:mAnd1, makPu:mPu1, makConts:mCont1, makTopWire:mTW1, calcMaxy:mCalc1 ]; gtr3:gateTypeRecord _ [ wWid:4, mwWid:8, norWireOff:2, standWidth:48, strtY:30, invOff:10, putWid:12, putLen:4, makAnd:mAnd1, makPu:mPu1, makConts:mCont1, makTopWire:mTW1, calcMaxy:mCalc1 ]; gtr4:gateTypeRecord _ [ wWid:4, mwWid:8, norWireOff:2, standWidth:8, strtY:28, -- putLen+20 invOff:6, putWid:4, putLen:8, makAnd:mAnd1, makPu:mPu2, makConts:mCont1, makTopWire:mTW1, calcMaxy:mCalc1 ]; gtr5:gateTypeRecord _ [ wWid:4, mwWid:8, norWireOff:2, standWidth:4, strtY:36, -- putLen+20 invOff:6, putWid:4, putLen:16, makAnd:mAnd1, makPu:mPu2, makConts:mCont1, makTopWire:mTW1, calcMaxy:mCalc1 ]; gateList:LONG POINTER TO gate_NIL; getGate:PUBLIC PROCEDURE[gc:LONG POINTER TO gateCharac,parms:INTEGER] RETURNS[gat:LONG POINTER TO gate] = BEGIN gat_gateList; WHILE gat#NIL DO IF gat.parmNum = parms AND gcSame[gc,gat.charac] THEN RETURN; gat_gat.nxt; ENDLOOP; gat_makeGate[gc,parms]; gat.nxt_gateList; gateList_gat; END; gcSame:PROCEDURE[a,b:LONG POINTER TO gateCharac] RETURNS[BOOLEAN] = BEGIN IF a.inCnt#b.inCnt OR a.norCnt#b.norCnt THEN RETURN[FALSE]; FOR i:INTEGER IN [0..a.norCnt) DO IF a.ands[i] # b.ands[i] THEN RETURN[FALSE]; ENDLOOP; RETURN[TRUE]; END; makeGate:PROCEDURE[gc:LONG POINTER TO gateCharac,parms:parmaCnt] RETURNS[gat:LONG POINTER TO gate] = BEGIN OPEN currentParameters; lp:LONG POINTER TO list;--_NIL; ob:LONG POINTER TO object; cp:LONG POINTER TO cList; x:locNum; y:locNum; i,inIdx,acnt,mx,maxy:INTEGER; topx1,topx2,dx,width,botx:INTEGER; currentParameters_parma[parms]; currentParamNumber_parms; gat_GetSpace[SIZE[gate[gc.inCnt]]]; gat.inCnt_gc.inCnt; gat.nxt_NIL; gat.charac_gc; gat.parmNum_currentParamNumber; mx_0; y_strtY; maxy_y+calcMaxy[gc]; x_-2; [dx,,lp]_makConts[0,gc.ands[0],x,y,maxy,NIL,gc.inCnt]; x_x+dx; botx_0; inIdx_0; FOR i IN [0..gc.norCnt) DO acnt_gc.ands[i]; [dx,width,lp]_makAnd[acnt,x,y,lp,inIdx,gat,gc.inCnt]; inIdx_inIdx+acnt; mx_MAX[mx,x+width]; x_x+dx; IF i=0 THEN topx1_x+norWireOff; IF i MOD 2 = 0 THEN BEGIN topx2_x+norWireOff+wWid; [dx,lp]_makTopWire[x+norWireOff,lp,gc.inCnt]; x_x+dx; mx_MAX[mx,topx2]; END ELSE BEGIN [dx,width,lp]_makConts[acnt,(IF i=gc.norCnt-1 THEN 0 ELSE gc.ands[i+1]),x,y,maxy,lp,gc.inCnt]; botx_x+2; mx_MAX[mx,x+width]; x_x+dx; END; ENDLOOP; [dx,lp]_makPu[topx1,topx2,mx,lp,gat,gc.inCnt]; mx_MAX[mx,dx]; IF botx>0 THEN BEGIN lp_insertList[lp,makeList[makeWire[botx+mwWid,6,met] ,0,maxy-2,2,0]]; END; gat.gnd_[botx+2,maxy-2]; ob_makeCell[mx,maxy+4,0,lp]; cp_alocCList[]; cp.ob_ob; cp.name_makeCellName[gc]; ob.returnable_FALSE; gat.cell_cp; cp.nxt_cellList; cellList_cp; END; makeCellName:PROCEDURE[gc:LONG POINTER TO gateCharac] RETURNS[s:STRING] = BEGIN ss:STRING_[101]; ss.length_0; AppendString[ss,"GATE"]; AppendDecimal[ss,currentParamNumber]; AppendChar[ss,'-]; AppendDecimal[ss,gc.norCnt]; FOR i:INTEGER IN [0..gc.norCnt) DO IF ss.length>92 THEN BEGIN AppendString[ss,".ETC"];EXIT;END; IF gc.ands[i]>1 THEN BEGIN AppendChar[ss,'-]; AppendChar[ss,('A+i)]; AppendDecimal[ss,gc.ands[i]]; END; ENDLOOP; s_newString[ss]; END; mAnd1:mAndProcd = BEGIN OPEN currentParameters; i:INTEGER; ll:LONG POINTER TO list; dx_0; gat.firstInTopAvail_TRUE; IF totIns=1 THEN BEGIN y_y+invOff; ll_makeList[makeXstr[standWidth,cLength],x,y-4,0,0]; lp_insertList[lp,ll]; gat.ins[0]_[x,y]; gat.firstInTop_[x-2,y+4]; gat.rSpac_2; gat.lSpac_3; dx_standWidth+2; nl_lp; wid_dx+6; RETURN; END; IF inputs=0 THEN gat.lSpac_gat.rSpac_1; FOR i IN [0..aCnt) DO ll_makeList[makeXstr[standWidth*aCnt,cLength],x+dx,y,2,0]; lp_insertList[lp,ll]; gat.ins[inputs+i]_[x+dx+4+cLength/2,y+standWidth*aCnt+6]; IF inputs+i=0 THEN gat.firstInTop_[x+dx+4+cLength/2,y+2]; dx_dx+8; ENDLOOP; nl_lp; wid_dx+4; END; mPu1:mPuProcd = BEGIN OPEN currentParameters; lpp:LONG POINTER TO list; wid:INTEGER_putWid+12; t:INTEGER_x2-wid; ox:INTEGER_mx+gat.rSpac*2; y:INTEGER_16; IF totIns=1 THEN BEGIN x2_x1; x1_x1-standWidth; t_x2-wid; y_y+invOff; END; IF t1 THEN 8 ELSE invOff+8),0,0]; nl_insertList[lp,lpp]; IF totIns=1 THEN BEGIN lpp_makeList[makeWire[invOff+4,putWid,dif],t+4,6,0,0]; nl_insertList[nl,lpp]; END; END; mTW1:mTWProcd = BEGIN IF totIns=1 THEN {dx_10;nl_lp;RETURN}; nl_makeList[makeWire[14,currentParameters.wWid,dif], x,currentParameters.strtY-6,0,0]; nl_insertList[lp,nl]; dx_currentParameters.wWid; END; mCont1:mContProcd = BEGIN OPEN currentParameters; lh,rh,ny,c:INTEGER; lh_standWidth*lCnt; rh_standWidth*rCnt; IF totIns=1 THEN BEGIN x_x+6; y_y-2+invOff; ny_y + 8; nl_makeList[makeDifcon[8],x,ny,0,0]; lp_insertList[lp,nl]; nl_makeList[makeWire[lh,4,dif],x,ny+2,2,0]; lp_insertList[lp,nl]; IF maxy-ny>2 THEN BEGIN nl_makeList[makeWire[maxy-ny+2,mwWid,met],x,ny+2,0,0]; nl_insertList[lp,nl]; END; dx_2; wid_2; RETURN; END; x_x+2; c_IF MAX[rh,lh]<12 THEN 1 ELSE (MAX[rh,lh]-8)/16+1; y_y+4; ny_y + ((MAX[rh,lh]-8)MOD 16); FOR i:INTEGER IN [0..c) DO nl_makeList[makeDifcon[8],x,ny+i*16,0,0]; lp_insertList[lp,nl]; ENDLOOP; nl_makeList[makeWire[MAX[rh,lh],4,dif],x+2,y,0,0]; lp_insertList[lp,nl]; nl_makeList[makeWire[maxy-ny+4,mwWid,met],x,ny,0,0]; nl_insertList[lp,nl]; dx_8; wid_10; END; mCalc1:calcMyProcd = BEGIN my_0; FOR i:INTEGER IN [0..gc.norCnt) DO my_MAX[my,gc.ands[i]]; ENDLOOP; my_my*currentParameters.standWidth+8; END; END. -- of rlgate