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); } }
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 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; }
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); }
static note_list* eval_note(note_list* all_note, cell_list* cell, input_list *entry, int size) { port_list* port; note_list* note; float latest=0, delay, R=0; int source_positiv, dest_positiv, cost; chain_list* portchain; /*operator too big*/ if (size<ABL_ARITY(cell->ABL)) return all_note; source_positiv=is_source_positiv(ABL_OPER(cell->ABL)); dest_positiv=is_dest_positiv(ABL_OPER(cell->ABL),ABL_ARITY(cell->ABL)); /*operator no matches*/ if (source_positiv==-1 || dest_positiv==-1) return all_note; /*eval cost */ cost=size/ABL_ARITY(cell->ABL)+size%ABL_ARITY(cell->ABL); /*search if there is already a couple of this arity*/ for (note=all_note; note; note=note->NEXT) { if (note->ARITY==ABL_ARITY(cell->ABL)) { /*if worse than last record, skip it*/ if (dest_positiv) { if (cost>note->COST) return all_note; } else if (cost>note->NEG_COST) return all_note; break; } } /*eval delay*/ for (portchain=ABL_CDR(cell->ABL); portchain; portchain=portchain->NEXT) { port=(port_list*) ABL_ATOM_VALUE(ABL_CAR(portchain)); delay=port->T; delay+=source_positiv?entry->DELAY:entry->NEG_DELAY; /*sortance=1*/ delay+= port->C * (source_positiv?entry->R:entry->NEG_R); if (delay>latest) {latest=delay; R=port->R;} if (note) { /*if worse than last record, skip it*/ if (dest_positiv) { if (latest>=note->DELAY) return all_note; } else if (latest>=note->NEG_DELAY) return all_note; } entry=entry->NEXT; } /*create a new couple if doesn't exist*/ if (!note) { note=newnote(); note->NEXT=all_note; all_note=note; note->ARITY=ABL_ARITY(cell->ABL); } /*take new solution*/ if (dest_positiv) { note->DELAY=latest; note->R=R; note->COST=cost; note->CELL=cell; } else { note->NEG_DELAY=latest; note->NEG_R=R; note->NEG_COST=cost; note->NEG_CELL=cell; } return all_note; }