How to make UVM build_phase cooperate with build function in SVunit

93 views
Skip to first unread message

Nan Ni

unread,
Dec 7, 2016, 5:26:48 AM12/7/16
to SVUnit User Group
I'm new to UVM and SVunit. As i'm trying to write a unit test for scoreboard, I found that if the uvm_analysis_imp port is instantiated in build phase of scoreboard and if we connect it to a uvm_analysis_port in build function of scoreboard_unit_test module, there will be a null handle problem. It seems that the build phase of scoreboard is executed later than the build() function inside module. If I put the instatiation of the uvm_analysis_imp into constructor of scoreboard, there will be no problem. But we cannot simply change the UUT to fit our test right? If I still want to keep every instatiation inside build phase, what can i do with this problem?

neil johnson

unread,
Dec 12, 2016, 6:42:39 PM12/12/16
to SVUnit User Group
I usually handle this kind of stuff in the wrapper class that's created inside the _unit_test.sv file (assuming it's created with create_unit_test.pl using the -uvm switch). particularly if you need to satisfy any uvm connectivity, you can instantiate fifos/ports/whatever in the wrapper and connect everything in the connect_phase (similar to how it'd be done in a real env).

fwiw... before the wrapper, I did actually change a uvm class so that it was easier to unit test. I found some of the uvm conventions to be arbitrary and breaking them didn't matter except for people wondering why I'd consider doing such a thing :)

-neil

Nan Ni

unread,
Dec 15, 2016, 7:42:18 AM12/15/16
to SVUnit User Group
Hi Neil,

Thank you for your answer. The problem is perfectly solved with the wrapper class. 

I did also change the uvm class at first, just for the sake of testing the functionality. But as the uvm classes were written by my boss, he would really not be happy if I changed his codes. :)   
Reply all
Reply to author
Forward
0 new messages