sanketshah Posted November 15, 2012 Report Share Posted November 15, 2012 Can we use semaphore in Systemverilog function? Can we call put and get implementation task from the function in UVM? Quote Link to comment Share on other sites More sharing options...
uwes Posted November 15, 2012 Report Share Posted November 15, 2012 >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? Quote Link to comment Share on other sites More sharing options...
sanketshah Posted November 15, 2012 Author Report Share Posted November 15, 2012 >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? Quote Link to comment Share on other sites More sharing options...
dave_59 Posted November 15, 2012 Report Share Posted November 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
sanketshah Posted November 15, 2012 Author Report Share Posted November 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
dave_59 Posted November 15, 2012 Report Share Posted November 15, 2012 Don't implement any write functions and use analysis fifos instead. Have your component arbitrate by peeking into each fifo and then selecting one of them to get() from the fifo. Quote Link to comment Share on other sites More sharing options...
sanketshah Posted November 15, 2012 Author Report Share Posted November 15, 2012 I have to use write functions because My each monitor broadcasts the same information to its scoreboard. What is the use of implementing analysis fifos? I do not know how to arbitrate by peeking into each FIFO and selecting them using get from FIFO. Can you elaborate on that please? Quote Link to comment Share on other sites More sharing options...
janick Posted November 15, 2012 Report Share Posted November 15, 2012 Or have each write_*() method put the transaction in an infinite mailbox using try_put() and have the upper layer pull them out of the other end of the mailbox. Quote Link to comment Share on other sites More sharing options...
sanketshah Posted November 15, 2012 Author Report Share Posted November 15, 2012 Hey Janick, How can I call try_put method from write_*() functions ?? because write is function and try_put is task. I believe function can not call task. Quote Link to comment Share on other sites More sharing options...
sanketshah Posted November 15, 2012 Author Report Share Posted November 15, 2012 Hey Janick, I believe, I can try what you said, try_put is a function. Thanks for the reply. Quote Link to comment Share on other sites More sharing options...
dave_59 Posted November 15, 2012 Report Share Posted November 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
sanketshah Posted November 16, 2012 Author Report Share Posted November 16, 2012 Hey Dave, Means, I will have to implement try_put method inside my receiving class. What happens if all write_() functions calls this method at the same time? Means write_a, write_b and write_c calls try_put method at the same time. Quote Link to comment Share on other sites More sharing options...
dave_59 Posted November 16, 2012 Report Share Posted November 16, 2012 (edited) 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 endclassThis is essentially what is inside the uvm_in_order_comparator. Edited November 16, 2012 by dave_59 up_level_port correction Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.