writing and instantiating .v file with function only

T

thomasc

Guest
My understanding is that it is possible to have a function that's made of
only one function and that the function can be used in another module by
"`include" the .v file from the module. That's what I did in my codes
below, but ModelSim gave an error message saying:

# ** Error: D:/My_Projects/temp/word_aligner.v(2): Cannot open `include
file "D:My_Projects empaligned_word.v".
# -- Compiling module word_aligner
# ** Error: D:/My_Projects/temp/word_aligner.v(11): Undefined variable:
aligned_word.


Below is my codes. I changed the forward slash('/') in the path of
`include statement. But it didn't work ou, too. Please let me know what
the problem is.

`timescale 1ns/1ns
`include "D:/My_Projects/temp/aligned_word.v" // line (2)

//MODULE word_aligner
module word_aligner;
output [3: 0] word_out;
integer i;

initial begin
for (i=0;i<4;i=i+1)
word_out=aligned_word; // line (11)
end

endmodule

//MODULE aligned_word
function aligned_word;
input index;
reg [7:0] temp=8'b01011010;

aligned_word = temp[index];

endfunction
 
You have a really quirky problem where the simulator is interpreting
/t as a tab character embedded in your file name string. You need to
"escape" the backslash character. Try ".../Projects//temp..." in your
string IOW add one backslash before the character t. If that still
doesn't work, rename your temporary directory or put the included file
into the same directory.

On Thu, 10 Mar 2005 19:23:41 -0500, "thomasc"
<altecsplinter@hotmail.com> wrote:

My understanding is that it is possible to have a function that's made of
only one function and that the function can be used in another module by
"`include" the .v file from the module. That's what I did in my codes
below, but ModelSim gave an error message saying:

# ** Error: D:/My_Projects/temp/word_aligner.v(2): Cannot open `include
file "D:My_Projects empaligned_word.v".
# -- Compiling module word_aligner
# ** Error: D:/My_Projects/temp/word_aligner.v(11): Undefined variable:
aligned_word.


Below is my codes. I changed the forward slash('/') in the path of
`include statement. But it didn't work ou, too. Please let me know what
the problem is.

`timescale 1ns/1ns
`include "D:/My_Projects/temp/aligned_word.v" // line (2)

//MODULE word_aligner
module word_aligner;
output [3: 0] word_out;
integer i;

initial begin
for (i=0;i<4;i=i+1)
word_out=aligned_word; // line (11)
end

endmodule

//MODULE aligned_word
function aligned_word;
input index;
reg [7:0] temp=8'b01011010;

aligned_word = temp[index];

endfunction

 
thomasc wrote:
My understanding is that it is possible to have a function that's made of
only one function and that the function can be used in another module by
"`include" the .v file from the module. That's what I did in my codes
below, but ModelSim gave an error message saying:

# ** Error: D:/My_Projects/temp/word_aligner.v(2): Cannot open `include
file "D:My_Projects empaligned_word.v".
# -- Compiling module word_aligner
# ** Error: D:/My_Projects/temp/word_aligner.v(11): Undefined variable:
aligned_word.


Below is my codes. I changed the forward slash('/') in the path of
`include statement. But it didn't work ou, too. Please let me know what
the problem is.

`timescale 1ns/1ns
`include "D:/My_Projects/temp/aligned_word.v" // line (2)

//MODULE word_aligner
module word_aligner;
output [3: 0] word_out;
integer i;

initial begin
for (i=0;i<4;i=i+1)
word_out=aligned_word; // line (11)
end
Try putting the `include INSIDE the module.


-jz
 

Welcome to EDABoard.com

Sponsor

Back
Top