Site icon Hardware Design and Verification

What is the difference between initial block and final block?

Differences

1. The most obvious one : Initial blocks get executed at the beginning of the simulation, final block gets executed  at the end of simulation

2. Final block has to be executed in zero time, which implies it can’t have any delay, wait, or non-blocking assignments. Initial block doesn’t have any such restrictions of execution in zero time (and can have delay, wait and non-blocking statements)
Final block can be used to display statistical/general information regarding the status of the execution like this

 

Program

1.final begin
2.$display(“Simulation Passed”);
3.$display(“Final value of xyz = %h”,xyz);
4.$display(“Bye :: So long, and Thanks for all the fishes”);
5.end

 

Exit mobile version