3 Program Code
3 Program Code
3 Program Code
-- AURORA_EXAMPLE
-- Aurora Generator
-- Description: Sample Instantiation of a 1 2-byte lane module.
-- Only tests initialization in hardware
Library IEEE;
Use IEEE.STD_LOGIC_1164.all;
UseIEEE.STD_LOGIC_MISC.all;
UseWORK.AURORA_PKG.all;
UseIEEE.std_logic_unsigned.all;
-- synthesistranslate_off
library UNISIM;
use UNISIM.VCOMPONENTS.ALL;
-- synthesistranslate_on
Entity aurora_8b10b_v5_3_example_design is
generic (
USE_CHIPSCOPE : integer := 0;
SIM_GTXRESET_SPEEDUP : integer := 1
);
port (-- User I/O
RESET : in std_logic;
HARD_ERR : out std_logic;
SOFT_ERR : out std_logic;
ERR_COUNT : out std_logic_vector(0 to 7);
LANE_UP : out std_logic;
CHANNEL_UP : out std_logic;
INIT_CLK : in std_logic;
GT_RESET_IN : in std_logic;
data_rdy : in std_logic;
tx_dst_rdy_n:outstd_logic;
-- Clocks
GTXD0_P : in std_logic;
GTXD0_N : in std_logic;
-- GT I/O
RXP : in std_logic;
RXN : in std_logic;
TXP : out std_logic;
TXN : out std_logic
);
end aurora_8b10b_v5_3_example_design;
architecture MAPPED of aurora_8b10b_v5_3_example_design is
attributecore_generation_info : string;
attributecore_generation_info of MAPPED : architecture is
"aurora_8b10b_v5_3,aurora_8b10b_v5_3,{user_interface=Legacy_LL,
backchannel_mode=Sidebands, c_aurora_lanes=1, c_column_used=left,
c_gt_clock_1=GTXD0,
c_gt_clock_2=None, c_gt_loc_1=1, c_gt_loc_10=X, c_gt_loc_11=X, c_gt_loc_12=X,
c_gt_loc_13=X, c_gt_loc_14=X, c_gt_loc_15=X, c_gt_loc_16=X, c_gt_loc_17=X,
c_gt_loc_18=X, c_gt_loc_19=X, c_gt_loc_2=X, c_gt_loc_20=X, c_gt_loc_21=X,
c_gt_loc_22=X, c_gt_loc_23=X, c_gt_loc_24=X, c_gt_loc_25=X, c_gt_loc_26=X,
c_gt_loc_27=X, c_gt_loc_28=X, c_gt_loc_29=X, c_gt_loc_3=X, c_gt_loc_30=X,
c_gt_loc_31=X, c_gt_loc_32=X, c_gt_loc_33=X, c_gt_loc_34=X, c_gt_loc_35=X,
c_gt_loc_36=X, c_gt_loc_37=X, c_gt_loc_38=X, c_gt_loc_39=X, c_gt_loc_4=X,
c_gt_loc_40=X, c_gt_loc_41=X, c_gt_loc_42=X, c_gt_loc_43=X, c_gt_loc_44=X,
c_gt_loc_45=X, c_gt_loc_46=X, c_gt_loc_47=X, c_gt_loc_48=X, c_gt_loc_5=X,
c_gt_loc_6=X, c_gt_loc_7=X, c_gt_loc_8=X, c_gt_loc_9=X, c_lane_width=2,
c_line_rate=3.125, c_nfc=false, c_nfc_mode=IMM, c_refclk_frequency=156.25,
c_simplex=false, c_simplex_mode=TX, c_stream=true, c_ufc=false, flow_mode=None,
interface_mode=Streaming, dataflow_config=Duplex}";
-- Parameter Declarations --
constant DLY : time := 1 ns;
-- External Register Declarations
signalHARD_ERR_Buffer : std_logic;
signalSOFT_ERR_Buffer : std_logic;
signalLANE_UP_Buffer : std_logic;
signalCHANNEL_UP_Buffer :std_logic;
signalTXP_Buffer : std_logic;
signalTXN_Buffer : std_logic;
-- Internal Register Declarations --
signalgt_reset_i : std_logic;
signalsystem_reset_i : std_logic;
-- Wire Declarations --
-- Stream TX Interface
signaltx_d_i : std_logic_vector(0 to 15);
signaltx_src_rdy_n_i : std_logic;
signaltx_dst_rdy_n_i : std_logic;
-- Stream RX Interface
signalrx_d_i : std_logic_vector(0 to 15);
signalrx_src_rdy_n_i : std_logic;
-- V5 Reference Clock Interface
signal GTXD0_left_i : std_logic;
-- Error Detection Interface
signalhard_err_i : std_logic;
signalsoft_err_i : std_logic;
-- Status
signalchannel_up_i : std_logic;
signallane_up_i : std_logic;
-- Clock Compensation Control Interface
signalwarn_cc_i : std_logic;
signaldo_cc_i : std_logic;
-- System Interface
signalpll_not_locked_i : std_logic;
signaluser_clk_i : std_logic;
signalsync_clk_i : std_logic;
signalreset_i : std_logic;
signalpower_down_i : std_logic;
signalloopback_i : std_logic_vector(2 downto 0);
signaltx_lock_i : std_logic;
signaltx_lock_out_i : std_logic;
signaltx_out_clk_i : std_logic;
signalbuf_tx_out_clk_i : std_logic;
--Frame check signals
signalerr_count_i : std_logic_vector(0 to 7);
signalERR_COUNT_Buffer :std_logic_vector(0 to 7);
-- VIO Signals
signalicon_to_vio_i : std_logic_vector (35 downto 0);
signalsync_in_i : std_logic_vector (63 downto 0);
signalsync_out_i : std_logic_vector (0 to 15);
signallane_up_i_i : std_logic;
signaltx_lock_i_i : std_logic;
signallane_up_reduce_i : std_logic;
signalrst_cc_module_i : std_logic;
signaltied_to_ground_i : std_logic;
--new signals
signalreset_c :std_logic;
signal my_data : std_logic_vector (15 downto 0):= X"AAAA";
signal count : std_logic_vector (15 downto 0):= X"0000";
signal i : std_logic_vector (1 downto 0):="00";
signalj,k : std_logic_vector (15 downto 0):=X"0000";
-- signal j,k: integer := 0;
-- state machine signals
typestate_type is (idle, state_1, state_2,state_3, state_4, stop);
signal state, next_state : state_type;
signalnew_data :std_logic_vector (15 downto 0):= X"0000";
-- Component Declarations -
component IBUFDS
port (
O : out std_ulogic;
I : in std_ulogic;
IB : in std_ulogic);
end component;
component BUFG
port (
O : out std_ulogic;
I : in std_ulogic
);
end component;
component aurora_8b10b_v5_3_CLOCK_MODULE
port (
GT_CLK : in std_logic;
GT_CLK_LOCKED : in std_logic;
USER_CLK : out std_logic;
SYNC_CLK : out std_logic;
PLL_NOT_LOCKED : out std_logic
);
end component;
component aurora_8b10b_v5_3_RESET_LOGIC
port (
RESET : in std_logic;
USER_CLK : in std_logic;
INIT_CLK : in std_logic;
GT_RESET_IN : in std_logic;
TX_LOCK_IN : in std_logic;
PLL_NOT_LOCKED : in std_logic;
TX_LOCK_OUT : out std_logic;
SYSTEM_RESET : out std_logic;
GT_RESET_OUT : out std_logic
);
end component;
component aurora_8b10b_v5_3
generic(
SIM_GTXRESET_SPEEDUP : integer := 1
);
port (
-- LocalLink TX Interface
TX_D : in std_logic_vector(0 to 15);
TX_SRC_RDY_N : in std_logic;
TX_DST_RDY_N : out std_logic;
-- LocalLink RX Interface
RX_D : out std_logic_vector(0 to 15);
RX_SRC_RDY_N : out std_logic;
-- GT Serial I/O
RXP : in std_logic;
RXN : in std_logic
TXP : out std_logic;
TXN : out std_logic;
-- GT Reference Clock Interface
GTXD0 : in std_logic;
-- Error Detection Interface
HARD_ERR : out std_logic;
SOFT_ERR : out std_logic;
-- Status
CHANNEL_UP : out std_logic;
LANE_UP : out std_logic;
-- Clock Compensation Control Interface
WARN_CC : in std_logic;
DO_CC : in std_logic;
-- System Interface
USER_CLK : in std_logic;
SYNC_CLK : in std_logic;
GT_RESET : in std_logic;
RESET : in std_logic;
POWER_DOWN : in std_logic;
LOOPBACK : in std_logic_vector(2 downto 0);
TX_OUT_CLK : out std_logic;
TX_LOCK : out std_logic
);
end component;
component aurora_8b10b_v5_3_STANDARD_CC_MODULE
port (
-- Clock Compensation Control Interface
WARN_CC : out std_logic;
DO_CC : out std_logic;
-- System Interface
PLL_NOT_LOCKED : in std_logic;
USER_CLK : in std_logic;
RESET : in std_logic
);
end component;
-- component aurora_8b10b_v5_3_FRAME_GEN
-- port
-- (
-- -- User Interface
-- TX_D : out std_logic_vector(0 to 15);
-- TX_SRC_RDY_N : out std_logic;
-- TX_DST_RDY_N : in std_logic;
-- -- System Interface
-- USER_CLK : in std_logic;
-- RESET : in std_logic;
-- CHANNEL_UP : in std_logic
-- );
-- end component;
-- component aurora_8b10b_v5_3_FRAME_CHECK
-- port
-- (
-- -- User Interface
-- RX_D : in std_logic_vector(0 to 15);
-- RX_SRC_RDY_N : in std_logic;
-- -- System Interface
-- USER_CLK : in std_logic;
-- RESET : in std_logic;
-- CHANNEL_UP : in std_logic;
-- ERR_COUNT : out std_logic_vector(0 to 7)
-- end component;
-------------------------------------------------------------------
-- ICON core component declaration
-------------------------------------------------------------------
component icon
port
(
control0 : out std_logic_vector(35 downto 0)
);
end component;
-------------------------------------------------------------------
-- VIO core component declaration
-------------------------------------------------------------------
componentvio
port
(
control : in std_logic_vector(35 downto 0);
clk : in std_logic;
sync_in : in std_logic_vector(63 downto 0);
sync_out : out std_logic_vector(15 downto 0)
);
end component;
begin
tied_to_ground_i<= '0';
lane_up_reduce_i<= lane_up_i;
rst_cc_module_i<= notlane_up_reduce_i;
HARD_ERR <= HARD_ERR_Buffer;
SOFT_ERR <= SOFT_ERR_Buffer;
ERR_COUNT <= ERR_COUNT_Buffer;
LANE_UP <= LANE_UP_Buffer;
CHANNEL_UP <= CHANNEL_UP_Buffer;
TXP <= TXP_Buffer;
TXN <= TXN_Buffer;
-- ___________________________Clock Buffers________________________
IBUFDS_i : IBUFDS
port map (
I => GTXD0_P ,
IB => GTXD0_N ,
O => GTXD0_left_i
);
BUFG_i : BUFG
port map(
I =>tx_out_clk_i ,
O =>buf_tx_out_clk_i
);
-- Instantiate a clock module for clock division
clock_module_i : aurora_8b10b_v5_3_CLOCK_MODULE
port map (
GT_CLK =>buf_tx_out_clk_i,
GT_CLK_LOCKED =>tx_lock_out_i,
USER_CLK =>user_clk_i,
SYNC_CLK =>sync_clk_i,
PLL_NOT_LOCKED =>pll_not_locked_i
);
-- Register User I/O --
-- Register User Outputs from core.
process (user_clk_i)
begin
if (user_clk_i 'event and user_clk_i = '1') then
HARD_ERR_Buffer<= hard_err_i;
SOFT_ERR_Buffer<= soft_err_i;
ERR_COUNT_Buffer<= err_count_i;
LANE_UP_Buffer<= lane_up_i;
CHANNEL_UP_Buffer<= channel_up_i;
end if;
end process;
-- System Interface
power_down_i<= '0';
loopback_i<= "000";
-- _______________________________ Module Instantiations
________________________--
-- -Connect a frame checker to the user interface
-- frame_check_i : aurora_8b10b_v5_3_FRAME_CHECK
-- port map
-- (
-- -- User Interface
-- RX_D =>rx_d_i,
-- RX_SRC_RDY_N =>rx_src_rdy_n_i,
-- System Interface
-- USER_CLK =>user_clk_i,
-- RESET =>reset_i,
-- CHANNEL_UP =>channel_up_i,
-- ERR_COUNT =>err_count_i
-- );
-- --Connect a frame generator to the user interface
-- frame_gen_i : aurora_8b10b_v5_3_FRAME_GEN
-- port map
-- (
-- User Interface
-- TX_D =>tx_d_i,
-- TX_SRC_RDY_N =>tx_src_rdy_n_i,
-- TX_DST_RDY_N =>tx_dst_rdy_n_i,
-- System Interface
-- USER_CLK =>user_clk_i,
-- RESET =>reset_i,
-- CHANNEL_UP =>channel_up_i
-- );
-- Module Instantiations --
aurora_module_i : aurora_8b10b_v5_3
generic map(
SIM_GTXRESET_SPEEDUP => SIM_GTXRESET_SPEEDUP
)
port map (
-- LocalLink TX Interface
TX_D =>tx_d_i,
TX_SRC_RDY_N =>tx_src_rdy_n_i,
TX_DST_RDY_N =>tx_dst_rdy_n_i,
-- LocalLink RX Interface
RX_D =>rx_d_i,
RX_SRC_RDY_N =>rx_src_rdy_n_i,
-- GT Serial I/O
RXP => RXP,
RXN => RXN,
TXP =>TXP_Buffer,
TXN =>TXN_Buffer,
-- GT Reference Clock Interface
GTXD0 => GTXD0_left_i,
-- Error Detection Interface
HARD_ERR =>hard_err_i,
SOFT_ERR =>soft_err_i,
-- Status
CHANNEL_UP =>channel_up_i,
LANE_UP =>lane_up_i,
-- Clock Compensation Control Interface
WARN_CC =>warn_cc_i,
DO_CC =>do_cc_i,
-- System Interface
USER_CLK =>user_clk_i,
SYNC_CLK =>sync_clk_i,
RESET =>reset_i,
POWER_DOWN =>power_down_i,
LOOPBACK =>loopback_i,
GT_RESET =>gt_reset_i,
TX_OUT_CLK =>tx_out_clk_i,
TX_LOCK =>tx_lock_i
);
standard_cc_module_i : aurora_8b10b_v5_3_STANDARD_CC_MODULE
port map (
-- Clock Compensation Control Interface
WARN_CC =>warn_cc_i,
DO_CC =>do_cc_i,
-- System Interface
PLL_NOT_LOCKED =>pll_not_locked_i,
USER_CLK =>user_clk_i,
RESET =>rst_cc_module_i
);
reset_logic_i : aurora_8b10b_v5_3_RESET_LOGIC
port map (
RESET => RESET,
USER_CLK =>user_clk_i,
INIT_CLK => INIT_CLK,
GT_RESET_IN => GT_RESET_IN,
TX_LOCK_IN =>tx_lock_i,
PLL_NOT_LOCKED =>pll_not_locked_i,
TX_LOCK_OUT =>tx_lock_out_i,
SYSTEM_RESET =>system_reset_i,
GT_RESET_OUT =>gt_reset_i
);
--frame gen
reset_c<=reset_i or not channel_up_i;
-- state machine
process (user_clk_i)
begin
if (user_clk_i'event and user_clk_i = '1') then
if (tx_dst_rdy_n_i = '1') then
state<= idle;
count<= X"0000";
if(reset_c = '1') then
tx_src_rdy_n_i<= '1' after DLY;
end if;
else
state<= next_state;
count<= new_data;
tx_src_rdy_n_i<= '0';
end if;
end if;
tx_d_i<= count;
end process;
process (user_clk_i,state)
begin
if (data_rdy = '1') then
if (tx_dst_rdy_n_i = '0') then
if (state = state_1) then
new_data<= X"AAAA";
elsif (state = state_2) then
new_data<= X"5555";
elsif (state = state_3) then
new_data<= X"0000";
elsif (state = state_4) then
new_data<= X"1111";
else
new_data<=X"0000";
end if;
end if;
end if;
end process;
process (user_clk_i,state)
begin
if (data_rdy = '1') then
if (tx_dst_rdy_n_i = '0') then
case state is
when idle =>next_state<= state_1;
when state_1 =>next_state<= state_2;
when state_2 =>next_state<= state_3;
when state_3 =>next_state<= state_4;
when others =>next_state<= idle;
end case;
end if;
end if;
tx_dst_rdy_n<= TX_DST_Rdy_N_i;
end process
chipscope1 : if USE_CHIPSCOPE = 1 generate
lane_up_i_i<= lane_up_i;
tx_lock_i_i<= '1' andtx_lock_i;
--Shared VIO Inputs
sync_in_i(15 downto 0) <= tx_d_i(0 to 15);
sync_in_i(31 downto 16) <= rx_d_i(0 to 15);
sync_in_i(39 downto 32) <= err_count_i;
sync_in_i(56 downto 40) <= (others => '0');
sync_in_i(57) <= '0';
sync_in_i(58) <= soft_err_i;
sync_in_i(59) <= hard_err_i;
sync_in_i(60) <= tx_lock_i_i;
sync_in_i(61) <= pll_not_locked_i;
sync_in_i(62) <= lane_up_i_i;
sync_in_i(63) <= channel_up_i;
-- -- ICON core instance
-- -------------------------------------------------------------------
-- i_icon : icon
-- port map
-- (
-- control0 =>icon_to_vio_i
-- );
-- -- VIO core instance
-- -------------------------------------------------------------------
-- i_vio : vio
-- port map
-- (
-- control =>icon_to_vio_i,
-- clk =>user_clk_i,
-- sync_in =>sync_in_i,
-- sync_out =>sync_out_i
-- )
end generate chipscope1;
--no_chipscope1 : if USE_CHIPSCOPE = 0 generate
-- sync_in_i<= (others=>'0');
--end generate no_chipscope1;
--chipscope2 : if USE_CHIPSCOPE = 1 generate
-- -- Shared VIO Outputs
-- reset_i<= system_reset_i or sync_out_i(0);
--end generate chipscope2;
--no_chipscope2 : if USE_CHIPSCOPE = 0 generate
-- -- Shared VIO Outputs
-- reset_i<= system_reset_i;
--end generate no_chipscope2;
end MAPPED;