/*************************************************************************** Copyright (c) 2014-2014, Armin Biere, Johannes Kepler University, Austria. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #include "aiger.h" #ifdef AIGER_HAVE_PICOSAT #include "../picosat/picosat.h" static int use_picosat; static PicoSAT * picosat; #endif #ifdef AIGER_HAVE_LINGELING #include "../lingeling/lglib.h" static int use_lingeling; static LGL * lgl; #endif #include #include #include #include static aiger * model; static int output_set, input_set; static const char * input_file_name; static const char * output_file_name; static int verbose, strip, symbols, indices; static FILE * output_file; static void die (const char * fmt, ...) { va_list ap; fputs ("*** aigdep: ", stderr); va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); fputc ('\n', stderr); exit (1); } static void msg (int level, const char * fmt, ...) { va_list ap; if (verbose < level) return; fputs ("[aigdep] ", stderr); va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); fputc ('\n', stderr); fflush (stderr); } static void check_symbols () { unsigned i, num_outputs_with_symbols = 0, num_inputs_with_symbols = 0; int not_enough_symbols; for (i = 0; i < model->num_outputs; i++) if (model->outputs[i].name) num_outputs_with_symbols++; msg (2, "found %u outputs with symbols", num_outputs_with_symbols); for (i = 0; i < model->num_inputs; i++) if (model->inputs[i].name) num_inputs_with_symbols++; msg (2, "found %u inputs with symbols", num_inputs_with_symbols); if (!num_outputs_with_symbols && !num_inputs_with_symbols) msg (1, "no input nor output symbols found"), symbols = 0; else if (strip) msg (1, "ignoring symbols as requested (by '-s' option)"), symbols = 0; else if (num_inputs_with_symbols && num_inputs_with_symbols < model->num_inputs) die ("found only %u of %u inputs with symbols (use '-s' option)", num_inputs_with_symbols, model->num_inputs); else if (num_outputs_with_symbols && num_outputs_with_symbols < model->num_outputs) die ("found only %u of %u outputs with symbols (use '-s' option)", num_outputs_with_symbols, model->num_outputs); else if (num_outputs_with_symbols && !num_inputs_with_symbols) die ("found all output but no input symbols"); else if (!num_outputs_with_symbols && num_inputs_with_symbols) die ("found all input but no output symbols"); else { assert (num_inputs_with_symbols == model->num_inputs); assert (num_outputs_with_symbols == model->num_outputs); msg (1, "all inputs and outputs have symbols"); symbols = 1; } } static const char * USAGE = "usage: aigdep [