|
|
|
|
|
|
|
|
|
|
|
|
Assertion system tasks
|
|
|
Systemverilog allows severity control by means of system tasks, also systemverilog allows to enable/disable assertions. Some of the system tasks for this purpose are. |
|
|
|
|
|
- $assertoff : Stop the checking of all specified assertions until a subsequent $asserton. An assertion that is already executing, including execution of the pass or fail statement, is not affected.
- $assertkill: Abort execution of any currently executing specified assertions and then stop the checking of all specified assertions until a subsequent $asserton.
- $asserton: Reenable the execution of all specified assertions.
- $fatal :Run-time fatal assertion error, which terminates the simulation with an error code. The first argument passed to $fatal shall be consistent with the corresponding argument to the Verilog $finish system task, which sets the level of diagnostic information reported by the tool. Calling $fatal results in an implicit call to $finish.
- $error: Run-time error.
- $warning: Run-time warning, which can be suppressed in a tool-specific manner.
- $info: Indicate that the assertion failure carries no specific severity.
|
|
|
|
|
|
|
|
|
|
|
|
Example : Assertion system tasks
|
|
|
|
|
|
1 module system_assert();
2
3 reg clk, grant, request;
4 time current_time;
5
6 initial begin
7 clk = 0;
8 grant = 0;
9 request = 0;
10 #4 request = 1;
11 #4 grant = 1;
12 #4 request = 0;
13 #4 grant = 0;
14 #4 request = 0;
15 #4 grant = 1;
16 #4 request = 0;
17 #4 $finish;
18 end
19
20 always #1 clk = ~clk;
21 //=================================================
22 // Assertion used in always block
23 //=================================================
24 always @ (posedge clk)
25 begin
26 if (grant == 1) begin
27 CHECK_REQ_WHEN_GNT : assert (grant && request) begin
28 $info("Seems to be working as expected");
29 end else begin
30 current_time = $time;
31 // We can use all below statements
32 // $fatal
33 // $error
34 // $warning
35 // $info
36 #1 $warning("assert failed at time %0t", current_time);
37 $assertoff(1,system_assert.CHECK_REQ_WHEN_GNT);
38 end
39 end
40 end
41
42 endmodule
You could download file system_assert.sv here
|
|
|
|
|
|
Simulator Output : Assertion system tasks
|
|
|
|
|
|
Info: "system_assert.sv", 27: system_assert.CHECK_REQ_WHEN_GNT: at time 9
Seems to be working as expected
Info: "system_assert.sv", 27: system_assert.CHECK_REQ_WHEN_GNT: at time 11
Seems to be working as expected
"system_assert.sv", 27: system_assert.CHECK_REQ_WHEN_GNT: started at 13s failed at 13s
Offending '(grant && request)'
Warning: "system_assert.sv", 27: system_assert.CHECK_REQ_WHEN_GNT: at time 14
assert failed at time 13
Stopping new attempts for assertion CHECK_REQ_WHEN_GNT at time 14s.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|