46 #include <type_traits>
47 #include <unordered_map>
48 #include <unordered_set>
54 class NetlistInternalManager;
75 bool operator==(
const Module& other)
const;
84 bool operator!=(
const Module& other)
const;
91 ssize_t get_hash()
const;
105 std::string get_name()
const;
112 void set_name(
const std::string&
name);
119 std::string get_type()
const;
126 void set_type(
const std::string&
type);
140 int get_submodule_depth()
const;
148 Module* get_parent_module()
const;
159 std::vector<Module*> get_parent_modules(
const std::function<
bool(
Module*)>& filter =
nullptr,
bool recursive =
true)
const;
168 bool set_parent_module(
Module* new_parent);
177 bool is_parent_module_of(
const Module*
module,
bool recursive =
false)
const;
188 std::vector<Module*> get_submodules(
const std::function<
bool(
Module*)>& filter =
nullptr,
bool recursive =
false)
const;
197 bool is_submodule_of(
const Module*
module,
bool recursive =
false)
const;
207 bool contains_module(
const Module* other,
bool recursive =
false)
const;
214 bool is_top_module()
const;
244 bool contains_net(
Net*
net,
bool recursive =
false)
const;
251 const std::unordered_set<Net*>& get_nets()
const;
262 std::unordered_set<Net*> get_nets(
const std::function<
bool(
Net*)>& filter,
bool recursive =
false)
const;
269 const std::unordered_set<Net*>& get_input_nets()
const;
276 const std::unordered_set<Net*>& get_output_nets()
const;
283 const std::unordered_set<Net*>& get_internal_nets()
const;
291 bool is_input_net(
Net*
net)
const;
299 bool is_output_net(
Net*
net)
const;
307 bool is_internal_net(
Net*
net)
const;
321 u32 get_unique_pin_id();
329 u32 get_unique_pin_group_id();
372 std::vector<ModulePin*> get_pins(
const std::function<
bool(
ModulePin*)>& filter =
nullptr)
const;
381 std::vector<std::string> get_pin_names(
const std::function<
bool(
ModulePin*)>& filter =
nullptr)
const;
388 std::vector<ModulePin*> get_input_pins()
const;
395 std::vector<std::string> get_input_pin_names()
const;
402 std::vector<ModulePin*> get_output_pins()
const;
409 std::vector<std::string> get_output_pin_names()
const;
418 std::vector<PinGroup<ModulePin>*> get_pin_groups(
const std::function<
bool(
PinGroup<ModulePin>*)>& filter =
nullptr)
const;
468 bool set_pin_name(
ModulePin* pin,
const std::string& new_name,
bool force_name =
false);
494 const std::string&
name,
495 const std::vector<ModulePin*>
pins = {},
500 bool delete_empty_groups =
true,
501 bool force_name =
false);
518 const std::vector<ModulePin*>
pins = {},
523 bool delete_empty_groups =
true,
524 bool force_name =
false);
552 bool set_pin_group_name(
PinGroup<ModulePin>* pin_group,
const std::string& new_name,
bool force_name =
false);
617 bool assign_gate(
Gate* gate);
626 bool assign_gates(
const std::vector<Gate*>& gates);
635 bool remove_gate(
Gate* gate);
644 bool remove_gates(
const std::vector<Gate*>& gates);
654 bool contains_gate(
Gate* gate,
bool recursive =
false)
const;
664 Gate* get_gate_by_id(
const u32 id,
bool recursive =
false)
const;
671 const std::vector<Gate*>& get_gates()
const;
682 std::vector<Gate*> get_gates(
const std::function<
bool(
Gate*)>& filter,
bool recursive =
false)
const;
697 struct NetConnectivity
699 bool has_internal_source;
700 bool has_internal_destination;
701 bool has_external_source;
702 bool has_external_destination;
715 std::unordered_map<u32, Module*> m_submodules_map;
716 std::vector<Module*> m_submodules;
720 std::set<u32> m_used_pin_ids;
721 std::set<u32> m_free_pin_ids;
722 u32 m_next_pin_group_id;
723 std::set<u32> m_used_pin_group_ids;
724 std::set<u32> m_free_pin_group_ids;
726 u32 m_next_input_index = 0;
727 u32 m_next_inout_index = 0;
728 u32 m_next_output_index = 0;
730 std::vector<std::unique_ptr<ModulePin>> m_pins;
731 std::unordered_map<u32, ModulePin*> m_pins_map;
732 std::unordered_map<std::string, ModulePin*> m_pin_names_map;
733 std::vector<std::unique_ptr<PinGroup<ModulePin>>> m_pin_groups;
734 std::unordered_map<u32, PinGroup<ModulePin>*> m_pin_groups_map;
735 std::unordered_map<std::string, PinGroup<ModulePin>*> m_pin_group_names_map;
736 std::list<PinGroup<ModulePin>*> m_pin_groups_ordered;
739 std::unordered_map<u32, Gate*> m_gates_map;
740 std::vector<Gate*> m_gates;
742 std::unordered_set<Net*> m_nets;
743 std::unordered_set<Net*> m_input_nets;
744 std::unordered_set<Net*> m_output_nets;
745 std::unordered_set<Net*> m_internal_nets;
749 NetConnectivity check_net_endpoints(
const Net*
net)
const;
752 bool remove_pin_net(
Net*
net);
754 bool delete_pin_internal(
ModulePin* pin);
const Module * module(const Gate *g, const NodeBoxes &boxes)
std::vector< PinInformation > pins