Skip to content

Commit

Permalink
Merge branch 'feature/word_level_structures' of github.com:emsec/hal …
Browse files Browse the repository at this point in the history
…into feature/word_level_structures
  • Loading branch information
Simon Klix committed Nov 14, 2023
2 parents ef5c436 + a1257ed commit 32e86ec
Show file tree
Hide file tree
Showing 22 changed files with 1,786 additions and 2,524 deletions.
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,40 @@ All notable changes to this project will be documented in this file.

## [Unreleased]
* miscellaneous
* added GUI PluginParameter type 'ComboBox' for parameters that can be requested from plugin
* added GUI PluginParameter types 'Module' and 'Gated' for parameters that can be requested from plugin
* added GUI PluginParameter type `ComboBox` for parameters that can be requested from plugin
* added GUI PluginParameter types `Module` and `Gated` for parameters that can be requested from plugin
* added `Show content` button to `Groupings` widget to show content of grouping as a list
* added flag which python editor tab is active when serializing project
* added `GateType::delete_pin_group` and `GateType::assign_pin_to_group` to enable more operations on pin groups of gate pins
* added extended gate library picker when importing a netlist
* added keyboard shortcut for delete-item action from toolbar
* added parameter `force_name` to enforce pin (group) renaming to `Module::set_pin_name`, `Module::set_pin_group_name`, `Module::create_pin`, and `Module::create_pin_group`
* changed supported input file formats for import from hard coded list to list provided by loadable parser plugins
* changed behavior of import netlist dialog, suggest only non-existing directory names and loop until an acceptable name was entered
* changed appearance and behavior of import project dialog, make sure existing hal projects don't get overwritten
* changed installation script policy to install Python packages (omit 'pip install' which would need virtual environment)
* bugfixes
* fixed colors in Python Console when switching between color schemes
* fixed pybind of `Module::get_gates`
* fixed Python script execution abort button disappearing when switching tabs
* fixed Python interpreter crash due to release of GIL semaphore before cleanup is done
* fixed segfault when deleting a module for which an exclusive view exists
* fixed not loading all plugins if the GUI is not in control
* fixed Verilog writer not being a dependency of Verilator plugin
* fixed order of pins within pin groups not being properly handled for modules and gate types
* fixed netlist parsers assigning gate pins in wrong order (compensated by the bug above, imported netlists were still correct)
* fixed wrong order of pins within pin groups in provided gate libraries
* fixed format string handling of enums in log outputs
* fixed restoring user assigned module colors from project file
* fixed no scrollbar shown in `Data` tab of `Selection Details` widget
* fixed problems in GUI plugin management caused by addressing plugins by absolute path
* fixed several bugs related to moving node boxes in GUI by drag'n'drop

* refactored layouter module
* switched to multithreaded algorithm
* boosted performance by using classes with faster memory access
* removed layouter code used prior to version 3.1.0 - thus removing the setting option to use that code
* added setting option to dump junction layout input data for experts to debug in case of layout errors

## [4.2.0](v4.2.0) - 2023-05-24 10:02:04-07:00 (urgency: medium)
* GUI plugin manager
Expand Down
20 changes: 10 additions & 10 deletions include/hal_core/netlist/decorators/netlist_traversal_decorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ namespace hal
* @param[in] entry_endpoint_filter - Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
* @returns The next gates fulfilling the target gate filter condition.
*/
Result<std::unordered_set<Gate*>> get_next_gates_fancy(const Net* net,
bool successors,
const std::function<bool(const Gate*)>& target_gate_filter,
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
Result<std::set<Gate*>> get_next_gates_fancy(const Net* net,
bool successors,
const std::function<bool(const Gate*)>& target_gate_filter,
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;

/**
* Starting from the given gate, traverse the netlist and return only the successor/predecessor gates for which the `target_gate_filter` evaluates to `true`.
Expand All @@ -105,11 +105,11 @@ namespace hal
* @param[in] entry_endpoint_filter - Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
* @returns The next gates fulfilling the target gate filter condition.
*/
Result<std::unordered_set<Gate*>> get_next_gates_fancy(const Gate* gate,
bool successors,
const std::function<bool(const Gate*)>& target_gate_filter,
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
Result<std::set<Gate*>> get_next_gates_fancy(const Gate* gate,
bool successors,
const std::function<bool(const Gate*)>& target_gate_filter,
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;

private:
const Netlist& m_netlist;
Expand Down
248 changes: 248 additions & 0 deletions include/hal_core/utilities/finite_set.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
// 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.
//
// 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/utilities/result.h>
#include <unordered_map>
#include <vector>

namespace hal
{
template<typename T>
struct FiniteSet
{
FiniteSet(const std::vector<T>* const data, const std::unordered_map<T, u32>* const data_to_index) : m_data(data), m_data_to_index(data_to_index)
{
m_size = m_data->size();
m_content = std::vector<u64>(((m_size - 1) >> 6) + 1, 0);
}

bool operator==(const FiniteSet<T>& rhs) const
{
return m_content == rhs.m_content;
}

bool operator<(const FiniteSet<T>& rhs) const
{
return m_content < rhs.m_content;
}

FiniteSet<T> operator&(const FiniteSet<T>& rhs) const
{
FiniteSet<T> res(m_data, m_data_to_index);
for (u32 i = 0; i < m_content.size(); i++)
{
res.m_content.at(i) = m_content.at(i) & rhs.m_content.at(i);
}
return res;
}

FiniteSet<T> operator|(const FiniteSet<T>& rhs) const
{
FiniteSet<T> res(m_data, m_data_to_index);
for (u32 i = 0; i < m_content.size(); i++)
{
res.m_content.at(i) = m_content.at(i) | rhs.m_content.at(i);
}
return res;
}

FiniteSet<T> operator-(const FiniteSet<T>& rhs) const
{
FiniteSet<T> res(m_data, m_data_to_index);
for (u32 i = 0; i < m_content.size(); i++)
{
res.m_content.at(i) = m_content.at(i) & ~rhs.m_content.at(i);
}
return res;
}

FiniteSet<T> operator^(const FiniteSet<T>& rhs) const
{
FiniteSet<T> res(m_data, m_data_to_index);
for (u32 i = 0; i < m_content.size(); i++)
{
res.m_content.at(i) = m_content.at(i) ^ rhs.m_content.at(i);
}
return res;
}

bool is_disjoint(const FiniteSet<T>& rhs) const
{
for (u32 i = 0; i < m_content.size(); i++)
{
if ((m_content.at(i) & rhs.m_content.at(i)) != 0)
{
return false;
}
}
return true;
}

bool is_subset(const FiniteSet<T>& rhs) const
{
for (u32 i = 0; i < m_content.size(); i++)
{
if ((m_content.at(i) & rhs.m_content.at(i)) != m_content.at(i))
{
return false;
}
}
return true;
}

bool is_superset(const FiniteSet<T>& rhs) const
{
for (u32 i = 0; i < m_content.size(); i++)
{
if ((m_content.at(i) & rhs.m_content.at(i)) != rhs.m_content.at(i))
{
return false;
}
}
return true;
}

bool insert(const u32 index)
{
if (index >= m_size)
{
return false;
}

m_content.at(index >> 6) ^= (u64)1 << (index & 0x3F);

return true;
}

bool insert(const T& elem)
{
const auto it = m_data_to_index->find(elem);
if (it == m_data_to_index->end())
{
return false;
}

const u32 index = it->second;
m_content.at(index >> 6) ^= (u64)1 << (index & 0x3F);
return true;
}

bool erase(const u32 index)
{
if (index >= m_size)
{
return false;
}

m_content.at(index >> 6) &= ~((u64)1 << (index & 0x3F));

return true;
}

bool erase(const T& elem)
{
const auto it = m_data_to_index->find(elem);
if (it == m_data_to_index->end())
{
return false;
}

const u32 index = it->second;
m_content.at(index >> 6) &= ~((u64)1 << (index & 0x3F));

return true;
}

bool contains(const u32 index)
{
if (index >= m_size)
{
return false;
}

return (m_content.at(index >> 6) & (u64)1 << (index & 0x3F)) != 0;
}

bool contains(const T& elem)
{
const auto it = m_data_to_index->find(elem);
if (it == m_data_to_index->end())
{
return false;
}

const u32 index = it->second;
return (m_content.at(index >> 6) & (u64)1 << (index & 0x3F)) != 0;
}

Result<T> get_at(u32 index) const
{
if (index >= m_size)
{
return ERR("index " + std::to_string(index) + " is out of range, FiniteSet has size " + std::to_string(m_size));
}

return OK(m_data->at(index));
}

Result<u32> get_index(const T& elem) const
{
const auto it = m_data_to_index->find(elem);
if (it == m_data_to_index->end())
{
return ERR("element cannot be part of FiniteSet because it is not contained in base data");
}

return OK(it->second);
}

std::vector<T> get_contained() const
{
std::vector<T> res;

for (u32 i = 0; i < m_content.size(); i++)
{
for (u32 j = 0; j < 64; j++)
{
if (m_content.at(i) & ((u64)1 << j))
{
res.push_back(m_data->at((i << 6) + j));
}
}
}

return res;
}

u32 m_size;
const std::vector<T>* const m_data;
const std::unordered_map<T, u32>* const m_data_to_index;
std::vector<u64> m_content;
};
} // namespace hal
7 changes: 3 additions & 4 deletions install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ elif [[ "$platform" == 'linux' ]]; then
libqt5svg5-dev libqt5svg5* ninja-build lcov gcovr python3-sphinx \
doxygen python3-sphinx-rtd-theme python3-jedi python3-pip \
pybind11-dev python3-pybind11 rapidjson-dev libspdlog-dev libz3-dev z3 \
libreadline-dev apport \
libreadline-dev apport python3-dateutil \
$additional_deps \
graphviz libomp-dev libsuitesparse-dev # For documentation
sudo pip3 install -r requirements.txt
elif [[ "$distribution" == "Arch" ]]; then
yay -S --needed base-devel lsb-release git verilator cmake boost-libs pkgconf \
qt5-base python ccache autoconf libsodium qt5-svg ninja lcov \
Expand All @@ -97,7 +96,7 @@ elif [[ "$platform" == 'docker' ]]; then
libpython3-dev ccache autoconf autotools-dev libsodium-dev \
libqt5svg5-dev libqt5svg5* ninja-build lcov gcovr python3-sphinx \
doxygen python3-sphinx-rtd-theme python3-jedi python3-pip \
pybind11-dev python3-pybind11 rapidjson-dev libspdlog-dev libz3-dev libreadline-dev \
pybind11-dev python3-pybind11 python3-dateutil rapidjson-dev \
libspdlog-dev libz3-dev libreadline-dev \
graphviz libomp-dev libsuitesparse-dev # For documentation
pip3 install -r requirements.txt
fi
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ namespace hal
u32 mMaxContextId;
void dump(const QString& title, u32 mid, u32 xid) const;
SettingsItemCheckbox* mSettingDebugGrid;
SettingsItemCheckbox* mSettingNetLayout;
SettingsItemCheckbox* mSettingDumpJunction;
SettingsItemCheckbox* mSettingParseLayout;
SettingsItemCheckbox* mSettingLayoutBoxes;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace hal {
* @param n - The underlying net
* @param l - The lines this GraphicsNet consists of
*/
StandardArrowNet(Net* n, const Lines& l);
StandardArrowNet(Net* n, const Lines& l, const QList<QPointF>& knots = QList<QPointF>());
/**
* Adds an input position.
*
Expand All @@ -67,7 +67,7 @@ namespace hal {
*
* @param v - The visuals to set.
*/
virtual void setVisuals(const Visuals& v);
virtual void setVisuals(const Visuals& v) override;

/**
* Overwritten qt function to draw the net.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ namespace hal
*/
void appendVLine(const qreal x, const qreal mSmallY, const qreal mBigY);

/**
* Merges all horizontal and vertical lines so that overlapping lines are replaced by only a single line.
*/
void mergeLines();

/**
* Gets the total amount of lines (includes horizontal AND vertical lines).
*
Expand Down Expand Up @@ -129,7 +124,7 @@ namespace hal
* @param n - The undelying net of the StandardGraphicsNet
* @param l - The lines this GraphicsNet consists of
*/
StandardGraphicsNet(Net* n, const Lines& l);
StandardGraphicsNet(Net* n, const Lines& l, const QList<QPointF>& knots = QList<QPointF>());

/**
* Draws the StandardGraphicsNet in the scene.
Expand Down
Loading

0 comments on commit 32e86ec

Please sign in to comment.