From 3fc6cc7763e67ebab76358845b06b94060dd19be Mon Sep 17 00:00:00 2001 From: handsomeliu-google Date: Fri, 18 Oct 2024 20:41:05 +0800 Subject: [PATCH] sim: Make SignalSinkPort::set virtual (#1679) We are implementing derived classes of SignalSinkPort that does some additional logic after it's triggered (set() invoked by SignalSourcePort peer), and before executing the callback that a device provides (in onChange_). The logic is like additional logging, or providing debugging features. However, set() itself directly calls the onChange_ callback. Making the set() virtual could provide the flexibility to achieve this feature. --- src/sim/signal.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sim/signal.hh b/src/sim/signal.hh index 233de07658..e89fbe0b9f 100644 --- a/src/sim/signal.hh +++ b/src/sim/signal.hh @@ -51,12 +51,11 @@ class SignalSinkPort : public Port SignalSourcePort *_source = nullptr; State _state = {}; - OnChangeFunc _onChange; protected: // if bypass_on_change is specified true, it will not call the _onChange // function. Only _state will be updated if needed. - void + virtual void set(const State &new_state, const bool bypass_on_change = false) { if (new_state == _state) @@ -67,6 +66,8 @@ class SignalSinkPort : public Port _onChange(_state); } + OnChangeFunc _onChange; + public: SignalSinkPort(const std::string &_name, PortID _id=InvalidPortID) : Port(_name, _id)