pub struct Port<I: ?Sized + 'static> { /* private fields */ }Expand description
A port: a component’s request for an interface it does not own.
One generic struct serves all three kinds, since the only difference is
which interface it holds — PutPort, GetPort and PeekPort are
aliases, not separate types.
The binding lives behind Rc<RefCell<..>> because connection happens
through erasure: connect reaches the port as an Rc<dyn Any> and must
write to it, so the mutability has to be interior. The component’s own
field and the handle connect obtains are two Rcs to the same cell.
Implementations§
Source§impl<T: 'static> Port<dyn PublishIf<T>>
impl<T: 'static> Port<dyn PublishIf<T>>
Sourcepub fn write(&self, item: &T)
pub fn write(&self, item: &T)
Broadcast an item. Returns immediately, however many subscribers are
listening — including none, which is why this does not panic on an
unconnected port the way put does. A source that nobody watches is a
legitimate testbench (D85).
Sourcepub fn has_subscribers(&self) -> bool
pub fn has_subscribers(&self) -> bool
Is anyone listening?
Source§impl<T: 'static> Port<dyn SinkHandle<T>>
impl<T: 'static> Port<dyn SinkHandle<T>>
Sourcepub fn subscribe<S: Subscriber<T>>(&self, subscriber: RustdvShared<S>)
pub fn subscribe<S: Subscriber<T>>(&self, subscriber: RustdvShared<S>)
Supply the receiver: hand the port a handle to the subscriber whose
write should run for every item.
Called in the subscriber’s build, before any connect phase runs, so
it is already in place when the hub comes looking for it. connect
chooses the stream; subscribe supplies the receiver.
Sourcepub fn subscriber(&self) -> Option<Rc<dyn SinkHandle<T>>>
pub fn subscriber(&self) -> Option<Rc<dyn SinkHandle<T>>>
The subscriber this port was given, if subscribe was called.
Source§impl<REQ: 'static, RSP: 'static> Port<dyn SeqItemIf<REQ, RSP>>
impl<REQ: 'static, RSP: 'static> Port<dyn SeqItemIf<REQ, RSP>>
Sourcepub async fn get_next_item(&self) -> SeqItem<REQ>
pub async fn get_next_item(&self) -> SeqItem<REQ>
Block until a sequence has an item ready for this driver.
Sourcepub fn try_next_item(&self) -> Option<SeqItem<REQ>>
pub fn try_next_item(&self) -> Option<SeqItem<REQ>>
Take an item only if one is waiting (the UVM’s try_next_item).
A driver that must also do something else this clock edge cannot
afford the blocking form.
Sourcepub fn put_response(&self, id: TxnId, rsp: RSP)
pub fn put_response(&self, id: TxnId, rsp: RSP)
Answer a request that was released earlier — the pipelined case.
Sourcepub fn bind_iface(&self, iface: Rc<dyn SeqItemIf<REQ, RSP>>)
pub fn bind_iface(&self, iface: Rc<dyn SeqItemIf<REQ, RSP>>)
Bind this port directly, for a component that is handed its export at
construction rather than wired in a connect phase.