75 lines
2.2 KiB
Plaintext
75 lines
2.2 KiB
Plaintext
:vpi_module "system";
|
|
|
|
; Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
|
;
|
|
; This source code is free software; you can redistribute it
|
|
; and/or modify it in source code form 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.
|
|
;
|
|
; 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.
|
|
;
|
|
; 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
|
; 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;
|
|
; begin
|
|
; #5 $display("FAILED...");
|
|
; $finish;
|
|
; end
|
|
; endtask
|
|
;
|
|
; initial begin
|
|
; fork
|
|
; test;
|
|
; #1 disable test;
|
|
; join
|
|
; $display("PASSED");
|
|
; end
|
|
; endmodule
|
|
;
|
|
|
|
S_main .scope "main";
|
|
S_test .scope "test", S_main;
|
|
|
|
|
|
; 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 ;
|
|
%delay 5;
|
|
%vpi_call "$display", "FAILED -- thread wasn't disabled";
|
|
%vpi_call "$finish";
|
|
%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;
|
|
%delay 1;
|
|
|
|
%disable S_test ; This is the statement that I'm testing.
|
|
|
|
%join;
|
|
%vpi_call "$display", "PASSED";
|
|
%end;
|
|
|
|
.thread T_0;
|