340 std::string indent = indent1 + indent2;
341 const char *indt = indent.c_str();
343 if (bucket.size() <= 1)
347 log(
"%s Trying to shatter bucket with %d signals.\n", indt,
int(bucket.size()));
350 std::vector<RTLIL::SigBit> bucket_sigbits;
351 for (
int idx : bucket)
353 log(
"%s Trying to shatter bucket with %d signals: %s\n", indt,
int(bucket.size()),
log_signal(bucket_sigbits));
356 std::vector<int> sat_set_list, sat_clr_list;
357 for (
int idx : bucket) {
362 std::vector<int> modelVars =
sat_out;
363 std::vector<bool> model;
365 modelVars.insert(modelVars.end(),
sat_def.begin(),
sat_def.end());
367 modelVars.insert(modelVars.end(),
sat_pi.begin(),
sat_pi.end());
375 sat_set_list.clear();
376 sat_clr_list.clear();
378 std::vector<int> sat_def_list;
380 for (
int idx : bucket)
385 sat_def_list.push_back(
sat_def[idx]);
394 int count_set = 0, count_clr = 0, count_undef = 0;
395 for (
int idx : bucket)
402 log(
"%s After %d iterations: %d set vs. %d clr vs %d undef\n", indt, iter_count, count_set, count_clr, count_undef);
406 for (
size_t i = 0; i <
pi_bits.size(); i++)
408 for (
int idx : bucket)
409 log(
"%s -> OUT %c == %s%s\n", indt, model[
sat_out.size() +
idx] ? model[
idx] ?
'1' :
'0' :
'x',
413 std::vector<int> buckets_a;
414 std::vector<int> buckets_b;
416 for (
int idx : bucket) {
418 buckets_a.push_back(idx);
420 buckets_b.push_back(idx);
422 analyze(results, results_map, buckets_a, indent1 +
".", indent2 +
" ");
423 analyze(results, results_map, buckets_b, indent1 +
"x", indent2 +
" ");
427 std::vector<int> undef_slaves;
429 for (
int idx : bucket) {
430 std::vector<int> sat_def_list;
431 for (
int idx2 : bucket)
433 sat_def_list.push_back(
sat_def[idx2]);
435 undef_slaves.push_back(idx);
438 if (undef_slaves.size() == bucket.size()) {
440 log(
"%s Complex undef overlap. None of the signals covers the others.\n", indt);
445 for (
int idx : undef_slaves)
449 log(
"%s Found %d equivialent signals:", indt,
int(bucket.size()));
450 for (
int idx : bucket)
456 for (
int idx : bucket) {
457 if (results_map.count(idx) == 0)
459 if (result_idx == -1) {
460 result_idx = results_map.at(idx);
463 int result_idx2 = results_map.at(idx);
464 results[result_idx].insert(results[result_idx2].begin(), results[result_idx2].end());
465 for (
int idx2 : results[result_idx2])
466 results_map[idx2] = result_idx;
467 results[result_idx2].clear();
470 if (result_idx == -1) {
471 result_idx = results.size();
472 results.push_back(std::set<int>());
475 results[result_idx].insert(bucket.begin(), bucket.end());
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
static std::string idx(std::string str)
void log(const char *format,...)