FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-11-2005, 12:23 AM
thomasc
Guest
 
Posts: n/a
Default writing and instantiating .v file with function only

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[i]=aligned_word[i]; // line (11)
end

endmodule

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

aligned_word = temp[index];

endfunction



Reply With Quote
  #2 (permalink)  
Old 03-11-2005, 01:38 AM
mk
Guest
 
Posts: n/a
Default Re: writing and instantiating .v file with function only

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"
<[email protected]> 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[i]=aligned_word[i]; // line (11)
> end
>
>endmodule
>
>//MODULE aligned_word
> function aligned_word;
> input index;
> reg [7:0] temp=8'b01011010;
>
> aligned_word = temp[index];
>
> endfunction
>
>


Reply With Quote
  #3 (permalink)  
Old 03-11-2005, 02:20 AM
Jason Zheng
Guest
 
Posts: n/a
Default Re: writing and instantiating .v file with function only

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[i]=aligned_word[i]; // line (11)
> end

Try putting the `include INSIDE the module.

-jz
Reply With Quote
Reply

Bookmarks


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Instantiating a module multiple times in Vlog '01 Andrew Whyte Verilog 2 02-10-2005 06:48 PM
writing 0's and 1's Sridhar_Gadda Verilog 2 02-10-2005 02:56 PM
Writing a binary file in Verilog Charles Bailey Verilog 9 10-07-2004 01:57 PM
Re: writing a 8bit char on a binary file, error... TorbaX Verilog 1 08-08-2003 06:47 PM
Re: writing a 8bit char on a binary file, error... Steven Sharp Verilog 0 08-08-2003 01:09 AM


All times are GMT +1. The time now is 12:13 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved