Jump to content

Semaphore/uvm port


Recommended Posts

>Can we use semaphore in Systemverilog function?

depends what you mean. you can instantiate it in a function, call put(),try_get() BUT you cant directly invoke get() since this could block if there are insufficient keys avail. and since you are in a function you cant have anything blocking in there.

>Can we call put and get implementation task from the function in UVM?

what do you mean TLM/semaphore or something else?

Link to comment
Share on other sites

>Can we use semaphore in Systemverilog function?

depends what you mean. you can instantiate it in a function, call put(),try_get() BUT you cant directly invoke get() since this could block if there are insufficient keys avail. and since you are in a function you cant have anything blocking in there.

>Got it.

>Can we call put and get implementation task from the function in UVM?

what do you mean TLM/semaphore or something else?

> I have three analysis ports and for that I have implemented three write functions in a class. Now I want to share a resource among this functions. One way I thought is to use semaphore, but we can only use it in task or any other procedural block but analysis implements write function not task. The other way I can think of is to implement own analysis port and implementation port where I can code my own write task instead using inbuilt write function. Is there any other way that I can share piece of code among write functions?

Link to comment
Share on other sites

You are going to have to explain a little more about the resource you want to share. The analysis port write methods are functions and therefore cannot be active concurrently.

Perhaps you meant to use three analysis fifos and have the subscriber class arbitrate which fifos it does a get() from.

Link to comment
Share on other sites

Lets say, I have three monitors and all of them have analysis port. Now I have only one component which implements this write functions. For example write_a, write_b, and write_c. Monitor1 one calls ap.write_a, Monitor2 calls ap.write_b, and Monitor3 calls ap.write_c. According to new UVM feature, We can have multiple write functions. Each monitor may call their respective functions as they observe the transaction, which happens randomly. Now I want to send only one of this at a time to upper layer if they all arrive at the same time. Because I have some priority issue among this transactions. So I want to implement semaphore among this functions. Basically, I want to implement inter process communication among functions which is not possible.

Let me know if you have further questions.

Link to comment
Share on other sites

try_put() is a function that returns true if the put succeeds, which is always the case for an unbounded mailbox. That is exactly what an analysis_fifo is. You can have multiple subscribers on one analysis port. One subscriber would be the scoreboard, and the other is this component that you seem to require. Look at the code for the uvm_in_order_comparator.

Link to comment
Share on other sites

No, use the run_phase in your receiving class.

class receiving_class extends uvm_component;
  uvm_tlm_analysis_fifo #(T) a_fifo;
  uvm_tlm_analysis_fifo #(T) b_fifo;
  uvm_tlm_analysis_fifo #(T) c_fifo;

  uvm_blocking_put_port #(T) up_level_port;

  task run_phase(uvm_phase phase);
  T a,b,c;
  forever begin
         fork
              a_fifo.get(a);
              b_fifo.get(;
              c_fifo.get(c);
         join
        // figure out what you want to do with a, b, or c
       ....
       up_level_port.put(a_or_b_or_c);
       end
endtask
endclass
This is essentially what is inside the uvm_in_order_comparator. Edited by dave_59
up_level_port correction
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...