⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stratixii_atoms.vhd

📁 free hardware ip core about sparcv8,a soc cpu in vhdl
💻 VHD
📖 第 1 页 / 共 5 页
字号:
-- Copyright (C) 1991-2006 Altera Corporation-- Your use of Altera Corporation's design tools, logic functions-- and other software and tools, and its AMPP partner logic-- functions, and any output files any of the foregoing-- (including device programming or simulation files), and any-- associated documentation or information are expressly subject-- to the terms and conditions of the Altera Program License-- Subscription Agreement, Altera MegaCore Function License-- Agreement, or other applicable license agreement, including,-- without limitation, that your use is for the sole purpose of-- programming logic devices manufactured by Altera and sold by-- Altera or its authorized distributors.  Please refer to the-- applicable agreement for further details.-- Quartus II 6.0 Build 178 04/27/2006library IEEE;use IEEE.std_logic_1164.all;use IEEE.VITAL_Timing.all;use IEEE.VITAL_Primitives.all;package stratixii_atom_pack isfunction str_to_bin (lut_mask : string ) return std_logic_vector;function product(list : std_logic_vector) return std_logic ;function alt_conv_integer(arg : in std_logic_vector) return integer;-- default generic values    CONSTANT DefWireDelay        : VitalDelayType01      := (0 ns, 0 ns);    CONSTANT DefPropDelay01      : VitalDelayType01      := (1 ns, 1 ns);    CONSTANT DefPropDelay01Z     : VitalDelayType01Z     := (OTHERS => 1 ns);    CONSTANT DefSetupHoldCnst    : TIME := 0 ns;    CONSTANT DefPulseWdthCnst    : TIME := 0 ns;-- default control options--    CONSTANT DefGlitchMode       : VitalGlitchKindType   := OnEvent;-- change default delay type to Transport : for spr 68748    CONSTANT DefGlitchMode       : VitalGlitchKindType   := VitalTransport;    CONSTANT DefGlitchMsgOn      : BOOLEAN       := FALSE;    CONSTANT DefGlitchXOn        : BOOLEAN       := FALSE;    CONSTANT DefMsgOnChecks      : BOOLEAN       := TRUE;    CONSTANT DefXOnChecks        : BOOLEAN       := TRUE;-- output strength mapping                                                --  UX01ZWHL-    CONSTANT PullUp      : VitalOutputMapType    := "UX01HX01X";    CONSTANT NoPullUpZ   : VitalOutputMapType    := "UX01ZX01X";    CONSTANT PullDown    : VitalOutputMapType    := "UX01LX01X";-- primitive result strength mapping    CONSTANT wiredOR     : VitalResultMapType    := ( 'U', 'X', 'L', '1' );    CONSTANT wiredAND    : VitalResultMapType    := ( 'U', 'X', '0', 'H' );    CONSTANT L : VitalTableSymbolType := '0';    CONSTANT H : VitalTableSymbolType := '1';    CONSTANT x : VitalTableSymbolType := '-';    CONSTANT S : VitalTableSymbolType := 'S';    CONSTANT R : VitalTableSymbolType := '/';    CONSTANT U : VitalTableSymbolType := 'X';    CONSTANT V : VitalTableSymbolType := 'B'; -- valid clock signal (non-rising)-- Declare array types for CAM_SLICE    TYPE stratixii_mem_data IS ARRAY (0 to 31) of STD_LOGIC_VECTOR (31 downto 0);function int2str( value : integer ) return string;function map_x_to_0 (value : std_logic) return std_logic;function SelectDelay (CONSTANT Paths: IN  VitalPathArray01Type) return TIME;end stratixii_atom_pack;library IEEE;use IEEE.std_logic_1164.all;package body stratixii_atom_pack istype masklength is array (4 downto 1) of std_logic_vector(3 downto 0);function str_to_bin (lut_mask : string) return std_logic_vector isvariable slice : masklength := (OTHERS => "0000");variable mask : std_logic_vector(15 downto 0);begin    for i in 1 to lut_mask'length loop        case lut_mask(i) is            when '0' => slice(i) := "0000";            when '1' => slice(i) := "0001";            when '2' => slice(i) := "0010";            when '3' => slice(i) := "0011";            when '4' => slice(i) := "0100";            when '5' => slice(i) := "0101";            when '6' => slice(i) := "0110";            when '7' => slice(i) := "0111";            when '8' => slice(i) := "1000";            when '9' => slice(i) := "1001";            when 'a' => slice(i) := "1010";            when 'A' => slice(i) := "1010";            when 'b' => slice(i) := "1011";            when 'B' => slice(i) := "1011";            when 'c' => slice(i) := "1100";            when 'C' => slice(i) := "1100";            when 'd' => slice(i) := "1101";            when 'D' => slice(i) := "1101";            when 'e' => slice(i) := "1110";            when 'E' => slice(i) := "1110";            when others => slice(i) := "1111";        end case;    end loop;    mask := (slice(1) & slice(2) & slice(3) & slice(4));    return (mask);end str_to_bin;function product (list: std_logic_vector) return std_logic isbegin    for i in 0 to 31 loop        if list(i) = '0' then            return ('0');        end if;    end loop;    return ('1');end product;function alt_conv_integer(arg : in std_logic_vector) return integer isvariable result : integer;begin    result := 0;    for i in arg'range loop        if arg(i) = '1' then            result := result + 2**i;        end if;    end loop;    return result;end alt_conv_integer;function int2str( value : integer ) return string isvariable ivalue,index : integer;variable digit : integer;variable line_no: string(8 downto 1) := "        ";begin    ivalue := value;    index := 1;    if (ivalue = 0) then        line_no := "       0";    end if;    while (ivalue > 0) loop        digit := ivalue MOD 10;        ivalue := ivalue/10;        case digit is            when 0 =>                    line_no(index) := '0';            when 1 =>                    line_no(index) := '1';            when 2 =>                    line_no(index) := '2';            when 3 =>                    line_no(index) := '3';            when 4 =>                    line_no(index) := '4';            when 5 =>                    line_no(index) := '5';            when 6 =>                    line_no(index) := '6';            when 7 =>                    line_no(index) := '7';            when 8 =>                    line_no(index) := '8';            when 9 =>                    line_no(index) := '9';            when others =>                    ASSERT FALSE                    REPORT "Illegal number!"                    SEVERITY ERROR;        end case;        index := index + 1;    end loop;    return line_no;end;function map_x_to_0 (value : std_logic) return std_logic isbegin    if (Is_X (value) = TRUE) then        return '0';    else        return value;    end if;end;function SelectDelay (CONSTANT Paths : IN  VitalPathArray01Type) return TIME ISvariable Temp  : TIME;variable TransitionTime  : TIME := TIME'HIGH;variable PathDelay : TIME := TIME'HIGH;begin    for i IN Paths'RANGE loop        next when not Paths(i).PathCondition;        next when Paths(i).InputChangeTime > TransitionTime;        Temp := Paths(i).PathDelay(tr01);        if Paths(i).InputChangeTime < TransitionTime then            PathDelay := Temp;        else            if Temp < PathDelay then                PathDelay := Temp;            end if;        end if;        TransitionTime := Paths(i).InputChangeTime;    end loop;    return PathDelay;end;end stratixii_atom_pack;Library ieee;use ieee.std_logic_1164.all;Package stratixii_pllpack is    procedure find_simple_integer_fraction( numerator   : in integer;                                            denominator : in integer;                                            max_denom   : in integer;                                            fraction_num : out integer;                                            fraction_div : out integer);    function gcd (X: integer; Y: integer) return integer;    function count_digit (X: integer) return integer;    function scale_num (X: integer; Y: integer) return integer;    function lcm (A1: integer; A2: integer; A3: integer; A4: integer;                A5: integer; A6: integer; A7: integer;                A8: integer; A9: integer; A10: integer; P: integer) return integer;    function output_counter_value (clk_divide: integer; clk_mult : integer ;            M: integer; N: integer ) return integer;    function counter_mode (duty_cycle: integer; output_counter_value: integer) return string;    function counter_high (output_counter_value: integer := 1; duty_cycle: integer)                        return integer;    function counter_low (output_counter_value: integer; duty_cycle: integer)                        return integer;    function mintimedelay (t1: integer; t2: integer; t3: integer; t4: integer;                        t5: integer; t6: integer; t7: integer; t8: integer;                        t9: integer; t10: integer) return integer;    function maxnegabs (t1: integer; t2: integer; t3: integer; t4: integer;                        t5: integer; t6: integer; t7: integer; t8: integer;                        t9: integer; t10: integer) return integer;    function counter_time_delay ( clk_time_delay: integer;                        m_time_delay: integer; n_time_delay: integer)                        return integer;    function get_phase_degree (phase_shift: integer; clk_period: integer) return integer;    function counter_initial (tap_phase: integer; m: integer; n: integer)                        return integer;    function counter_ph (tap_phase: integer; m : integer; n: integer) return integer;    function ph_adjust (tap_phase: integer; ph_base : integer) return integer;    function translate_string (mode : string) return string;    function str2int (s : string) return integer;    function dqs_str2int (s : string) return integer;end stratixii_pllpack;package body stratixii_pllpack is-- finds the closest integer fraction of a given pair of numerator and denominator.procedure find_simple_integer_fraction( numerator   : in integer;                                        denominator : in integer;                                        max_denom   : in integer;                                        fraction_num : out integer;                                        fraction_div : out integer) is    constant MAX_ITER : integer := 20;    type INT_ARRAY is array ((MAX_ITER-1) downto 0) of integer;    variable quotient_array : INT_ARRAY;    variable int_loop_iter : integer;    variable int_quot  : integer;    variable m_value   : integer;    variable d_value   : integer;    variable old_m_value : integer;    variable swap  : integer;    variable loop_iter : integer;    variable num   : integer;    variable den   : integer;    variable i_max_iter : integer;begin    loop_iter := 0;    num := numerator;    den := denominator;    i_max_iter := max_iter;    while (loop_iter < i_max_iter) loop        int_quot := num / den;        quotient_array(loop_iter) := int_quot;        num := num - (den*int_quot);        loop_iter := loop_iter+1;        if ((num = 0) or (max_denom /= -1) or (loop_iter = i_max_iter)) then            -- calculate the numerator and denominator if there is a restriction on the            -- max denom value or if the loop is ending            m_value := 0;            d_value := 1;            -- get the rounded value at this stage for the remaining fraction            if (den /= 0) then                m_value := (2*num/den);            end if;            -- calculate the fraction numerator and denominator at this stage            for int_loop_iter in (loop_iter-1) downto 0 loop                if (m_value = 0) then                    m_value := quotient_array(int_loop_iter);                    d_value := 1;                else                    old_m_value := m_value;                    m_value := (quotient_array(int_loop_iter)*m_value) + d_value;                    d_value := old_m_value;                end if;            end loop;            -- if the denominator is less than the maximum denom_value or if there is no restriction save it            if ((d_value <= max_denom) or (max_denom = -1)) then                if ((m_value = 0) or (d_value = 0)) then                    fraction_num := numerator;                    fraction_div := denominator;                else                    fraction_num := m_value;                    fraction_div := d_value;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -