Skip to content

Commit

Permalink
Merge branch 'main' into clone-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
xtofalex committed Nov 1, 2024
2 parents bfa5e64 + 7295482 commit 68f9e42
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 189 deletions.
3 changes: 3 additions & 0 deletions docs/bne/classes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ BNE classes

.. doxygenclass:: naja::BNE::ActionTree
:members:

.. doxygenclass:: naja::BNE::Action
:members:
2 changes: 1 addition & 1 deletion docs/bne/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BNE
.. image:: ../images/Naja-BNE.png

Once a DNL representation of the SNL is established, the BNE allows to cache directives from DNL-based algorithms, which are purely computational.
BNE apply these directives to the SNL in an optimized manner, focusing on eliminating redundant unification and enhancing usability for the user.
BNE apply these directives to the SNL in an optimized manner, focusing on eliminating redundant uniquification and enhancing usability for the user.

.. toctree::
:maxdepth: 1
Expand Down
Binary file added docs/images/Naja-Clone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/snl/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Naja SNL (Structured Netlist)

identification.rst
classes/index.rst
uniquification.rst
snl_cpp_api_examples.rst
snl_python_api_examples.rst
primitives.rst
primitives.rst
18 changes: 18 additions & 0 deletions docs/snl/uniquification.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Uniquification
=========

.. image:: ../images/Naja-Clone.png
:alt: Naja SNL

In an hierarchical netlist, there are models who are being used multiple times as implementation for different instances.

The action of uniquification of an instance means to create a unique model for the context of the instance alone by cloning its original model.

In order to implement the operations of the BNE(Batch Netlist Editor), we will have to be able to uniquify models as there will be times when we will want to edit a specific context without affecting the rest of the instances of the current model.

In order to enable uniquification in SNL, we are providing 2 APIs:

1) clone() API for SNLDesign.
2) setModel(SNLModel* model) for SNLInstance.

These 2 APIs are the atomic actions that together can implement Uniquification.
44 changes: 22 additions & 22 deletions src/bne/ActionTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,54 +172,54 @@ class ActionTree {
public:
/**
* \brief Create an ActionTree.
* \param blockNormalization true if the normalization is blocked.
* \param keepOrder true if the order is kept.
* \return the created ActionTree.
* \param blockNormalization True if the normalization is blocked.
* \param keepOrder True if the order is kept.
* \return The created ActionTree.
*/
ActionTree(bool blockNormalization = false, bool keepOrder = false);
/**
* \brief get the node for the context.
* \param context the context of the node.
* \return the node for the context.
* \brief Get the node for the context.
* \param context The context of the node.
* \return The node for the context.
*/
ActionTreeNode* getNodeForContext(
const std::vector<SNLID::DesignObjectID>& context);
/**
* \brief add a node childe for the context path.
* \param context the context of the node.
* \return the node for the context.
* \brief Add a node childe for the context path.
* \param context The context of the node.
* \return The node for the context.
*/
ActionTreeNode& addHierChild(
const std::vector<SNLID::DesignObjectID>& context);
/**
* \brief add a node childe for the context path.
* \param context the context of the node.
* \return the node for the context.
* \brief Add a node childe for the context path.
* \param context The context of the node.
* \return The node for the context.
*/
void addAction(Action* action);
/**
* \brief normalize the tree.
* \brief Normalize the tree.
*/
void normalize();
/**
* \brief get the root of the tree.
* \return the root of the tree.
* \brief Get the root of the tree.
* \return The root of the tree.
*/
ActionTreeNode& getRoot() { return nodes_[0]; }
/**
* \brief get the node of the id.
* \param id the id of the node.
* \return the node of the id.
* \brief Get the node of the id.
* \param id The id of the node.
* \return The node of the id.
*/
ActionTreeNode& getNode(size_t id) { return nodes_[id]; }
/**
* \brief process the tree.
* \brief Process the tree.
*/
void process();
/**
* \brief get the action of the id.
* \param id the id of the action.
* \return the action of the id.
* \brief Get the action of the id.
* \param id The id of the action.
* \return The action of the id.
*/
Action* getAction(size_t id) { return actions_[id]; }
// Destructor that releases all the actions
Expand Down
17 changes: 17 additions & 0 deletions src/bne/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,27 @@ enum ActionType { DELETE, DRIVE_WITH_CONSTANT, REDUCTION, NONE };

class Action {
public:
/**
* \brief Create an Action.
* \param type The type of the action.
* \return The created Action.
*/
Action(ActionType type) : type_(type) {}
/**
* \brief Process the action on the context.
* \param design The design to process the action on.
*/
virtual void processOnContext(SNLDesign* design) = 0;
/**
* \brief Get the type of the action.
* \return The type of the action.
*/
ActionType getType() const { return type_; }
// get context
/**
* \brief Get the context of the action.
* \return The context of the action.
*/
virtual const std::vector<SNLID::DesignObjectID>& getContext() const = 0;
// comparator
virtual bool operator==(const Action& action) const = 0;
Expand Down
23 changes: 13 additions & 10 deletions src/bne/bne.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ class BNE {
public:
/**
* \brief Create a BNE.
* \param blockNormalization true if the normalization is blocked.
* \param blockOptimization true if the optimization is blocked.
* \param blockNormalization True if the normalization is blocked.
* \param blockOptimization True if the optimization is blocked.
*/
BNE(bool blockNormalization = false, bool blockOptimization = false)
: tree_(blockNormalization, blockOptimization) {}
/**
* \brief add a delete action to the BNE.
* \param pathToDelete the path to delete.
* \brief Add a delete action to the BNE.
* \param pathToDelete The path to delete.
*/
void addDeleteAction(const std::vector<SNLID::DesignObjectID>& pathToDelete);
/**
* \brief add a delete action to the BNE.
* \param pathToDelete the path to delete.
* \brief Add a drive with constant action to the BNE.
* \param pathToDrive The context.
* \param termToDrive The term to drive.
* \param value The value to drive.
*/
void addDriveWithConstantAction(
const std::vector<SNLID::DesignObjectID>& context,
Expand All @@ -34,16 +36,17 @@ class BNE {
const double& value,
SNLBitTerm* topTermToDrive = nullptr);
/**
* \brief add a delete action to the BNE.
* \param pathToDelete the path to delete.
* \brief Add a reduction action to the BNE.
* \param context The context.
* \param instance The instance that can be reduced.
* \param result The interface reduction needed.
*/
void addReductionCommand(
const std::vector<SNLID::DesignObjectID>& context,
SNLID::DesignObjectID instance,
const std::pair<SNLDesign*, SNLLibraryTruthTables::Indexes>& result);
/**
* \brief add a delete action to the BNE.
* \param pathToDelete the path to delete.
* \brief Process the commands.
*/
void process();
private:
Expand Down
Loading

0 comments on commit 68f9e42

Please sign in to comment.