Z
Zhi
Here is a package below. It cannot even pass the Syntax check. Error:
" In Complex_Pkg. function + declared in the PackageDeclaration not
found.
In Complex_Pkg. function - declared in the PackageDeclaration not
found."
I don't know what is wrong with the function "+/-" declaration.
Please help!
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
package Complex_Pkg is
constant length_c: integer :=32;
type Complex32_Typ is record
R : signed(length_c-1 downto 0);
I : signed(length_c-1 downto 0);
end record;
type Complex64_Typ is record
R : signed(2*length_c-1 downto 0);
I : signed(2*length_c-1 downto 0);
end record;
type A2x2C32_Typ is array(1 to 4) of Complex32_Typ;
type A2x2C64_Typ is array(1 to 4) of Complex64_Typ;
function "+" (A : Complex32_Typ;
B : Complex32_Typ) return Complex32_Typ;
function "-" (A : Complex32_Typ;
B : Complex32_Typ) return Complex32_Typ;
function "+" (A : Complex64_Typ;
B : Complex64_Typ) return Complex64_Typ;
function "-" (A : Complex64_Typ;
B : Complex64_Typ) return
Complex64_Typ;
function "*" (A : Complex32_Typ;
B : Complex32_TYp) return Complex64_Typ;
function "*" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return A2x2C64_Typ;
function "+" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return A2x2C32_Typ;
function "-" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return
A2x2C32_Typ;
end Complex_Pkg;
--
======================================================================
package body Complex_Pkg is
function "+" (A: Complex32_Typ;
B: Complex32_Typ) return Complex32_Typ is
variable V: Complex32_Typ;
begin
V.R :=A.R + B.R;
V.I :=A.I + B.I;
return V;
end "+";
function "-" (A: Complex32_Typ;
B: Complex32_Typ) return Complex32_Typ is
variable V: Complex32_Typ;
begin
V.R := A.R - B.R;
V.I := A.I - B.I;
return V;
end "-";
function "*" (A: Complex32_Typ;
B: Complex32_Typ) return Complex64_Typ is
variable V: Complex64_Typ;
begin
V.R :=(A.R * B.R) - (A.I * B.I);
V.I :=(A.I * B.R) + (A.R * B.I);
return V;
end "*";
function "*"(A: A2x2C32_Typ;
B: A2x2C32_Typ) return A2x2C64_Typ is
variable V :A2x2C64_Typ;
begin
V(1) :=(A(1) * B(1)) + (A(2) * B(3));
V(2) :=(A(1) * B(2)) + (A(2) * B(4));
V(3) :=(A(3) * B(1)) + (A(4) * B(3));
V(4) :=(A(3) * B(2)) + (A(4) * B(4));
return V;
end "*";
function "+" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return A2x2C32_Typ is
variable V: A2x2C32_Typ;
begin
for I in A'range loop
V(I) :=A(I) + B(I);
end loop;
return V;
end "+";
function "-" (A: A2x2C32_Typ;
B: A2x2C32_Typ) return A2x2C32_Typ is
variable V: A2x2C32_Typ;
begin
for I in A'range loop
V(I) :=A(I) - B(I);
end loop;
return V;
end "-";
end Complex_Pkg;
" In Complex_Pkg. function + declared in the PackageDeclaration not
found.
In Complex_Pkg. function - declared in the PackageDeclaration not
found."
I don't know what is wrong with the function "+/-" declaration.
Please help!
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
package Complex_Pkg is
constant length_c: integer :=32;
type Complex32_Typ is record
R : signed(length_c-1 downto 0);
I : signed(length_c-1 downto 0);
end record;
type Complex64_Typ is record
R : signed(2*length_c-1 downto 0);
I : signed(2*length_c-1 downto 0);
end record;
type A2x2C32_Typ is array(1 to 4) of Complex32_Typ;
type A2x2C64_Typ is array(1 to 4) of Complex64_Typ;
function "+" (A : Complex32_Typ;
B : Complex32_Typ) return Complex32_Typ;
function "-" (A : Complex32_Typ;
B : Complex32_Typ) return Complex32_Typ;
function "+" (A : Complex64_Typ;
B : Complex64_Typ) return Complex64_Typ;
function "-" (A : Complex64_Typ;
B : Complex64_Typ) return
Complex64_Typ;
function "*" (A : Complex32_Typ;
B : Complex32_TYp) return Complex64_Typ;
function "*" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return A2x2C64_Typ;
function "+" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return A2x2C32_Typ;
function "-" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return
A2x2C32_Typ;
end Complex_Pkg;
--
======================================================================
package body Complex_Pkg is
function "+" (A: Complex32_Typ;
B: Complex32_Typ) return Complex32_Typ is
variable V: Complex32_Typ;
begin
V.R :=A.R + B.R;
V.I :=A.I + B.I;
return V;
end "+";
function "-" (A: Complex32_Typ;
B: Complex32_Typ) return Complex32_Typ is
variable V: Complex32_Typ;
begin
V.R := A.R - B.R;
V.I := A.I - B.I;
return V;
end "-";
function "*" (A: Complex32_Typ;
B: Complex32_Typ) return Complex64_Typ is
variable V: Complex64_Typ;
begin
V.R :=(A.R * B.R) - (A.I * B.I);
V.I :=(A.I * B.R) + (A.R * B.I);
return V;
end "*";
function "*"(A: A2x2C32_Typ;
B: A2x2C32_Typ) return A2x2C64_Typ is
variable V :A2x2C64_Typ;
begin
V(1) :=(A(1) * B(1)) + (A(2) * B(3));
V(2) :=(A(1) * B(2)) + (A(2) * B(4));
V(3) :=(A(3) * B(1)) + (A(4) * B(3));
V(4) :=(A(3) * B(2)) + (A(4) * B(4));
return V;
end "*";
function "+" (A : A2x2C32_Typ;
B : A2x2C32_Typ) return A2x2C32_Typ is
variable V: A2x2C32_Typ;
begin
for I in A'range loop
V(I) :=A(I) + B(I);
end loop;
return V;
end "+";
function "-" (A: A2x2C32_Typ;
B: A2x2C32_Typ) return A2x2C32_Typ is
variable V: A2x2C32_Typ;
begin
for I in A'range loop
V(I) :=A(I) - B(I);
end loop;
return V;
end "-";
end Complex_Pkg;