Writemem

Hi,

Can the system task $writememh be executed within an object? Kindly let me know.

In my case, the code outline is as follows:

class environment_c;

bit [7:0] frame_out [1023:0];
bit [7:0] input[1023:0];

task process();
$readmemh("input.txt",input);
$writememh("out_frame.txt",frame_out); //Array is initialized prior to this

endtask

endclass

I have created an object, env_o and run this. $readmemh functions as expected but $writememh does not write any data into the file “out_frame.txt”, though it creates the file “out_frame.txt”.

Additionally, The following warning appears during simulation

**** Warning: ** Warning: (vsim-4014) No objects found matching ‘this’**.

In reply to Anuradha Rangineni:

Hi,
Can the system task $writememh be executed within an object? Kindly let me know.
In my case, the code outline is as follows:
class environment_c;
bit [7:0] frame_out [1023:0];
bit [7:0] input[1023:0];
task process();
$readmemh(“input.txt”,input);
$writememh(“out_frame.txt”,frame_out); //Array is initialized prior to this
endtask
endclass
I have created an object, env_o and run this. $readmemh functions as expected but $writememh does not write any data into the file “out_frame.txt”, though it creates the file “out_frame.txt”.

In reply to Anuradha Rangineni:

This line of code:

bit [7:0] input[1023:0];

will cause trouble, since you are using a Verilog reserved keyword (input) as a variable name.

Hi,

Modified code to:

class environment_c;

bit [7:0] frame_out [1023:0];
bit [7:0] frame_input[1023:0];

task process();
$readmemh(“input_frame.txt”,frame_input);
$writememh(“out_frame.txt”,frame_out); //Array is initialized prior to this

endtask

endclass

Modified the code to the above but still facing the error :

** Warning: ** Warning: (vsim-4014) No objects found matching ‘this’.
regarding $writememh

In reply to Anuradha Rangineni:

Does frame_out fill with all memory locations ? if not try to specify start address and end address.
$writememh(“out_frame.txt”,frame_out, , );

Thanks

Yes, I have used the $display statement to view the memory frame_out. The data is displayed correctly.

I have tried using $writememh in the program block, in which case the memory contents are written into the file out_frame.txt correctly.

$writememh(“out_frame.txt”,frame_out);

The same thing doesn’t work when used in environment class object. Does anyone know why this is happening?

Thanks
Anuradha

In reply to kbkdec15:

In reply to Anuradha Rangineni:
Does frame_out fill with all memory locations ? if not try to specify start address and end address.
$writememh(“out_frame.txt”,frame_out, , );
Thanks

Yes, I have used the $display statement to view the memory frame_out. The data is displayed correctly.

I have tried using $writememh in the program block, in which case the memory contents are written into the file out_frame.txt correctly.

$writememh(“out_frame.txt”,frame_out);

The same thing doesn’t work when used in environment class object. Does anyone know why this is happening?

Thanks
Anuradha

In reply to kbkdec15:

In reply to Anuradha Rangineni:
Does frame_out fill with all memory locations ? if not try to specify start address and end address.
$writememh(“out_frame.txt”,frame_out, , );
Thanks

As Dave mentioned in one of the other thread, making the variable static will work.