Beispiel #1
0
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 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;
   
}