![]() |
HAL
|
#include <gate_type.h>
Public Member Functions | |
ssize_t | get_hash () const |
std::vector< GateTypeComponent * > | get_components (const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const |
GateTypeComponent * | get_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< GateTypeProperty > | get_properties () const |
std::vector< GateTypeProperty > | get_property_list () const |
bool | has_property (GateTypeProperty property) const |
GateLibrary * | get_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 |
GatePin * | get_pin_by_id (const u32 id) const |
GatePin * | get_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) |
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.
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.
[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().
void hal::GateType::add_boolean_functions | ( | const std::unordered_map< std::string, BooleanFunction > & | functions | ) |
Add multiple Boolean functions to the gate type.
[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().
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.
[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 . |
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.
void hal::GateType::assign_property | ( | const GateTypeProperty | property | ) |
Assign a new property to the gate type.
[in] | property | - The property to assign. |
Definition at line 69 of file gate_type.cpp.
Referenced by hal::gate_type_init().
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.
[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 . |
Definition at line 205 of file gate_type.cpp.
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.
[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 . |
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().
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.
[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 . |
Definition at line 426 of file gate_type.cpp.
References ascending, direction, name, pins, start_index, and type.
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.
[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 . |
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 the given pin group.
[in] | pin_group | - The pin group to be deleted. |
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.
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.
[in] | pin | - The pin. |
Definition at line 731 of file gate_type.cpp.
References hal::BasePin< T >::get_name(), and log_warning.
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.
[in] | name | - The name of the Boolean function. |
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().
const std::unordered_map< std::string, BooleanFunction > & hal::GateType::get_boolean_functions | ( | ) | const |
Get all Boolean functions of the gate type.
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().
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.
[in] | filter | - The filter applied to all candidate components. |
Definition at line 42 of file gate_type.cpp.
Referenced by hal::gate_type_init().
|
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.
[in] | filter | - The user-defined filter function applied to all candidate components. |
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().
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.
[in] | filter | - The filter applied to all candidate components, disabled by default. |
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().
GateLibrary * hal::GateType::get_gate_library | ( | ) | const |
Get the gate library this gate type is associated with.
Definition at line 106 of file gate_type.cpp.
Referenced by hal::gate_type_init(), and operator==().
ssize_t hal::GateType::get_hash | ( | ) | const |
Hash function for python binding.
Definition at line 14 of file gate_type.cpp.
Referenced by hal::gate_type_init().
u32 hal::GateType::get_id | ( | ) | const |
Get 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().
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).
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().
std::vector< GatePin * > hal::GateType::get_input_pins | ( | ) | const |
Get an ordered vector of all input pins of the gate type (including inout 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().
const std::string & hal::GateType::get_name | ( | ) | const |
Get the name of the gate type.
Definition at line 64 of file gate_type.cpp.
Referenced by hal::ModuleContextMenu::addGateSubmenu(), hal::GateLibrary::contains_gate_type(), hal::gate_type_init(), hal::GateLibraryWizard::GateLibraryWizard(), hal::GraphicsGate::GraphicsGate(), hal::event_log::handle_gate_event(), hal::GateLibraryManager::handleDeleteType(), hal::GateLibrary::mark_gnd_gate_type(), hal::GateLibrary::mark_vcc_gate_type(), hal::NetlistModificationDecorator::replace_gate(), hal::GatelibraryFrameGeneral::update(), and hal::GateLibraryTabTruthTable::update().
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).
Definition at line 293 of file gate_type.cpp.
References direction, and hal::BasePin< T >::get_direction().
Referenced by hal::gate_type_init().
std::vector< GatePin * > hal::GateType::get_output_pins | ( | ) | const |
Get an ordered vector of all output pins of the gate type (including inout 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 the pin corresponding to the given ID.
[in] | id | - The ID of the pin. |
nullptr
otherwise. Definition at line 301 of file gate_type.cpp.
References log_warning.
Referenced by hal::gate_type_init().
GatePin * hal::GateType::get_pin_by_name | ( | const std::string & | name | ) | const |
Get the pin corresponding to the given name.
[in] | name | - The name of the pin. |
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 the pin group corresponding to the given ID.
[in] | id | - The ID of the pin group. |
nullptr
otherwise. Definition at line 569 of file gate_type.cpp.
References log_warning.
Referenced by hal::gate_type_init().
Get the pin group corresponding to the given name.
[in] | name | - The name of the pin group. |
nullptr
otherwise. Definition at line 586 of file gate_type.cpp.
References log_debug, log_warning, and name.
Referenced by hal::gate_type_init().
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.
[in] | filter | - An optional filter. |
Definition at line 548 of file gate_type.cpp.
Referenced by hal::gate_type_init(), and hal::PinModel::setGate().
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.
[in] | filter | - An optional filter. |
Definition at line 238 of file gate_type.cpp.
References pins.
Referenced by hal::gate_type_init().
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.
[in] | filter | - An optional filter. |
Definition at line 210 of file gate_type.cpp.
References pins.
Referenced by hal::gate_type_init(), hal::GatePinsTreeModel::setGate(), and hal::TEST_F().
std::set< GateTypeProperty > hal::GateType::get_properties | ( | ) | const |
Get the properties assigned to the gate type.
Definition at line 74 of file gate_type.cpp.
Referenced by hal::gate_type_init(), and hal::TEST_F().
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.
Definition at line 79 of file gate_type.cpp.
Referenced by hal::gate_type_init(), hal::GateLibraryWizard::GateLibraryWizard(), and hal::GatelibraryFrameGeneral::update().
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.
Definition at line 144 of file gate_type.cpp.
u32 hal::GateType::get_unique_pin_id | ( | ) |
Get a spare pin ID.
The value of 0 is reserved and represents an invalid ID.
Definition at line 131 of file gate_type.cpp.
bool hal::GateType::has_component_of_type | ( | const GateTypeComponent::ComponentType | type | ) | const |
Check if the gate type contains a component of the specified type.
[in] | type | - The component type to check for. |
Definition at line 54 of file gate_type.cpp.
References hal::GateTypeComponent::get_type(), and type.
Referenced by hal::gate_type_init(), hal::RAMPortWizardPage::initializePage(), hal::FlipFlopWizardPage::setData(), hal::InitWizardPage::setData(), hal::LatchWizardPage::setData(), hal::LUTWizardPage::setData(), hal::RAMWizardPage::setData(), hal::StateWizardPage::setData(), hal::GatelibraryFrameFF::update(), hal::GatelibraryFrameInit::update(), hal::GateLibraryFrameLatch::update(), hal::GatelibraryFrameLut::update(), hal::GateLibraryFrameRAM::update(), hal::GateLibraryFrameRAMPort::update(), hal::GatelibraryFrameState::update(), hal::GatelibraryLutInit::update(), and hal::GateLibraryTabTruthTable::update().
bool hal::GateType::has_property | ( | GateTypeProperty | property | ) | const |
Check whether the gate type has the specified property.
[in] | property | - The property to check for. |
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().
bool hal::GateType::operator!= | ( | const GateType & | other | ) | const |
Check whether two gate types are unequal.
[in] | other | - The gate type object to compare to. |
Definition at line 126 of file gate_type.cpp.
bool hal::GateType::operator== | ( | const GateType & | other | ) | const |
Check whether two gate types are equal.
[in] | other | - The gate type to compare against. |
Definition at line 121 of file gate_type.cpp.
References get_gate_library(), and get_id().
bool hal::GateType::set_pin_group_direction | ( | PinGroup< GatePin > * | pin_group, |
PinDirection | new_direction | ||
) |
Set the direction of the given pin group.
[in] | pin_group | - The pin group. |
[in] | new_direction | - The direction to be assigned to the pin group. |
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().
bool hal::GateType::set_pin_group_name | ( | PinGroup< GatePin > * | pin_group, |
const std::string & | new_name | ||
) |
Set the name of the given pin group.
[in] | pin_group | - The pin group. |
[in] | new_name | - The name to be assigned to the pin group. |
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 the type of the given pin group.
[in] | pin_group | - The pin group. |
[in] | new_type | - The type to be assigned to the pin group. |
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().
std::string hal::GateType::to_string | ( | ) | const |
Get a string describing the given gate type.
Definition at line 111 of file gate_type.cpp.
Referenced by hal::gate_type_init().
|
friend |
Definition at line 447 of file gate_type.h.
|
friend |
Insert the gate type object to an output stream.
[in] | os | - The output stream. |
[in] | gate_type | - The gate type. |
Definition at line 116 of file gate_type.cpp.