2020-10-03 11:57:25 +02:00
|
|
|
:ivl_version "12.0" "vec4-stack";
|
2001-04-21 02:34:39 +02:00
|
|
|
:vpi_module "system";
|
|
|
|
|
|
2015-08-16 05:28:23 +02:00
|
|
|
; Copyright (c) 2001-2015 Stephen Williams (steve@icarus.com)
|
2001-04-21 02:34:39 +02:00
|
|
|
;
|
2014-12-09 05:54:04 +01:00
|
|
|
; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
; it under the terms of the GNU General Public License as published by
|
|
|
|
|
; the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
; (at your option) any later version.
|
2001-04-21 02:34:39 +02:00
|
|
|
;
|
|
|
|
|
; This program is distributed in the hope that it will be useful,
|
|
|
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
; GNU General Public License for more details.
|
|
|
|
|
;
|
2014-12-09 05:54:04 +01:00
|
|
|
; You should have received a copy of the GNU General Public License along
|
|
|
|
|
; with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2001-04-21 02:34:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
; This example is similar to the following Verilog code. The idea is
|
|
|
|
|
; to test the disable statement. The task creates a scope (called test)
|
|
|
|
|
; that is a hook for the disable statement to get at the thread that
|
|
|
|
|
; threatens to fail the test. If the disable statement works properly,
|
|
|
|
|
; the test task will be disabled before the #5 delay expires.
|
|
|
|
|
;
|
|
|
|
|
; module main;
|
|
|
|
|
; task test;
|
2014-12-09 05:54:04 +01:00
|
|
|
; begin
|
|
|
|
|
; #5 $display("FAILED...");
|
|
|
|
|
; $finish;
|
|
|
|
|
; end
|
2001-04-21 02:34:39 +02:00
|
|
|
; endtask
|
|
|
|
|
;
|
|
|
|
|
; initial begin
|
2014-12-09 05:54:04 +01:00
|
|
|
; fork
|
|
|
|
|
; test;
|
|
|
|
|
; #1 disable test;
|
|
|
|
|
; join
|
|
|
|
|
; $display("PASSED");
|
2001-04-21 02:34:39 +02:00
|
|
|
; end
|
|
|
|
|
; endmodule
|
|
|
|
|
;
|
|
|
|
|
|
2014-12-09 05:54:04 +01:00
|
|
|
S_main .scope module, "main" "main" 0 0;
|
|
|
|
|
S_test .scope task, "test" "test" 0 0, 0 0 0, S_main;
|
2001-04-21 02:34:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
; This code in the implementation of the thread that goes into the
|
|
|
|
|
; test scope. The idea is to disable this thread before it does its
|
|
|
|
|
; job and prints a failure.
|
|
|
|
|
.scope S_test;
|
|
|
|
|
T_0/1 ;
|
2008-01-02 19:42:23 +01:00
|
|
|
%delay 5, 0;
|
2014-12-09 05:54:04 +01:00
|
|
|
%vpi_call 0 0 "$display", "FAILED -- thread wasn't disabled" {0 0 0};
|
|
|
|
|
%vpi_call 0 0 "$finish" {0 0 0};
|
2001-04-21 02:34:39 +02:00
|
|
|
%end;
|
|
|
|
|
|
|
|
|
|
; This is the main thread. Fork the thread under test, delay for a
|
|
|
|
|
; moment to let it run, then %disable the test thread. If I don't
|
|
|
|
|
; disable the test thread in time, then the child will print an error
|
|
|
|
|
; message and exit.
|
|
|
|
|
.scope S_main;
|
|
|
|
|
T_0 ;
|
|
|
|
|
%fork T_0/1, S_test;
|
2008-01-02 19:42:23 +01:00
|
|
|
%delay 1, 0;
|
2001-04-21 02:34:39 +02:00
|
|
|
|
|
|
|
|
%disable S_test ; This is the statement that I'm testing.
|
|
|
|
|
|
|
|
|
|
%join;
|
2014-12-09 05:54:04 +01:00
|
|
|
%vpi_call 0 0 "$display", "PASSED" {0 0 0};
|
2001-04-21 02:34:39 +02:00
|
|
|
%end;
|
|
|
|
|
|
|
|
|
|
.thread T_0;
|
2008-01-02 19:42:23 +01:00
|
|
|
:file_names 2;
|
|
|
|
|
"N/A";
|
|
|
|
|
"<interactive>";
|