sim: provide a signal constructor with an init_state

Add more description to the code

Change-Id: Iff8fb20762baa0c9d0b7e5f24fb8769d7e198b5c
This commit is contained in:
Johnny
2023-08-23 10:13:32 +08:00
parent 6acb687975
commit 76fe71ebd0

View File

@@ -79,6 +79,7 @@ class SignalSinkPort : public Port
_source = dynamic_cast<SignalSourcePort<State> *>(&peer);
fatal_if(!_source, "Attempt to bind signal pin %s to "
"incompatible pin %s", name(), peer.name());
// The state of sink has to match the state of source.
_state = _source->state();
Port::bind(peer);
}
@@ -104,6 +105,7 @@ class SignalSourcePort : public Port
_state = {};
}
// Give an initial value to the _state instead of using a default value.
SignalSourcePort(const std::string &_name, PortID _id,
const State &init_state)
: SignalSourcePort(_name, _id)