Skip to content

Commit

Permalink
Pin- and pingroup automatted tests should be fixed by now
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Oct 4, 2023
1 parent e9c9595 commit cfb43bc
Showing 1 changed file with 147 additions and 152 deletions.
299 changes: 147 additions & 152 deletions tests/test_utils/src/gate_library_test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GatePin>* 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<GateLibrary> create_gate_library(const std::filesystem::path& file_path)
{
std::unique_ptr<GateLibrary> lib = std::unique_ptr<GateLibrary>(new GateLibrary(file_path, "TESTING_GATE_LIBRARY"));
Expand Down Expand Up @@ -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<GatePin*> 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<GatePin*> 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<GatePin*> 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<GatePin*> 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<GatePin*> 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());
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit cfb43bc

Please sign in to comment.