Drive at most N consecutive items to the DUT

I am a beginner in UVM and I would like any suggestion in the following situation:

I am designing the testbench for a DUT, which has 2 agents. One of the agents is master: it sends requests to the DUT and gets a response back after a random number of cycles; one agent is slave: it receives requests from DUT and sends a response back after a random number of cycles.

The DUT should be able to handle up to 3 requests from the master agent. Let’s say:

Clock1 Clock2 Clock3
Req1 Req2 Req3

It is the responsibility of the agent, not to send more then 3 requests.

What is the best way to control the number of sent requests doesn’t exceed 3?

The number of active requests on the DUT are given: driven_req - received_resp and driven_req is visible in the driver, while received_resp is visible in the monitor.

Hope you can help me with any suggestion.

Kind regards

In reply to ML_Burn:

You can use an SystemVerilog semaphore for this. Allocate it with 3 keys. The master driver can wait for a key before getting a request. The monitor can put it back.

You might want to see this for some alternative approaches.