iverilog/vvp/examples/disable.vvp

78 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

:vpi_module "system";
; Copyright (c) 2001-2008 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 module, "main";
S_test .scope task, "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, 0;
%vpi_call 0 0 "$display", "FAILED -- thread wasn't disabled";
%vpi_call 0 0 "$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, 0;
%disable S_test ; This is the statement that I'm testing.
%join;
%vpi_call 0 0 "$display", "PASSED";
%end;
.thread T_0;
:file_names 2;
"N/A";
"<interactive>";