Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5194e78
buggy and incomplete prototype for clock tree extraction
saschatommasone Oct 10, 2025
e8ee5c9
rewrite prototype to prevent incomplete clocktrees
saschatommasone Oct 17, 2025
7cf8a6d
don't fail on unconnected nets, etc.
saschatommasone Oct 22, 2025
1f5e7db
don't traverse control signals of clock gates
saschatommasone Oct 22, 2025
333499e
don't traverse latches for now
saschatommasone Oct 22, 2025
0b2bfd2
some small improvements for low quality netlists
saschatommasone Oct 24, 2025
fff09d2
include toggle flip-flop-based clock dividers
saschatommasone Oct 28, 2025
5d3a15d
change source file suffix
saschatommasone Nov 10, 2025
d3b8973
merge master to resolve ci errors
saschatommasone Nov 10, 2025
62e9afa
rewrite to use igraph internally
saschatommasone Nov 12, 2025
2164d55
start to implement methods to query clock tree
saschatommasone Nov 24, 2025
1d6355a
allow to retrieve subtree of parent
saschatommasone Nov 26, 2025
db19f29
user can now convert vertices to ptrs and vice versa
saschatommasone Nov 27, 2025
abc94cb
extend api for bt
saschatommasone Jan 28, 2026
0b632f7
Merge branch 'master' into feature/clock_tree_extractor
saschatommasone Jan 29, 2026
bdd88da
bugfix: invalid paths
Feb 2, 2026
8ca814b
Merge branch 'master' into feature/clock_tree_extractor
Feb 17, 2026
25b5943
allow the algorithm to also extract meshes
Feb 23, 2026
9c912a5
Merge branch 'master' into feature/clock_tree_extractor
Apr 9, 2026
e47a62b
include clock gates in clock tree
Jun 5, 2026
17246b6
Merge branch 'master' into feature/clock_tree_extractor
saschatommasone Jun 5, 2026
1b0436f
Merge branch 'master' into feature/clock_tree_extractor
saschatommasone Jul 5, 2026
e9771d4
support delay gate types; fix missing unconnected flip-flops; add wor…
saschatommasone Jul 5, 2026
6641841
add gate type as node attribute to dot export
saschatommasone Jul 6, 2026
1a50e4e
add missing dependency for docker
saschatommasone Jul 31, 2026
ff3479e
Merge branch 'master' into feature/clock_tree_extractor
saschatommasone Aug 28, 2026
ed836a8
update readme and copyright
saschatommasone Aug 28, 2026
62af230
update ipgraph api calls
saschatommasone Aug 28, 2026
a993e43
update license
saschatommasone Aug 28, 2026
9abe409
fix borrowing
saschatommasone Aug 28, 2026
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This repository contains a selection of curated plugins:
- Detailed widgets with information on all aspects of the inspected netlist
- **Netlist Simulator:** A simulator for arbitrary parts of a loaded netlist
- **Dataflow Analysis:** Our dataflow analysis plugin [DANA](https://eprint.iacr.org/2020/751.pdf) that recovers high-level registers in an unstructured netlist
- **Clock Tree Extractor:** A plugin to recover clock trees from an unstructured gate-level netlist
- **Graph Algorithms:** [igraph](https://igraph.org) integration for direct access to common algorithms from graph-theory
- **Python Shell:** A command-line plugin to spawn a Python shell preloaded with the HAL Python bindings
- **VHDL & Verilog Parsers:** Adds support for parsing VHDL and Verilog files as netlist input formats
Expand Down
2 changes: 1 addition & 1 deletion install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ elif [[ "$platform" == 'docker' ]]; then
libqt5svg5-dev libqt5svg5* ninja-build lcov gcovr python3-sphinx \
doxygen python3-sphinx-rtd-theme python3-jedi python3-pip \
pybind11-dev python3-pybind11 python3-dateutil rapidjson-dev \
libspdlog-dev libz3-dev libreadline-dev \
libspdlog-dev libz3-dev libreadline-dev libgraphviz-dev \
graphviz libomp-dev libsuitesparse-dev # For documentation
fi
24 changes: 24 additions & 0 deletions plugins/clock_tree_extractor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
option(PL_CLOCK_TREE_EXTRACTOR "PL_CLOCK_TREE_EXTRACTOR" ON)

if(PL_CLOCK_TREE_EXTRACTOR OR BUILD_ALL_PLUGINS)

if(IWYU)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "include-what-you-use")
message(STATUS "include-what-you-use turned ON")
else()
message(STATUS "include-what-you-use turned OFF")
endif()

file(GLOB_RECURSE CLOCK_TREE_EXTRACTOR_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
file(GLOB_RECURSE CLOCK_TREE_EXTRACTOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE CLOCK_TREE_EXTRACTOR_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/python/*.cpp)

hal_add_plugin(clock_tree_extractor
SHARED
HEADER ${CLOCK_TREE_EXTRACTOR_INC}
SOURCES ${CLOCK_TREE_EXTRACTOR_SRC} ${CLOCK_TREE_EXTRACTOR_PYTHON_SRC}
LINK_LIBRARIES graph_algorithm
COMPILE_OPTIONS "-march=native"
)

endif()
138 changes: 138 additions & 0 deletions plugins/clock_tree_extractor/include/clock_tree_extractor/clock_tree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// MIT License
//
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
// Copyright (c) 2025-2026 Sascha Tommasone. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once

#include "graph_algorithm/netlist_graph.h"
#include "hal_core/defines.h"
#include "hal_core/utilities/result.h"

#include <igraph/igraph.h>
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <variant>
#include <vector>

namespace hal
{
class Netlist;
}

namespace hal
{
class Gate;
}

namespace hal
{
class Net;
}

namespace hal
{
namespace cte
{
enum PtrType { UNKNOWN, GATE, NET };

struct VoidPtrHash
{
std::size_t operator()( const std::pair<const void *, const void *> &pair ) const noexcept
{
return std::hash<const void *>()( pair.first ) ^ ( std::hash<const void *>()( pair.second ) << 1 );
}
};

struct PairPtrEq
{
bool operator()( const std::pair<const void *, const void *> &p1,
const std::pair<const void *, const void *> &p2 ) const noexcept
{
return p1.first == p2.first && p1.second == p2.second;
}
};

class ClockTree
{
public:
ClockTree( const Netlist *netlist,
igraph_t &&graph,
std::unordered_set<igraph_integer_t> &&roots,
std::unordered_map<igraph_integer_t, const void *> &&m_vertices_to_ptrs,
std::unordered_map<const void *, PtrType> &&m_ptrs_to_types );

~ClockTree();

static Result<std::unique_ptr<ClockTree>> from_netlist( const Netlist *netlist );

Result<std::monostate> export_dot( const std::string &pathname ) const;

Result<std::vector<std::pair<const void *, PtrType>>> get_neighbors( const void *ptr,
igraph_neimode_t direction ) const;

Result<std::unique_ptr<ClockTree>> get_subtree( const void *ptr, const bool parent ) const;

Result<igraph_integer_t> get_vertex_from_ptr( const void *ptr ) const;

Result<std::pair<const void *, PtrType>> get_ptr_from_vertex( const igraph_integer_t vertex ) const;

Result<std::vector<igraph_integer_t>> get_vertices_from_ptrs( const std::vector<const void *> &ptrs ) const;

Result<std::vector<std::pair<const void *, PtrType>>>
get_ptrs_from_vertices( const std::vector<igraph_integer_t> &vertices ) const;

const std::vector<const Gate *> get_gates() const;

const std::vector<const Net *> get_nets() const;

const std::unordered_map<const void *, PtrType> get_all() const;

const Netlist *get_netlist() const;

const igraph_t *get_igraph() const;

private:
ClockTree() = delete;

ClockTree( const Netlist *netlist );

const Netlist *m_netlist;

igraph_t m_igraph;

igraph_t *m_igraph_ptr;

std::unordered_set<igraph_integer_t> m_roots;

std::unordered_map<igraph_integer_t, const void *> m_vertices_to_ptrs;

std::unordered_map<const void *, igraph_integer_t> m_ptrs_to_vertices;

std::unordered_map<const void *, PtrType> m_ptrs_to_types;
};
} // namespace cte
} // namespace hal
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// MIT License
//
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
// Copyright (c) 2025-2026 Sascha Tommasone. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once

#include "hal_core/defines.h"
#include "hal_core/plugin_system/plugin_interface_base.h"

#include <set>
#include <string>

namespace hal
{
class PLUGIN_API ClockTreeExtractorPlugin : public BasePluginInterface
{
public:
ClockTreeExtractorPlugin() = default;

~ClockTreeExtractorPlugin() = default;

std::string get_name() const override;

std::string get_version() const override;

std::string get_description() const override;

std::set<std::string> get_dependencies() const override;

void initialize() override;

void on_load() override;

void on_unload() override;
};
} // namespace hal
Loading
Loading