HAL
hal::GateType Class Reference

#include <gate_type.h>

Collaboration diagram for hal::GateType:
Collaboration graph

Public Member Functions

ssize_t get_hash () const
 
std::vector< GateTypeComponent * > get_components (const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
 
GateTypeComponentget_component (const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
 
template<typename T >
T * get_component_as (const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
 
bool has_component_of_type (const GateTypeComponent::ComponentType type) const
 
u32 get_id () const
 
const std::string & get_name () const
 
void assign_property (const GateTypeProperty property)
 
std::set< GateTypePropertyget_properties () const
 
std::vector< GateTypePropertyget_property_list () const
 
bool has_property (GateTypeProperty property) const
 
GateLibraryget_gate_library () const
 
std::string to_string () const
 
bool operator== (const GateType &other) const
 
bool operator!= (const GateType &other) const
 
u32 get_unique_pin_id ()
 
u32 get_unique_pin_group_id ()
 
Result< GatePin * > create_pin (const u32 id, const std::string &name, PinDirection direction, PinType type=PinType::none, bool create_group=true)
 
Result< GatePin * > create_pin (const std::string &name, PinDirection direction, PinType type=PinType::none, bool create_group=true)
 
std::vector< GatePin * > get_pins (const std::function< bool(GatePin *)> &filter=nullptr) const
 
std::vector< std::string > get_pin_names (const std::function< bool(GatePin *)> &filter=nullptr) const
 
std::vector< GatePin * > get_input_pins () const
 
std::vector< std::string > get_input_pin_names () const
 
std::vector< GatePin * > get_output_pins () const
 
std::vector< std::string > get_output_pin_names () const
 
GatePinget_pin_by_id (const u32 id) const
 
GatePinget_pin_by_name (const std::string &name) const
 
Result< PinGroup< GatePin > * > create_pin_group (const u32 id, const std::string &name, const std::vector< GatePin * > pins={}, PinDirection direction=PinDirection::none, PinType type=PinType::none, bool ascending=true, i32 start_index=0, bool delete_empty_groups=true)
 
Result< PinGroup< GatePin > * > create_pin_group (const std::string &name, const std::vector< GatePin * > pins={}, PinDirection direction=PinDirection::none, PinType type=PinType::none, bool ascending=true, i32 start_index=0, bool delete_empty_groups=true)
 
std::vector< PinGroup< GatePin > * > get_pin_groups (const std::function< bool(PinGroup< GatePin > *)> &filter=nullptr) const
 
PinGroup< GatePin > * get_pin_group_by_id (const u32 id) const
 
PinGroup< GatePin > * get_pin_group_by_name (const std::string &name) const
 
bool delete_pin_group (PinGroup< GatePin > *pin_group)
 
Result< std::monostate > assign_pin_to_group (PinGroup< GatePin > *pin_group, GatePin *pin, bool delete_empty_groups=true)
 
bool set_pin_group_name (PinGroup< GatePin > *pin_group, const std::string &new_name)
 
bool set_pin_group_type (PinGroup< GatePin > *pin_group, PinType new_type)
 
bool set_pin_group_direction (PinGroup< GatePin > *pin_group, PinDirection new_direction)
 
void add_boolean_function (const std::string &name, const BooleanFunction &function)
 
void add_boolean_functions (const std::unordered_map< std::string, BooleanFunction > &functions)
 
const std::unordered_map< std::string, BooleanFunction > & get_boolean_functions () const
 
BooleanFunction get_boolean_function (const std::string &name) const
 
BooleanFunction get_boolean_function (const GatePin *pin=nullptr) const
 

Friends

class GateLibrary
 
std::ostream & operator<< (std::ostream &os, const GateType &gate_type)
 

Detailed Description

A gate type contains information about its internals such as input and output pins as well as its Boolean functions.

Definition at line 51 of file gate_type.h.

Member Function Documentation

◆ add_boolean_function()

void hal::GateType::add_boolean_function ( const std::string &  name,
const BooleanFunction function 
)

Add a Boolean function with the specified name to the gate type.

Parameters
[in]name- The name of the Boolean function.
[in]function- The Boolean function.

Definition at line 701 of file gate_type.cpp.

References hal::BooleanFunction::clone().

Referenced by hal::gate_type_init().

◆ add_boolean_functions()

void hal::GateType::add_boolean_functions ( const std::unordered_map< std::string, BooleanFunction > &  functions)

Add multiple Boolean functions to the gate type.

Parameters
[in]functions- A map from names to Boolean functions.

Definition at line 706 of file gate_type.cpp.

References name.

Referenced by hal::GateLibraryWizard::accept(), and hal::gate_type_init().

◆ assign_pin_to_group()

Result< std::monostate > hal::GateType::assign_pin_to_group ( PinGroup< GatePin > *  pin_group,
GatePin pin,
bool  delete_empty_groups = true 
)

Assign a pin to a pin group.

Parameters
[in]pin_group- The new pin group.
[in]pin- The pin to be added.
[in]delete_empty_groups- Set true to delete groups that are empty after the pin has been assigned to the new group, false to keep empty groups. Defaults to true.
Returns
Ok on success, an error message otherwise.

Definition at line 493 of file gate_type.cpp.

References hal::PinGroup< T >::assign_pin(), ERR, hal::BasePin< T >::get_group(), hal::BasePin< T >::get_id(), hal::PinGroup< T >::get_id(), hal::BasePin< T >::get_name(), hal::PinGroup< T >::get_name(), and OK.

◆ assign_property()

void hal::GateType::assign_property ( const GateTypeProperty  property)

Assign a new property to the gate type.

Parameters
[in]property- The property to assign.

Definition at line 69 of file gate_type.cpp.

Referenced by hal::gate_type_init().

◆ create_pin() [1/2]

Result< GatePin * > hal::GateType::create_pin ( const std::string &  name,
PinDirection  direction,
PinType  type = PinType::none,
bool  create_group = true 
)

Create a gate pin with the specified name. The ID of the pin is set automatically.

Parameters
[in]name- The name of the pin.
[in]direction- The direction of the pin.
[in]type- The type of the pin. Defaults to PinType::none.
[in]create_group- Set true to create a pin group for the pin, false otherwise. Defaulrs to false.
Returns
The gate pin on success, an error message otherwise.

Definition at line 205 of file gate_type.cpp.

References direction, name, and type.

◆ create_pin() [2/2]

Result< GatePin * > hal::GateType::create_pin ( const u32  id,
const std::string &  name,
PinDirection  direction,
PinType  type = PinType::none,
bool  create_group = true 
)

Create a gate pin with the specified name.

Parameters
[in]id- The ID of the pin.
[in]name- The name of the pin.
[in]direction- The direction of the pin.
[in]type- The type of the pin. Defaults to PinType::none.
[in]create_group- Set true to automatically assign the pin to a new pin group, false otherwise. Defaults to true.
Returns
The gate pin on success, an error message otherwise.

Definition at line 157 of file gate_type.cpp.

References direction, hal::enum_to_string(), ERR, ERR_APPEND, id, name, OK, and type.

Referenced by hal::GateLibraryWizard::accept().

◆ create_pin_group() [1/2]

Result< PinGroup< GatePin > * > hal::GateType::create_pin_group ( const std::string &  name,
const std::vector< GatePin * >  pins = {},
PinDirection  direction = PinDirection::none,
PinType  type = PinType::none,
bool  ascending = true,
i32  start_index = 0,
bool  delete_empty_groups = true 
)

Create a pin group with the given name. The ID of the pin group is set automatically.

Parameters
[in]name- The name of the pin group.
[in]pins- The pins to be assigned to the pin group. Defaults to an empty vector.
[in]direction- The direction of the pin group. Defaults to PinDirection::none.
[in]type- The type of the pin group. Defaults to PinType::none.
[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]delete_empty_groups- Set true to delete groups that are empty after the pins have been assigned to the new group, false to keep empty groups. Defaults to true.
Returns
The pin group on success, an error message otherwise.

Definition at line 426 of file gate_type.cpp.

References ascending, direction, name, pins, start_index, and type.

◆ create_pin_group() [2/2]

Result< PinGroup< GatePin > * > hal::GateType::create_pin_group ( const u32  id,
const std::string &  name,
const std::vector< GatePin * >  pins = {},
PinDirection  direction = PinDirection::none,
PinType  type = PinType::none,
bool  ascending = true,
i32  start_index = 0,
bool  delete_empty_groups = true 
)

Create a pin group with the given name.

Parameters
[in]id- The ID of the pin group.
[in]name- The name of the pin group.
[in]pins- The pins to be assigned to the pin group. Defaults to an empty vector.
[in]direction- The direction of the pin group. Defaults to PinDirection::none.
[in]type- The type of the pin group. Defaults to PinType::none.
[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]delete_empty_groups- Set true to delete groups that are empty after the pins have been assigned to the new group, false to keep empty groups. Defaults to true.
Returns
The pin group on success, an error message otherwise.

Definition at line 369 of file gate_type.cpp.

References ascending, direction, ERR, ERR_APPEND, name, OK, pins, start_index, and type.

Referenced by hal::GateLibraryWizard::accept().

◆ delete_pin_group()

bool hal::GateType::delete_pin_group ( PinGroup< GatePin > *  pin_group)

Delete the given pin group.

Parameters
[in]pin_group- The pin group to be deleted.
Returns
true on success, false otherwise.

Definition at line 460 of file gate_type.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), hal::PinGroup< T >::get_pins(), and log_warning.

◆ get_boolean_function() [1/2]

BooleanFunction hal::GateType::get_boolean_function ( const GatePin pin = nullptr) const

Get the Boolean function corresponding to the given output pin. If pin is a nullptr, the Boolean function of the first output pin is returned.

Parameters
[in]pin- The pin.
Returns
The Boolean function on success, an empty Boolean function otherwise.

Definition at line 731 of file gate_type.cpp.

References hal::BasePin< T >::get_name(), and log_warning.

◆ get_boolean_function() [2/2]

BooleanFunction hal::GateType::get_boolean_function ( const std::string &  name) const

Get the Boolean function specified by the given name. This name can for example be an output pin of the gate or any other user-defined function name.

Parameters
[in]name- The name of the Boolean function.
Returns
The Boolean function on success, an empty Boolean function otherwise.

Definition at line 714 of file gate_type.cpp.

References log_warning, and name.

Referenced by hal::gate_type_init(), hal::GateLibrary::mark_gnd_gate_type(), hal::GateLibrary::mark_vcc_gate_type(), and hal::GateLibraryTabTruthTable::update().

◆ get_boolean_functions()

const std::unordered_map< std::string, BooleanFunction > & hal::GateType::get_boolean_functions ( ) const

Get all Boolean functions of the gate type.

Returns
A map from names to Boolean functions.

Definition at line 746 of file gate_type.cpp.

Referenced by hal::gate_type_init(), hal::BoolWizardPage::initializePage(), hal::TEST_F(), and hal::GatelibraryFrameBoolean::update().

◆ get_component()

GateTypeComponent * hal::GateType::get_component ( const std::function< bool(const GateTypeComponent *)> &  filter = nullptr) const

Get a single component matching the filter condition (if provided). Returns a nullptr if (i) the gate type does not contain any components, (ii) multiple components match the filter condition, or (iii) no component matches the filter condition.

Parameters
[in]filter- The filter applied to all candidate components.
Returns
The component or a nullptr.

Definition at line 42 of file gate_type.cpp.

Referenced by hal::gate_type_init().

◆ get_component_as()

template<typename T >
T* hal::GateType::get_component_as ( const std::function< bool(const GateTypeComponent *)> &  filter = nullptr) const
inline

Get a single component and convert it to a component of the type specified by the template parameter. A user-defined filter may be applied to the result set, but is disabled by default. If more no or than one components match the filter condition, a nullptr is returned. A check is performed to determine whether the conversion is legal and a nullptr is returned in case it is not.

Parameters
[in]filter- The user-defined filter function applied to all candidate components.
Returns
The component converted to the target type or a nullptr.

Definition at line 89 of file gate_type.h.

References hal::GateTypeComponent::convert_to(), and hal::T.

Referenced by hal::PyCodeProvider::pyCodeGateAsyncSetResetBehavior(), hal::FlipFlopWizardPage::setData(), hal::InitWizardPage::setData(), hal::LatchWizardPage::setData(), hal::LUTWizardPage::setData(), hal::RAMWizardPage::setData(), hal::StateWizardPage::setData(), hal::TEST_F(), hal::GatelibraryFrameFF::update(), hal::GatelibraryFrameInit::update(), hal::GateLibraryFrameLatch::update(), hal::GatelibraryFrameLut::update(), hal::GateLibraryFrameRAM::update(), hal::GatelibraryFrameState::update(), and hal::GatelibraryLutInit::update().

◆ get_components()

std::vector< GateTypeComponent * > hal::GateType::get_components ( const std::function< bool(const GateTypeComponent *)> &  filter = nullptr) const

Get all components matching the filter condition (if provided) as a vector. Returns an empty vector if (i) the gate type does not contain any components or (ii) no component matches the filter condition.

Parameters
[in]filter- The filter applied to all candidate components, disabled by default.
Returns
The components.

Definition at line 19 of file gate_type.cpp.

Referenced by hal::gate_type_init(), hal::RAMPortWizardPage::initializePage(), hal::TEST_F(), and hal::GateLibraryFrameRAMPort::update().

◆ get_gate_library()

GateLibrary * hal::GateType::get_gate_library ( ) const

Get the gate library this gate type is associated with.

Returns
The gate library.

Definition at line 106 of file gate_type.cpp.

Referenced by hal::gate_type_init(), and operator==().

◆ get_hash()

ssize_t hal::GateType::get_hash ( ) const

Hash function for python binding.

Returns
Pybind11 compatible hash.

Definition at line 14 of file gate_type.cpp.

Referenced by hal::gate_type_init().

◆ get_id()

u32 hal::GateType::get_id ( ) const

Get the unique ID of the gate type.

Returns
The unique ID of the gate type.

Definition at line 59 of file gate_type.cpp.

Referenced by hal::GateLibraryWizard::accept(), hal::gate_type_init(), operator==(), and hal::GatelibraryFrameGeneral::update().

◆ get_input_pin_names()

std::vector< std::string > hal::GateType::get_input_pin_names ( ) const

Get an ordered vector of the names of all input pins of the gate type (including inout pins).

Returns
An ordered vector of input pin names.

Definition at line 277 of file gate_type.cpp.

References direction, and hal::BasePin< T >::get_direction().

Referenced by hal::gate_type_init(), hal::netlist_utils::remove_buffers(), and hal::GateLibraryTabTruthTable::update().

◆ get_input_pins()

std::vector< GatePin * > hal::GateType::get_input_pins ( ) const

Get an ordered vector of all input pins of the gate type (including inout pins).

Returns
An ordered vector of input pins.

Definition at line 269 of file gate_type.cpp.

References direction, and hal::BasePin< T >::get_direction().

Referenced by hal::gate_type_init(), hal::GraphicsGate::GraphicsGate(), hal::GateLibrary::mark_gnd_gate_type(), hal::GateLibrary::mark_vcc_gate_type(), and hal::GateLibraryTabTruthTable::update().

◆ get_name()

◆ get_output_pin_names()

std::vector< std::string > hal::GateType::get_output_pin_names ( ) const

Get an ordered vector of the names of all output pins of the gate type (including inout pins).

Returns
An ordered vector of output pin names.

Definition at line 293 of file gate_type.cpp.

References direction, and hal::BasePin< T >::get_direction().

Referenced by hal::gate_type_init().

◆ get_output_pins()

std::vector< GatePin * > hal::GateType::get_output_pins ( ) const

Get an ordered vector of all output pins of the gate type (including inout pins).

Returns
An ordered vector of output pins.

Definition at line 285 of file gate_type.cpp.

References direction, and hal::BasePin< T >::get_direction().

Referenced by hal::gate_type_init(), hal::GraphicsGate::GraphicsGate(), hal::VHDLParser::instantiate(), hal::GateLibrary::mark_gnd_gate_type(), hal::GateLibrary::mark_vcc_gate_type(), and hal::GateLibraryTabTruthTable::update().

◆ get_pin_by_id()

GatePin * hal::GateType::get_pin_by_id ( const u32  id) const

Get the pin corresponding to the given ID.

Parameters
[in]id- The ID of the pin.
Returns
The pin on success, a nullptr otherwise.

Definition at line 301 of file gate_type.cpp.

References log_warning.

Referenced by hal::gate_type_init().

◆ get_pin_by_name()

GatePin * hal::GateType::get_pin_by_name ( const std::string &  name) const

Get the pin corresponding to the given name.

Parameters
[in]name- The name of the pin.
Returns
The pin on success, a nullptr otherwise.

Definition at line 318 of file gate_type.cpp.

References log_warning, and name.

Referenced by hal::Net::add_destination(), hal::Net::add_source(), hal::gate_type_init(), hal::Net::is_a_destination(), hal::Net::is_a_source(), hal::Net::remove_destination(), and hal::Net::remove_source().

◆ get_pin_group_by_id()

PinGroup< GatePin > * hal::GateType::get_pin_group_by_id ( const u32  id) const

Get the pin group corresponding to the given ID.

Parameters
[in]id- The ID of the pin group.
Returns
The pin group on success, a nullptr otherwise.

Definition at line 569 of file gate_type.cpp.

References log_warning.

Referenced by hal::gate_type_init().

◆ get_pin_group_by_name()

PinGroup< GatePin > * hal::GateType::get_pin_group_by_name ( const std::string &  name) const

Get the pin group corresponding to the given name.

Parameters
[in]name- The name of the pin group.
Returns
The pin group on success, a nullptr otherwise.

Definition at line 586 of file gate_type.cpp.

References log_debug, log_warning, and name.

Referenced by hal::gate_type_init().

◆ get_pin_groups()

std::vector< PinGroup< GatePin > * > hal::GateType::get_pin_groups ( const std::function< bool(PinGroup< GatePin > *)> &  filter = nullptr) const

Get an ordered vector of all pin groups of the gate type. 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
An ordered vector of pin groups.

Definition at line 548 of file gate_type.cpp.

Referenced by hal::gate_type_init(), and hal::PinModel::setGate().

◆ get_pin_names()

std::vector< std::string > hal::GateType::get_pin_names ( const std::function< bool(GatePin *)> &  filter = nullptr) const

Get an ordered vector of the names of all pins of the gate type. 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
An ordered vector of pin names.

Definition at line 238 of file gate_type.cpp.

References pins.

Referenced by hal::gate_type_init().

◆ get_pins()

std::vector< GatePin * > hal::GateType::get_pins ( const std::function< bool(GatePin *)> &  filter = nullptr) const

Get an ordered vector of all pins of the gate type. 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
An ordered vector of pins.

Definition at line 210 of file gate_type.cpp.

References pins.

Referenced by hal::gate_type_init(), hal::GatePinsTreeModel::setGate(), and hal::TEST_F().

◆ get_properties()

std::set< GateTypeProperty > hal::GateType::get_properties ( ) const

Get the properties assigned to the gate type.

Returns
The properties of the gate type.

Definition at line 74 of file gate_type.cpp.

Referenced by hal::gate_type_init(), and hal::TEST_F().

◆ get_property_list()

std::vector< GateTypeProperty > hal::GateType::get_property_list ( ) const

Get the properties assigned to the gate type as list where the most significant property stands at first position.

Returns
The properties of the gate type.

Definition at line 79 of file gate_type.cpp.

Referenced by hal::gate_type_init(), hal::GateLibraryWizard::GateLibraryWizard(), and hal::GatelibraryFrameGeneral::update().

◆ get_unique_pin_group_id()

u32 hal::GateType::get_unique_pin_group_id ( )

Get a spare pin group ID.
The value of 0 is reserved and represents an invalid ID.

Returns
The pin group ID.

Definition at line 144 of file gate_type.cpp.

◆ get_unique_pin_id()

u32 hal::GateType::get_unique_pin_id ( )

Get a spare pin ID.
The value of 0 is reserved and represents an invalid ID.

Returns
The pin ID.

Definition at line 131 of file gate_type.cpp.

◆ has_component_of_type()

◆ has_property()

bool hal::GateType::has_property ( GateTypeProperty  property) const

Check whether the gate type has the specified property.

Parameters
[in]property- The property to check for.
Returns
True if the gate type has the specified property, false otherwise.

Definition at line 101 of file gate_type.cpp.

Referenced by hal::gate_type_init(), hal::NetlistTraversalDecorator::get_next_combinational_gates(), hal::NetlistTraversalDecorator::get_next_sequential_gates(), hal::netlist_utils::remove_buffers(), and hal::dataflow::Configuration::with_gate_types().

◆ operator!=()

bool hal::GateType::operator!= ( const GateType other) const

Check whether two gate types are unequal.

Parameters
[in]other- The gate type object to compare to.
Returns
True if both gate types are unequal, false otherwise.

Definition at line 126 of file gate_type.cpp.

◆ operator==()

bool hal::GateType::operator== ( const GateType other) const

Check whether two gate types are equal.

Parameters
[in]other- The gate type to compare against.
Returns
True if both gate types are equal, false otherwise.

Definition at line 121 of file gate_type.cpp.

References get_gate_library(), and get_id().

◆ set_pin_group_direction()

bool hal::GateType::set_pin_group_direction ( PinGroup< GatePin > *  pin_group,
PinDirection  new_direction 
)

Set the direction of the given pin group.

Parameters
[in]pin_group- The pin group.
[in]new_direction- The direction to be assigned to the pin group.
Returns
true on success, false otherwise.

Definition at line 678 of file gate_type.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), log_warning, and hal::PinGroup< T >::set_direction().

Referenced by hal::gate_type_init().

◆ set_pin_group_name()

bool hal::GateType::set_pin_group_name ( PinGroup< GatePin > *  pin_group,
const std::string &  new_name 
)

Set the name of the given pin group.

Parameters
[in]pin_group- The pin group.
[in]new_name- The name to be assigned to the pin group.
Returns
true on success, false otherwise.

Definition at line 603 of file gate_type.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), log_warning, and hal::PinGroup< T >::set_name().

Referenced by hal::gate_type_init().

◆ set_pin_group_type()

bool hal::GateType::set_pin_group_type ( PinGroup< GatePin > *  pin_group,
PinType  new_type 
)

Set the type of the given pin group.

Parameters
[in]pin_group- The pin group.
[in]new_type- The type to be assigned to the pin group.
Returns
true on success, false otherwise.

Definition at line 655 of file gate_type.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), log_warning, and hal::PinGroup< T >::set_type().

Referenced by hal::gate_type_init().

◆ to_string()

std::string hal::GateType::to_string ( ) const

Get a string describing the given gate type.

Returns
A string describing the gate type.

Definition at line 111 of file gate_type.cpp.

Referenced by hal::gate_type_init().

Friends And Related Function Documentation

◆ GateLibrary

friend class GateLibrary
friend

Definition at line 447 of file gate_type.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const GateType gate_type 
)
friend

Insert the gate type object to an output stream.

Parameters
[in]os- The output stream.
[in]gate_type- The gate type.
Returns
An output stream.

Definition at line 116 of file gate_type.cpp.


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