What' my mistake? (Load data to memory)

P

Peng Yu

Guest
Hi there,
The simulator indicates that there is something wrong with the line
marked with /*error*/.
error message is:
Error: (vsim-PLI-3502) acc_set_value(): The object_handle
parameter is not a handle to a net, register, variable, or sequential
UDP.
But I don't why it isn't correct. Could somebody help me?
Best wishes,
Peng

module read_pattern;
integer file;
reg [3:0] bin [0:2];
//reg [3:0] bin;

integer i;

initial
begin
file = $fopen("my_read_pattern.pat", "r");
for(i = 0;i < 3;i = i + 1)
begin
// #10 $fscanf(file,"%b\n", bin);
#10 $fscanf(file,"%b\n", bin);/*error*/
end
$fclose(file);
end

always
@(bin[0], bin[1], bin[2])
$display("bin[0,1,2] = %b,%b,%b", bin[0], bin[1], bin[2]);
/*always
@(bin)
$display("bin = %b", bin);
*/

endmodule
 
Peng Yu wrote:
Hi there,
The simulator indicates that there is something wrong with the line
marked with /*error*/.
error message is:
Error: (vsim-PLI-3502) acc_set_value(): The object_handle
parameter is not a handle to a net, register, variable, or sequential
UDP.
But I don't why it isn't correct. Could somebody help me?
Best wishes,
Peng
Looks to me like the simulator has a bug in the acc_set_value()
implementation that is used to implement $fscanf. acc_set_value()
is a standard PLI1 function that should be able to set memory
word values.


module read_pattern;
integer file;
reg [3:0] bin [0:2];
//reg [3:0] bin;

integer i;

initial
begin
file = $fopen("my_read_pattern.pat", "r");
for(i = 0;i < 3;i = i + 1)
begin
// #10 $fscanf(file,"%b\n", bin);
#10 $fscanf(file,"%b\n", bin);/*error*/
end
$fclose(file);
end

always
@(bin[0], bin[1], bin[2])
$display("bin[0,1,2] = %b,%b,%b", bin[0], bin[1], bin[2]);
/*always
@(bin)
$display("bin = %b", bin);
*/

endmodule


--
Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."
 
yupeng_@hotmail.com (Peng Yu) wrote in message news:<d7b3726c.0307292322.dc178d3@posting.google.com>...
Hi there,
The simulator indicates that there is something wrong with the line
marked with /*error*/.
error message is:
Error: (vsim-PLI-3502) acc_set_value(): The object_handle
parameter is not a handle to a net, register, variable, or sequential
UDP.
But I don't why it isn't correct. Could somebody help me?
Best wishes,
Peng

module read_pattern;
integer file;
reg [3:0] bin [0:2];
//reg [3:0] bin;

integer i;

initial
begin
file = $fopen("my_read_pattern.pat", "r");
for(i = 0;i < 3;i = i + 1)
begin
// #10 $fscanf(file,"%b\n", bin);
#10 $fscanf(file,"%b\n", bin);/*error*/
end
$fclose(file);
end

always
@(bin[0], bin[1], bin[2])
$display("bin[0,1,2] = %b,%b,%b", bin[0], bin[1], bin[2]);
/*always
@(bin)
$display("bin = %b", bin);
*/

endmodule


Does the file exist? You're opening a file for reading, so the file
must exist; otherwise you can't read it!

--a
 
yupeng_@hotmail.com (Peng Yu) wrote in message news:<d7b3726c.0307292322.dc178d3@posting.google.com>...
error message is:
Error: (vsim-PLI-3502) acc_set_value(): The object_handle
parameter is not a handle to a net, register, variable, or sequential
UDP.
But I don't why it isn't correct. Could somebody help me?
Apparently there is a bug in your simulator's implementation of
$fscanf. It is unable to read into a memory word. Apparently
the implementation of $fscanf was done using PLI, which is why
you are getting a PLI error message.

As a workaround, you could read into a reg and then copy that
value into the memory word.

I ran this testcase in NC-Verilog. Since $fscanf is a function,
and you are trying to call it as a task, your testcase is actually
erroneous. I had to modify it to assign the return value of
$fscanf to a variable. After that, it worked fine.
 
Hi,
Is there any other function that can initialize the memory from a file?
Peng
Looks to me like the simulator has a bug in the acc_set_value()
implementation that is used to implement $fscanf. acc_set_value()
is a standard PLI1 function that should be able to set memory
word values.
 
sharp@cadence.com (Steven Sharp) wrote in message news:<3a8e124e.0307301427.133b3e7b@posting.google.com>...
I ran this testcase in NC-Verilog. Since $fscanf is a function,
and you are trying to call it as a task, your testcase is actually
erroneous. I had to modify it to assign the return value of
$fscanf to a variable. After that, it worked fine.
I ran this testcase in Modelsim. It doesn't produce any error message
if the return value isn't assigned to a variable.
That means different simulators deal with this issue differently.
 
yupeng_@hotmail.com (Peng Yu) wrote in message news:<d7b3726c.0308071932.7b3c796@posting.google.com>...
I ran this testcase in Modelsim. It doesn't produce any error message
if the return value isn't assigned to a variable.
That means different simulators deal with this issue differently.
It means that Modelsim is not strictly compliant with the standard.
If you want your code to be portable, you should stick with the standard.
 

Welcome to EDABoard.com

Sponsor

Back
Top