# What is the purpose of using "program block" in Systemverilog?

**URL:** <https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, program-block\
**Created:** [August 6, 2018, 6:44am UTC](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806 "2018-08-06T06:44:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![UVM\_LOVE](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/uvm_love/32/1684_2.png) [@UVM\_LOVE](https://verificationacademy.com/forums/u/UVM_LOVE)\
**Post date:** [August 6, 2018, 6:44am UTC](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/1 "2018-08-06T06:44:55Z")

</div>

Dear All,

I’m trying to understand about “program block” in Systemverilog. and I’m currently referring [this](http://www.asic-world.com/systemverilog/program1.html) site.

As I see that program block is the same as “module block” in verilog.  
So I’m curious what is the purpose of using “program block” in system verilog or drawback?

---

<div class="post-metadata">

**Author:** ![Rakesh\_Kumar\_S](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/rakesh_kumar_s/32/3690_2.png) [@Rakesh\_Kumar\_S](https://verificationacademy.com/forums/u/Rakesh_Kumar_S)\
**Post date:** [August 6, 2018, 8:14am UTC](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/2 "2018-08-06T08:14:26Z")

</div>

hi,

```
module block will sample at active region and executes in the same region.where as program block will sample in active region and executes in reactive region.That's why program block is mainly used in the testbench and module is design.

```

program block will avoid race conditions,the initial statement in program block will be executed in Reactive region where as initial block of module is executed in active region.

---

<div class="post-metadata">

**Author:** ![UVM\_LOVE](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/uvm_love/32/1684_2.png) [@UVM\_LOVE](https://verificationacademy.com/forums/u/UVM_LOVE)\
**Post date:** [August 7, 2018, 12:35am UTC](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/3 "2018-08-07T00:35:45Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/3):_

> _In reply to [sylee](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/3):_  
> There is no need to use program blocks. Please see [Are Program Blocks Necessary? - Verification Horizons](https://blogs.sw.siemens.com/verificationhorizons/2009/05/07/programblocks/)

Thanks, Perfectly Cleared.

---

<div class="post-metadata">

**Author:** ![shahkavish77](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/d6d6ee/32.png) [@shahkavish77](https://verificationacademy.com/forums/u/shahkavish77)\
**Post date:** [January 4, 2020, 2:34am UTC](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/4 "2020-01-04T02:34:06Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/4):_

Hi Dave,

From SV LRM, 24.4 Eliminating testbench races,  
It is important to understand that simply sampling input signals (or setting nonzero skews on  
clocking block inputs) does not eliminate the potential for races. Proper input sampling only addresses a single clocking block. With multiple clocks, the arbitrary order in which overlapping or simultaneous clocks are processed is still a potential source for races. The program construct addresses this issue by scheduling its execution in the Reactive region, after all design events have been processed, including clocks driven by nonblocking assignments.

Does it mean that Program block is mandatory while dealing with multiple clocks/clocking blocks ?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 4, 2020, 3:22am UTC](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/5 "2020-01-04T03:22:55Z")

</div>

_In reply to [shahkavish77](https://verificationacademy.com/forums/t/what-is-the-purpose-of-using-program-block-in-systemverilog/34806/5):_

No, not at all. RTL designs deal with multiple clocks all the time and there is no need for additional constructs if you understand Verilog semantics,
