#include "defs.h" char newname[]; int skiptype; /* * * line not begining with '.' * */ nusig(src) REG STRING src[]; { TAG t; SIG s; STRING sn = *src++; /* attach to current signal tree */ t=gentag(sn, EXTSIG(sn)); s=HEAP(_SIG); s->s_tag=t; s->s_next=c_chip->c_sig; /* attach signals to current chip */ c_chip->c_sig=s; /* fill in pin number */ if(*src==0) errmsg(*--src, "no pin number\n"); if(number(*src)) { s->s_pinnum=geti(*src); } elif(**src==0) { s->s_pinnum=0; } else{ errmsg(*src, "bad pin number\n"); } src++; /* fill in pin name */ if(*src) { s->s_pinnam = gettag(*src++, &GENTAG); } else{ s->s_pinnam=nil(TAG); } } /* * chip description */ nuchip(src) REG STRING src[]; { TAG t; CHP c; STRING tn; STRING cn = *src++; t=gentag(cn, &LCHP); if((c=CHEAT(CHP,t->val))==nil(CHP)) { c=HEAP(_CHP); c->c_next=c_head; c_head=c; c->c_tag=t; c->c_sig=nil(SIG); c->c_type=nil(TAG); c->c_bdx=0; c->c_bdp=0; t->val=CHEAT(TAG,c); } c_chip=c; if(*src!=nil(STRING)) { TAG ct=c->c_type; tn = *src++; if(ct!=nil(TAG)) { /* check same */ if(equstr(ct->tc, tn)==0) { errmsg(tn, ct->tc); msg(" type names differ\n"); } newtag=0; } else { c->c_type=gettag(tn, &TYPES); } concat(tn,'.',"w"); if(newtag && isfile(newname)) { DEF ct; CHP c_save; CHP h_save; TAG sav_sig; TAG sav_chp; TAG sav_pin; ITEM fn; INT sav_lsl; movstr(newname,fn); ct=HEAP(_DEF); c->c_type->nxt=CHEAT(TAG,ct); c_save=c_chip; c_chip=nil(CHP); h_save=c_head; c_head=nil(CHP); sav_sig=LSIG; LSIG=nil(TAG); sav_chp=LCHP; LCHP=nil(TAG); sav_pin=PINS; PINS=nil(TAG); sav_lsl=lslflg; lslflg=0; filescan(fn); /* record tree roots in this defn */ ct->d_chips=c_chip; c_chip=c_save; c_head=h_save; ct->d_sig=LSIG; LSIG=sav_sig; ct->d_chp=LCHP; LCHP=sav_chp; ct->d_pin=PINS; PINS=sav_pin; lslflg=sav_lsl; } elif(newtag) { c->c_type->val = CHEAT(TAG, &c->c_type->nxt); } } } swchip(src, c) STRING src[]; { switch(c) { case 's': case 'h': c_chip->c_bdp = atoi(src[0]); c_chip->c_bdx = (c=='s' ? SOFT : HARD); } } nudefn(src) REG STRING src[]; { /* attach pin,signal to current defn */ /* current defn is root of pin name tree */ /* val field of pin name is signal tag */ TAG s, p; STRING pn, sn; if(gen(pn = *src++) > 0) { generate(pn, &PINS); p=find(pn, PINS); notnil(p); sn = *src++; generate(sn, EXTSIG(sn)); s=find(sn, *EXTSIG(sn)); notnil(s); while(p && s) { sigpin(s, p); s=s->nxt; p=p->nxt; } if(p || s) { errmsg(pn, sn); msg(", macro definition mismatch\n"); } } else{ p=gettag(pn, &PINS); sn = *src++; s=gentag(sn, EXTSIG(sn)); sigpin(s, p); } } sigpin(s, p) TAG s, p; { if(p->val) { errmsg(p->tc, "pin defined twice\n"); } else { p->val = s; } } /* * chip type description */ nutype(src) REG STRING src[]; { /* .t name package pin ... * .t name = name * .t name */ REG TAG t; TAG *tp; REG STRING type; skiptype=0; type = *src++; tp = lookup(type, &TYPES); if(newtag==0) { t = *tp; if(*src && equstr(*src++, "=")) { REG TAG r=gettag(*src++, &TYPES); if(newtag) { r->val = CHEAT(TAG,&r->nxt); } if((*CHEAT(TAG*,t->val))!=nil(TAG)){ errmsg(type, "already defined\n"); skiptype++; } else{ t->val=r->val; } } c_type=t; } else{ skiptype++; } } /* * type mode command */ swtype(src, c) STRING src[]; CHAR c; { switch(c) { case 'c': tclock(src); break; case 'd': toplh(src); break; case 'p': topins(src); break; } } /* * read virtual pin names */ topins(src) REG STRING src[]; { REG TAG t; REG STRING n; g_val=nil(TAG); generate(n = *src++, CHEAT(TAG*, c_type->val)); t=find(n, *CHEAT(TAG*, c_type->val)); notnil(t); while(t) { if(*src == nil(STRING)) { bad("tp syntax, not enough pin numbers\n"); } elif(t->val) { errmsg(t->tc, "pin name repeated\n"); errjmp(); } else{ INT p=geti(*src++); t->val=CHEAT(TAG,p); if(lslflg){ c_type->lev=min(c_type->lev,p); c_type->flg=max(c_type->flg,p); } t=t->nxt; } } } /* * read clock signal pin numbers */ tclock(src) REG STRING src[]; { g_val=nil(TAG); while(*src) { STRING sn = *src++; generate(sn, EXTSIG(sn)); } } /* * read plh stuff */ toplh(src) REG STRING src[]; { g_val=nil(TAG); if(*src) { while(*src) { STRING sn = *src++; generate(sn, EXTSIG(sn)); } } } nuioc(src, c) REG STRING src[]; CHAR c; { bad("io\n"); }