Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Verilog Task pass value problem?

 
Thread Tools Search this Thread
Old 03-25-2006, 01:52 AM   #1
Default Verilog Task pass value problem?


Hi all,

I am reading the book "Writing Testbench". And write the code below:
It seems the code is blocked in the task "@ (posedge clk)", and the
task never return the "valid", why?
I guess task cannot pass the continuous clk value?

//--------test.v-------------
module test;

reg clk;
integer i;
reg [7:0] input1,input2;
reg [7:0] valid1;

test_lib test_lib();

always begin
#50 clk <= 1'b0;
#50 clk <= 1'b1;
end

initial begin
for (i=1;i<=8;i=i+1)
begin
input1 = i;
input2 = i;
begin
test_lib.compare_vector(clk,input1,input2,valid1);
end
@ (posedge clk);
end
end

endmodule
//---------end test.v--------------

//----------test_lib.v-------------
module test_lib;

task automatic compare_vector;
input clk;
input [7:0] input1;
input [7:0] input2;
output valid;
begin
$write("p1\n");
@ (posedge clk)
valid = (input1==input2);
$write("p2\n");
end
endtask
endmodule
//-------end test_lib.v------------

Any suggestions will be appreciated!
Best regards,
Davy



Davy
  Reply With Quote
Old 03-25-2006, 03:15 PM   #2
Ajeetha
 
Posts: n/a
Default Re: Verilog Task pass value problem?
Task arguments are passed by value and hence is what you have
seen/observed. Your option will be to pass the clk as input to test_lib
module.

HTH
Ajeetha, CVC
www.noveldv.com



Ajeetha
  Reply With Quote
Old 03-26-2006, 02:46 AM   #3
Davy
 
Posts: n/a
Default Re: Verilog Task pass value problem?
Hi Ajeetha,

If I pass clk to test_lib, shall I use `include "test_lib.v"?

Best regards,
Davy



Davy
  Reply With Quote
Old 03-26-2006, 03:35 AM   #4
Ajeetha
 
Posts: n/a
Default Re: Verilog Task pass value problem?
Davy,
That wouldn't change from the way you currently compile it. Say:

vcs test_lib.v test.v

Only the instantiation changes:

>>test_lib test_lib();

test_lib test_lib(.clk(clk));

HTH
Ajeetha CVC
www.noveldv.com



Ajeetha
  Reply With Quote
Old 03-26-2006, 06:33 AM   #5
Davy
 
Posts: n/a
Default Re: Verilog Task pass value problem?
Hi Ajeetha,

All OK, thank you!

Best regards,
Davy



Davy
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Task Scheduler problem akashmonu Software 0 08-14-2008 01:50 PM
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46