-------------------------------------------------------------------------------
-- TPGMini_Wrap
--
-- Wrapper over TPGMini.vhd, part of SLAC's 'LCLS2 Timing Core'.
-- This wrapper eases integration with LBNL's Verilog LLRF firmware. Its purpose
-- is to act as a simplistic timing stream generator for testing purposes
-------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;

library surf;
use surf.StdRtlPkg.all;

library lcls_timing_core;
use lcls_timing_core.TimingPkg.all;
use lcls_timing_core.TimingExtnPkg.all;
use lcls_timing_core.TPGPkg.all;

use ieee.numeric_std.all;

entity TPGMini_Wrap is
  port (
    txClk   : in  std_logic;
    txRst   : in  std_logic;
    txRdy   : in  std_logic;
    txData  : out std_logic_vector(15 downto 0);
    txDataK : out std_logic_vector(1 downto 0)
    );
end TPGMini_Wrap;

architecture rtl of TPGMini_Wrap is

   signal tpg_cfg : TPGConfigType;

begin

   p_tpg_cfg : process begin
      tpg_cfg             <= TPG_CONFIG_INIT_C;
      tpg_cfg.pulseIdWrEn <= '0';
      wait;
   end process;

   i_tpgmini: entity lcls_timing_core.TPGMini
     generic map (
       TPD_G => 1 ns,
       NARRAYSBSA => 2
       )
     port map (
       statusO => open,
       configI => tpg_cfg,
       txClk   => txClk,
       txRst   => txRst,
       txRdy   => txRdy,
       txData  => txData,
       txDataK => txDataK
       );

end rtl;
