cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Teacher
Teacher
8,571 Views
Registered: ‎03-31-2012

reference arguments are broken in simulation?

Jump to solution

I am trying to get the following test to run: 

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// test for ref parameters
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////

module test;
int a; 

initial 
begin 
#10 a = 10; 
#10 a = 20; 
#10 a = 30; 
#10 $finish; 
end 

task pass_by_val(int i); 
forever 
@i $display("pass_by_val: I is %0d",i); 
endtask 

task pass_by_ref(ref int i); 
forever 
@i $display("pass_by_ref: I is %0d",i); 
endtask 

initial 
pass_by_val(a); 

initial 
pass_by_ref(a); 

endmodule

 If I am not missing anything this should print 

pass_by_ref is 10

pass_by_ref is 20 ...

 

But I get nothing when I run this test. Does Vivado simulator support reference arguments properly?

 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
1 Solution

Accepted Solutions
Teacher
Teacher
15,241 Views
Registered: ‎03-31-2012

this is a very much simplified case. My main problem was trying to pass a clock as a ref argument. A task with a @(posedge clk) where clk is a ref argument doesn't see any events. I think the problem is still that ref arguments don't work. In your example every time the variable changes, you call the task again so the event is detected outside the task. If the ref worked properly the event could be observed inside the task too.

 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.

View solution in original post

0 Kudos
3 Replies
Highlighted
Xilinx Employee
Xilinx Employee
8,554 Views
Registered: ‎09-13-2014

Hi,

 

First you need to do slight modification in your example i.e change the definition of task 'pass_by_ref' as automatic becuase task/function having ref port can't be static so change to

 

task automatic pass_by_ref ...

 

Coming on Vivado Simulator side, it's bug which need to be fixed. The issue is not with ref port, it's because of forever block inside that. If you want, you can do slight modification like

 

____________________

module test;
int a;

initial
begin
#10 a = 10;
#10 a = 20;
#10 a = 30;
#10 $finish;
end

task pass_by_val(int i);
forever
@i $display("pass_by_val: I is %0d",i);
endtask

task automatic pass_by_ref(ref int i);
//forever
//@i
$display("pass_by_ref: I is %0d",i);
endtask

initial
pass_by_val(a);

initial
forever @a pass_by_ref(a);

endmodule

 

_______________

And with, you should see the expected o/p.

 

--dhiRAj

0 Kudos
Teacher
Teacher
15,242 Views
Registered: ‎03-31-2012

this is a very much simplified case. My main problem was trying to pass a clock as a ref argument. A task with a @(posedge clk) where clk is a ref argument doesn't see any events. I think the problem is still that ref arguments don't work. In your example every time the variable changes, you call the task again so the event is detected outside the task. If the ref worked properly the event could be observed inside the task too.

 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.

View solution in original post

0 Kudos
Highlighted
Teacher
Teacher
8,527 Views
Registered: ‎03-31-2012

this has been accepted as a bug in Vivado simulator, Modelsim does the right thing, xsim doesn't. 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos