Skip to content

Commit

Permalink
1.Remove parent object from user action 2.Merge master 3.Minor fixes …
Browse files Browse the repository at this point in the history
…for view tree actions
  • Loading branch information
joern274 committed Mar 11, 2024
2 parents 6b5ce6f + 8a6afbb commit f61f505
Show file tree
Hide file tree
Showing 102 changed files with 3,718 additions and 2,308 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
* refactored module widget
* added option to show gate content for each module
* added option to show interior nets for each module
* added `Isolate in new view` feature for nets
* added button to expand or collapse all tree items
* added delete module action and shortcut
* added entries for context menu
Expand All @@ -18,7 +19,14 @@ All notable changes to this project will be documented in this file.
* 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
* module pins
* added qualifier for `pin_changed` core events telling receiver details about the recent modification
* added event scope and stacking classes so that `pin_changed` events can be collected and prioritized
* added specific GUI handler for every `pin_changed` event thus replacing the reload-entire-pingroup-tree policy
* added class `ActionPingroup` so that UNDO function works for all pin / pin group actions issued from GUI
* miscellaneous
* added INIT field declaration to FF-gate-types in example library
* added drag'n drop feature allowing to move several nodes in graph view at same time
* added functions to Python GUI API to create, modifiy and delete views
* 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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This repository contains a selection of curated plugins:
A comprehensive documentation of HAL's features from a user perspective is available in our [Wiki](https://github.com/emsec/hal/wiki). In addition, we provide a full [C++ API](https://emsec.github.io/hal/doc/) and [Python API](https://emsec.github.io/hal/pydoc/) documentation.

## Slack, Contact and Support
For all kinds of inquiries, please contact us using our dedicated e-mail address: [hal@csp.mpg.de](mailto:hal@csp.mpg.de). To receive an invite to our dedicated hal-support Slack workspace, please write us an e-mail as well.
For all kinds of inquiries, please contact us using our dedicated e-mail address: [hal@mpi-sp.org](mailto:hal@mpi-sp.org).

<a name="build-instructions"></a>
# Build Instructions
Expand Down
34 changes: 25 additions & 9 deletions cmake/detect_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ find_package(Sanitizers REQUIRED)
# ###############################
# #### Bitwuzla
# ###############################
find_package(Bitwuzla)
pkg_check_modules(BITWUZLA bitwuzla)

if(BITWUZLA_FOUND)
message(STATUS "Found BITWUZLA")
message(STATUS " BITWUZLA_LIBRARIES: ${BITWUZLA_LIBRARIES}")
message(STATUS " BITWUZLA_LINK_LIBRARIES: ${BITWUZLA_LINK_LIBRARIES}")
message(STATUS " BITWUZLA_INCLUDE_DIRS: ${BITWUZLA_INCLUDE_DIRS}")
else()
set(BITWUZLA_LIBRARY "")
set(BITWUZLA_INCLUDE_DIRS "")
message(STATUS "Bitwuzla not found, but this is optional...")
endif(BITWUZLA_FOUND)

if(Bitwuzla_FOUND)
set(BITWUZLA_LIBRARY Bitwuzla::bitwuzla)
endif()

# ###############################
# #### OpenMP
Expand Down Expand Up @@ -109,24 +117,32 @@ endif()
# ###############################
find_package(Filesystem REQUIRED Final Experimental)


# ###############################
# #### RapidJSON
# ###############################
find_package(RapidJSON REQUIRED)
message(STATUS "Found rapidjson ${RAPIDJSON_INCLUDEDIR}")

if(RapidJSON_FOUND AND NOT TARGET RapidJSON::RapidJSON)
if(NOT RAPIDJSON_INCLUDEDIR)
set(RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDE_DIRS})
endif()

# fix for macOS if most recent version
if(NOT RAPIDJSON_INCLUDEDIR)
set(RAPIDJSON_INCLUDEDIR ${RapidJSON_INCLUDE_DIRS})
endif()


add_library(RapidJSON::RapidJSON INTERFACE IMPORTED)
set_target_properties(RapidJSON::RapidJSON PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${RAPIDJSON_INCLUDEDIR}"
)
message(STATUS "Set rapidjson successully: ${RAPIDJSON_INCLUDEDIR}")
message(STATUS "Found rapidjson ${RAPIDJSON_INCLUDEDIR}")
message(STATUS "Set rapidjson path successully: ${RAPIDJSON_INCLUDEDIR}")
endif()



# ###############################
# #### pybind11
# ###############################
Expand Down Expand Up @@ -243,7 +259,7 @@ endif(Z3_FOUND)
# ###############################
# #### igraph
# ###############################
set (IGRAPH_SUBDIR "${CMAKE_SOURCE_DIR}/deps/igraph-0.9.10")
set(IGRAPH_SUBDIR "${CMAKE_SOURCE_DIR}/deps/igraph-0.9.10")
add_subdirectory(${IGRAPH_SUBDIR})
get_directory_property(IGRAPH_INCLUDES DIRECTORY ${IGRAPH_SUBDIR} DEFINITION IGRAPH_INCLUDES)
get_directory_property(IGRAPH_LIB DIRECTORY ${IGRAPH_SUBDIR} DEFINITION IGRAPH_LIB)
get_directory_property(IGRAPH_LIB DIRECTORY ${IGRAPH_SUBDIR} DEFINITION IGRAPH_LIB)
2 changes: 1 addition & 1 deletion include/hal_core/netlist/event_system/event_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace hal
gates_remove_begin, ///< associated_data = number of gates to remove
gates_remove_end, ///< associated_data = number of removed gates
gate_removed, ///< associated_data = id of removed gate
pin_changed, ///< no associated_data
pin_changed, ///< associated_data = [4LSB: type of action] [28HSB: id of pin group or pin]
};
};

Expand Down
166 changes: 166 additions & 0 deletions include/hal_core/netlist/gate_library/enums/pin_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// 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/utilities/enums.h"
#include "hal_core/defines.h"
#include <unordered_map>
#include <vector>

namespace hal
{
/**
* Spezifies the pin_changed event type
*
* The order of events in enum class defines the order in which events are handled.
*
*/
enum class PinEvent
{
unknown,
GroupCreate, /// new pin group created
GroupRename, /// pin group renamed
GroupTypeChange, /// changed PinType attribute of group (like data)
GroupDirChange, /// changed PinDirection attribute of group (like input)
GroupReorder, /// moved group to a new position within containing module
PinCreate, /// new pin created
PinAssignToGroup, /// pin assigned to new group
PinRename, /// pin renamed
PinTypeChange, /// changed PinType attribute of pin (like data)
PinDirChange, /// changed PinDirection attribute of pin (like input)
PinReorder, /// moved pin to a new position within containing group
PinDelete, /// pin deleted
GroupDelete /// group deleted
};

template<>
std::map<PinEvent, std::string> EnumStrings<PinEvent>::data;

class Module;

/**
* Wrapper class for core pin_changed events.
*
* Events can be send immediately or stacked and send at according to their priority.
*/
class PinChangedEvent
{
friend bool pin_event_order(const PinChangedEvent& a, const PinChangedEvent& b);
friend class PinChangedEventScope;

/**
* Subclass for event stack.
*/
class EventStack : public std::vector<PinChangedEvent>
{
public:
/**
* Scope count indicates the nesting depth of event-throwing subroutines.
* Only the top level (m_count=0) is allowed to send the events from stack.
*/
int m_count;

/**
* Construct empty stack
*/
EventStack() : m_count(0) {;}

/**
* Attempts to send events, typically at the end of a pin-changing subroutine.
* Events will only be send if m_count is zero.
*/
void send_events(Module* m);
};

static std::unordered_map<Module*,EventStack*> s_event_stack;

Module* m_module;
PinEvent m_event;
u32 m_id;

public:
/**
* PinChangedEvent class for single event
* @param m - The module comprising pins and pin groups
* @param pev - The pin event enum
* @param id - pin or pin group ID
*/
PinChangedEvent(Module* m, PinEvent pev, u32 id);

/**
* Returns the module for which pins or pin groups have been changed
* @return The module comprising pins and pin groups
*/
Module* get_module() const;

/**
* Return bitwise binary encoded PinEvent and ID
* 4LSB = The pin event enum as 4 bit int
* 28HSB = The ID as 28 bit int
* @return The bitcode according to scheme above
*/
u32 associated_data();

/**
* Attempts to send event.
* If this routine or any calling routine wants to collect events the event gets written on stack instead.
*/
void send();
};

/**
* By creating an instance of this class a new scope gets created thus collecting events.
*/
class PinChangedEventScope
{
Module* m_module;
public:

/**
* Constructor for scope instance incrementing scope count
* @param m The module comprising pins and pin groups
*/
PinChangedEventScope(Module* m);

/**
* Destructor for scope instance decrementing scope count
*/
~PinChangedEventScope();

/**
* Attempts to send all stacked events. Will do nothing if not issued from top-level scope.
*/
void send_events();
};

/**
* Function used by sort algorithm to organize events according to their priority.
* @param a - Pin changed event A
* @param b - Pin changed event B
* @return true if A should be handled before B, false otherwise.
*/
bool pin_event_order(const PinChangedEvent& a, const PinChangedEvent& b);
}
3 changes: 2 additions & 1 deletion include/hal_core/netlist/gate_library/enums/pin_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ namespace hal

template<>
std::map<PinType, std::string> EnumStrings<PinType>::data;
} // namespace hal

} // namespace hal
6 changes: 3 additions & 3 deletions include/hal_core/netlist/gate_library/gate_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ namespace hal
* Delete the given pin group.
*
* @param[in] pin_group - The pin group to be deleted.
* @returns Ok on success, an error message otherwise.
* @returns true on success, false otherwise.
*/
Result<std::monostate> delete_pin_group(PinGroup<GatePin>* pin_group);
bool delete_pin_group(PinGroup<GatePin>* pin_group);

/**
* Assign a pin to a pin group.
Expand Down Expand Up @@ -469,6 +469,6 @@ namespace hal
GateType& operator=(const GateType&) = delete;

Result<PinGroup<GatePin>*> create_pin_group_internal(const u32 id, const std::string& name, PinDirection direction, PinType type, bool ascending, u32 start_index);
Result<std::monostate> delete_pin_group_internal(PinGroup<GatePin>* pin_group);
bool delete_pin_group_internal(PinGroup<GatePin>* pin_group);
};
} // namespace hal
Loading

0 comments on commit f61f505

Please sign in to comment.