28 std::unordered_map<Module*,PinChangedEvent::EventStack*> PinChangedEvent::s_event_stack;
29 u64 PinChangedEvent::s_order = 0;
30 int PinChangedEvent::s_bulk_depth = 0;
33 : m_module(m), m_event(pev), m_id(
id), m_order(++s_order)
38 auto it = s_event_stack.find(m_module);
39 if (it == s_event_stack.end())
41 if (s_bulk_depth <= 0)
49 it = s_event_stack.emplace(m_module,
new EventStack).first;
50 it->second->m_sticky =
true;
54 it->second->push_back(*
this);
59 auto it = s_event_stack.find(m);
60 if (it == s_event_stack.end())
63 s_event_stack.erase(it);
73 return (m_id << 4) | (((
u32)m_event)&0xF);
78 if (a.m_event < b.m_event)
return true;
79 if (a.m_event > b.m_event)
return false;
81 return a.m_order > b.m_order;
85 void PinChangedEvent::EventStack::send_events(
Module* m)
88 for (
auto it=begin(); it != end(); ++it)
95 auto it = PinChangedEvent::s_event_stack.find(m);
96 if (it == PinChangedEvent::s_event_stack.end())
98 auto* stack =
new PinChangedEvent::EventStack;
99 stack->m_sticky = (PinChangedEvent::s_bulk_depth > 0);
100 PinChangedEvent::s_event_stack[m] = stack;
103 ++it->second->m_count;
108 auto it = PinChangedEvent::s_event_stack.find(m_module);
109 if (it == PinChangedEvent::s_event_stack.end())
111 if (it->second->m_count > 0)
112 --it->second->m_count;
113 else if (!it->second->m_sticky)
116 PinChangedEvent::s_event_stack.erase(it);
122 auto it = PinChangedEvent::s_event_stack.find(m_module);
123 if (it == PinChangedEvent::s_event_stack.end())
125 if (it->second->m_count > 0)
127 if (it->second->m_sticky)
129 it->second->send_events(m_module);
134 ++PinChangedEvent::s_bulk_depth;
139 if (--PinChangedEvent::s_bulk_depth > 0)
143 std::unordered_map<Module*,PinChangedEvent::EventStack*> stacks;
144 stacks.swap(PinChangedEvent::s_event_stack);
146 for (
auto& [
module, stack] : stacks)
void notify(NetlistEvent::event ev, Netlist *netlist, u32 associated_data=0xFFFFFFFF)
@ pin_changed
associated_data = [4LSB: type of action] [28HSB: id of pin group or pin]
EventHandler * get_event_handler() const
static void discard(Module *m)
PinChangedEvent(Module *m, PinEvent pev, u32 id)
Module * get_module() const
PinChangedEventScope(Module *m)
const Module * module(const Gate *g, const NodeBoxes &boxes)
@ PinsReload
group deleted
@ PinTypeChange
pin renamed
@ GroupReorder
changed PinDirection attribute of group (like input)
@ PinDirChange
changed PinType attribute of pin (like data)
@ PinCreate
moved group to a new position within containing module
@ GroupTypeChange
pin group renamed
@ PinRename
pin assigned to new group
@ PinAssignToGroup
new pin created
@ PinDelete
moved pin to a new position within containing group
@ GroupRename
new pin group created
@ GroupDirChange
changed PinType attribute of group (like data)
@ PinReorder
changed PinDirection attribute of pin (like input)
bool pin_event_order(const PinChangedEvent &a, const PinChangedEvent &b)