Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Added num_levels() to AIGs #13

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Set the project name and version
project(
aigverse
VERSION 0.0.6
VERSION 0.0.7
DESCRIPTION
"A Python library for working with logic networks, synthesis, and optimization."
HOMEPAGE_URL "https://github.com/marcelwa/aigverse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <mockturtle/networks/mig.hpp>
#include <mockturtle/networks/xag.hpp>
#include <mockturtle/traits.hpp>
#include <mockturtle/views/depth_view.hpp>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

Expand Down Expand Up @@ -82,6 +83,13 @@ void network(pybind11::module& m, const std::string& network_name)
.def("num_pos", &Ntk::num_pos)
.def("num_cos", &Ntk::num_cos)

.def("num_levels",
[](const Ntk& ntk) -> uint32_t
{
mockturtle::depth_view depth_ntk{ntk};
return depth_ntk.depth();
})

.def("get_node", &Ntk::get_node, "s"_a)
.def("make_signal", &Ntk::make_signal, "n"_a)
.def("is_complemented", &Ntk::is_complemented, "s"_a)
Expand Down
7 changes: 7 additions & 0 deletions bindings/aigverse/test/networks/test_aig.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,28 @@ def test_aig_structural_properties(self):
self.assertTrue(hasattr(aig, 'num_pis'))
self.assertTrue(hasattr(aig, 'num_pos'))
self.assertTrue(hasattr(aig, 'num_gates'))
self.assertTrue(hasattr(aig, 'num_levels'))
self.assertTrue(hasattr(aig, 'fanin_size'))
self.assertTrue(hasattr(aig, 'fanout_size'))

# Create two primary inputs
x1 = aig.create_pi()
x2 = aig.create_pi()

self.assertEqual(aig.num_levels(), 0)

# Create AND and OR gates
f1 = aig.create_and(x1, x2)
f2 = aig.create_or(x1, x2)

self.assertEqual(aig.num_levels(), 0)

# Create primary outputs
aig.create_po(f1)
aig.create_po(f2)

self.assertEqual(aig.num_levels(), 1)

# Check structural properties
self.assertEqual(aig.size(), 5)
self.assertEqual(aig.num_pis(), 2)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "aigverse"
version = "0.0.6"
version = "0.0.7"
description = "A Python library for working with logic networks, synthesis, and optimization."
readme = "README.md"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def build_extension(self, ext):

setup(
name='aigverse',
version='0.0.6',
version='0.0.7',
author='Marcel Walter',
author_email='marcel.walter@tum.de',
description='A Python library for working with logic networks, synthesis, and optimization.',
Expand Down
Loading