HAL
hal::PinGroup< T > Class Template Reference

#include <pin_group.h>

Collaboration diagram for hal::PinGroup< T >:
Collaboration graph

Public Member Functions

 PinGroup (const u32 id, const std::string &name, PinDirection direction, PinType type, bool ascending=true, u32 start_index=0, bool ordered=false)
 
 ~PinGroup ()=default
 
bool operator== (const PinGroup< T > &other) const
 
bool operator!= (const PinGroup< T > &other) const
 
ssize_t get_hash () const
 
u32 get_id () const
 
void set_name (const std::string &name)
 
const std::string & get_name () const
 
void set_type (PinType type)
 
PinType get_type () const
 
void set_direction (PinDirection direction)
 
PinDirection get_direction () const
 
std::vector< T * > get_pins (const std::function< bool(T *)> &filter=nullptr) const
 
Result< T * > get_pin_at_index (i32 index) const
 
Result< i32get_index (const T *pin) const
 
bool is_ascending () const
 
bool is_descending () const
 
i32 get_lowest_index () const
 
i32 get_highest_index () const
 
i32 get_start_index () const
 
bool is_ordered () const
 
void set_ordered (bool ordered=true)
 
bool empty () const
 
size_t size () const
 
bool assign_pin (T *pin)
 
Result< std::monostate > move_pin (T *pin, i32 new_index)
 
bool remove_pin (T *pin)
 
bool contains_pin (T *pin)
 

Detailed Description

template<class T>
class hal::PinGroup< T >

A group of pins made up of a name, the pins, a pin order, and a start index.

Definition at line 50 of file pin_group.h.

Constructor & Destructor Documentation

◆ PinGroup()

template<class T >
hal::PinGroup< T >::PinGroup ( const u32  id,
const std::string &  name,
PinDirection  direction,
PinType  type,
bool  ascending = true,
u32  start_index = 0,
bool  ordered = false 
)
inline

Construct a new pin group from its name, pin order, and start index.

Parameters
[in]id- The ID of the pin group.
[in]name- The name of the pin group.
[in]direction- The direction of the pin group.
[in]type- The type of the pin group.
[in]ascending- Set true for ascending pin order (from 0 to n-1), false otherwise (from n-1 to 0). Defaults to true.
[in]start_index- The start index of the pin group. Defaults to 0.
[in]ordered- Set true if the pin group features an inherent order, false otherwise. Defaults to false.

Definition at line 64 of file pin_group.h.

◆ ~PinGroup()

template<class T >
hal::PinGroup< T >::~PinGroup ( )
default

Member Function Documentation

◆ assign_pin()

template<class T >
bool hal::PinGroup< T >::assign_pin ( T *  pin)
inline

Assign a pin to the pin group. The pin will automatically assigned highest_index+1 as its index, independent of whether the group is ascending or descending. The highest_index of the group will be incremented by 1. For ascending groups, the pin will be inserted at the end of the list of pins. For descending groups, it will be inserted at the beginning of the list of pins.

Parameters
[in]pin- The pin to assign.
Returns
true on success, false otherwise.

Definition at line 370 of file pin_group.h.

References log_warning.

Referenced by hal::GateType::assign_pin_to_group(), hal::Module::assign_pin_to_group(), and hal::NetlistModificationDecorator::connect_nets().

◆ contains_pin()

template<class T >
bool hal::PinGroup< T >::contains_pin ( T *  pin)
inline

Check whether the pin group contains the given pin.

Parameters
[in]pin- The pin to check.
Returns
true if the pin group contains the pin, false otherwise.

Definition at line 527 of file pin_group.h.

Referenced by hal::Module::assign_pin_to_group().

◆ empty()

template<class T >
bool hal::PinGroup< T >::empty ( ) const
inline

Check whether the pin group is empty, i.e., contains no pins.

Returns
True if the pin group is empty, false otherwise.

Definition at line 345 of file pin_group.h.

◆ get_direction()

template<class T >
PinDirection hal::PinGroup< T >::get_direction ( ) const
inline

Get the direction of the pin group.

Returns
The direction of the pin group.

Definition at line 190 of file pin_group.h.

Referenced by hal::ActionPingroup::exec(), hal::ModulePinsTreeModel::handleModulePortsChanged(), hal::PinGroup< T >::operator==(), and hal::Module::set_pin_group_direction().

◆ get_hash()

template<class T >
ssize_t hal::PinGroup< T >::get_hash ( ) const
inline

Hash function for python binding.

Returns
Pybind11 compatible hash.

Definition at line 120 of file pin_group.h.

◆ get_highest_index()

template<class T >
i32 hal::PinGroup< T >::get_highest_index ( ) const
inline

Get the numerically highest index of the pin group.

Returns
The highest index.

Definition at line 303 of file pin_group.h.

Referenced by hal::PinGroup< T >::operator==().

◆ get_id()

◆ get_index()

template<class T >
Result<i32> hal::PinGroup< T >::get_index ( const T *  pin) const
inline

Get the index within the pin group of the given pin.

Parameters
[in]pin- The pin.
Returns
The index of the pin on success, an error message otherwise.

Definition at line 253 of file pin_group.h.

References ERR, and OK.

◆ get_lowest_index()

template<class T >
i32 hal::PinGroup< T >::get_lowest_index ( ) const
inline

Get the numerically lowest index of the pin group.

Returns
The lowest index.

Definition at line 293 of file pin_group.h.

Referenced by hal::PinGroup< T >::operator==().

◆ get_name()

◆ get_pin_at_index()

template<class T >
Result<T*> hal::PinGroup< T >::get_pin_at_index ( i32  index) const
inline

Get the pin specified by the given index.

Parameters
[in]index- The index of the pin within the pin group.
Returns
The pin on success, an error message otherwise.

Definition at line 228 of file pin_group.h.

References ERR, and OK.

◆ get_pins()

template<class T >
std::vector<T*> hal::PinGroup< T >::get_pins ( const std::function< bool(T *)> &  filter = nullptr) const
inline

Get the (ordered) pins of the pin groups. The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.

Parameters
[in]filter- An optional filter.
Returns
The ordered pins.

Definition at line 202 of file pin_group.h.

References hal::T.

Referenced by hal::ActionPingroup::changePinGroupType(), hal::GateType::delete_pin_group(), hal::Module::delete_pin_group(), hal::ActionPingroup::deletePinGroup(), hal::BooleanFunctionDecorator::get_boolean_function_from(), hal::PinGroup< T >::operator==(), and hal::ActionPingroup::toggleAscendingGroup().

◆ get_start_index()

template<class T >
i32 hal::PinGroup< T >::get_start_index ( ) const
inline

Get the start index of the pin group. For ascending pin groups, this index equals the lowest index of the pin group. For descending pin groups, it is equal to the highest index of the pin group.

Returns
The start index.

Definition at line 315 of file pin_group.h.

Referenced by hal::ActionPingroup::exec().

◆ get_type()

template<class T >
PinType hal::PinGroup< T >::get_type ( ) const
inline

◆ is_ascending()

template<class T >
bool hal::PinGroup< T >::is_ascending ( ) const
inline

Check whether the pin order of a pin group comprising n pins is ascending, e.g., from index 0 to n-1.

Returns
true for ascending bit order, false otherwise.

Definition at line 273 of file pin_group.h.

Referenced by hal::ActionPingroup::exec(), hal::ModulePinsTreeModel::handleModulePortsChanged(), hal::PinGroup< T >::operator==(), hal::GatePinsTreeModel::setGate(), and hal::ActionPingroup::toggleAscendingGroup().

◆ is_descending()

template<class T >
bool hal::PinGroup< T >::is_descending ( ) const
inline

Check whether the pin order of a pin group comprising n pins is descending, e.g., from index n-1 to 0.

Returns
true for descending bit order, false otherwise.

Definition at line 283 of file pin_group.h.

◆ is_ordered()

template<class T >
bool hal::PinGroup< T >::is_ordered ( ) const
inline

Check whether the pin group features an inherent order.

Returns
true if the pin group is inherently ordered, false otherwise.

Definition at line 325 of file pin_group.h.

Referenced by hal::PinGroup< T >::operator==().

◆ move_pin()

template<class T >
Result<std::monostate> hal::PinGroup< T >::move_pin ( T *  pin,
i32  new_index 
)
inline

Move a pin to another index within the pin group. The indices of all pins between the old index and the new index will be affected as well, because they are incremented or decremented accordingly.

Parameters
[in]pin- The pin to move.
[in]new_index- The index to move the pin to.
Returns
Ok on success, an error message otherwise.

Definition at line 400 of file pin_group.h.

References direction, ERR, and OK.

Referenced by hal::NetlistModificationDecorator::connect_nets(), and hal::Module::move_pin_within_group().

◆ operator!=()

template<class T >
bool hal::PinGroup< T >::operator!= ( const PinGroup< T > &  other) const
inline

Check whether two pin groups are unequal.

Parameters
[in]other- The pin group to compare against.
Returns
true if both pin groups are unequal, false otherwise.

Definition at line 110 of file pin_group.h.

References hal::PinGroup< T >::operator==().

◆ operator==()

template<class T >
bool hal::PinGroup< T >::operator== ( const PinGroup< T > &  other) const
inline

Check whether two pin groups are equal.

Parameters
[in]other- The pin group to compare against.
Returns
true if both pin groups are equal, false otherwise.

Definition at line 77 of file pin_group.h.

References hal::PinGroup< T >::get_direction(), hal::PinGroup< T >::get_highest_index(), hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_lowest_index(), hal::PinGroup< T >::get_name(), hal::PinGroup< T >::get_pins(), hal::PinGroup< T >::get_type(), hal::PinGroup< T >::is_ascending(), and hal::PinGroup< T >::is_ordered().

Referenced by hal::PinGroup< T >::operator!=().

◆ remove_pin()

template<class T >
bool hal::PinGroup< T >::remove_pin ( T *  pin)
inline

Remove a pin from the pin group. The indices of all pins with a higher index than the removed pin will be reduced by 1. The highest_index will also be reduced by 1.

Parameters
[in]pin- The pin to remove.
Returns
true on success, false otherwise.

Definition at line 478 of file pin_group.h.

References log_warning.

◆ set_direction()

template<class T >
void hal::PinGroup< T >::set_direction ( PinDirection  direction)
inline

Set the direction of the pin group.

Parameters
[in]direction- The direction of the pin group.

Definition at line 180 of file pin_group.h.

References direction.

Referenced by hal::GateType::set_pin_group_direction(), and hal::Module::set_pin_group_direction().

◆ set_name()

template<class T >
void hal::PinGroup< T >::set_name ( const std::string &  name)
inline

Set the name of the pin group.

Parameters
[in]name- The name of the pin group.

Definition at line 140 of file pin_group.h.

References name.

Referenced by hal::GateType::set_pin_group_name(), and hal::Module::set_pin_group_name().

◆ set_ordered()

template<class T >
void hal::PinGroup< T >::set_ordered ( bool  ordered = true)
inline

Set whether the pin group features an inherent order.

Parameters
[in]ordered- Set true if the pin group is inherently ordered, false otherwise. Defaults to true.

Definition at line 335 of file pin_group.h.

References ordered.

◆ set_type()

template<class T >
void hal::PinGroup< T >::set_type ( PinType  type)
inline

Set the type of the pin group.

Parameters
[in]type- The pin group type.

Definition at line 160 of file pin_group.h.

References type.

Referenced by hal::GateType::set_pin_group_type(), and hal::Module::set_pin_group_type().

◆ size()

template<class T >
size_t hal::PinGroup< T >::size ( ) const
inline

Get the size, i.e., the number of pins, of the pin group.

Returns
The size of the pin group.

Definition at line 355 of file pin_group.h.


The documentation for this class was generated from the following file: