Hi Everyone,
I am creating UVM Testbench for a SC model. In this SC-Model one of the slave sockets is using a tlm_generic_payload with extensions.
So, i am trying in the UVM side to define my uvm_tlm_generic_payload & add to it similar extensions like that in SC. so that when i send it using the socket to SC-side, the information inside the extensions could be read & accessed.
I tried the following code in UVM & SC but i also failed to read the extensions correctly in SC:
// Create a simple extension
class my_extension extends uvm_tlm_extension#(my_extension);
int m_add_info;
uvm_object_utils_begin(my_extension)
uvm_field_int(m_add_info, UVM_ALL_ON)
`uvm_object_utils_end
function new(string name = “my_extension”);
super.new(name);
endfunction
endclass
//prepare the generic payload to be sent to SC
uvm_tlm_generic_payload gp = new(“gp”);
uvm_tlm_time delay = new();
byte unsigned data;
//intialization
gp.set_data_length(1);
gp.set_write();
data = '{8'hFF};
m_my_extension = my_extension::type_id::create("m_my_extension");
m_my_extension.m_add_info = 4;
gp.set_extension(m_my_extension);
gp.set_data(data);
// Relay request to TLM receiver
delay.set_abstime(10,1e-9);
my_skt.b_transport(gp, delay);
------------------------SC------------------------
class my_extension : public tlm::tlm_extension<my_extension> {
public:
long m_add_info;
//virtual functions of tlm::tlm_extension
virtual tlm_extension_base* clone() const {
my_extension* ext = new my_extension();
ext->m_add_info = m_add_info;
return ext;
}
virtual void copy_from(tlm_extension_base const & other) {
const my_extension& ext = dynamic_cast<const my_extension&>(other);
m_add_info = ext.m_add_info;
}
};
class my_payload : public tlm::tlm_generic_payload {
public:
my_payload() {
set_extension(new my_extension());
}
~my_payload() {
}
public:
inline void set_Add_Info(long m_add_info) {
my_extension* ext = NULL;
get_extension(ext);
assert(ext);
ext->m_add_info = m_add_info;
}
public:
inline long get_Add_Info() const {
my_extension* ext = NULL;
get_extension(ext);
assert(ext);
return ext->m_add_info;
}
};
Thanks
Hana A.Aziz