How to access a variable inside a UVM class and connect it to an SV interface?

I need to connect a variable present inside a uvm_component class to an interface. I tried using uvm_top to access the sign al and connect it but, it is not working. I need the class variables to be visible on the waveform and for that I am trying to connect them to interface

first I tried
assign intf. a = uvm_top.env.model.x;

Since assign statement wont work I removed and tried without assign and it didn’t work.

any idea would help.

In reply to gpb:

Don’t connect directly - this eliminates any reuse.

Instead, make a method in your interface, set_a(value) that sets the signal a=value. Then you can call this from your testbench with virtual_interface.set_a(value)

There are even better ways to implement this, but all rely on indirectly setting the signal though a method in the interface.