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

📄 transmittermegafunction .txt

📁 lvds transmitter megafunction
💻 TXT
📖 第 1 页 / 共 2 页
字号:
		inclk	   : in std_logic_vector(1 downto 0) := (others => '0');
		clkena     : in std_logic_vector(5 downto 0) := (others => '1');
		clk     	: out std_logic_vector(5 downto 0);
		locked		: out std_logic
	);
end component;

begin

    tx_in_int  <= tx_rgd when registered_input = "ON" else tx_in;
    tx_clock0_int <= tx_pll_clk0 when deserialization_factor > 1 else tx_inclock;
    tx_clock1_int <= tx_pll_clk1 when deserialization_factor > 1 else tx_inclock;
    tx_rgd_clk <= sync_inclock when multi_clock = "ON" else tx_inclock;
    tx_pll_clk2 <= tx_pll_clk2_deser when inclock_boost = 0 else tx_pll_clk2_boost;
    tx_outclock <= tx_pll_clk2 when intended_device_family = "MERCURY" else tx_clock1_int;
    tx_coreclock <= tx_mercury_core_clock when (((deserialization_factor rem 2)/=0) and (intended_device_family = "MERCURY")) else tx_clock1_int;
    tx_locked <= tx_locked_int when deserialization_factor > 1 else '1';
    mercury_pll_clk0 <= mercury_pll_clk0_deser when inclock_boost = 0 else mercury_pll_clk0_boost;
    mercury_pll_clk1 <= mercury_pll_clk1_deser when inclock_boost = 0 else mercury_pll_clk1_boost;
    tx_pll_clk0 <= mercury_pll_clk0 when intended_device_family = "MERCURY" or intended_device_family = "YEAGER" else apex20ke_pll_clk0;
    tx_pll_clk1 <= mercury_pll_clk1 when intended_device_family = "MERCURY" or intended_device_family = "YEAGER" else apex20ke_pll_clk1;
    mercury_locked_int <= mercury_locked_int_deser when inclock_boost = 0 else mercury_locked_int_boost;
    tx_locked_int <= mercury_locked_int when (intended_device_family = "MERCURY" or intended_device_family = "YEAGER") else apex20ke_locked_int;
    apex20ke_en <= tx_pll_enable when ( intended_device_family = "APEX20KE" or intended_device_family = "APEX20KC" or
                              (intended_device_family = "APEXII" or intended_device_family = "APEX II") or
                              intended_device_family = "EXCALIBUR_ARM" or intended_device_family = "EXCALIBUR_MIPS") else '0';
    mercury_en <= tx_pll_enable when ((intended_device_family = "MERCURY" or intended_device_family = "YEAGER") and inclock_boost = 0) else '0';
    mercury_boost_en <= tx_pll_enable when ((intended_device_family = "MERCURY" or intended_device_family = "YEAGER") and inclock_boost /= 0) else '0';


			int_clock_boost <= inclock_boost;


    U0: altclklock -- APEX20KE PLL
            generic map
              ( inclock_period => inclock_period,
                clock0_boost => deserialization_factor, clock1_boost => 1,
                valid_lock_cycles => 5,
                intended_device_family => intended_device_family)
            port map
              ( inclock => tx_inclock, inclocken => apex20ke_en,
                clock0 => apex20ke_pll_clk0, clock1 => apex20ke_pll_clk1,
                locked => apex20ke_locked_int );

    U1: altclklock -- MERCURY PLL with inclock boost = 0
            generic map
              ( inclock_period => inclock_period,
                clock0_boost => deserialization_factor, clock1_boost => 1,
                clock2_boost => deserialization_factor, clock2_divide => outclock_divide_by,
                valid_lock_cycles => 3,
                intended_device_family => intended_device_family)
            port map
              ( inclock => tx_inclock, inclocken => mercury_en,
                clock0 => mercury_pll_clk0_deser, clock1 => mercury_pll_clk1_deser,
                clock2 => tx_pll_clk2_deser, locked => mercury_locked_int_deser );


	YEAGER_PLL:
	if intended_device_family = "STRATIX" generate
	U2: altpll -- STRATIX PLL 
            generic map
              ( inclk0_input_frequency => inclock_period,
               
		clk0_multiply_by => clock_boost_calc (output_data_rate, inclock_period, deserialization_factor, inclock_boost), 
		clk1_multiply_by => clock_boost_calc (output_data_rate, inclock_period, deserialization_factor, inclock_boost),
                clk1_divide_by => deserialization_factor,
		clk2_multiply_by => clock_boost_calc (output_data_rate, inclock_period, deserialization_factor, inclock_boost),
		clk2_divide_by => outclock_divide_by,
               
		clk0_phase_shift => get_phase_delay (inclock_data_alignment),
		clk1_phase_shift => get_phase_delay (outclock_alignment),
                device_family => intended_device_family)
            port map
              ( inclk(0) => tx_inclock, inclk (1) => temp_zero, clkena(0) => mercury_boost_en, clkena(1 to 5) => temp_high,
                clk(0) => mercury_pll_clk0_boost, clk(1) => mercury_pll_clk1_boost, clk(2) => tx_pll_clk2_boost, clk (3 to 5) => temp_clk ,
                locked => mercury_locked_int_boost );

	end generate YEAGER_PLL;

	MERCURY_PLL:
	if intended_device_family /= "STRATIX" generate
	    U2: altclklock -- MERCURY PLL with inclock boost
            generic map
              ( inclock_period => inclock_period,
                clock0_boost => inclock_boost,
                clock1_boost => inclock_boost, clock1_divide => deserialization_factor,
                clock2_boost => inclock_boost, clock2_divide => outclock_divide_by,
                valid_lock_cycles => 3,
                intended_device_family => intended_device_family)
            port map
              ( inclock => tx_inclock, inclocken => mercury_boost_en,
                clock0 => mercury_pll_clk0_boost, clock1 => mercury_pll_clk1_boost,
                clock2 => tx_pll_clk2_boost, locked => mercury_locked_int_boost );
	end generate MERCURY_PLL;


    msg: process 
    begin
        if (intended_device_family = "APEX20KE" or intended_device_family = "APEX20KC" or
             intended_device_family = "EXCALIBUR_ARM" or intended_device_family = "EXCALIBUR_MIPS") and
             (deserialization_factor /= 4) and (deserialization_factor /= 7) and (deserialization_factor /= 8) then
                ASSERT FALSE
                REPORT "APEX20KE does not support the specified deserialization factor!"
                SEVERITY ERROR;
        elsif (intended_device_family = "MERCURY") and
              (((deserialization_factor > 12) and (deserialization_factor /= 14)
                and (deserialization_factor /= 16) and (deserialization_factor /= 18)
                and (deserialization_factor /= 20)) or (deserialization_factor<3)) then
                ASSERT FALSE
                REPORT "MERCURY does not support the specified deserialization factor!"
                SEVERITY ERROR;
        elsif (((intended_device_family = "APEXII" or intended_device_family = "APEX II")) and
              ((deserialization_factor > 10) or (deserialization_factor < 4))) then
                ASSERT FALSE
                REPORT "APEXII does not support the specified deserialization factor!"
                SEVERITY ERROR;
        end if;
        wait;
    end process;

    serialize: process(tx_clock0_int, tx_clock1_int)
    variable posedge_count: integer := 0;
    variable negedge_count: integer := 0;
    variable shift_data : std_logic := '0';
    variable count: integer := 0;
    variable sample: integer;
    variable tx_in2: std_logic_vector(deserialization_factor*number_of_channels -1 downto 0);
    begin
        if deserialization_factor > 1 then
            if tx_clock1_int'event and tx_clock1_int = '1' then
                posedge_count := 0;
                negedge_count := 0;
            end if;
            if (tx_clock0_int'event and tx_clock0_int = '0') then
                negedge_count := negedge_count + 1;
                if negedge_count = 3 then
                    if ((deserialization_factor < 3) or (deserialization_factor > 6)) then
                        data_int <= tx_hold_rgd; 
                    else 
                        data_int <= tx_in_int;
                    end if;
                end if;
            end if;
            if (tx_clock0_int'event and tx_clock0_int = '1') then
                posedge_count := posedge_count + 1;
                if posedge_count = 3 then
                    tx_in2 := data_int; -- register the incoming data on the third falling edge
                    count := 0;
                    shift_data := '1'; -- third rising edge
                end if;
                if shift_data = '1' then
                    count := count + 1;
                    for i in 0 to number_of_channels-1 loop
                        -- Data in MSB gets shifted out first.
                        -- NB: This happens 1/2clk cycle later for APEXII (MSB
                        -- only) when center_align_msb is ON.
                        if ((i = number_of_channels-1) and (count = 1) and ((intended_device_family = "APEXII" or intended_device_family = "APEX II")) and
                            (center_align_msb = "ON")) then
                            tx_out(i) <= tx_in2((i+1)*deserialization_factor - count) after (inclock_period/(deserialization_factor*2) * 1 ps);
                        else
                            tx_out(i) <= tx_in2((i+1)*deserialization_factor - count);
                        end if;
                    end loop;
                end if;
            end if;
            -- Update asymmetrical outclock for MERCURY for odd deserial
            -- factors.
            if deserialization_factor rem 2 /= 0 then
                if tx_clock1_int'event and tx_clock1_int = '1' then
                    tx_mercury_core_clock <= tx_clock1_int;
                end if;
                if tx_clock0_int'event and (tx_clock0_int = '1') and (posedge_count=(deserialization_factor+1)/2+1) then
                    tx_mercury_core_clock <= NOT tx_mercury_core_clock;
                end if;
            end if;
        else
            if tx_clock1_int'event and tx_clock1_int = '1' then
                tx_out <= tx_in;
            end if;
        end if;
    end process;

    sync: process(tx_rgd_clk)
    begin
        if deserialization_factor > 1 then
            if (tx_rgd_clk = '0') and  ((deserialization_factor < 3) or (deserialization_factor > 6)) then
                tx_hold_rgd <= tx_in_int;
            elsif tx_rgd_clk = '1' then
                tx_rgd <= tx_in;
            end if;
        end if;
    end process sync;

end behavior;

⌨️ 快捷键说明

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