Skip to content

Commit

Permalink
Merge pull request #13 from marcelwa/depth-view
Browse files Browse the repository at this point in the history
✨ Added `num_levels()` to AIGs
  • Loading branch information
marcelwa authored Sep 13, 2024
2 parents cfd1fad + e26fd51 commit 2f74ab7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
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

0 comments on commit 2f74ab7

Please sign in to comment.