Jump to content

how to access verilog module internal signals in UVM testbench


mjet08

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,

Link to comment
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.

Link to comment
Share on other sites

  • 11 months later...

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

Link to comment
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...