Select Git revision
technology_pkg.vhd
-
Eric Kooistra authoredEric Kooistra authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
technology_pkg.vhd 5.09 KiB
-------------------------------------------------------------------------------
--
-- Copyright (C) 2014
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-------------------------------------------------------------------------------
-- Purpose: Define the list of FPGA technology identifiers
-- Description:
-- The technology dependent IP is organised per FPGA device type. Each FPGA
-- type that is supported has a c_tech_<device_name> identifier constant.
-- Remark:
-- . The package also contains some low level functions that often are copied
-- from common_pkg.vhd. They need to be redefined in this technology_pkg.vhd
-- because the common_lib also use technology dependent IP like RAM, FIFO,
-- DDIO. Therefore common_lib can not be used in the IP wrappers for those
-- IP blocks, because common_lib is compiled later.
-- . For technology wrappers that are not used by components in common_lib the
-- common_pkg.vhd can be used. Similar technology wrappers that are not used
-- by components in dp_lib can use the dp_stream_pkg.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.MATH_REAL.ALL;
PACKAGE technology_pkg IS
-- Technology identifiers
CONSTANT c_tech_inferred : INTEGER := 0;
CONSTANT c_tech_virtex4 : INTEGER := 1; -- e.g. used on RSP3 for Lofar
CONSTANT c_tech_stratixiv : INTEGER := 2; -- e.g. used on UniBoard1
CONSTANT c_tech_virtex6 : INTEGER := 3; -- e.g. used on Roach2 for Casper
CONSTANT c_tech_virtex7 : INTEGER := 4; -- e.g. used on Roach3 for Casper
CONSTANT c_tech_arria10 : INTEGER := 5; -- e.g. used on UniBoard2
CONSTANT c_tech_nof_technologies : INTEGER := 6;
-- Functions
FUNCTION tech_sel_a_b(sel : BOOLEAN; a, b : STRING) RETURN STRING;
FUNCTION tech_sel_a_b(sel : BOOLEAN; a, b : INTEGER) RETURN INTEGER;
FUNCTION tech_true_log2(n : NATURAL) RETURN NATURAL; -- tech_true_log2(n) = log2(n)
FUNCTION tech_ceil_log2(n : NATURAL) RETURN NATURAL; -- tech_ceil_log2(n) = log2(n), but force tech_ceil_log2(1) = 1
FUNCTION tech_ceil_div(n, d : NATURAL) RETURN NATURAL; -- tech_ceil_div = n/d + (n MOD d)/=0
FUNCTION tech_nat_to_mbps_str( n : IN NATURAL ) RETURN STRING;
END technology_pkg;
PACKAGE BODY technology_pkg IS
FUNCTION tech_sel_a_b(sel : BOOLEAN; a, b : STRING) RETURN STRING IS
BEGIN
IF sel=TRUE THEN RETURN a; ELSE RETURN b; END IF;
END;
FUNCTION tech_sel_a_b(sel : BOOLEAN; a, b : INTEGER) RETURN INTEGER IS
BEGIN
IF sel=TRUE THEN RETURN a; ELSE RETURN b; END IF;
END;
FUNCTION tech_true_log2(n : NATURAL) RETURN NATURAL IS
-- Purpose: For calculating extra vector width of existing vector
-- Description: Return mathematical ceil(log2(n))
-- n log2()
-- 0 -> -oo --> FAILURE
-- 1 -> 0
-- 2 -> 1
-- 3 -> 2
-- 4 -> 2
-- 5 -> 3
-- 6 -> 3
-- 7 -> 3
-- 8 -> 3
-- 9 -> 4
-- etc, up to n = NATURAL'HIGH = 2**31-1
BEGIN
RETURN natural(integer(ceil(log2(real(n)))));
END;
FUNCTION tech_ceil_log2(n : NATURAL) RETURN NATURAL IS
-- Purpose: For calculating vector width of new vector
-- Description:
-- Same as tech_true_log2() except tech_ceil_log2(1) = 1, which is needed to support
-- the vector width width for 1 address, to avoid NULL array for single
-- word register address.
BEGIN
IF n = 1 THEN
RETURN 1; -- avoid NULL array
ELSE
RETURN tech_true_log2(n);
END IF;
END;
FUNCTION tech_ceil_div(n, d : NATURAL) RETURN NATURAL IS
BEGIN
RETURN n/d + tech_sel_a_b(n MOD d = 0, 0, 1);
END;
FUNCTION tech_nat_to_mbps_str( n : IN NATURAL ) RETURN STRING IS -- Converts a selection of naturals to Mbps strings, used for edited MegaWizard file in ip_stratixiv_hssi_*_generic.vhd
VARIABLE r : STRING(1 TO 9);
BEGIN
CASE n is
WHEN 2500 => r := "2500 Mbps";
WHEN 3125 => r := "3125 Mbps";
WHEN 5000 => r := "5000 Mbps";
WHEN 6250 => r := "6250 Mbps";
WHEN OTHERS =>
r := "ERROR: tech_nat_to_mbps_str UNSUPPORTED DATA RATE"; -- This too long string will cause an error in Quartus synthesis
REPORT r SEVERITY FAILURE; -- Severity Failure will stop the Modelsim simulation
END CASE;
RETURN r;
END;
END technology_pkg;