Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

user defined functions in VHDL

Status
Not open for further replies.

Bartart

Full Member level 2
Joined
Feb 20, 2002
Messages
124
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
Europt
Activity points
1,107
Hi!

My problem is I have wrote a function with 3 input parameters (integer, integer and std_logic_vector) and return std_logic_vector. This package is synthesible. that OK

but in my VHDL code when I use the function it doesn't work.

the syntax is

SO <= fun 3 6 "101";

the error is

IN mode Formal xfrom of fun with no default value must be associated with an actual value.


any idea how to solve my problem?

bart
 

Bartart said:
Hi!
but in my VHDL code when I use the function it doesn't work.

the syntax is

SO <= fun 3 6 "101";

the error is

IN mode Formal xfrom of fun with no default value must be associated with an actual value.
bart

I guess the parentheses were lost and you really meant:

SO <= fun(3,6,"101");

Can you post the definition of the function?

function fun(a:integer; b:integer; c:std_logic_vector) return std_logic_vector; ?

The error shows that there is at least one missing parameter.
 

This function gets two arguments as integer and a number as std_logic_vector. Output of the function is logic_vector with extended sign bit (MSB) of the input data.

example:

fun(3,6,"101") should return 111101
fun(8,6,"001") - || - 001 error

This is a function definition:

function fun (
signal xfrom : integer;
signalal xto : integer;
signal xdat : std_logic_vector ) return std_logic_vector is

variable lxdat : std_logic_vector ((xto - xfrom) downto 0 );

begin
if ((xto - xfrom) = 0 or (xto - xfrom) < 0 ) then
return xdat;
elsif (xto - xfrom) > 0 then
for i in xfrom to xto loop
lxdat(i + xfrom) := xdat(xfrom);
end loop;
return lxdat;
end if;
end fun;


I have tried with fun() but no effect.
:cry:


thx vomit!

Bart
 

The problem here is the matching between actual and formal parameters:

you defined xfrom, xto and xdata (formal parameters) as signals, while the actual parameters you're using are constants.

You can:

1) define three signals A, B as integer, C as std_logic_vector and use them to pass actual parameters to the function;

2) remove the signal definition from formal parameters

Try to change you function definition as:

function fun ( xfrom : integer;
xto : integer;
xdat : std_logic_vector )
return std_logic_vector

It works fine!

Pay attention also to your implementation; imho there is some errors: if i've understood your intentions, the right code would be

function fun ( xfrom : integer;
xto : integer;
xdat : std_logic_vector )
return std_logic_vector is

variable lxdat : std_logic_vector ((xto - 1) downto 0 );

begin
if ((xto - xfrom) = 0 or (xto - xfrom) < 0 ) then
return xdat;
elsif (xto - xfrom) > 0 then
for i in 0 to xfrom - 1 loop
lxdat(i) := xdat(i);
end loop;
for i in xfrom - 1 to xto - 1 loop
lxdat(i) := xdat(xfrom-1);
end loop;
return lxdat;
end if;
end fun;

Hoping this will be an help for you,

Ro.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top