Пример #1
0
void trans(Node *p) 
{	
  if (!p || tl_errs) return;
  
  if (tl_verbose || tl_terse) {	
    fprintf(tl_out, "\t/* Normlzd: ");
    dump(p);
    fprintf(tl_out, " */\n");
  }
  if (tl_terse)
    return;
 
  // Buddy might have been initialized by a third-party library.
  if (!bdd_isrunning()) {
    bdd_init(100000, 10000);
    // Disable the default GC handler.
    bdd_gbc_hook(0);
  }

  mk_alternating(p);
    if (!tl_hoaf || tl_hoaf > 1) {
      mk_generalized();
      if ((!tl_spot_out || tl_spot_out > 2) && (!tl_hoaf || tl_hoaf > 2))
        mk_buchi();
    }
  
  releasenode(1, p);
  
  bdd_done();
}
Пример #2
0
Файл: muddy.c Проект: Armael/HOL
/* ML type: int -> int -> unit */
EXTERNML value mlbdd_bdd_init(value nodes, value cachesize) /* ML */
{
  /* setup the our error handler */
  bdd_error_hook(&mlbdd_errorhandler);
  bdd_init(Int_val(nodes), Int_val(cachesize));
  bdd_error_hook(&mlbdd_errorhandler);
  /* bdd_gbc_hook(NULL); */
  bdd_gbc_hook(mlbdd_gc);
  return Val_unit;    
}
Пример #3
0
int main(int ac,char**av)
{
  BDD a,b,c;
  bdd_init(N_NODES, CACHESIZE);
  bdd_setvarnum(2);
  a = bdd_ithvar(0);
  b = bdd_ithvar(1);  
  c = bdd_xor(a, b);
  bdd_fnprintdot("xor.dot", c);
  bdd_done();
}
Пример #4
0
int main(int ac,char**av)
{
  BDD a,b,c;
  bdd_init(N_NODES, CACHESIZE);
  bdd_setvarnum(2);
  a = bdd_ithvar(0);
  b = bdd_ithvar(1);  
  c = bdd_apply(a, b, bddop_less);
  bdd_fnprintdot("less.dot", c);
  bdd_done();
}
Пример #5
0
static void init_buddy(int states)
{
	//TODO: calculate the parameters to buddy from the number of states
	bdd_init(70000000, 100000);
	bdd_setmaxincrease(500000);
	bdd_setcacheratio(5);
	bdd_error_hook(bdd_errhandler);
//	bdd_resize_hook(bdd_resizehandler);
//	bdd_gbc_hook(bdd_gbchandler);
//	bdd_reorder_hook(bdd_reorderhandler);
}
Пример #6
0
void xo_equivalence_checker_bdd_evaluate_program_on_state(const xo_program *prog, xo_machine_state *st)
{
  bdd_init(1000, 100); // TODO: good values?

  bdd r[XO_NUM_REGISTERS][XO_NUM_BITS], f[XO_NUM_FLAGS];

  for(size_t i = 0; i < XO_NUM_REGISTERS; ++i)
    bdd_from_register_(r[i], st->regs[i]);
  bdd_from_flag_set_(f, st->flags);

  evaluate_program_(prog, r, f);

  for(size_t i = 0; i < XO_NUM_REGISTERS; ++i)
    st->regs[i] = bdd_to_register_(r[i]);
  st->flags = bdd_to_flag_set_(f);

  bdd_done();
}
Пример #7
0
CAMLprim void wrapper_bdd_init(value v1, value v2) {
    int nodesize = Int_val(v1);
    int cachesize = Int_val(v2);
    bdd_init(nodesize, cachesize);

    bddops.identifier = NULL;
    bddops.finalize = _deletebdd;
    bddops.compare = _comparebdd;
    bddops.hash = _hashbdd;
    bddops.serialize = NULL;
    bddops.deserialize = NULL;

    bddpairops.identifier = NULL;
    bddpairops.finalize = _deletebddpair;
    bddpairops.compare = NULL;
    bddpairops.hash = NULL;
    bddpairops.serialize = NULL;
    bddpairops.deserialize = NULL;
}
Пример #8
0
bool xo_equivalence_checker_bdd_programs_equivalent(const xo_program *prog1, const xo_program *prog2)
{
  xo_register_set ro_set_1, ro_set_2;

  xo_program_analyze(prog1, NULL, &ro_set_1);
  xo_program_analyze(prog2, NULL, &ro_set_2);

  if(ro_set_1 != ro_set_2)
    return false;

  bdd_init(1000000, 100000); // TODO: good values?
  bdd_setvarnum(XO_NUM_REGISTERS*XO_NUM_BITS);

  bdd r[2][XO_NUM_REGISTERS][XO_NUM_BITS], f[2][XO_NUM_FLAGS];

  int index = 0;
  for(int bi = 0; bi < XO_NUM_BITS; ++bi)
    for(int ri = 0; ri < XO_NUM_REGISTERS; ++ri)
      r[0][ri][bi] = r[1][ri][bi] = bdd_ithvar(index++);

  bdd_from_flag_set_(f[0], 0);
  bdd_from_flag_set_(f[1], 0);

  evaluate_program_(prog1, r[0], f[0]);
  evaluate_program_(prog2, r[1], f[1]);

  size_t ro_index = xo_register_set_first_live_index(ro_set_1);
  bool equiv = true;

  for(size_t i = 0; i < XO_NUM_BITS; ++i)
  {
    if(r[0][ro_index][i] != r[1][ro_index][i])
    {
      equiv = false;
      break;
    }
  }

  bdd_done();

  return equiv;
}
Пример #9
0
	BddManager::BddManager() 
	{
		m_Manager = bdd_init();
	}
Пример #10
0
int main() {
bdd_init(1000000,1000000,40);
bdd_ptr v1 = ithvar(0);
bdd_ptr v4 = ithvar(1);
bdd_ptr v8 = ithvar(2);
bdd_ptr v11 = ithvar(3);
bdd_ptr v14 = ithvar(4);
bdd_ptr v17 = ithvar(5);
bdd_ptr v21 = ithvar(6);
bdd_ptr v24 = ithvar(7);
bdd_ptr v27 = ithvar(8);
bdd_ptr v30 = ithvar(9);
bdd_ptr v34 = ithvar(10);
bdd_ptr v37 = ithvar(11);
bdd_ptr v40 = ithvar(12);
bdd_ptr v43 = ithvar(13);
bdd_ptr v47 = ithvar(14);
bdd_ptr v50 = ithvar(15);
bdd_ptr v53 = ithvar(16);
bdd_ptr v56 = ithvar(17);
bdd_ptr v60 = ithvar(18);
bdd_ptr v63 = ithvar(19);
bdd_ptr v66 = ithvar(20);
bdd_ptr v69 = ithvar(21);
bdd_ptr v73 = ithvar(22);
bdd_ptr v76 = ithvar(23);
bdd_ptr v79 = ithvar(24);
bdd_ptr v82 = ithvar(25);
bdd_ptr v86 = ithvar(26);
bdd_ptr v89 = ithvar(27);
bdd_ptr v92 = ithvar(28);
bdd_ptr v95 = ithvar(29);
bdd_ptr v99 = ithvar(30);
bdd_ptr v102 = ithvar(31);
bdd_ptr v105 = ithvar(32);
bdd_ptr v108 = ithvar(33);
bdd_ptr v112 = ithvar(34);
bdd_ptr v115 = ithvar(35);
std::cout << 0 << std::endl;
bdd_ptr v118 = bdd_not(v1);
std::cout << 1 << std::endl;
bdd_ptr v119 = bdd_not(v4);
std::cout << 2 << std::endl;
bdd_ptr v122 = bdd_not(v11);
std::cout << 3 << std::endl;
bdd_ptr v123 = bdd_not(v17);
std::cout << 4 << std::endl;
bdd_ptr v126 = bdd_not(v24);
std::cout << 5 << std::endl;
bdd_ptr v127 = bdd_not(v30);
std::cout << 6 << std::endl;
bdd_ptr v130 = bdd_not(v37);
std::cout << 7 << std::endl;
bdd_ptr v131 = bdd_not(v43);
std::cout << 8 << std::endl;
bdd_ptr v134 = bdd_not(v50);
std::cout << 9 << std::endl;
bdd_ptr v135 = bdd_not(v56);
std::cout << 10 << std::endl;
bdd_ptr v138 = bdd_not(v63);
std::cout << 11 << std::endl;
bdd_ptr v139 = bdd_not(v69);
std::cout << 12 << std::endl;
bdd_ptr v142 = bdd_not(v76);
std::cout << 13 << std::endl;
bdd_ptr v143 = bdd_not(v82);
std::cout << 14 << std::endl;
bdd_ptr v146 = bdd_not(v89);
std::cout << 15 << std::endl;
bdd_ptr v147 = bdd_not(v95);
std::cout << 16 << std::endl;
bdd_ptr v150 = bdd_not(v102);
std::cout << 17 << std::endl;
bdd_ptr v151 = bdd_not(v108);
std::cout << 18 << std::endl;
bdd_ptr v154 = bdd_nand(v118,v4);
std::cout << 19 << std::endl;
bdd_ptr v157 = bdd_nor(v8,v119);
std::cout << 20 << std::endl;
bdd_ptr v158 = bdd_nor(v14,v119);
std::cout << 21 << std::endl;
bdd_ptr v159 = bdd_nand(v122,v17);
std::cout << 22 << std::endl;
bdd_ptr v162 = bdd_nand(v126,v30);
std::cout << 23 << std::endl;
bdd_ptr v165 = bdd_nand(v130,v43);
std::cout << 24 << std::endl;
bdd_ptr v168 = bdd_nand(v134,v56);
std::cout << 25 << std::endl;
bdd_ptr v171 = bdd_nand(v138,v69);
std::cout << 26 << std::endl;
bdd_ptr v174 = bdd_nand(v142,v82);
std::cout << 27 << std::endl;
bdd_ptr v177 = bdd_nand(v146,v95);
std::cout << 28 << std::endl;
bdd_ptr v180 = bdd_nand(v150,v108);
std::cout << 29 << std::endl;
bdd_ptr v183 = bdd_nor(v21,v123);
std::cout << 30 << std::endl;
bdd_ptr v184 = bdd_nor(v27,v123);
std::cout << 31 << std::endl;
bdd_ptr v185 = bdd_nor(v34,v127);
std::cout << 32 << std::endl;
bdd_ptr v186 = bdd_nor(v40,v127);
std::cout << 33 << std::endl;
bdd_ptr v187 = bdd_nor(v47,v131);
std::cout << 34 << std::endl;
bdd_ptr v188 = bdd_nor(v53,v131);
std::cout << 35 << std::endl;
bdd_ptr v189 = bdd_nor(v60,v135);
std::cout << 36 << std::endl;
bdd_ptr v190 = bdd_nor(v66,v135);
std::cout << 37 << std::endl;
bdd_ptr v191 = bdd_nor(v73,v139);
std::cout << 38 << std::endl;
bdd_ptr v192 = bdd_nor(v79,v139);
std::cout << 39 << std::endl;
bdd_ptr v193 = bdd_nor(v86,v143);
std::cout << 40 << std::endl;
bdd_ptr v194 = bdd_nor(v92,v143);
std::cout << 41 << std::endl;
bdd_ptr v195 = bdd_nor(v99,v147);
std::cout << 42 << std::endl;
bdd_ptr v196 = bdd_nor(v105,v147);
std::cout << 43 << std::endl;
bdd_ptr v197 = bdd_nor(v112,v151);
std::cout << 44 << std::endl;
bdd_ptr v198 = bdd_nor(v115,v151);
std::cout << 45 << std::endl;
bdd_ptr v199_1_0 = bdd_and(v154,v159);
bdd_ptr v199_1_2 = bdd_and(v162,v165);
bdd_ptr v199_1_4 = bdd_and(v168,v171);
bdd_ptr v199_1_6 = bdd_and(v174,v177);
bdd_ptr v199_2_0 = bdd_and(v199_1_0,v199_1_2);
bdd_ptr v199_2_4 = bdd_and(v199_1_4,v199_1_6);
bdd_ptr v199_3_0 = bdd_and(v199_2_0,v199_2_4);
bdd_ptr v199 = bdd_and(v199_3_0,v180);
std::cout << 46 << std::endl;
bdd_ptr v203 = bdd_not(v199);
std::cout << 47 << std::endl;
bdd_ptr v213 = bdd_not(v199);
std::cout << 48 << std::endl;
bdd_ptr v223 = bdd_not(v199);
std::cout << 49 << std::endl;
bdd_ptr v224 = bdd_xor(v203,v154);
std::cout << 50 << std::endl;
bdd_ptr v227 = bdd_xor(v203,v159);
std::cout << 51 << std::endl;
bdd_ptr v230 = bdd_xor(v203,v162);
std::cout << 52 << std::endl;
bdd_ptr v233 = bdd_xor(v203,v165);
std::cout << 53 << std::endl;
bdd_ptr v236 = bdd_xor(v203,v168);
std::cout << 54 << std::endl;
bdd_ptr v239 = bdd_xor(v203,v171);
std::cout << 55 << std::endl;
bdd_ptr v242 = bdd_nand(v1,v213);
std::cout << 56 << std::endl;
bdd_ptr v243 = bdd_xor(v203,v174);
std::cout << 57 << std::endl;
bdd_ptr v246 = bdd_nand(v213,v11);
std::cout << 58 << std::endl;
bdd_ptr v247 = bdd_xor(v203,v177);
std::cout << 59 << std::endl;
bdd_ptr v250 = bdd_nand(v213,v24);
std::cout << 60 << std::endl;
bdd_ptr v251 = bdd_xor(v203,v180);
std::cout << 61 << std::endl;
bdd_ptr v254 = bdd_nand(v213,v37);
std::cout << 62 << std::endl;
bdd_ptr v255 = bdd_nand(v213,v50);
std::cout << 63 << std::endl;
bdd_ptr v256 = bdd_nand(v213,v63);
std::cout << 64 << std::endl;
bdd_ptr v257 = bdd_nand(v213,v76);
std::cout << 65 << std::endl;
bdd_ptr v258 = bdd_nand(v213,v89);
std::cout << 66 << std::endl;
bdd_ptr v259 = bdd_nand(v213,v102);
std::cout << 67 << std::endl;
bdd_ptr v260 = bdd_nand(v224,v157);
std::cout << 68 << std::endl;
bdd_ptr v263 = bdd_nand(v224,v158);
std::cout << 69 << std::endl;
bdd_ptr v264 = bdd_nand(v227,v183);
std::cout << 70 << std::endl;
bdd_ptr v267 = bdd_nand(v230,v185);
std::cout << 71 << std::endl;
bdd_ptr v270 = bdd_nand(v233,v187);
std::cout << 72 << std::endl;
bdd_ptr v273 = bdd_nand(v236,v189);
std::cout << 73 << std::endl;
bdd_ptr v276 = bdd_nand(v239,v191);
std::cout << 74 << std::endl;
bdd_ptr v279 = bdd_nand(v243,v193);
std::cout << 75 << std::endl;
bdd_ptr v282 = bdd_nand(v247,v195);
std::cout << 76 << std::endl;
bdd_ptr v285 = bdd_nand(v251,v197);
std::cout << 77 << std::endl;
bdd_ptr v288 = bdd_nand(v227,v184);
std::cout << 78 << std::endl;
bdd_ptr v289 = bdd_nand(v230,v186);
std::cout << 79 << std::endl;
bdd_ptr v290 = bdd_nand(v233,v188);
std::cout << 80 << std::endl;
bdd_ptr v291 = bdd_nand(v236,v190);
std::cout << 81 << std::endl;
bdd_ptr v292 = bdd_nand(v239,v192);
std::cout << 82 << std::endl;
bdd_ptr v293 = bdd_nand(v243,v194);
std::cout << 83 << std::endl;
bdd_ptr v294 = bdd_nand(v247,v196);
std::cout << 84 << std::endl;
bdd_ptr v295 = bdd_nand(v251,v198);
std::cout << 85 << std::endl;
bdd_ptr v296_1_0 = bdd_and(v260,v264);
bdd_ptr v296_1_2 = bdd_and(v267,v270);
bdd_ptr v296_1_4 = bdd_and(v273,v276);
bdd_ptr v296_1_6 = bdd_and(v279,v282);
bdd_ptr v296_2_0 = bdd_and(v296_1_0,v296_1_2);
bdd_ptr v296_2_4 = bdd_and(v296_1_4,v296_1_6);
bdd_ptr v296_3_0 = bdd_and(v296_2_0,v296_2_4);
bdd_ptr v296 = bdd_and(v296_3_0,v285);
std::cout << 86 << std::endl;
bdd_ptr v300 = bdd_not(v263);
std::cout << 87 << std::endl;
bdd_ptr v301 = bdd_not(v288);
std::cout << 88 << std::endl;
bdd_ptr v302 = bdd_not(v289);
std::cout << 89 << std::endl;
bdd_ptr v303 = bdd_not(v290);
std::cout << 90 << std::endl;
bdd_ptr v304 = bdd_not(v291);
std::cout << 91 << std::endl;
bdd_ptr v305 = bdd_not(v292);
std::cout << 92 << std::endl;
bdd_ptr v306 = bdd_not(v293);
std::cout << 93 << std::endl;
bdd_ptr v307 = bdd_not(v294);
std::cout << 94 << std::endl;
bdd_ptr v308 = bdd_not(v295);
std::cout << 95 << std::endl;
bdd_ptr v309 = bdd_not(v296);
std::cout << 96 << std::endl;
bdd_ptr v319 = bdd_not(v296);
std::cout << 97 << std::endl;
bdd_ptr v329 = bdd_not(v296);
std::cout << 98 << std::endl;
bdd_ptr v330 = bdd_xor(v309,v260);
std::cout << 99 << std::endl;
bdd_ptr v331 = bdd_xor(v309,v264);
std::cout << 100 << std::endl;
bdd_ptr v332 = bdd_xor(v309,v267);
std::cout << 101 << std::endl;
bdd_ptr v333 = bdd_xor(v309,v270);
std::cout << 102 << std::endl;
bdd_ptr v334 = bdd_nand(v8,v319);
std::cout << 103 << std::endl;
bdd_ptr v335 = bdd_xor(v309,v273);
std::cout << 104 << std::endl;
bdd_ptr v336 = bdd_nand(v319,v21);
std::cout << 105 << std::endl;
bdd_ptr v337 = bdd_xor(v309,v276);
std::cout << 106 << std::endl;
bdd_ptr v338 = bdd_nand(v319,v34);
std::cout << 107 << std::endl;
bdd_ptr v339 = bdd_xor(v309,v279);
std::cout << 108 << std::endl;
bdd_ptr v340 = bdd_nand(v319,v47);
std::cout << 109 << std::endl;
bdd_ptr v341 = bdd_xor(v309,v282);
std::cout << 110 << std::endl;
bdd_ptr v342 = bdd_nand(v319,v60);
std::cout << 111 << std::endl;
bdd_ptr v343 = bdd_xor(v309,v285);
std::cout << 112 << std::endl;
bdd_ptr v344 = bdd_nand(v319,v73);
std::cout << 113 << std::endl;
bdd_ptr v345 = bdd_nand(v319,v86);
std::cout << 114 << std::endl;
bdd_ptr v346 = bdd_nand(v319,v99);
std::cout << 115 << std::endl;
bdd_ptr v347 = bdd_nand(v319,v112);
std::cout << 116 << std::endl;
bdd_ptr v348 = bdd_nand(v330,v300);
std::cout << 117 << std::endl;
bdd_ptr v349 = bdd_nand(v331,v301);
std::cout << 118 << std::endl;
bdd_ptr v350 = bdd_nand(v332,v302);
std::cout << 119 << std::endl;
bdd_ptr v351 = bdd_nand(v333,v303);
std::cout << 120 << std::endl;
bdd_ptr v352 = bdd_nand(v335,v304);
std::cout << 121 << std::endl;
bdd_ptr v353 = bdd_nand(v337,v305);
std::cout << 122 << std::endl;
bdd_ptr v354 = bdd_nand(v339,v306);
std::cout << 123 << std::endl;
bdd_ptr v355 = bdd_nand(v341,v307);
std::cout << 124 << std::endl;
bdd_ptr v356 = bdd_nand(v343,v308);
std::cout << 125 << std::endl;
bdd_ptr v357_1_0 = bdd_and(v348,v349);
bdd_ptr v357_1_2 = bdd_and(v350,v351);
bdd_ptr v357_1_4 = bdd_and(v352,v353);
bdd_ptr v357_1_6 = bdd_and(v354,v355);
bdd_ptr v357_2_0 = bdd_and(v357_1_0,v357_1_2);
bdd_ptr v357_2_4 = bdd_and(v357_1_4,v357_1_6);
bdd_ptr v357_3_0 = bdd_and(v357_2_0,v357_2_4);
bdd_ptr v357 = bdd_and(v357_3_0,v356);
std::cout << 126 << std::endl;
bdd_ptr v360 = bdd_not(v357);
std::cout << 127 << std::endl;
bdd_ptr v370 = bdd_not(v357);
std::cout << 128 << std::endl;
bdd_ptr v371 = bdd_nand(v14,v360);
std::cout << 129 << std::endl;
bdd_ptr v372 = bdd_nand(v360,v27);
std::cout << 130 << std::endl;
bdd_ptr v373 = bdd_nand(v360,v40);
std::cout << 131 << std::endl;
bdd_ptr v374 = bdd_nand(v360,v53);
std::cout << 132 << std::endl;
bdd_ptr v375 = bdd_nand(v360,v66);
std::cout << 133 << std::endl;
bdd_ptr v376 = bdd_nand(v360,v79);
std::cout << 134 << std::endl;
bdd_ptr v377 = bdd_nand(v360,v92);
std::cout << 135 << std::endl;
bdd_ptr v378 = bdd_nand(v360,v105);
std::cout << 136 << std::endl;
bdd_ptr v379 = bdd_nand(v360,v115);
std::cout << 137 << std::endl;
bdd_ptr v380_1_0 = bdd_nand(v4,v242);
bdd_ptr v380_1_2 = bdd_nand(v334,v371);
bdd_ptr v380 = bdd_nand(v380_1_0,v380_1_2);
std::cout << 138 << std::endl;
bdd_ptr v381_1_0 = bdd_nand(v246,v336);
bdd_ptr v381_1_2 = bdd_nand(v372,v17);
bdd_ptr v381 = bdd_nand(v381_1_0,v381_1_2);
std::cout << 139 << std::endl;
bdd_ptr v386_1_0 = bdd_nand(v250,v338);
bdd_ptr v386_1_2 = bdd_nand(v373,v30);
bdd_ptr v386 = bdd_nand(v386_1_0,v386_1_2);
std::cout << 140 << std::endl;
bdd_ptr v393_1_0 = bdd_nand(v254,v340);
bdd_ptr v393_1_2 = bdd_nand(v374,v43);
bdd_ptr v393 = bdd_nand(v393_1_0,v393_1_2);
std::cout << 141 << std::endl;
bdd_ptr v399_1_0 = bdd_nand(v255,v342);
bdd_ptr v399_1_2 = bdd_nand(v375,v56);
bdd_ptr v399 = bdd_nand(v399_1_0,v399_1_2);
std::cout << 142 << std::endl;
bdd_ptr v404_1_0 = bdd_nand(v256,v344);
bdd_ptr v404_1_2 = bdd_nand(v376,v69);
bdd_ptr v404 = bdd_nand(v404_1_0,v404_1_2);
std::cout << 143 << std::endl;
bdd_ptr v407_1_0 = bdd_nand(v257,v345);
bdd_ptr v407_1_2 = bdd_nand(v377,v82);
bdd_ptr v407 = bdd_nand(v407_1_0,v407_1_2);
std::cout << 144 << std::endl;
bdd_ptr v411_1_0 = bdd_nand(v258,v346);
bdd_ptr v411_1_2 = bdd_nand(v378,v95);
bdd_ptr v411 = bdd_nand(v411_1_0,v411_1_2);
std::cout << 145 << std::endl;
bdd_ptr v414_1_0 = bdd_nand(v259,v347);
bdd_ptr v414_1_2 = bdd_nand(v379,v108);
bdd_ptr v414 = bdd_nand(v414_1_0,v414_1_2);
std::cout << 146 << std::endl;
bdd_ptr v415 = bdd_not(v380);
std::cout << 147 << std::endl;
bdd_ptr v416_1_0 = bdd_and(v381,v386);
bdd_ptr v416_1_2 = bdd_and(v393,v399);
bdd_ptr v416_1_4 = bdd_and(v404,v407);
bdd_ptr v416_1_6 = bdd_and(v411,v414);
bdd_ptr v416_2_0 = bdd_and(v416_1_0,v416_1_2);
bdd_ptr v416_2_4 = bdd_and(v416_1_4,v416_1_6);
bdd_ptr v416 = bdd_and(v416_2_0,v416_2_4);
std::cout << 148 << std::endl;
bdd_ptr v417 = bdd_not(v393);
std::cout << 149 << std::endl;
bdd_ptr v418 = bdd_not(v404);
std::cout << 150 << std::endl;
bdd_ptr v419 = bdd_not(v407);
std::cout << 151 << std::endl;
bdd_ptr v420 = bdd_not(v411);
std::cout << 152 << std::endl;
bdd_ptr v421 = bdd_nor(v415,v416);
std::cout << 153 << std::endl;
bdd_ptr v422 = bdd_nand(v386,v417);
std::cout << 154 << std::endl;
bdd_ptr v425_1_0 = bdd_nand(v386,v393);
bdd_ptr v425_1_2 = bdd_nand(v418,v399);
bdd_ptr v425 = bdd_nand(v425_1_0,v425_1_2);
std::cout << 155 << std::endl;
bdd_ptr v428_1_0 = bdd_nand(v399,v393);
bdd_ptr v428 = bdd_nand(v428_1_0,v419);
std::cout << 156 << std::endl;
bdd_ptr v429_1_0 = bdd_nand(v386,v393);
bdd_ptr v429_1_2 = bdd_nand(v407,v420);
bdd_ptr v429 = bdd_nand(v429_1_0,v429_1_2);
std::cout << 157 << std::endl;
bdd_ptr v430_1_0 = bdd_nand(v381,v386);
bdd_ptr v430_1_2 = bdd_nand(v422,v399);
bdd_ptr v430 = bdd_nand(v430_1_0,v430_1_2);
std::cout << 158 << std::endl;
bdd_ptr v431_1_0 = bdd_nand(v381,v386);
bdd_ptr v431_1_2 = bdd_nand(v425,v428);
bdd_ptr v431 = bdd_nand(v431_1_0,v431_1_2);
std::cout << 159 << std::endl;
bdd_ptr v432_1_0 = bdd_nand(v381,v422);
bdd_ptr v432_1_2 = bdd_nand(v425,v429);
bdd_ptr v432 = bdd_nand(v432_1_0,v432_1_2);
return 0;
}
Пример #11
0
int main() {
  bdd_manager *bddm, *bddm1;
  bdd_ptr zero, one;
  bdd_handle var2, var7;
  bdd_ptr and_2_7, nand_2_7;
  /*bdd_handle handle;*/

  bdd_init(); /* needed since we're using statistics */

  bddm = bdd_new_manager(100,50);
  /* get a BDD pointer to a node that is the leaf with value 0 */
  zero = bdd_find_leaf_hashed_add_root(bddm, 0);
  /* and a leaf with value 1 */
  one =  bdd_find_leaf_hashed_add_root(bddm, 1);
  /* note already at this point "zero" could have been invalidated if
     the table doubled, but we know that there is room for a 100
     nodes---anyway, this is really very bad style, so we go on in
     a more appropriate manner */

  /* "then" part is one, "else" part is zero */
  var2 = bdd_handle_find_node_hashed_add_root(bddm, zero, one, 2);
  var7 = bdd_handle_find_node_hashed_add_root(bddm, zero, one, 7);
  
  /* check node pointers and handles */
  assert(zero == BDD_ROOT(bddm, 0)); /* since table was not doubled */
  assert(one  == BDD_ROOT(bddm, 1)); 
  assert(var2 == 2);
  assert(var7 == 3);

  bddm1 = bdd_new_manager(100,50); /* make room for at least 100 nodes,
				      overflow increment is 50 */
  
  bdd_make_cache(bddm1, 100, 50); /* apply2 needs a result cache, here the size
				     is a hundred with increment 50 */

  /* apply operation on var2 and var7 in bddm; the result is 
     a completely fresh bdd in bddm1 and a BDD pointer, named "and_2_7" */
  and_2_7 = bdd_apply2_hashed(bddm, BDD_ROOT(bddm, var2), /* BDD #1 */
      			      bddm, BDD_ROOT(bddm, var7), /* BDD #2 */
			      bddm1, /* result BDD */
			      &and); /* leaf operation */
  
  bdd_update_statistics(bddm, 0); /* update statics group "0" with data from bddm 
				     before killing the manager */
 
  printf("Size of bddm: %d\n\n", bdd_size(bddm)); /* let's see the number of nodes created */
 
  bdd_kill_manager(bddm);
 
  printf("Size of bddm1: %d\n\n", bdd_size(bddm1));
 
  /*handle = BDD_LAST_HANDLE(bddm1);*/

  /*
  assert(handle == 0);
  assert(BDD_ROOT(bddm1, handle) == and_2_7);
  */

  /* reset all mark fields in bddm1 before an apply1 operation */
  bdd_prepare_apply1(bddm1); 
  
  /* a new bdd (which as an unlabelled graph is isomorphic to old one)
     in bddm1 is the result of the following apply operation */

  /* it's safe here to use and_2_7 since no operations were performed
     after it was calculated that could have entailed doubling of table */
  nand_2_7 = bdd_apply1(bddm1, and_2_7, bddm1, &not);
 
  bdd_update_statistics(bddm1, 1);
  printf("Size of bddm1: %d\n\n", bdd_size(bddm1));

  print_bdd(bddm1, and_2_7);
  printf("\n\n");
  print_bdd(bddm1, nand_2_7);
  printf("\n\n");

  bdd_kill_manager(bddm1);

  bdd_print_statistics(0, "bddm"); /* print group 0 statistics with heading "bddm" */
  bdd_print_statistics(1, "bddm1"); /* print group 1 statistics with heading "bddm1" */
  return 0;
}
Пример #12
0
int main(int argc, char** argv)
{
   bdd *c, *cp, *h, *hp, *t, *tp;
   bdd I, T, R;
   int n;
   
   if(argc < 2)
   {
      printf("usage: %s N\n",argv[0]);
      printf("\tN  number of cyclers\n");
      exit(1);
   }
   
   N = atoi(argv[1]);
   if (N <= 0)
   {
      printf("The number of cyclers must more than zero\n");
      exit(2);
   }
   
   bdd_init(100000, 10000);
   bdd_setvarnum(N*6);
      
   c  = (bdd *)malloc(sizeof(bdd)*N);
   cp = (bdd *)malloc(sizeof(bdd)*N);
   t  = (bdd *)malloc(sizeof(bdd)*N);
   tp = (bdd *)malloc(sizeof(bdd)*N);
   h  = (bdd *)malloc(sizeof(bdd)*N);
   hp = (bdd *)malloc(sizeof(bdd)*N);
   
   normvar = (int *)malloc(sizeof(int)*N*3);
   primvar = (int *)malloc(sizeof(int)*N*3);
   
   for (n=0 ; n<N*3 ; n++)
   {
      normvar[n] = n*2;
      primvar[n] = n*2+1;
   }
   normvarset = bdd_addref( bdd_makeset(normvar, N*3) );
   pairs = bdd_newpair();
   bdd_setpairs(pairs, primvar, normvar, N*3);
   
   for (n=0 ; n<N ; n++)
   {
      c[n]  = bdd_ithvar(n*6);
      cp[n] = bdd_ithvar(n*6+1);
      t[n]  = bdd_ithvar(n*6+2);
      tp[n] = bdd_ithvar(n*6+3);
      h[n]  = bdd_ithvar(n*6+4);
      hp[n] = bdd_ithvar(n*6+5);
   }
   
   I = bdd_addref( initial_state(t,h,c) );
   T = bdd_addref( transitions(t,tp,h,hp,c,cp) );
   R = bdd_addref( reachable_states(I,T) );
   
   /*if(has_deadlocks(R,T))
     printf("Milner's Scheduler has deadlocks!\n"); */
   
   printf("SatCount R = %.0f\n", bdd_satcount(R));
   printf("Calc       = %.0f\n", (double)N*pow(2.0,1.0+N)*pow(2.0,3.0*N));
   
   bdd_done();
   
   return 0;
}
Пример #13
0
int main (int argc, char** argv)
{
    int argi = init_sysCx (&argc, &argv);
    const int xdomsz = 4;
    int xdoms[3];

    int xfddidcs[3];
    bdd ybdds[3];
    bdd satbdd;
    int off;

    bdd a, b, c, d, e;

    if (argi < argc)  return 1;

    xdoms[0] = xdoms[1] = xdoms[2] = xdomsz;

    bdd_init (1000,100);
    push_losefn_sysCx (bdd_done);

    off = bdd_extvarnum (1);
    satbdd = bdd_ithvar (off);

    xfddidcs[0] = fdd_extdomain (xdoms, 3);
    xfddidcs[1] = xfddidcs[0] + 1;
    xfddidcs[2] = xfddidcs[1] + 1;

    off = bdd_extvarnum (3);
    printf ("y0:%d y1:%d y2:%d\n", off + 0, off + 1, off + 2);
    ybdds[0] = bdd_ithvar (off + 0);
    ybdds[1] = bdd_ithvar (off + 1);
    ybdds[2] = bdd_ithvar (off + 2);

    {
        int cnt = bdd_getnodenum ();
        printf ("Start with %d nodes!\n", cnt);
    }


    d = satbdd;
    {:for (i ; 3)
        a = fdd_equals (xfddidcs[i], xfddidcs[(i+1)%3]);
        a = bdd_addref (a);

        b = bdd_biimp (ybdds[i], ybdds[(i+1)%3]);
        b = bdd_addref (b);

        e = bdd_imp (a, b);
        e = bdd_addref (e);
        bdd_delref (a);
        bdd_delref (b);

        c = d;
        d = bdd_and (c, e);
        d = bdd_addref (d);
        bdd_delref (c);
        bdd_delref (e);
    }

#if 0
    a = bdd_satone (d);
    a = bdd_addref (a);

    fdd_printset (a);
    fputc ('\n', stdout);
    bdd_printset (a);
    fputc ('\n', stdout);
    bdd_delref (a);
#endif

    bdd_printtable (d);
    bdd_delref (d);
        /* fdd_clearall (); */

    {
        int cnt;
        bdd_gbc ();
        cnt = bdd_getnodenum ();
        printf ("Still have %d nodes!\n", cnt);
    }

    lose_sysCx ();
    return 0;
}
Пример #14
0
int main(int argc,char **argv) {
   char ambiguous_treatment='A';
   char linebuff[1024];
   char *parseptr;
   PARSE_STATE ps;
   uint32_t low_code,high_code;
   int width,i,j,vi,vj;
   FILE *unicode_db;
   BDD x,y,child[8];
   BDD *queue;
   int queue_low,queue_high,queue_max;

   puts("/*\n"
	" * GENERATED CODE - DO NOT EDIT!\n"
	" * Edit mkwcw.c, which generates this, or the input to that\n"
	" * program, instead.  Distributions of IDSgrep will nonetheless\n"
	" * usually include a ready-made copy of this file because\n"
	" * compiling and running mkwcw.c requires a library and data\n"
	" * file that, although free, not everyone is expected to have.\n"
	" */\n\n"
	"#include \"_stdint.h\"\n"
       );
   
   if (argc>1)
     ambiguous_treatment=argv[1][0]&~32;
   
   bdd_init(1000000,15625);
   bdd_setcacheratio(64);
   bdd_setvarnum(32);
   bdd_gbc_hook(NULL);
   
   defined_codes=bddfalse;
   zero_codes=bddfalse;
   wide_codes=bddfalse;

   /* yes, unfortunately UnicodeData.txt and EastAsianWidth.txt are just
    * different enough to need separate parsers, at least if the parsers
    * are as stupid as I'd like these ones to be */
   
   if (argc>2) {
      unicode_db=fopen(argv[2],"rt");

      while (1) {
	 fgets(linebuff,sizeof(linebuff),unicode_db);
	 if (feof(unicode_db))
	   break;
	 
	 ps=psLOW;
	 linebuff[sizeof(linebuff)-1]='\0';
	 low_code=0;
	 width=-1;
	 
	 for (parseptr=linebuff;(*parseptr) && (ps!=psSTOP);parseptr++)
	   switch (ps) {
	      
	    case psLOW:
	      if ((*parseptr>='0') && (*parseptr<='9'))
		low_code=(low_code<<4)+(*parseptr-'0');
	      else if ((*parseptr>='a') && (*parseptr<='f'))
		low_code=(low_code<<4)+(*parseptr-'a'+10);
	      else if ((*parseptr>='A') && (*parseptr<='F'))
		low_code=(low_code<<4)+(*parseptr-'A'+10);
	      else if (*parseptr==';')
		 ps=psSEMI;
	      else if ((*parseptr==' ') || (*parseptr=='\t'))
		{ /* skip spaces and tabs */ }
	      else
		ps=psSTOP; /* this catches comment lines */
	      break;
	      
	    case psSEMI:
	      if (*parseptr==';')
		ps=psWIDTH;
	      break;
	      
	    case psWIDTH:
	      if (((parseptr[0]=='M') && ((parseptr[1]=='e') ||
					  (parseptr[1]=='n'))) ||
		  ((parseptr[0]=='C') && (parseptr[1]=='f')))
		width=0;
	      /* FALL THROUGH */
	      
	    default:
	      ps=psSTOP;
	      break;
	   }
	 
	 if (width==0)
	   set_range_width(low_code,low_code,0);
      }

      fclose(unicode_db);
   }
   
   while (1) {
      fgets(linebuff,sizeof(linebuff),stdin);
      if (feof(stdin))
	break;
      
      ps=psLOW;
      linebuff[sizeof(linebuff)-1]='\0';
      low_code=0;
      high_code=0;
      width=-1;

      for (parseptr=linebuff;(*parseptr) && (ps!=psSTOP);parseptr++)
	switch (ps) {

	 case psLOW:
	   if ((*parseptr>='0') && (*parseptr<='9'))
	     low_code=(low_code<<4)+(*parseptr-'0');
	   else if ((*parseptr>='a') && (*parseptr<='f'))
	     low_code=(low_code<<4)+(*parseptr-'a'+10);
	   else if ((*parseptr>='A') && (*parseptr<='F'))
	     low_code=(low_code<<4)+(*parseptr-'A'+10);
	   else if (*parseptr=='.')
	     ps=psHIGH;
	   else if (*parseptr==';') {
	      high_code=low_code;
	      ps=psWIDTH;
	   } else if ((*parseptr==' ') || (*parseptr=='\t'))
		{ /* skip spaces and tabs */ }
	   else
	     ps=psSTOP; /* this catches comment lines */
	   break;

	 case psHIGH:
	   if ((*parseptr>='0') && (*parseptr<='9'))
	     high_code=(high_code<<4)+(*parseptr-'0');
	   else if ((*parseptr>='a') && (*parseptr<='f'))
	     high_code=(high_code<<4)+(*parseptr-'a'+10);
	   else if ((*parseptr>='A') && (*parseptr<='F'))
	     high_code=(high_code<<4)+(*parseptr-'A'+10);
	   else if ((*parseptr=='.') || (*parseptr==' ') || (*parseptr=='\t'))
	     { /* skip spaces, tabs, and dots */ }
	   else if (*parseptr==';')
	     ps=psWIDTH;
	   else
	     ps=psSTOP;
	   break;
	   
	 case psWIDTH:
	   if (*parseptr=='A')
	     *parseptr=ambiguous_treatment;
	   switch (*parseptr) {
	    case 'F': /* full-width treated as wide */
	    case 'W': /* wide */
	      width=2;
	      break;
	      
	    case 'H': /* half-width treated as narrow */
	    case 'N': /* narrow or neutral */
	      width=1;
	      break;
	      
	    case '0': /* zero-width - should only appear in user database */
	      width=0;
	      break;
	      
	    default:
	      /* ignore all others */
	      break;
	   }
	   /* FALL THROUGH */
	   
	 default:
	   ps=psSTOP;
	   break;
	}
      
      if (width>=0)
	set_range_width(low_code,high_code,width);
   }
   
   printf("/* node counts before simplification: %d %d %d */\n",
	  bdd_nodecount(defined_codes),
	  bdd_nodecount(zero_codes),
	  bdd_nodecount(wide_codes));

   x=bdd_addref(bdd_simplify(wide_codes,defined_codes));
   bdd_delref(wide_codes);
   wide_codes=x;

   x=bdd_addref(bdd_apply(defined_codes,wide_codes,bddop_diff));
   bdd_delref(defined_codes);
   defined_codes=x;
   
   x=bdd_addref(bdd_simplify(zero_codes,defined_codes));
   bdd_delref(zero_codes);
   zero_codes=x;
   
   printf("/* node counts after simplification: %d %d %d */\n\n",
	  bdd_nodecount(defined_codes),
	  bdd_nodecount(zero_codes),
	  bdd_nodecount(wide_codes));

   bdd_varblockall();
   bdd_intaddvarblock(0,7,0);
   bdd_intaddvarblock(8,15,0);
   bdd_intaddvarblock(16,23,0);
   bdd_intaddvarblock(24,31,0);
   bdd_intaddvarblock(0,31,1);

   bdd_reorder_probe(&reordering_size_callback);
   
   puts("typedef struct _WIDTH_BBD_ENT {\n"
	"  int16_t child[8];\n"
	"  char byte,shift;\n"
	"} WIDTH_BDD_ENT;\n\n"
	"static WIDTH_BDD_ENT width_bdd[]={");

   queue=(BDD *)malloc(sizeof(BDD)*1000);
   queue_max=1000;
   queue_low=2;
   queue_high=4;
   queue[0]=bddfalse;
   queue[1]=bddtrue;
   queue[2]=wide_codes;
   queue[3]=zero_codes;
   
   while (queue_low<queue_high) {
      if (queue_high+8>queue_max) {
	 queue_max/=3;
	 queue_max*=4;
	 queue=(BDD *)realloc(queue,sizeof(BDD)*queue_max);
      }
      
      reorder_focus=queue[queue_low];
      bdd_reorder(BDD_REORDER_WIN2ITE);
      
      vj=bdd_var(queue[queue_low]);
      vi=(vj/8)*8;
      vj=((vj-vi+1)/3)*3-1;
      if (vj<0) vj=0;
      
      x=bdd_addref(bdd_restrict(queue[queue_low],bdd_nithvar(vi+vj)));
      y=bdd_addref(bdd_restrict(x,bdd_nithvar(vi+vj+1)));
      child[0]=bdd_addref(bdd_restrict(y,bdd_nithvar(vi+vj+2)));
      child[1]=bdd_addref(bdd_restrict(y,bdd_ithvar(vi+vj+2)));
      bdd_delref(y);
      y=bdd_addref(bdd_restrict(x,bdd_ithvar(vi+vj+1)));
      child[2]=bdd_addref(bdd_restrict(y,bdd_nithvar(vi+vj+2)));
      child[3]=bdd_addref(bdd_restrict(y,bdd_ithvar(vi+vj+2)));
      bdd_delref(y);
      bdd_delref(x);
      x=bdd_addref(bdd_restrict(queue[queue_low],bdd_ithvar(vi+vj)));
      y=bdd_addref(bdd_restrict(x,bdd_nithvar(vi+vj+1)));
      child[4]=bdd_addref(bdd_restrict(y,bdd_nithvar(vi+vj+2)));
      child[5]=bdd_addref(bdd_restrict(y,bdd_ithvar(vi+vj+2)));
      bdd_delref(y);
      y=bdd_addref(bdd_restrict(x,bdd_ithvar(vi+vj+1)));
      child[6]=bdd_addref(bdd_restrict(y,bdd_nithvar(vi+vj+2)));
      child[7]=bdd_addref(bdd_restrict(y,bdd_ithvar(vi+vj+2)));
      bdd_delref(y);
      bdd_delref(x);
      
      fputs("  {{",stdout);
      for (i=0;i<8;i++) {
	 queue[queue_high]=child[i];
	 for (j=0;queue[j]!=child[i];j++);
	 if (j==queue_high)
	   queue_high++;
	 else
	   bdd_delref(child[i]);
	 printf("%d",j-2);
	 if (i<7) putchar(',');
      }
      printf("},%d,%d},\n",vi/8,5-vj);
      
      queue_low++;
   }

   puts("};\n\n"
"int idsgrep_utf8cw(char *);\n"
"\n"
"#define WBS width_bdd[search]\n"
"\n"
"int idsgrep_utf8cw(char *cp) {\n"
"   int search;\n"
"\n"
"   for (search=0;search>=0;)\n"
"     search=WBS.child[(cp[WBS.byte]>>WBS.shift)&7];\n"
"   if (search==-1)\n"
"     return 2;\n"
"   for (search=1;search>=0;)\n"
"     search=WBS.child[(cp[WBS.byte]>>WBS.shift)&7];\n"
"   return ((-1)-search);\n"
"}\n");
   
   bdd_done();

   exit(0);
}
Пример #15
0
int main(int argc, char *argv[])
{
  char **vars;
  int *orders;
  DFA *a;
  char *example;
  unsigned indices[1];
  unsigned index;
  int i;

  if (argc != 3) {
    printf("usage: %s <dfa-file> <variable-name>\n", argv[0]);
    exit(-1);
  }

  /* initialize the BDD package */
  bdd_init();

  /* import the automaton */
  a = dfaImport(argv[1], &vars, &orders);
  if (!a) {
    printf("error: unable to import '%s'\n", argv[1]);
    exit(-1);
  }

  /* find the index */
  for (index = 0; vars[index]; index++)
    if (strcmp(vars[index], argv[2]) == 0)
      break;
  if (!vars[index]) {
    printf("error: '%s' not found in '%s'\n", argv[2], argv[1]);
    exit(-1);
  }

  /* 'dfaMakeExample' finds a string leading from the initial state
     to a nearest accepting state, 
     this string represents a binary encoded number for
     each free variable */
  indices[0] = index;
  example = dfaMakeExample(a, 1, 1, indices);
  
  /* print the result */
  if (!example)
    printf("relation is unsatisfiable!\n");
  else {
    printf("satisfying example:\n"
	   "%s = %d\n", 
	   argv[2], decode_example(example, 0, 1));
    mem_free(example);
  }

  /* clean up */
  dfaFree(a);

  for (i = 0; vars[i]; i++)
    mem_free(vars[i]);
  mem_free(vars);
  mem_free(orders);

  return 0;
}