Jump to content
mjet08

how to access verilog module internal signals in UVM testbench

Recommended Posts

if you want to read the signal, here is one solution:

task read;
  wait(top.dut.internal_module.signal == 1'b1);
  //do something
endtask: read

You can use force to drive the signal:

task drive;
  force top.dut.internal_module.signal = 1'b1;
  // do something
  release top.dut.internal_module.signal;

endtask: drive

Best regards,

Share this post


Link to post
Share on other sites

Be aware that adding any kind of hierarchical path like that would make your driver and monitor non-reusable. It also only works with Verilog, since hierarchical paths aren't allowed in VHDL. If you want more flexibility you can go the long way of binding an interface inside the DUT and assigning that to your monitor and driver.

interface whitebox_if(
  input logic some_signal,
  input logic some_other_signal
);
endinterface


// somewhere in your top level
bind dut whitebox_if wb_if;

initial
  uvm_config_db #(whitebox_if)::set(null, "*", dut.wb_if);

This way you can reuse your components on different projects even if the path to the signal you want changes.

Share this post


Link to post
Share on other sites

Hi Tudor,

 

VHDL 2008 does allow hierarchical signals. However of course for use cross-language, you are at the mercy of your simulator.

 

regards

Alan

 

P.S. bind is better of course as you say - and cross-language bind works, again subject to your simulator.

Share this post


Link to post
Share on other sites

Be aware that adding any kind of hierarchical path like that would make your driver and monitor non-reusable. It also only works with Verilog, since hierarchical paths aren't allowed in VHDL. If you want more flexibility you can go the long way of binding an interface inside the DUT and assigning that to your monitor and driver.

interface whitebox_if(
  input logic some_signal,
  input logic some_other_signal
);
endinterface


// somewhere in your top level
bind dut whitebox_if wb_if;

initial
  uvm_config_db #(whitebox_if)::set(null, "*", dut.wb_if);

This way you can reuse your components on different projects even if the path to the signal you want changes.

 

Hi Tudor,

 

I have a similar problem but I do not understand the solution you proposed. 

 

If I need to read a certain internal signal, supposing this signal is "sig" inside a DUT submodule "sub 1". Where should I put that specific signal? In which way? 

 

Thank you in advance

Share this post


Link to post
Share on other sites
interface whitebox_if(
  input logic sig
);
endinterface

module top;

  Dut inst_dut (...); // instantiate DUT

  bind inst_dut whitebox_if wb_if( sub_1.sig ); // bind interface to DUT + connect internal signals

  initial
    uvm_config_db #(virtual whitebox_if)::set(null, "*", dut.wb_if); // place (bound/buried) interface into database

endmodule



Then if your testbench needs the signal, just do a database "get" of the virtual interface.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×