본문 바로가기

System verilog

[SV] event / concurrency

iff in event control example

module event_ctrl;
  bit clk;
  bit reset;
  always #2 clk = ~clk;

  //at posedge of clk if reset is equals to '0',always block will be executed
  always @(posedge clk iff reset == 0)
  begin :block-1
    $display($time,"\tInside always block");
  end :block-1

  //always block will be executed at every posedge and negedge of clk signal
  always @(posedge reset or negedge reset)
  begin :block-2
    $display($time,"\tReset Value = %0d",reset);
  end :block-2

  initial begin
   #40 $finish;
  end
  initial begin
    reset = 1;
    #7 reset = 0;
    #8 reset = 1;
    #5 reset = 0;
  end
endmodule

 

  • Concurrency

fork 

   statement1

   statement2

   statement3

join | join_any | join_none

statement4

 

fork - join : non-blocking, statement1~3이 모두 종료되어야 statement4 동작 

ex) 

module fork_join;

  initial begin
    $display("-----------------------------------------------------------------");
    fork
      //-------------------
      //Process-1
      //-------------------
      begin
        $display($time,"\tProcess-1 Started");
        #5;
        $display($time,"\tProcess-1 Finished");
      end

      //-------------------
      //Process-2
      //-------------------
      begin
        $display($time,"\tProcess-2 Started");
        #20;
        $display($time,"\tProcess-2 Finished");
      end
    join
    $display($time,"\tOutside Fork-Join");
    $display("-----------------------------------------------------------------");
    $finish;
  end
endmodule
// begin - end : blocking 
   fork - join : non-blocking

 

fork - join_any : statement 1~3 중 하나라도 동작이 끝나면 statement4 동작

fork - join_none : statement 1~3 가 queue 되고, parent thread가 끝나거나, blocking statement를 만났을 때, 

                            child process 시작.

 

wait fork : fork 에 모든 process 가 끝나야 join 이후의 statement를 실행함

 

 

 

'System verilog' 카테고리의 다른 글

[SV] Class  (0) 2022.12.15
[SV] Do while loop  (0) 2022.12.15
[SV] Arrays  (0) 2022.12.14
[SV] Data type  (0) 2022.12.13