Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

why the simulation result is differenct between fork join and begin end?

Altera_Forum
Honored Contributor II
1,347 Views

this is the testbench in an495. 

why can not use begin ... end. 

initial  

begin 

arst <= 1'b0; // resetting the contoller initially 

# 250  

arst <= 1'b1;  

iderst <= 1'b0; 

ideen <= 1'b1; 

pioiordyen <= 1'b1; 

piorqst <= 1'b1; 

pioaddr <= 4'b0111; 

piodatain <= 16'b1111111100000000; 

piowe <= 1'b1; 

# 600 piowe <= 1'b0; 

ddi <= 16'b0000000011111111; 

iordy <= 1'b1; 

intrq <= 1'b1; 

flag <= 1'b0; //if error occured in the test procedure,then asserted 

# 5000 

$stop; 

end 

use the fork join,the result is right 

fork 

arst = 1'b0; // resetting the contoller initially 

# 250  

arst = 1'b1;  

iderst = 1'b0; 

ideen = 1'b1; 

pioiordyen = 1'b1; 

piorqst = 1'b1; 

pioaddr = 4'b0111; 

piodatain = 16'b1111111100000000; 

piowe = 1'b1; 

# 600 piowe = 1'b0; 

ddi = 16'b0000000011111111; 

iordy = 1'b1; 

intrq = 1'b1; 

flag = 1'b0; //if error occured in the test procedure,then asserted 

# 5000 

$stop; 

join
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
667 Views

The difference between "begin-end" and "fork-join" is that in initial block "begin-end" operations work step-by-step, but in "fork-join" they work simultaneously. You can rewrite the testbench using "begin-end". For example,  

 

begin 

arst <= 1'b0; // resetting the contoller initially 

iderst <= 1'b0; 

ideen <= 1'b1; 

pioiordyen <= 1'b1; 

piorqst <= 1'b1; 

pioaddr <= 4'b0111; 

piodatain <= 16'b1111111100000000; 

piowe <= 1'b1; 

iordy <= 1'b1; 

intrq <= 1'b1; 

flag <= 1'b0; //if error occured in the test procedure,then asserted 

ddi <= 16'b0000000011111111; 

# 250 arst <= 1'b1;  

# 350 piowe <= 1'b0; 

# 4400 $stop; 

end 

 

I believe, it will work like original "fork-join"
0 Kudos
Altera_Forum
Honored Contributor II
667 Views

The begin-end-block also assigns the values to the nets simultaneously if non-blocking assignments are used (as it's the case in the example). The difference is that all timing assignments are with respect to the block entry time in case of fork-join and with respect to the previous timing assignment in case of begin-end.

0 Kudos
Reply