예제 #1
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
      unsigned aiger_add_xnor ( aiger *aig, unsigned lhs, unsigned rhs )
      {
        result_type t1 = new_var ();
        result_type t2 = new_var ();

        aiger_add_and ( aig, t1, aiger_not ( lhs ), aiger_not ( rhs ) ); 
        aiger_add_and ( aig, t2, lhs, rhs ); 

        return aiger_add_or ( aig, t1, t2 ); 
      }
예제 #2
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 unsigned aiger_add_ite ( aiger *aig, unsigned I, unsigned T, unsigned E )
 {
   result_type t = new_var (); 
   aiger_add_and ( aig 
       , t
       , aiger_add_or ( aig, aiger_not (I), T )
       , aiger_add_or ( aig, I, E ) );
   return t;
 }
예제 #3
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 result_type operator() (logic::tag::nor_tag const&, result_type lhs, result_type rhs )
 {
   return aiger_not ( aiger_add_or ( aig, lhs, rhs ) );
 }
예제 #4
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 result_type operator() (logic::tag::implies_tag const&, result_type lhs, result_type rhs )
 {
   return aiger_add_or ( aig, aiger_not (lhs), rhs ); 
 }
예제 #5
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 result_type operator() (logic::tag::nand_tag const&, result_type lhs, result_type rhs )
 {
   result_type t = new_var();
   aiger_add_and ( aig, t, lhs, rhs );
   return aiger_not ( t );
 }
예제 #6
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 result_type operator() (logic::tag::not_tag const&, result_type operand)
 {
   return aiger_not ( operand );
 }
예제 #7
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 unsigned aiger_add_xor ( aiger *aig, unsigned lhs, unsigned rhs )
 {
   return aiger_not ( aiger_add_xnor ( aig, lhs, rhs ) );
 }
예제 #8
0
파일: Aiger.hpp 프로젝트: anithag/kleestr
 unsigned aiger_add_or ( aiger *aig, unsigned lhs, unsigned rhs )
 {
   result_type t = new_var ();
   aiger_add_and ( aig, t, aiger_not (lhs), aiger_not (rhs) ); 
   return aiger_not ( t );  
 }
예제 #9
0
파일: aigmove.c 프로젝트: sebastianHi/aiger
int main (int argc, char ** argv) {
  const char * input, * output, * err;
  aiger_and * a;
  unsigned j;
  int i, ok;

  input = output = 0;

  for (i = 1; i < argc; i++) {
    if (!strcmp (argv[i], "-h")) { printf ("%s", USAGE); exit (0); }
    else if (!strcmp (argv[i], "-v")) verbose = 1;
    else if (!strcmp (argv[i], "-i")) ignore = 1;
    else if (!strcmp (argv[i], "-r")) reverse = 1;
    else if (argv[i][0] == '-')
      die ("invalid command line option '%s'", argv[i]);
    else if (output) die ("too many arguments");
    else if (input) output = argv[i];
    else input = argv[i];
  }

  src = aiger_init ();
  if (input) {
    msg ("reading '%s'", input);
    err = aiger_open_and_read_from_file (src, input);
  } else {
    msg ("reading '<stdin>'");
    err = aiger_read_from_file (src, stdin);
  }

  if (err) die ("read error: %s", err);

  msg ("read MILOA %u %u %u %u %u BCJF %u %u %u %u", 
    src->maxvar,
    src->num_inputs, src->num_latches, src->num_outputs, src->num_ands,
    src->num_bad, src->num_constraints, src->num_justice, src->num_fairness);

  if (!ignore && src->num_justice) 
    die ("will not ignore justice properties (use '-i')");
  if (!ignore && src->num_fairness)
    die ("will not ignore fairness properties (use '-i')");

  if (!reverse && src->num_outputs &&
      !src->num_bad && !src->num_constraints && 
      !src->num_justice && !src->num_fairness)
    die ("only outputs founds (use '-r' for reverse move)");

  dst = aiger_init ();
  for (j = 0; j < src->num_inputs; j++)
    aiger_add_input (dst, src->inputs[j].lit, src->inputs[j].name);
  for (j = 0; j < src->num_latches; j++) {
    aiger_add_latch (dst, 
      src->latches[j].lit, src->latches[j].next, src->latches[j].name);
    aiger_add_reset (dst, src->latches[j].lit, src->latches[j].reset);
  }
  for (j = 0; j < src->num_ands; j++) {
    a = src->ands + j;
    aiger_add_and (dst, a->lhs, a->rhs0, a->rhs1);
  }

  if (reverse) {
    for (j = 0; j < src->num_outputs; j++)
      aiger_add_bad (dst, src->outputs[j].lit, src->outputs[j].name);
  } else {
    for (j = 0; j < src->num_outputs; j++)
      aiger_add_output (dst, src->outputs[j].lit, src->outputs[j].name);

    if (src->num_bad && src->num_constraints) {
      if (src->num_latches) {
	latch = next ();
	valid = latch + 2*src->num_constraints;
	aiger_add_latch (dst, latch, 
			 aiger_not (valid), "AIGMOVE_INVALID_LATCH");
	prev = aiger_not (latch);
	for (j = 0; j < src->num_constraints; j++) {
	  unsigned tmp = latch + 2*(j+1);
	  aiger_add_and (dst, tmp, prev, src->constraints[j].lit);
	  prev = tmp;
	}
	assert (prev == valid);
      } else {
	valid = src->constraints[0].lit;
	for (j = 1; j < src->num_constraints; j++) {
	  unsigned tmp = next ();
	  aiger_add_and (dst, tmp, valid, src->constraints[j].lit);
	  valid = tmp;
	}
      }
      for (j = 0; j < src->num_bad; j++) {
	bad = next ();
	aiger_add_and (dst, bad, valid, src->bad[j].lit);
	aiger_add_output (dst, bad, src->bad[j].name);
      }
    } else
      for (j = 0; j < src->num_bad; j++)
	aiger_add_output (dst, src->bad[j].lit, src->bad[j].name);
  }

  aiger_reset (src);

  msg ("write MILOA %u %u %u %u %u", dst->maxvar,
       dst->num_inputs, dst->num_latches, dst->num_outputs, dst->num_ands);
  
  if (output) {
    msg ("writing '%s'", output);
    ok = aiger_open_and_write_to_file (dst, output);
  } else {
    msg ("writing '<stdout>'", output);
    ok = aiger_write_to_file (dst, 
           (isatty (1) ? aiger_ascii_mode : aiger_binary_mode), stdout);
  }
  if (!ok) die ("write error");

  aiger_reset (dst);

  return 0;
}