Writing configuration data to a file using simulator1 and reading the configuration data from the file using simulator2

I tried using the below code to dump the configuration -

function void display_config() ;
 uvm_printer printer_knobs;
 printer_knobs.mcd = $fopen("CONFIG_OVERRIDE_FILE.txt"); // opening the file
 this.print();
 $fclose(mcd); // closing the file
endtask

But it results in a compilation error. Is there any way to dump the configuration data to a file and read then read this configuration data ?
Do I need to modify the format while reading ?

Thanks !

In reply to saurabhchauhan:

How does the compilation error look like?

*In reply to chr_sue:

I used the following function (corrected typo from previous one) -

function  display_config() ;
 uvm_printer printer_knobs;
 printer_knobs.mcd = $fopen("CONFIG_OVERRIDE_FILE.txt"); // opening the file
 this.print();
 $fclose(mcd); // closing the file
endfunction

Compilation errors -

** Error: /local/saurabhc/p65bf6/p65bf6_uvm/p65bf6/model/p65bf6_config.sv(1736): Field/method name (mcd) not in ‘printer_knobs’

** Error (suppressible): /local/saurabhc/p65bf6/p65bf6_uvm/p65bf6/model/p65bf6_config.sv(1738): (vlog-7027) The name (‘mcd’) was not found in the current scope. Please verify the spelling of the name ‘mcd’.

*

In reply to saurabhchauhan:

uvm_printer does not have a data member mcd, uvm_printer_knobs has.

*In reply to chr_sue:

Thanks chr_sue for your observation.
Also I modified the code with some changes for uvm_printer to uvm_default_printer and now it works -

function void display_config() ; 
 uvm_default_printer.knobs.mcd = $fopen("CONFIG_OVERRIDE_FILE.txt"); // opening the file 
 this.print();   
 $fclose(uvm_default_printer.knobs.mcd); // closing the file    
endfunction

Still the question about reading the configuration remains unanswered. Any suggestions ?

*

In reply to saurabhchauhan:

This.print does not print to your file.

*In reply to chr_sue:

The function display_config() is called with the my_cfg_handle.display_config() form the test class.
It DOES print all the TB configuration to the file - CONFIG_OVERRIDE_FILE.txt which is created in the present working dir.

*

In reply to saurabhchauhan:

And what is your problem now?

*In reply to chr_sue:

I want to read this dumped TB configuration so that I can re-create the same test and simulate it using another simulator. Is there any way to read an existing TB configuration in UVM to recreate the same test ?

*

*In reply to chr_sue:

Thanks for the pointer. You are correct. I was able to achieve the result by setting the appropriate constraints to replicate the TB configuration with another simulator.

*