Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

Process Class: A Complete Example

SystemVerilog Threads & Processes

Runnable example from the SystemVerilog Process Class tutorial (A Complete Example)

Open in IDE
testbench.sv
module tb;
  process bg_proc;

  task background_task ();
    bg_proc = process::self();   // capture this task's own process handle

    forever begin
      #10 $display ("[%0t] Background task running", $time);
    end
  endtask

  initial begin
    fork
      background_task ();
    join_none

    #25;
    $display ("[%0t] Status before kill: %s", $time, bg_proc.status().name());

    bg_proc.kill();
    $display ("[%0t] Background task killed", $time);

    #20 $finish;
  end
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.