Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
VHDL
Matrix of Records of Arrays
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="mostafa.elhoushi, post: 4185416, member: 71791"] 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): [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;[/CODE] Using this package, we can represent y=6.5 by: 1- Defining [CODE]signal y : sfixed (4 downto –5);[/CODE] which means that y has 4 binary digits before the decimal point and 5 binary digits after the decimal point. then we use either: [CODE]y <= "0011010000"; -- y = 6.5 = “00110.10000”[/CODE] OR [CODE]y <= to_sfixed(6.5);[/CODE] 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;[/CODE] Therefore a complex number such as alpha = 1 + 0i can be represented as: [CODE]alpha: complex_fixed := to_cplxfixed((1.0, 0.0));[/CODE] 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;[/CODE] 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] It passes by compilation stage in ModelSim (vcom), however an error appears to me in vsim: [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[/CODE] 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? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
VHDL
Matrix of Records of Arrays
Top