static int relation_between(chain_list* expr, char* pattern) { authelem *elem; elem=searchauthelem(HTABLE,pattern); if (elem) { chain_list* old_abl=(chain_list*)elem->VALUE; if (ABL_ATOM(old_abl) && ABL_ATOM(expr) && ABL_ATOM_VALUE(old_abl)==ABL_ATOM_VALUE(expr)) return 1; else return 0; } addauthelem(HTABLE, pattern,(long)expr); return 1; }
static void find_d_z_abl(chain_list* abl, long value) { if (ABL_ATOM(abl)) { if (ABL_ATOM_VALUE(abl)==getablatomdc()/* = namealloc("'d'")*/) { /*non standard IEEE VHDL*/ /*it means "don't care"*/ /* we can put zero either one, only to simplify*/ ABL_CAR_L(abl)=value?getablatomone():getablatomzero(); } else if (ABL_ATOM_VALUE(abl)==getablatomtristate()/* =namealloc("'z'")*/){ /*no drive on signal*/ /* a pull-up is done for better conductance*/ ABL_CAR_L(abl)=getablatomone()/* = namealloc("'1'")*/; } return; } /*the first operator influences the most*/ switch (ABL_OPER(abl)) { case ABL_OR: case ABL_NOR: value=1; case ABL_AND: case ABL_NAND: value=0; } /*for each operator*/ for (abl=ABL_CDR(abl); abl; abl=ABL_CDR(abl)) { find_d_z_abl(ABL_CAR(abl),value); } }
extern void display_abl(chain_list* abl) { static int first=1; /*flags for braces*/ int sig_first=0; int oper; if (!abl) { fprintf (stderr,"(null)"); fflush(stderr); return; } if (ABL_ATOM (abl)) { /* Traitement atomique */ fprintf (stderr,"%s", ABL_ATOM_VALUE (abl)); fflush(stderr); return; } oper=ABL_OPER(abl); /*memorisation de l'operateur*/ /*operateur unaire*/ switch (oper) { case ABL_NOT: fprintf (stderr,"%s ",getabloperuppername(oper)); fflush(stderr); display_abl (ABL_CADR (abl)); return; case ABL_STABLE: display_abl (ABL_CADR (abl)); fprintf (stderr," '%s",getabloperuppername(oper)); fflush(stderr); return; } /*need of brace?*/ if (first) {first=0; sig_first=1;} else fprintf (stderr,"("); fflush(stderr); /* Traitement des autres operateurs */ for (abl=ABL_CDR(abl); abl; abl=ABL_CDR(abl)) { display_abl(ABL_CAR(abl)); /* Un operateur en moins que le nombre d'arguments */ if (ABL_CDR (abl)) fprintf (stderr," %s ",getabloperuppername(oper)); fflush(stderr); } if (sig_first) first=1; else fprintf(stderr,")"); fflush(stderr); }
extern void put_arity_abl (chain_list* abl) { chain_list* pattern; int arity; /*pattern is an atom*/ if (ABL_ATOM (abl)) return; arity=0; for (pattern = ABL_CDR (abl); pattern; pattern=ABL_CDR(pattern)) { arity++; put_arity_abl((chain_list*)ABL_CAR(pattern)); } ABL_ARITY_L(abl)=arity; return ; }
static void search_abl(chain_list* abl, befig_list* befig) { if (!abl) { fprintf(stderr,"search_abl: NULL pointer\n"); exit(1); } if (!ABL_ATOM(abl)) { /*operator*/ for (abl=ABL_CDR(abl); abl; abl=ABL_CDR(abl)) { search_abl(ABL_CAR(abl),befig); } return; } if (isdelaydefined(ABL_ATOM_VALUE(abl))) return; search_name(ABL_ATOM_VALUE(abl),befig); }
static int loc_pattern_matching(chain_list* expr, chain_list* pattern) { if (!expr || !pattern) { fprintf(stderr,"loc_pattern_matching: NULL pointer\n"); exit(1); } /*pattern is an atom*/ if (ABL_ATOM (pattern)) { /*constants MUST match*/ if (ABL_ATOM_VALUE(pattern)==getablatomone()) { if (ABL_ATOM(expr) && ABL_ATOM_VALUE(expr)==getablatomone()) return 1; else return 0; } if (ABL_ATOM_VALUE(pattern)==getablatomzero()) { if (ABL_ATOM(expr) && ABL_ATOM_VALUE(expr)==getablatomzero()) return 1; else return 0; } if (ABL_ATOM_VALUE(pattern)==getablatomdc() /* 'd' */) { if (ABL_ATOM(expr) && ABL_ATOM_VALUE(expr)==getablatomdc()) return 1; else return 0; } if (ABL_ATOM_VALUE(pattern)==getablatomtristate() /* 'z' */) { if (ABL_ATOM(expr) && ABL_ATOM_VALUE(expr)==getablatomtristate()) return 1; else return 0; } return relation_between(expr,ABL_ATOM_VALUE(pattern)); } /* pattern isn't an atom and expr is*/ if (ABL_ATOM (expr)) return 0; /* not the same oper */ if (ABL_OPER (expr) != ABL_OPER (pattern)) return 0; if (ABL_ARITY (expr) != ABL_ARITY (pattern)) return 0; for (pattern = ABL_CDR(pattern); pattern&&expr; pattern=ABL_CDR(pattern)) { expr = ABL_CDR(expr); if (!expr) return 0; if (!loc_pattern_matching(ABL_CAR (expr), ABL_CAR (pattern))) return 0; } return 1; }