$monitor does not get printed


class display;
int cc, ccmon;
task chkincr( int bbb, int bb);
  for(int ii=0; ii<3; ii++) begin
  #1ns;
	cc = bb+ii;	//increments but does not assign
	ccmon= bb+1;	//increments but does not assign
	$display("\n=============================================================");
	$display("At %0tns display\t: %0d",$time, cc);
	$write("At %0tns No new line: write\t: %0d",$time, cc);
	$monitor("At %0tns monitor\t: %0d",$time, cc);
	$strobe("At %0tns strobe\t: %0d",$time, cc);
	$monitor("At %0tns ccmon monitor\t: %0d",$time, ccmon);
  end
	$display("\n\n|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
	$write("\n\tOutside for loop - new line: At %0tns write\t: %0d\n",$time, cc);
	$strobe("\tOutside for loop - At %0tns strobe\t: %0d",$time, cc);
endtask
endclass

module top();
int a=10, bbbb=0;
initial begin
	display inca_ii;
	inca_ii = new();
	inca_ii.chkincr(bbbb, a); // pass 10 and 0 respectively
end
endmodule


Result:
/*

At 1ns display : 10
At 1ns No new line: write : 10At 1ns strobe : 10
At 1ns ccmon monitor : 11

=============================================================
At 2ns display : 11
At 2ns No new line: write : 11At 2ns strobe : 11
At 2ns ccmon monitor : 11

=============================================================
At 3ns display : 12
At 3ns No new line: write : 12

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Outside for loop - new line: At 3ns write	: 12

At 3ns strobe : 12
Outside for loop - At 3ns strobe : 12
At 3ns ccmon monitor : 11
*/

How come “$monitor(“At %0tns monitor\t: %0d”,$time, cc);” this $monitor statement never gets executed?
The result only shows the ccmon monitor statement from the program, not the other one.

In reply to natasv:

Hi,

the reason is that “only one monitoring list can be active at a time. If there is more than one $monitor statement in your simulation, the last $monitor statement will be the active statement.”

In reply to UVM_Xplorer:

Is this the IEEE standard

In reply to natasv:

Only one $monitor display list can be active at any one time; however, a new $monitor task with a new display list can be issued any number of times during simulation.

$monitor is meant to be just a quick and simple debugging statement.

In reply to dave_59:

Thank you.
Sorry, I have another follow on question on $monitor


class display;
int cc, ccmon;
task chkincr( int bbb, int bb);
  ccmon= bb+1;	

  for(int ii=0; ii<4; ii++) begin
  #1ns;
	cc = bb+ii;	

	$monitor("At %0tns ccmon monitor\t: %0d",$time, ccmon);
	//$monitor("At %0tns monitor\t: %0d ",$time, cc);		 
  end
	$monitor("Outside for loop - At %0tns ccmon monitor\t: %0d",$time, ccmon);	
endtask
endclass

module top();
int a=10, bbbb=0;
initial begin
	display inca_ii;
	inca_ii = new();
	inca_ii.chkincr(bbbb, a); // pass 10 and 0 respectively
end
endmodule

/*
Result
At 1ns ccmon monitor	: 11
At 2ns ccmon monitor	: 11
At 3ns ccmon monitor	: 11
Outside for loop - At 4ns ccmon monitor	: 11
*/

$monitor description says it prints value at the end of timestamp if there is a change in value of any variable.
How come this program prints “ccmon monitor” at end of every time step, although there is NO change in value of the variable “ccmon” at every time step?
I expected it to print only once at 1ns.

Thanks again.

In reply to natasv:

It also prints once at the call time to the $monitor statement to establish the initial set of values at the beginning of the monitoring session.

In reply to dave_59:

Thank you, Dave.