qinhailiang 1 Report post Posted January 17, 2014 Hi, all There is a piece of code in the function m_add_tw_cbs of the uvm_typed_callbacks#(type T=uvm_object) of the file uvm_callback.sv as follow: if(m_t_inst.m_pool.first(obj)) begin do begin if($cast(me,obj)) begin q = m_t_inst.m_pool.get(obj); if(q==null) begin q=new; m_t_inst.m_pool.add(obj,q); end if(m_cb_find(q,cb) == -1) begin if(ordering == UVM_APPEND) q.push_back(cb); else q.push_front(cb); end end end while(m_t_inst.m_pool.next(obj)); end I want to know whether the red piece is worthless ? Thank you in advanced! BR QIN Quote Share this post Link to post Share on other sites
uwes 17 Report post Posted January 17, 2014 at the first glance this code isnt useless. if obj isnt part of m_t_inst.m_pool (and obj is of a class type) then the pool returns "null" as indication that no object with key "obj" did exist in the pool. if missing its added to the pool. on the second thought the whole code is an iterator over the m_pool key set - so there is an entry for each key. but yet the entry could be "null" through a m_pool.add(key,null) ... i'm not sure if this is scenario is valid ... Quote Share this post Link to post Share on other sites
qinhailiang 1 Report post Posted January 18, 2014 when the m_pool.add(obj, q) is called by the function add(T obj, uvm_callback cb, uvm_apprepend ordering=UVM_APPEND) in the class uvm_callbacks #(type T=uvm_object, type CB=uvm_callback), if q (i.e the entry you said) is null, the q will be newed, i.e the q (the entry) is not null. Quote Share this post Link to post Share on other sites