- Joined
- Feb 12, 2011
- Messages
- 2
- Reaction score
- 0
Dear All,
This is the first time I post a question here in Velocity Reviews.
I hope that in the future I can get more experience so that I may help answering other people's questions.
I am developing a VHDL application dealing with complex numbers - and I decided to develop complex numbers using fixed point representation (using IEEE fixed_pkg):
Using this package, we can represent y=6.5 by:
1- Defining
which means that y has 4 binary digits before the decimal point and 5 binary digits after the decimal point.
then we use either:
OR
For more details search Google for: "Fixed point package user’s guide"
Therefore I have defined the following function to ease the definition of complex numbers:
Therefore a complex number such as alpha = 1 + 0i can be represented as:
Within my application, I want to deal with a matrix of complex numbers:
The problem I am asking for is this:
When I define the following matrix:
It passes by compilation stage in ModelSim (vcom), however an error appears to me in vsim:
i.e. When it deals with I cmplx_matrix assignment, it considers the length of one dimension of the matrix being 0 to 1, and tries to equate it to the length of the result of s_fixed function.
What can the solution be?
This is the first time I post a question here in Velocity Reviews.
I hope that in the future I can get more experience so that I may help answering other people's questions.
I am developing a VHDL application dealing with complex numbers - and I decided to develop complex numbers using fixed point representation (using IEEE fixed_pkg):
Code:
use ieee.fixed_float_types.all;
use ieee.fixed_pkg.all;
....
type complex_fixed is record
RE : sfixed (1 downto -10);
IM : sfixed (1 downto -10);
end record;
Using this package, we can represent y=6.5 by:
1- Defining
Code:
signal y : sfixed (4 downto –5);
then we use either:
Code:
y <= "0011010000"; -- y = 6.5 = “00110.10000”
Code:
y <= to_sfixed(6.5);
For more details search Google for: "Fixed point package user’s guide"
Therefore I have defined the following function to ease the definition of complex numbers:
Code:
function to_cplxfixed (RE, IM: real) return complex_fixed;
....
function to_cplxfixed (RE, IM: real) return complex_fixed is
begin
return (to_sfixed(RE, -1, 10), to_sfixed(IM, -1, 10));
end function;
Therefore a complex number such as alpha = 1 + 0i can be represented as:
Code:
alpha: complex_fixed := to_cplxfixed((1.0, 0.0));
Within my application, I want to deal with a matrix of complex numbers:
Code:
type cmplx_matrix is array (natural range<>, natural range<>) of complex_fixed;
The problem I am asking for is this:
When I define the following matrix:
Code:
constant I: cmplx_matrix(0 to 1, 0 to 1) := ((to_cplxfixed((1.0,0.0)), to_cplxfixed((0.0,0.0))),
(to_cplxfixed((0.0,0.0)), to_cplxfixed((1.0,0.0)))
);
Code:
# ** Fatal: (vsim-3420) Array lengths do not match. Left is 12 (1 downto -10). Right is 0 (0 downto 1 (null array)).
# Time: 0 ns Iteration: 0 Region: /quantum_systems File: COMPLEX_FIXED.vhd Line: 27
# FATAL ERROR while loading design
i.e. When it deals with I cmplx_matrix assignment, it considers the length of one dimension of the matrix being 0 to 1, and tries to equate it to the length of the result of s_fixed function.
What can the solution be?