Hello,
I have a class extending from uvm_reg_cbs (not a component) which creates some messages that need to be redirected and formatted to different file, I know that I could use $fopen, $fwrite to achieve this but I was wondering if there is a "UVM way" of doing this, below the code I have usign $fopen, $fwrite
virtual class fd_wrapper;
static integer fd;
static function open_fd();
fd = $fopen("./data", "w");
endfunction
static function close_fd();
fd = $fclose(fd);
endfunction
static function void write_fd(string msg)
$fwrite(fd, msg);
endfunction
endclass
class my_env extends uvm_env;
//regular uvm code
my_cb cb;
virtual function end_of_elaboration_phase(uvm_phase phase);
cb = my_cb::type_id::create("cb");
//add cb to all registers
//open the file
fd_wrapper::open_fd();
endfunction
virtual function final_phase(uvm_phase phase);
fd_wrapper::close_fd();
endfunction
endclass
class my_cb extends uvm_reg_cbs;
//regular uvm stuff
virtual task pre_write(uvm_reg_item rw);
format(rw);
endtask
virtual function void format(uvm_reg_item rw);
string msg;
//create msg based on some logic using rw
fd_wrapper::write_fd(msg);
//`uvm_info(...) //redirect and format uvm_info instead of calling write_fd
endfunction
endclass
Apologies if my code and question is a bit messy.
Thanks,
-R