Jump to content

qinhailiang

Members
  • Content Count

    61
  • Joined

  • Last visited

About qinhailiang

  • Rank
    Advanced Member
  1. Hi, all When i read the uvm source code, I had a puzzle as follow: Why are the twelve runtime phases added into m_uvm_schedule phase instead of being added directly m_uvm_domain domain in file uvm_domain.svh? static function void add_uvm_phases(uvm_phase schedule); schedule.add(uvm_pre_reset_phase::get()); schedule.add(uvm_reset_phase::get()); schedule.add(uvm_post_reset_phase::get()); schedule.add(uvm_pre_configure_phase::get()); schedule.add(uvm_configure_phase::get()); schedule.add(uvm_post_configure_phase::get()); schedule.add(uvm_pre_main_phase::get()); schedule.add(uvm_main_phase::get()); schedule.add(uvm_post_main_phase::get()); schedule.add(uvm_pre_shutdown_phase::get()); schedule.add(uvm_shutdown_phase::get()); schedule.add(uvm_post_shutdown_phase::get()); endfunction static function uvm_domain get_uvm_domain(); if (m_uvm_domain == null) begin m_uvm_domain = new("uvm"); m_uvm_schedule = new("uvm_sched", UVM_PHASE_SCHEDULE); add_uvm_phases(m_uvm_schedule); m_uvm_domain.add(m_uvm_schedule); end return m_uvm_domain; endfunction Could the two functions be mergered one function as follow? static function uvm_domain get_uvm_domain(); if (m_uvm_domain == null) begin m_uvm_domain = new("uvm"); m_uvm_domain.add(uvm_pre_reset_phase::get()); m_uvm_domain.add(uvm_reset_phase::get()); m_uvm_domain.add(uvm_post_reset_phase::get()); m_uvm_domain.add(uvm_pre_configure_phase::get()); m_uvm_domain.add(uvm_configure_phase::get()); m_uvm_domain.add(uvm_post_configure_phase::get()); m_uvm_domain.add(uvm_pre_main_phase::get()); m_uvm_domain.add(uvm_main_phase::get()); m_uvm_domain.add(uvm_post_main_phase::get()); m_uvm_domain.add(uvm_pre_shutdown_phase::get()); m_uvm_domain.add(uvm_shutdown_phase::get()); m_uvm_domain.add(uvm_post_shutdown_phase::get()); end return m_uvm_domain; endfunction
  2. Hi, all Thanks for your valuable informaiton. It is very useful to understand the cast operation. Thank you again. BR QIN
  3. Hi, Alan I modified the code as you said above, it worked well. Thank you for your value information. BR QIN
  4. Hi, Zhuang Thank you for your value information. I also want to know what the assignment of P1 with P2 does? BR
  5. Hi, Zhuang I modified the source code as you said as follow: class BasePacket; int A = 1; int C = 2; function void printA; $display("BasePacket::A is %d", A); endfunction : printA virtual function void printC; $display("BasePacket::C is %d", C); endfunction : printC endclass : BasePacket class My_Packet extends BasePacket; int A = 3; int C = 4; function void printA; $display("My_Packet::A is %d", A); endfunction: printA virtual function void printC; $display("My_Packet::C is %d", C); endfunction : printC endclass : My_Packet BasePacket P1 = new; My_Packet P2; initial begin //P1 = P2; P1.printA; P1.printC; $cast(P2, P1); P2.printA; P2.printC; end The simulator also reported fatal error as follow: # BasePacket::A is 1 # BasePacket::C is 2 # ** Error: (vsim-3971) $cast to type 'class work.obc_pkg_sv_unit::My_Packet' from 'class work.obc_pkg_sv_unit::BasePacket' failed in file ../../sv/top/bip4_vtop.sv at line 77. # Time: 0 ps Iteration: 0 Instance: /bip4_vtop # ** Fatal: (SIGSEGV) Bad handle or reference. # Time: 0 ps Iteration: 0 Process: /bip4_vtop/#INITIAL#73 File: ../../sv/top/bip4_vtop.sv # Fatal error in Function obc_pkg_sv_unit/My_Packet::printA at ../../sv/top/bip4_vtop.sv line 20 Could you like to explain the reason? Thank you in advanced. BR QIN
  6. Hi, all //Case One class BasePacket; int A; endclass : BasePacket class My_Packet extends BasePacket; int C; endclass : My_Packet class BaseTest; BasePacket PB[string]; virtual function void Create_PKT(string s); PB = new(); endfunction : Create_PKT virtual function void Configure_PKT(string s); PB.A = 1; endfunction : Configure_PKT virtual function void printP(string s); $display("BaseTest::PB[%s].A is %d", s, PB.A); endfunction : printP endclass : BaseTest class My_Test extends BaseTest; virtual function void Create_PKT(string s); My_Packet MP = new(); PB = MP; endfunction : Create_PKT virtual function void Configure_PKT(string s); // My_Packet mp; super.Configure_PKT(s); My_Packet mp; $cast(mp, PB); mp.C = 2; PB = mp; endfunction : Configure_PKT virtual function void printP(string s); // My_Packet mp; super.printP(s); My_Packet mp; $cast(mp, PB); $display("My_test::PB[%s].C is %d", s, mp.C); endfunction : printP endclass : My_Test BaseTest T1 = new(); My_Test T2 = new(); initial begin T1.Create_PKT("StringBase"); T1.Configure_PKT("StringBase"); T1.printP("StringBase"); T2.Create_PKT("MY_String"); T2.Configure_PKT("MY_String"); T2.printP("MY_String"); end //Output Information (Compiler Report Error) // //near "mp": syntax error, unexpected IDENTIFIER, expecting # //Case Two class BasePacket; int A; endclass : BasePacket class My_Packet extends BasePacket; int C; endclass : My_Packet class BaseTest; BasePacket PB[string]; virtual function void Create_PKT(string s); PB = new(); endfunction : Create_PKT virtual function void Configure_PKT(string s); PB.A = 1; endfunction : Configure_PKT virtual function void printP(string s); $display("BaseTest::PB[%s].A is %d", s, PB.A); endfunction : printP endclass : BaseTest class My_Test extends BaseTest; virtual function void Create_PKT(string s); My_Packet MP = new(); PB = MP; endfunction : Create_PKT virtual function void Configure_PKT(string s); My_Packet mp; super.Configure_PKT(s); //My_Packet mp; $cast(mp, PB); mp.C = 2; PB = mp; endfunction : Configure_PKT virtual function void printP(string s); My_Packet mp; super.printP(s); //My_Packet mp; $cast(mp, PB); $display("My_test::PB[%s].C is %d", s, mp.C); endfunction : printP endclass : My_Test BaseTest T1 = new(); My_Test T2 = new(); initial begin T1.Create_PKT("StringBase"); T1.Configure_PKT("StringBase"); T1.printP("StringBase"); T2.Create_PKT("MY_String"); T2.Configure_PKT("MY_String"); T2.printP("MY_String"); end //Output Information // //# BaseTest::PB[stringBase].A is 1 //# BaseTest::PB[MY_String].A is 1 //# My_test::PB[MY_String].C is 2 I designed two cases as above, ran case one, the simulator reported error as above. Would like to tell me the different of the declaration class handle before and after the super call? Thank you in advanced. BR QIN
  7. Hi, all I has an example as follow: class BasePacket; int A = 1; int C = 2; function void printA; $display("BasePacket::A is %d", A); endfunction : printA virtual function void printC; $display("BasePacket::C is %d", C); endfunction : printC endclass : BasePacket class My_Packet extends BasePacket; int A = 3; int C = 4; function void printA; $display("My_Packet::A is %d", A); endfunction: printA virtual function void printC; $display("My_Packet::C is %d", C); endfunction : printC endclass : My_Packet BasePacket P1 = new; My_Packet P2 = new; Case one: initial begin //P1 = P2; P1.printA; P1.printC; $cast(P2, P1); P2.printA; P2.printC; end ... # BasePacket::A is 1 # BasePacket::C is 2 # ** Error: (vsim-3971) $cast to type 'class work.obc_pkg_sv_unit::My_Packet' from 'class work.obc_pkg_sv_unit::BasePacket' failed in file ../../sv/top/bip4_vtop.sv at line 80. # Time: 0 ps Iteration: 0 Instance: /bip4_vtop # My_Packet::A is 3 # My_Packet::C is 4 ... Case Two: initial begin P1 = P2; P1.printA; P1.printC; $cast(P2, P1); P2.printA; P2.printC; end ... # BasePacket::A is 1 # My_Packet::C is 4 # My_Packet::A is 3 # My_Packet::C is 4 ... Case one, I didn't assign P1 with P2, the simulator reported error information as above; the type of P1 is not a superclass of the P2 type? Case twon, I assign P1 with P2 at the begbining, the simulator reported normally as above; Why the assignment of P2 with P1 is cast-compatible after assigned P1 with P2? How to do the simulator judge the cast-compatible? So I want to know what the assignment of P1 with P2 does? Thank you in advanced. BR QIN
  8. 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.
  9. 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
  10. Hi, all We have one monitor and one driver as follow: class monitor extends uvm_monitor; `uvm_component_utils(monitor) function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual task post_shutdown_phase(uvm_phase phase); #50ns; `uvm_info(get_type_name(), "Monitor is printing at post_shutdown_phase executing...", UVM_LOW ) endtask: post_shutdown_phase virtual function void phase_ready_to_end(uvm_phase phase); if(phase.get_name == "post_shutdown") `uvm_info(get_type_name(), "Monitor is printing at phase_ready_to_end...", UVM_LOW ) endfunction: phase_ready_to_end virtual function void phase_ended(uvm_phase phase); if(phase.get_name == "post_shutdown") `uvm_info(get_type_name(), "Monitor is printing at phase_ended...", UVM_LOW ) endfunction: phase_ended endclass : monitor class driver extends uvm_driver; `uvm_component_utils(driver) function new(string name, uvm_component parent); super.new(name); endfunction task run_phase(uvm_phase phase); phase.raise_objection(this, "Starting test"); #100ns; `uvm_info(get_type_name(), "Driver is printing at run_phase executing...", UVM_LOW ) phase.drop_objection(this, "Finishing test"); endtask: run_phase virtual function void phase_ready_to_end(uvm_phase phase); if(phase.get_name == "run") `uvm_info(get_type_name(), "Driver is printing at phase_ready_to_end...", UVM_LOW ) endfunction: phase_ready_to_end virtual function void phase_ended(uvm_phase phase); if(phase.get_name == "run") `uvm_info(get_type_name(), "Driver is printing at phase_ended...", UVM_LOW ) endfunction: phase_ended endclass: driver when it run one of cases, it printed the information as follow: # UVM_INFO @ 0: reporter [RNTST] Running test tc_read_ver_reg... # UVM_INFO ../../monitor.sv(41) @ 0: uvm_test_top.tb.agent.monitor [monitor] Monitor is printing at phase_ready_to_end... # UVM_INFO ../../monitor.sv(35) @ 50000: uvm_test_top.tb.agent.monitor [monitor] Monitor is printing at post_shutdown_phase executing... # UVM_INFO ../../driver.sv(22) @ 100000: uvm_test_top.tb.agent.driver [driver] Driver is printing at run_phase executing... # UVM_INFO ../../driver.sv(28) @ 100000: uvm_test_top.tb.agent.driver [driver] Driver is printing at phase_ready_to_end... # UVM_INFO ../../monitor.sv(48) @ 100000: uvm_test_top.tb.agent.monitor [monitor] Monitor is printing at phase_ended... # UVM_INFO ../../driver.sv(34) @ 100000: uvm_test_top.tb.agent.driver [driver] Driver is printing at phase_ended... # The post_shutdown_phase of the monitor reached to phase_ready_to_end at 0, but it's task post_shutdown_phase did not finish until @ 50000. What is wrong with it? Thank you in advanced! BR QIN
  11. Hi, all Why is not the 12 realtime phases directly wrapped by m_uvm_domain but also the m_uvm_schedule is inserted between m_uvm_domain and the 12 realtime phases? Thank you in advanced! BR QIN
×
×
  • Create New...