title: Semaphore in system verilog
body: <pre><code>module sema;
  semaphore sem;
  initial begin
  sem=new(2);
  
  begin
  sem.get(1);
    begin
      $display("%t,Event 3", $time);
      sem.put(1);
    end
    sem.get(2);
  
      $display ("%t, Event1",$time);
  
    sem.get(1);
    begin
      $display("%t,Event 2",$time);
      sem.put(2);
    end
  end
  end
  endmodule
  </code></pre>
  
  <p>The outputs are supposed to be Event3, Event 2, Event1</p>