S
Stanley
Guest
Hi all,
I knew that my VHDL synthesizer "Synplify" does not support 2D array
declaration...thus I wonder how can my input be rewritten into 1D
array? Any feedback will be very appreciate!!!
package test is
type matrix is array(natural range<>, natural range<> of complex;
end package test;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use work.test.all;
-- This matrix function calculates the square of each term, then
returns the
-- sum of sqared results
-- This matrix function is capable to accept any length of matrix
-- The data type can be either real or complex number (floating-point)
entity matrix_agr is
generic (args : integer :=1);
port(
arg: in matrix(0 to args, 0 to args);
rst:in std_logic;
resultut real
);
end matrix_agr;
architecture beh of matrix_agr is
begin
process (rst) is
variable temp_r,temp_i: real;
begin
if rst='1' then
temp_r:=0.0;
temp_i:=0.0;
else
for i in 0 to args loop
for j in 0 to args loop
temp_r:=temp_r + (arg(i,j).re)**2;
temp_i:=temp_i + (arg(i,j).im)**2;
end loop;
end loop;
end if;
result<=temp_r + temp_i;
end process;
end architecture;
I knew that my VHDL synthesizer "Synplify" does not support 2D array
declaration...thus I wonder how can my input be rewritten into 1D
array? Any feedback will be very appreciate!!!
package test is
type matrix is array(natural range<>, natural range<> of complex;
end package test;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use work.test.all;
-- This matrix function calculates the square of each term, then
returns the
-- sum of sqared results
-- This matrix function is capable to accept any length of matrix
-- The data type can be either real or complex number (floating-point)
entity matrix_agr is
generic (args : integer :=1);
port(
arg: in matrix(0 to args, 0 to args);
rst:in std_logic;
resultut real
);
end matrix_agr;
architecture beh of matrix_agr is
begin
process (rst) is
variable temp_r,temp_i: real;
begin
if rst='1' then
temp_r:=0.0;
temp_i:=0.0;
else
for i in 0 to args loop
for j in 0 to args loop
temp_r:=temp_r + (arg(i,j).re)**2;
temp_i:=temp_i + (arg(i,j).im)**2;
end loop;
end loop;
end if;
result<=temp_r + temp_i;
end process;
end architecture;