Skip to content
Snippets Groups Projects
Commit f7d13182 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Clarified 2arr_2 notation. Corrected variable instead of constant in function...

Clarified 2arr_2 notation. Corrected variable instead of constant in function pack_complex() and unpack_complex().
parent c9f75113
Branches
Tags
1 merge request!198Clarified reading one WPFB unit into sp_subband_powers_arr2. Updated comments....
Pipeline #24658 passed
......@@ -137,10 +137,18 @@ PACKAGE common_pkg IS
TYPE t_slv_32_matrix IS ARRAY (INTEGER RANGE <>, INTEGER RANGE <>) OF STD_LOGIC_VECTOR(31 DOWNTO 0);
TYPE t_slv_64_matrix IS ARRAY (INTEGER RANGE <>, INTEGER RANGE <>) OF STD_LOGIC_VECTOR(63 DOWNTO 0);
TYPE t_natural_2arr_2 IS ARRAY (INTEGER RANGE <>) OF t_natural_arr(1 DOWNTO 0);
TYPE t_complex_integer_arr2 IS ARRAY (NATURAL RANGE <>) OF t_integer_arr(1 DOWNTO 0);
TYPE t_complex_real_arr2 IS ARRAY (NATURAL RANGE <>) OF t_real_arr(1 DOWNTO 0);
-- Multi-dimensional array types with fixed LS-dimension
-- . 2arr_2
-- . first '2' indicates two dimensions, so array I of array J, where I is
-- free in (NATURAL RANGE <>)
-- . second '_2' indicate that the last dimension J has fixed size 2 is
-- (1 DOWNTO 0)
TYPE t_natural_2arr_2 IS ARRAY (NATURAL RANGE <>) OF t_natural_arr(1 DOWNTO 0);
TYPE t_integer_2arr_2 IS ARRAY (NATURAL RANGE <>) OF t_integer_arr(1 DOWNTO 0);
TYPE t_real_2arr_2 IS ARRAY (NATURAL RANGE <>) OF t_real_arr(1 DOWNTO 0);
SUBTYPE t_complex_integer_arr_2 IS t_integer_2arr_2;
SUBTYPE t_complex_real_arr_2 IS t_real_2arr_2;
-- STRUCTURE DECLARATIONS ---------------------------------------------------
......@@ -724,38 +732,40 @@ PACKAGE BODY common_pkg IS
FUNCTION pack_complex(re, im : INTEGER; w : NATURAL) RETURN INTEGER IS
CONSTANT c_complex_w : NATURAL := 2 * w;
CONSTANT c_complex_slv : STD_LOGIC_VECTOR(c_complex_w-1 DOWNTO 0) := TO_SVEC(im, w) & TO_SVEC(re, w);
VARIABLE v_complex_slv : STD_LOGIC_VECTOR(c_complex_w-1 DOWNTO 0) := TO_SVEC(im, w) & TO_SVEC(re, w);
BEGIN
ASSERT c_complex_w <= c_word_w REPORT "common_pkg: Complex value to large to pack into 32 bit integer" SEVERITY FAILURE;
IF c_complex_w < c_word_w THEN -- fits in 31 bit unsigned NATURAL
RETURN TO_UINT(c_complex_slv);
RETURN TO_UINT(v_complex_slv);
ELSE -- need to use 32 bit signed INTEGER
RETURN TO_SINT(c_complex_slv);
RETURN TO_SINT(v_complex_slv);
END IF;
END;
FUNCTION unpack_complex_re(data : STD_LOGIC_VECTOR; w : NATURAL) RETURN INTEGER IS
BEGIN
ASSERT w <= c_word_w REPORT "common_pkg: Complex value to large to unpack into 32 bit integer parts" SEVERITY FAILURE;
RETURN TO_SINT(data(w-1 DOWNTO 0)); -- Re in LS part
END;
FUNCTION unpack_complex_re(data : INTEGER; w : NATURAL) RETURN INTEGER IS
CONSTANT c_complex_w : NATURAL := 2 * w;
CONSTANT c_complex_slv : STD_LOGIC_VECTOR(c_complex_w-1 DOWNTO 0) := TO_SVEC(data, c_complex_w);
VARIABLE v_complex_slv : STD_LOGIC_VECTOR(c_complex_w-1 DOWNTO 0) := TO_SVEC(data, c_complex_w);
BEGIN
RETURN TO_SINT(c_complex_slv(w-1 DOWNTO 0)); -- Re in LS part
RETURN TO_SINT(v_complex_slv(w-1 DOWNTO 0)); -- Re in LS part
END;
FUNCTION unpack_complex_im(data : STD_LOGIC_VECTOR; w : NATURAL) RETURN INTEGER IS
BEGIN
ASSERT w <= c_word_w REPORT "common_pkg: Complex value to large to unpack into 32 bit integer parts" SEVERITY FAILURE;
RETURN TO_SINT(data(2*w-1 DOWNTO w)); -- Im in MS part
END;
FUNCTION unpack_complex_im(data : INTEGER; w : NATURAL) RETURN INTEGER IS
CONSTANT c_complex_w : NATURAL := 2 * w;
CONSTANT c_complex_slv : STD_LOGIC_VECTOR(c_complex_w-1 DOWNTO 0) := TO_SVEC(data, c_complex_w);
VARIABLE v_complex_slv : STD_LOGIC_VECTOR(c_complex_w-1 DOWNTO 0) := TO_SVEC(data, c_complex_w);
BEGIN
RETURN TO_SINT(c_complex_slv(c_complex_w-1 DOWNTO w)); -- Im in MS part
RETURN TO_SINT(v_complex_slv(c_complex_w-1 DOWNTO w)); -- Im in MS part
END;
FUNCTION atan2(Y, X: REAL) RETURN REAL IS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment