diff --git a/tests/test_utils/src/gate_library_test_utils.cpp b/tests/test_utils/src/gate_library_test_utils.cpp index 83d94cb8edd..c074221da03 100644 --- a/tests/test_utils/src/gate_library_test_utils.cpp +++ b/tests/test_utils/src/gate_library_test_utils.cpp @@ -12,6 +12,21 @@ namespace hal { namespace test_utils { + + void dumpPingroups(const GateType *gt) + { + std::cerr << "gate type: " << gt->get_id() << " <" << gt->get_name() << ">\n"; + for (PinGroup* pg : gt->get_pin_groups()) + { + std::cerr << " grp: " << pg->get_id() << (pg->is_ascending()?" asc ": " des ") << pg->get_start_index() + << " <" << pg->get_name() << ">\n"; + for (GatePin* pin : pg->get_pins()) + std::cerr << " pin: " << pin->get_id() << " inx:" << pin->get_group().second << " <" << pin->get_name() << ">\n"; + } + std::cerr << "-------------" << std::endl; + } + + std::unique_ptr create_gate_library(const std::filesystem::path& file_path) { std::unique_ptr lib = std::unique_ptr(new GateLibrary(file_path, "TESTING_GATE_LIBRARY")); @@ -416,201 +431,179 @@ namespace hal return nullptr; } - if (auto res_grp = carry4->create_pin_group("DI", {}, PinDirection::input, PinType::none, false, 3); res_grp.is_error()) + std::vector temp_pins; + + //--- pingroup DI --- + if (auto res = carry4->create_pin("DI(3)", PinDirection::input, PinType::none, false); res.is_error()) { return nullptr; } else { - const auto grp = res_grp.get(); - - std::list pins; - if (auto res = carry4->create_pin("DI(0)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("DI(1)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("DI(2)", PinDirection::input, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("DI(2)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("DI(1)", PinDirection::input, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("DI(3)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("DI(0)", PinDirection::input, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - for (auto pin : pins) - grp->assign_pin(pin); + if (auto res_grp = carry4->create_pin_group("DI", temp_pins, PinDirection::input, PinType::none, false, 3); res_grp.is_error()) + { + return nullptr; } + temp_pins.clear(); - if (auto res_grp = carry4->create_pin_group("S", {}, PinDirection::input, PinType::none, false, 3); res_grp.is_error()) + //--- pingroup S ---- + if (auto res = carry4->create_pin("S(3)", PinDirection::input, PinType::none, false); res.is_error()) { return nullptr; } else { - const auto grp = res_grp.get(); - - std::list pins; - if (auto res = carry4->create_pin("S(0)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("S(1)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("S(2)", PinDirection::input, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("S(2)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("S(1)", PinDirection::input, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("S(3)", PinDirection::input, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("S(0)", PinDirection::input, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - for (auto pin : pins) - grp->assign_pin(pin); + if (auto res_grp = carry4->create_pin_group("S", temp_pins, PinDirection::input, PinType::none, false, 3); res_grp.is_error()) + { + return nullptr; } + temp_pins.clear(); - if (auto res_grp = carry4->create_pin_group("CO", {}, PinDirection::output, PinType::carry, false, 3); res_grp.is_error()) + //--- pingroup CO --- + if (auto res = carry4->create_pin("CO(3)", PinDirection::output, PinType::carry, false); res.is_error()) { return nullptr; } else { - const auto grp = res_grp.get(); - - std::list pins; - if (auto res = carry4->create_pin("CO(0)", PinDirection::output, PinType::carry, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("CO(1)", PinDirection::output, PinType::carry, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("CO(2)", PinDirection::output, PinType::carry, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("CO(2)", PinDirection::output, PinType::carry, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("CO(1)", PinDirection::output, PinType::carry, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("CO(3)", PinDirection::output, PinType::carry, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("CO(0)", PinDirection::output, PinType::carry, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - for (auto pin : pins) - grp->assign_pin(pin); + if (auto res_grp = carry4->create_pin_group("CO", temp_pins, PinDirection::output, PinType::carry, false, 3); res_grp.is_error()) + { + return nullptr; } + temp_pins.clear(); - if (auto res_grp = carry4->create_pin_group("O", {}, PinDirection::output, PinType::none, false, 3); res_grp.is_error()) + //--- pingroup O ---- + if (auto res = carry4->create_pin("O(3)", PinDirection::output, PinType::none, false); res.is_error()) { return nullptr; } else { - const auto grp = res_grp.get(); - - std::list pins; - if (auto res = carry4->create_pin("O(0)", PinDirection::output, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("O(1)", PinDirection::output, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("O(2)", PinDirection::output, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("O(2)", PinDirection::output, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("O(1)", PinDirection::output, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - if (auto res = carry4->create_pin("O(3)", PinDirection::output, PinType::none, false); res.is_error()) - { - return nullptr; - } - else - { - pins.push_front(res.get()); - } + if (auto res = carry4->create_pin("O(0)", PinDirection::output, PinType::none, false); res.is_error()) + { + return nullptr; + } + else + { + temp_pins.push_back(res.get()); + } - for (auto pin : pins) - grp->assign_pin(pin); + if (auto res_grp = carry4->create_pin_group("O", temp_pins, PinDirection::output, PinType::none, false, 3); res_grp.is_error()) + { + return nullptr; } + temp_pins.clear(); carry4->add_boolean_function("CO(0)", BooleanFunction::from_string("((S(0) & (CI | CYINIT)) | ((! S(0)) & DI(0)))").get()); carry4->add_boolean_function("CO(1)", BooleanFunction::from_string("((S(1) & CO(0)) | ((! S(1)) & DI(1)))").get()); @@ -1389,6 +1382,8 @@ namespace hal if (!gate_pin_groups_are_equal(*pg1_it, *pg2_it)) { log_info("test_utils", "unequal pin groups of gate types with names '{}' and '{}'", gt1->get_name(), gt2->get_name()); + test_utils::dumpPingroups(gt1); + test_utils::dumpPingroups(gt2); return false; } }