The monitor statement is a system task and is ignored by the synthesis tool. It is used to monitor values for verification. It diplays the values of its parameters whenever there is a change. The syntax is given below:
$monitor ("format_string", parameter1, parameter2, ... );
The 'format string' specifies the format in which the values must be displayed. For displaying values in decimal "%d" is used. For displaying values in hexadecimal format "%h" is used and "%b" is used for binary representation.
If you want to display 4-bit binary number you use "%4b". For example:
$monitor("a=%2b,b=%2d,c=%b \n",a,b,c);
The above given code diplays the variable 'a' as 2-bit binary number, the variable 'b' as 2 digit decimal number and the variable 'c' as 1 bit binary number.