Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16556 Discussions

Call a function from a function in VHDL

Altera_Forum
Honored Contributor II
2,487 Views

Hi guys, I think this is my first post and I am glad to belong to ALTERA forums. 

Here is my problem: I've read some posts from other forums and I cannot find anything related to invoke a function from a function in VHDL. Is that possible???? Here is the thing, I created a ROM of 168 positions of std_logic_vectors (7 downto 0) and I did it in a function that returns a std_logic_vector (one of them) so I can read de data several times by calling the function whenever I want. The problem is that I do not know if I can read the data from another function, I have not tried yet, it is a little bit complicated to do it right now at work, I think I could try this weekend , but if you advise me it would be much better:D:D:D. Sorry for my english I speak spanish;)
0 Kudos
9 Replies
Altera_Forum
Honored Contributor II
1,277 Views

Calling a function from a function is no problem in VHDL. You can nest functions in any levels of functions. And it will simulate not problem (just dont make some infinitely recursive function) 

 

The problem may come in synthesis - your code needs to map to some real hardware. As long as this is the case, then no problem. But if you're trying to be too clever, it may not synthesise. 

Post some code that has a problem to discuss further.
0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Thanks, I will post the possible problems next Monday after simulation and synthesis. I do not have internet at home :(

0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Implementing data storage in procedures and impure functions is more a simulation than hardware synthesis thing in my opinion, even if it's supported by Quartus synthesis.

0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Hi, as I said last friday, I worked on the calling function form a function last weekend and it was just great!!!!!!!!:):):) Now I am trying to do some things inside the function called in order to achieve may goal. If I have problems I'll post them here. Thanks everyone. ;)

0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Remember that functions can only create logic and not registers. Creating complicated functions will create complicated logic that you may not being able to break up easily for pipelining and hence lowering your FMax

0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

What I want to do is create a bidimiensional array of integers and I want to do it in a function, but first I need to calculate the values of the integers form a mathematical operation with real numbers, I want it to do it in a for loopinside the function, so while I am doing the math operation and conversion I enter the numbers in the positions of the array. The array has to be bidimensional because I have to access it with two variables as indexes. I do not think that would cause a huge problem. I hope it can be done, what do you think about it Tricky??

0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Is this for initialising a ROM? Real values cannot be used in synthesisable code, but they can be used to initialise ROM/RAM contents assuming the ROM/RAM contains a synthesisable type (not real).  

If it is for some run-time code, your description makes it sound like it wont map nicely to hardware and probably should not be inside a function. It sounds more like a software description rather than hardware.
0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Yes, it is for initializing a rom of integers, the values of the rom are integers converted from a math operation with real numbers, the value of the rom depend on two set of constants an unidimensional array of integers and an unidimensional array of reals. In order to sinthesise the code I convert the result of the math operation in an integer and that is what I save in the rom. Then I expect to read the rom in some process of the program.

0 Kudos
Altera_Forum
Honored Contributor II
1,277 Views

Heyyyy :) I did it!!!!!!!!!!!!!!!!!!! I only need to simulate in ModelSim for seeing the values in the rom, but so far I did not receive any error. Thanks for your piece of advise Tricky, I am not finish yet but this is a huge step for my design. I will continue, if I have some kind of trouble I will tell, thanks :o

0 Kudos
Reply