Welcome ! This website will help YOU (recent graduates/professionals) learn verification languages like SystemVerilog and UVM. Register for free and access more content !

There are ways to group a set of statements together that are syntactically equivalent to a single statement and are known as block statements. There are two kinds of block statements: sequential and parallel.

Sequential

Statements are wrapped using begin and end keywords and will be executed sequentially in the given order, one after the other. Delay values are treated relative to the time of execution of the previous statement. After all the statements within the block are executed control may be passed elsewhere.

initial-begin-end
 
  initial begin
    #10   data = 8'hfe;
    #20   data = 8'h11;
  end
 

In the example above, first statement in the begin-end block will be executed at 10 time units, and the second statement at 30 time units because of the relative nature. It is 20 time units after the execution of the previous statement.

Parallel

A parallel block can execute statements concurrently and delay control can be used to provide time-ordering of the assignments. Statements are launched in parallel by wrapping them within the fork and join keywords.

 
  initial begin
    #10   data = 8'hfe;
    fork
       #20 data = 8'h11;
       #10 data = 8'h00;
    join
  end
 
fork-join-verilog

In the example above, fork-join block will be launched after executing the statement at 10 time units. Statements within this block will be executed in parallel and the first statement that will be launched will be the one where data is assigned a value of 8'h00 since the delay for that is 10 time units after the launch of the fork-join. After 10 more time units, the first statement will be launched and data will get the value 8'h11.

 
  initial begin
    #10 data = 8'hfe;
    fork
      #10 data = 8'h11;
      begin
        #20 data = 8'h00;
        #30 data = 8'haa;
      end
    join
  end
 

There is a begin-end block in the example above, and all statements within the begin-end block will be executed sequentially, but the block itself will be launched in parallel along with the other statements. So, data will get 8'h11 at 20 time units, 8'h00 at 30 time units and 8'haa at 60 time units.

Naming of blocks

Both sequential and parallel blocks can be named by adding : name_of_block after the keywords begin and fork. By doing so, the block can be referenced in a disable statement.

 
  begin : name_seq
    [statements]
  end
 
  fork : name_fork
    [statements]
  join
 

Was this article helpful ?

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. You consent to our cookies if you continue to use our website. To find out more about the cookies we use and how to delete them, see our privacy policy.

  I accept cookies from this site.
Agree
EU Cookie Directive plugin by www.channeldigital.co.uk