Device-mode (reactive) UVM agents
In implementing the i2c_agent (device-mode), Tung has found some uvm materials which recommend having the monitor capture the request from the bus (if), and send it to a uvm_tlm_analysis_fifo in the sequencer which is connected to the driver, thus is driven onto the bus.
It seems to me there is no reason to go through the sequencer. The way I've implemented device-mode in an agent is to add a uvm_tlm_analysis_fifo to the driver and a uvm_analysis_port to the monitor and connect them in the agent. Then when the monitor captures a request, it sends it to this ap which is connected to the driver, which then drives the response on the bus.
I believe the i2c is the first agent in device-mode. I recommend Tung implements it like we have in the past with the monitor connected directly to the driver but I wanted to see if the opentitan community has implemented differently or has planned for a different implementation.
Probably, the material is this paper (the bible of the reactive UVM agent) ? https://www.verilab.com/files/mastering_reactive_slaves.pdf
Actually the TL agent is already operational in both host and device modes (heavily used in XBAR DV). The UART agent also operates in device mode, but it's a different case (device path and host path are async and disjoint). SPI agent will soon get support for device mode in light of upcoming RTL changes.
I think the advantage of having the monitor->sequencer TLM port connection is the ability to directly grab the in-flight host-initiated request from within the sequence via the p_sequencer handle and pattern the response exactly as needed.
hw/dv/sv/tl_agent/tl_seq_lib.sv:
class tl_device_seq ...
...
virtual task body();
fork
forever begin // collect req thread
int req_cnt;
tl_seq_item req;
// directly access in-flight req captured by monitor from within the sequence
p_sequencer.a_chan_req_fifo.get(req);
req_q.push_back(req);
`uvm_info(`gfn, $sformatf("Received req[%0d] : %0s",
req_cnt, req.convert2string()), UVM_HIGH)
req_cnt++;
end
// in another thread, I pop req from the req_q and send exactly the response I want
...
If we made a monitor -> driver TLM connection, we lose this capability. In that case, the sequence would have to "blindly" send response packets to the sequencer (and hence the driver) since it no longer has the knowledge of when and what transactions arrive on the bus. There is some degree of loss of controllability.
Having said that, I don't think we are recommending one approach over the other (if we are, please send me a pointer!). It may be perfectly ok to have monitor -> driver TLM connection instead as long as the loss of controllability from a higher level sequence is known and acceptable.
Thanks for the pointer @eunchan - it reinforces the rationale of our existing approach.
@senelson7 can this issue be closed?