# Using $display in consequent in System Verilog assertions

**URL:** <https://verificationacademy.com/forums/t/using-display-in-consequent-in-system-verilog-assertions/34408>\
**Category:** SystemVerilog\
**Tags:** SVA-Assertion, SystemVerilog\
**Created:** [April 30, 2018, 5:15pm UTC](https://verificationacademy.com/forums/t/using-display-in-consequent-in-system-verilog-assertions/34408 "2018-04-30T17:15:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhirbarefoot2018](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@sudhirbarefoot2018](https://verificationacademy.com/forums/u/sudhirbarefoot2018)\
**Post date:** [April 30, 2018, 5:15pm UTC](https://verificationacademy.com/forums/t/using-display-in-consequent-in-system-verilog-assertions/34408/1 "2018-04-30T17:15:20Z")

</div>

I have a simple assertion to check clock period. The assertion fails when I add $display() in consequent. If I remove remove $display in consequent, it passes. I have used $display() in antecedents before. Can we use $display() in consequent?. Below is the code.

property clk\_period ( real exp\_clk\_period );  
time current\_time;  
disable iff (count\>10)  
(en, current\_time = $time) |=\> ((clk\_period == ($time - current\_time)), $display(“dfiff=7.2%f”, $time - current\_time));//FAILS

```
//(en, current_time = $time) |=> ((clk_period == ($time - current_time));//PASS

```

endproperty : p\_period

chk\_clk\_period: assert property(@ (posedge clk)  
clk\_period(exp\_clk\_period))

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [April 30, 2018, 10:29pm UTC](https://verificationacademy.com/forums/t/using-display-in-consequent-in-system-verilog-assertions/34408/2 "2018-04-30T22:29:30Z")

</div>

_In reply to [sudhirbarefoot2018](https://verificationacademy.com/forums/t/using-display-in-consequent-in-system-verilog-assertions/34408):_  
Rather than debugging your code, here is code that works as expected.

```verilog

import uvm_pkg::*; `include "uvm_macros.svh" 
module top; 
    timeunit 1ns; timeprecision 100ps;    
	bit clk, en=1'b1, b;  
    initial forever #10 clk=!clk;  
    realtime exp_clk_period=20;
    initial begin
        $timeformat(-9, 1, "ns", 8);
        $display("%t", $realtime);
    end 
    property p_period ( realtime exp_clk_period );
        realtime current_time; 
        // disable iff (count>10)
        (en, current_time = $realtime) |=>
        (exp_clk_period == $realtime - current_time, 
        $display("dfiff=%t", $realtime - current_time));// OK      
        //(en, current_time = $time) |=> ((clk_period == ($time - current_time));//PASS
    endproperty : p_period
    
    ap_period: assert property(@ (posedge clk) p_period(exp_clk_period)); 
endmodule  
// sim results 

# 0.0ns
# dfiff= 20.0ns
# dfiff= 20.0ns
# dfiff= 20.0ns
# dfiff= 20.0ns
 

```

Ben Cohen  
[http://www.systemverilog.us/](http://www.systemverilog.us/) [ben@systemverilog.us](mailto:ben@systemverilog.us)  
For training, consulting, services: contact [Home - My cvcblr](http://cvcblr.com/home)

- [SVA Handbook 4th Edition, 2016 ISBN 978-1518681448](http://goo.gl/JOfuEB)
- [Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 978-1539769712](https://goo.gl/d10QHh)
- A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
- Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
- Component Design by Example ", 2001 ISBN 0-9705394-0-1
- VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
- VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115

* * *

See Paper: [VF Horizons:PAPER: SVA Alternative for Complex Assertions | Verification Academy](https://verificationacademy.com/forums/systemverilog/vf-horizonspaper-sva-alternative-complex-assertions)
