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.

Where to store values ?

Status
Not open for further replies.

Binome

Full Member level 3
Full Member level 3
Joined
Nov 16, 2009
Messages
153
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
Lyon, France
Visit site
Activity points
2,412
Hi,
I will simplify my question: say I want to store an array of n*m numbers. Then I want to be able to compute the product of two such values, many products at the same time. I think I can't use a memory as only one value will be readable at each clock cycle and I need to read any value immediatly at any time.
How should I implement it in VHDL language?
Thanks.
 

If you dont want to do it serially from a memory, your only option will be to store it in registers. If n*m is sufficiently large, it will use a large proportion of FPGA resources.
 

Unfortunely not.
They are the sine and cosine values of an FFT function. They are constant during a process but can change from a process to the other depending on the number of points.
 

OK, I just have to think about a simple code to show what I want because the FFT algorithm is a bit complicated.
I let you know...
 

Hi,
I will simplify my question: say I want to store an array of n*m numbers. Then I want to be able to compute the product of two such values, many products at the same time. I think I can't use a memory as only one value will be readable at each clock cycle and I need to read any value immediatly at any time.
How should I implement it in VHDL language?
Implement the numbers as a two dimensional matrix of numbers. Something like this...

type t_MATRIX_O_NUMBERS is array(1 to n, 1 to m) of unsigned(...); -- If you want to use unsigned numbers
type t_MATRIX_O_NUMBERS is array(1 to n, 1 to m) of ufixed(...); -- If you want to use fixed point unsigned numbers
type t_MATRIX_O_NUMBERS is array(1 to n, 1 to m) of sfixed(...); -- If you want to use fixed point signed numbers
type t_MATRIX_O_NUMBERS is array(1 to n, 1 to m) of integer range ...; -- If you want to use integer numbers

Then you declare a signal as...

signal My_Matrix: t_MATRIX_O_NUMBERS;

** In each of the above, the '...' needs to be replaced by something that defines how many bits of precision you want for these n*m numbers.

** It's also likely that it would be better to define the range of the array as '0 to (n-1), 0 to (m-1)' rather than '1 to n, 1 to m'. That's up to you to decide.

Kevin Jennings
 

Well, I won't post any code as it's too complicated. So I'll try to explain with words:
When computing the FFT algorithm, some partial results have to be multiplied by sine and cosine of 2*Pi*k/N (they're called the twiddle-factors) where N is any power of 2 from 2 to the number of input points and k is an integer from 0 to N-1. So I want these values to be precomputed (bu Matlab for example) and to be stored in a table where my circuit could read any value instantly.
The solution proposed by K-J seems pretty good. I have some questions though:
Wouldn't it be better to declare all the values as constants in a package?
How to precompute a lot of values with Matlab and automatically put them in a VHDL file?
Is the sfixed type something that is well understood by any synthesizer?
 

Well, I won't post any code as it's too complicated. So I'll try to explain with words:
When computing the FFT algorithm, some partial results have to be multiplied by sine and cosine of 2*Pi*k/N (they're called the twiddle-factors) where N is any power of 2 from 2 to the number of input points and k is an integer from 0 to N-1. So I want these values to be precomputed (bu Matlab for example) and to be stored in a table where my circuit could read any value instantly.

Then they are constants, so simply change 'signal' to 'constant' in my previous post and then define the value of that constant which is a 2d array of numbers.

The solution proposed by K-J seems pretty good. I have some questions though:
Wouldn't it be better to declare all the values as constants in a package?
The constant would need to be in a package if it needs to be accessed by multiple entities. If the numbers are only needed inside a single entity/architecture, then there is no advantage to putting it in a package. In that situation you can put it in a package, there is just no advantage (or disadvantage) to doing so.
How to precompute a lot of values with Matlab and automatically put them in a VHDL file?
FFT twiddle factors won't change so this sounds like a one time thing which can be accomplished with copy/paste. I'll further add that there is likely no reason to even involve Matlab in the first place. The VHDL language has sine and cosine functions and can be used to directly compute the twiddle factors with a function. No need then to have two applications and wonder about the best way to move something from one to the other.
Is the sfixed type something that is well understood by any synthesizer?
'Any' of course makes it a loaded question. The fixed point package is supported by Altera, I'm pretty sure Xilinx also. If you have something else in mind then you should be more specific, or perhaps simply try it out.

Lastly, since your goal for this matrix of numbers is that they be twiddle factors, then you'll likely want a second step to what I had posted earlier. You will want a function to compute (or copy/paste from Matlab) a two dimensional matrix of real number constants. In the next step, you'll want a function that receives as input that two dimensional matrix of real numbers and outputs a two dimensional matrix of sfixed (signed fixed point) numbers. While real number signals are not currently synthesizable, real number constants are.

Kevin Jennings
 

I really thank you for this complete explanation.
I didn't know VHDL was able to compute sine and cosine functions, I think that will make my circuit easy to write now. Just tell me how I have to use it, which package, which syntax for whatever precision I want...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top