33a34
> #include <vector>
35a37,38
> #include "sim/eventq.hh"
> #include "systemc/core/bindinfo.hh"
38a42
> #include "systemc/ext/core/sc_interface.hh"
39a44
> #include "systemc/ext/core/sc_port.hh"
44a50,245
> class Sensitivity
> {
> protected:
> Process *process;
> void satisfy();
>
> public:
> Sensitivity(Process *p) : process(p) {}
> virtual ~Sensitivity() {}
>
> virtual void notifyWork(Event *e) { satisfy(); }
> void notify(Event *e);
> void notify() { notify(nullptr); }
>
> const std::string name();
> };
>
> class SensitivityTimeout : virtual public Sensitivity
> {
> private:
> EventWrapper<Sensitivity, &Sensitivity::notify> timeoutEvent;
> ::sc_core::sc_time timeout;
>
> public:
> SensitivityTimeout(Process *p, ::sc_core::sc_time t);
> ~SensitivityTimeout();
> };
>
> class SensitivityEvent : virtual public Sensitivity
> {
> private:
> const ::sc_core::sc_event *event;
>
> public:
> SensitivityEvent(Process *p, const ::sc_core::sc_event *e);
> ~SensitivityEvent();
> };
>
> //XXX This sensitivity can't be reused. To reset it, it has to be deleted and
> //recreated. That works for dynamic sensitivities, but not for static.
> //Fortunately processes can't be statically sensitive to sc_event_and_lists.
> class SensitivityEventAndList : virtual public Sensitivity
> {
> private:
> const ::sc_core::sc_event_and_list *list;
> int count;
>
> public:
> SensitivityEventAndList(
> Process *p, const ::sc_core::sc_event_and_list *list);
> ~SensitivityEventAndList();
>
> virtual void notifyWork(Event *e) override;
> };
>
> class SensitivityEventOrList : virtual public Sensitivity
> {
> private:
> const ::sc_core::sc_event_or_list *list;
>
> public:
> SensitivityEventOrList(
> Process *p, const ::sc_core::sc_event_or_list *list);
> ~SensitivityEventOrList();
> };
>
> // Combined sensitivities. These trigger when any of their parts do.
>
> class SensitivityTimeoutAndEvent :
> public SensitivityTimeout, public SensitivityEvent
> {
> public:
> SensitivityTimeoutAndEvent(
> Process *p, ::sc_core::sc_time t, const ::sc_core::sc_event *e) :
> Sensitivity(p), SensitivityTimeout(p, t), SensitivityEvent(p, e)
> {}
> };
>
> class SensitivityTimeoutAndEventAndList :
> public SensitivityTimeout, public SensitivityEventAndList
> {
> public:
> SensitivityTimeoutAndEventAndList(
> Process *p, ::sc_core::sc_time t,
> const ::sc_core::sc_event_and_list *eal) :
> Sensitivity(p), SensitivityTimeout(p, t),
> SensitivityEventAndList(p, eal)
> {}
> };
>
> class SensitivityTimeoutAndEventOrList :
> public SensitivityTimeout, public SensitivityEventOrList
> {
> public:
> SensitivityTimeoutAndEventOrList(
> Process *p, ::sc_core::sc_time t,
> const ::sc_core::sc_event_or_list *eol) :
> Sensitivity(p), SensitivityTimeout(p, t),
> SensitivityEventOrList(p, eol)
> {}
> };
>
> typedef std::vector<Sensitivity *> Sensitivities;
>
>
> /*
> * Pending sensitivities. These are records of sensitivities to install later,
> * once all the information to configure them is available.
> */
>
> class PendingSensitivity
> {
> protected:
> Process *process;
>
> public:
> virtual void finalize(Sensitivities &s) = 0;
> PendingSensitivity(Process *p) : process(p) {}
> virtual ~PendingSensitivity() {}
> };
>
> class PendingSensitivityEvent : public PendingSensitivity
> {
> private:
> const sc_core::sc_event *event;
>
> public:
> PendingSensitivityEvent(Process *p, const sc_core::sc_event *e) :
> PendingSensitivity(p), event(e) {}
>
> void
> finalize(Sensitivities &s) override
> {
> s.push_back(new SensitivityEvent(process, event));
> }
> };
>
> class PendingSensitivityInterface : public PendingSensitivity
> {
> private:
> const sc_core::sc_interface *interface;
>
> public:
> PendingSensitivityInterface(Process *p, const sc_core::sc_interface *i) :
> PendingSensitivity(p), interface(i)
> {}
>
> void
> finalize(Sensitivities &s) override
> {
> s.push_back(new SensitivityEvent(process,
> &interface->default_event()));
> }
> };
>
> class PendingSensitivityPort : public PendingSensitivity
> {
> private:
> const sc_core::sc_port_base *port;
>
> public:
> PendingSensitivityPort(Process *p, const sc_core::sc_port_base *pb) :
> PendingSensitivity(p), port(pb)
> {}
>
> void
> finalize(Sensitivities &s) override
> {
> for (int i = 0; i < port->size(); i++) {
> const ::sc_core::sc_event *e =
> &port->_gem5BindInfo[i]->interface->default_event();
> s.push_back(new SensitivityEvent(process, e));
> }
> }
> };
>
> class PendingSensitivityFinder : public PendingSensitivity
> {
> private:
> const sc_core::sc_event_finder *finder;
>
> public:
> PendingSensitivityFinder(Process *p, const sc_core::sc_event_finder *f) :
> PendingSensitivity(p), finder(f)
> {}
>
> void
> finalize(Sensitivities &s) override
> {
> s.push_back(new SensitivityEvent(process, &finder->find_event()));
> }
> };
>
> typedef std::vector<PendingSensitivity *> PendingSensitivities;
>
>
81c282
< void dontInitialize() { popListNode(); }
---
> void dontInitialize();
84a286,287
> void finalize();
>
86a290,292
> void addStatic(PendingSensitivity *);
> void setDynamic(Sensitivity *);
>
96c302,307
< virtual ~Process() { delete func; }
---
> virtual ~Process()
> {
> delete func;
> for (auto s: staticSensitivities)
> delete s;
> }
115a327,331
>
> Sensitivities staticSensitivities;
> PendingSensitivities pendingStaticSensitivities;
>
> Sensitivity *dynamicSensitivity;
117a334,346
> inline void
> Sensitivity::notify(Event *e)
> {
> if (!process->disabled())
> notifyWork(e);
> }
>
> inline const std::string
> Sensitivity::name()
> {
> return std::string(process->name()) + ".timeout";
> }
>