Detecting high impedence z isunknown

Hi All,

I would like to detect Z (high impedence) and raise a flag; But I could not do in the following way;


initial begin

clk <= 0;
rstn <= 0;

#20   rstn <= 1'hz;                   
#15   rstn <= 1;                   
#80  rstn <= 0;
#50   rstn <= 1;

//method1
if ($isunknown(rstn)) begin
$display(“%t DETECTED Z:: rstnnnnn=%0d”, $time, rstn);
end

//method2
//a = $isunknown(rstn);
//if (a)
//$display(“%t DETECTED Z:: rstn=%0d”, $time, rstn);

From both the methods, not able to get the display, can someone suggest ?

In reply to Mahesh K:

Statements within Initial blocks run sequentially ( unless one has fork join )

The $isunknown( rstn ) executes at Time T=165 ( 20 + 15 + 80 + 50 )

By this time rstn has value 1 ( due to last #50 rstn <= 1; )

Hence the $isunknown() is NEVER True in your code .