Skip to content

Commit

Permalink
Merge pull request #59 from slaclab/pre-release
Browse files Browse the repository at this point in the history
elease Candidate v5.12.0
  • Loading branch information
ruck314 authored Jan 14, 2025
2 parents 546b2ed + c126bbc commit 86e8e3d
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 15 deletions.
1 change: 1 addition & 0 deletions hardware/XilinxVariumC1100/ruckus.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source -quiet $::env(RUCKUS_DIR)/vivado_proc.tcl
# Load local source Code
loadSource -lib lcls2_pgp_fw_lib -dir "$::DIR_PATH/rtl"
loadConstraints -path "$::DIR_PATH/xdc/C1100Hsio.xdc"
loadSource -sim_only -dir "$::DIR_PATH/tb"

# Case the timing on communication protocol
if { [info exists ::env(INCLUDE_PGP4_6G)] == 1 || [info exists ::env(INCLUDE_PGP4_10G)] == 1 } {
Expand Down
168 changes: 168 additions & 0 deletions hardware/XilinxVariumC1100/tb/TimingGtCoreWrapperTb.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
-------------------------------------------------------------------------------
-- Company : SLAC National Accelerator Laboratory
-------------------------------------------------------------------------------
-- Description: Simulation test bed
-------------------------------------------------------------------------------
-- This file is part of LCLS2 PGP Firmware Library'.
-- It is subject to the license terms in the LICENSE.txt file found in the
-- top-level directory of this distribution and at:
-- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
-- No part of LCLS2 PGP Firmware Library', including this file,
-- may be copied, modified, propagated, or distributed except according to
-- the terms contained in the LICENSE.txt file.
-------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

library unisim;
use unisim.vcomponents.all;

library surf;
use surf.StdRtlPkg.all;
use surf.AxiLitePkg.all;
use surf.AxiStreamPkg.all;
use surf.SsiPkg.all;

library lcls_timing_core;
use lcls_timing_core.TimingPkg.all;

library l2si_core;
use l2si_core.L2SiPkg.all;

library lcls2_pgp_fw_lib;

entity TimingGtCoreWrapperTb is end TimingGtCoreWrapperTb;

architecture testbed of TimingGtCoreWrapperTb is

signal axilWriteMaster : AxiLiteWriteMasterType := AXI_LITE_WRITE_MASTER_INIT_C;
signal axilWriteSlave : AxiLiteWriteSlaveType := AXI_LITE_WRITE_SLAVE_EMPTY_SLVERR_C;
signal axilReadMaster : AxiLiteReadMasterType := AXI_LITE_READ_MASTER_INIT_C;
signal axilReadSlave : AxiLiteReadSlaveType := AXI_LITE_READ_SLAVE_EMPTY_SLVERR_C;

signal axilClk : sl := '0';
signal axilRst : sl := '1';

signal stableClk : sl := '0';
signal stableRst : sl := '1';

signal refClk : sl := '0';
signal refClkDiv2 : sl := '1';

signal timingP : sl := '0';
signal timingN : sl := '1';

signal gtRxOutClk : sl := '0';
signal gtRxControl : TimingPhyControlType := TIMING_PHY_CONTROL_INIT_C;
signal gtRxStatus : TimingPhyStatusType := TIMING_PHY_STATUS_INIT_C;
signal gtRxData : slv(15 downto 0) := x"BCBC";
signal gtRxDataK : slv(1 downto 0) := "11";
signal gtRxDispErr : slv(1 downto 0) := "00";
signal gtRxDecErr : slv(1 downto 0) := "00";

signal gtTxOutClk : sl := '0';
signal gtTxControl : TimingPhyControlType := TIMING_PHY_CONTROL_INIT_C;
signal gtTxStatus : TimingPhyStatusType := TIMING_PHY_STATUS_INIT_C;
signal gtTxData : slv(15 downto 0) := x"BCBC";
signal gtTxDataK : slv(1 downto 0) := "11";

signal mmcmLocked : sl := '0';

begin

U_axilClk : entity surf.ClkRst
generic map (
CLK_PERIOD_G => 6.4 ns, -- 156.25 MHz
RST_START_DELAY_G => 0 ns,
RST_HOLD_TIME_G => 1000 ns)
port map (
clkP => axilClk,
rst => axilRst);

U_stableClk : BUFGCE_DIV
generic map (
BUFGCE_DIVIDE => 2)
port map (
I => axilClk,
CE => '1',
CLR => '0',
O => stableClk);

U_stableRst : entity surf.RstSync
port map (
clk => stableClk,
asyncRst => axilRst,
syncRst => stableRst);

mmcmLocked <= not(stableRst);

U_refClk : entity surf.ClkRst
generic map (
CLK_PERIOD_G => 4 ns, -- 250 MHz
RST_START_DELAY_G => 0 ns,
RST_HOLD_TIME_G => 1000 ns)
port map (
clkP => refClk,
rst => open);

U_refClkDiv2 : BUFGCE_DIV
generic map (
BUFGCE_DIVIDE => 2)
port map (
I => refClk,
CE => '1',
CLR => '0',
O => refClkDiv2);

U_GTY : entity lcls_timing_core.TimingGtCoreWrapper
generic map (
TPD_G => 1 ns,
EXTREF_G => false,
AXI_CLK_FREQ_G => 156.25E+6,
AXIL_BASE_ADDR_G => x"00000000",
GTY_DRP_OFFSET_G => x"00001000")
port map (
-- AXI-Lite Port
axilClk => axilClk,
axilRst => axilRst,
axilReadMaster => axilReadMaster,
axilReadSlave => axilReadSlave,
axilWriteMaster => axilWriteMaster,
axilWriteSlave => axilWriteSlave,
stableClk => stableClk,
stableRst => stableRst,
-- GTH FPGA IO
gtRefClk => '0', -- Using GTGREFCLK instead
gtRefClkDiv2 => refClkDiv2,
gtRxP => timingP,
gtRxN => timingN,
gtTxP => timingP,
gtTxN => timingN,
-- GTGREFCLK Interface Option
gtgRefClk => refClk,
cpllRefClkSel => "111",
-- Rx ports
rxControl => gtRxControl,
rxStatus => gtRxStatus,
rxUsrClkActive => mmcmLocked,
rxUsrClk => gtRxOutClk,
rxData => gtRxData,
rxDataK => gtRxDataK,
rxDispErr => gtRxDispErr,
rxDecErr => gtRxDecErr,
rxOutClk => gtRxOutClk,
-- Tx Ports
txControl => gtTxControl, --temTimingTxPhy.control,
txStatus => gtTxStatus,
txUsrClk => gtTxOutClk,
txUsrClkActive => mmcmLocked,
txData => gtTxData,
txDataK => gtTxDataK,
txOutClk => gtTxOutClk,
-- Misc.
loopback => "000");

end testbed;
117 changes: 117 additions & 0 deletions hardware/XilinxVariumC1100/tb/TimingRxTb.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
-------------------------------------------------------------------------------
-- Company : SLAC National Accelerator Laboratory
-------------------------------------------------------------------------------
-- Description: Simulation test bed
-------------------------------------------------------------------------------
-- This file is part of LCLS2 PGP Firmware Library'.
-- It is subject to the license terms in the LICENSE.txt file found in the
-- top-level directory of this distribution and at:
-- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
-- No part of LCLS2 PGP Firmware Library', including this file,
-- may be copied, modified, propagated, or distributed except according to
-- the terms contained in the LICENSE.txt file.
-------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

library unisim;
use unisim.vcomponents.all;

library surf;
use surf.StdRtlPkg.all;
use surf.AxiLitePkg.all;
use surf.AxiStreamPkg.all;
use surf.SsiPkg.all;

library lcls_timing_core;
use lcls_timing_core.TimingPkg.all;

library l2si_core;
use l2si_core.L2SiPkg.all;

library lcls2_pgp_fw_lib;

entity TimingRxTb is end TimingRxTb;

architecture testbed of TimingRxTb is

signal axilWriteMaster : AxiLiteWriteMasterType := AXI_LITE_WRITE_MASTER_INIT_C;
signal axilWriteSlave : AxiLiteWriteSlaveType := AXI_LITE_WRITE_SLAVE_EMPTY_SLVERR_C;
signal axilReadMaster : AxiLiteReadMasterType := AXI_LITE_READ_MASTER_INIT_C;
signal axilReadSlave : AxiLiteReadSlaveType := AXI_LITE_READ_SLAVE_EMPTY_SLVERR_C;

signal axilClk : sl := '0';
signal axilRst : sl := '1';

signal userClk25 : sl := '0';
signal userRst25 : sl := '1';

signal gtP : slv(1 downto 0) := "00";
signal gtN : slv(1 downto 0) := "11";

begin

U_axilClk : entity surf.ClkRst
generic map (
CLK_PERIOD_G => 6.4 ns, -- 156.25 MHz
RST_START_DELAY_G => 0 ns,
RST_HOLD_TIME_G => 1000 ns)
port map (
clkP => axilClk,
rst => axilRst);

U_userClk25 : entity surf.ClkRst
generic map (
CLK_PERIOD_G => 40 ns, -- 25 MHz
RST_START_DELAY_G => 0 ns,
RST_HOLD_TIME_G => 10 us)
port map (
clkP => userClk25,
rst => userRst25);

------------------
-- Timing Receiver
------------------
U_TimingRx : entity lcls2_pgp_fw_lib.TimingRx
generic map (
USE_GT_REFCLK_G => false, -- FALSE: userClk25/userRst25
SIMULATION_G => false,
DMA_AXIS_CONFIG_G => AXI_STREAM_CONFIG_INIT_C,
AXIL_CLK_FREQ_G => 156.25E+6,
AXI_BASE_ADDR_G => x"00000000",
NUM_DETECTORS_G => 1,
EN_LCLS_I_TIMING_G => true,
EN_LCLS_II_TIMING_G => true)
port map (
-- Reference Clock and Reset
userClk156 => axilClk,
userClk25 => userClk25,
userRst25 => userRst25,
-- Trigger interface
triggerClk => axilClk,
triggerRst => axilRst,
l1Clk => axilClk,
l1Rst => axilRst,
-- Event interface
eventClk => axilClk,
eventRst => axilRst,
eventTrigMsgSlaves => (others => AXI_STREAM_SLAVE_FORCE_C),
eventTrigMsgCtrl => (others => AXI_STREAM_CTRL_UNUSED_C),
eventTimingMsgSlaves => (others => AXI_STREAM_SLAVE_FORCE_C),
-- AXI-Lite Interface (axilClk domain)
axilClk => axilClk,
axilRst => axilRst,
axilReadMaster => axilReadMaster,
axilReadSlave => axilReadSlave,
axilWriteMaster => axilWriteMaster,
axilWriteSlave => axilWriteSlave,
-- GT Serial Ports
timingRxP => gtP,
timingRxN => gtN,
timingTxP => gtP,
timingTxN => gtN);

end testbed;
4 changes: 3 additions & 1 deletion hardware/XilinxVariumC1100/xdc/C1100Hsio.xdc
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,7 @@ set_clock_groups -asynchronous \
-group [get_clocks -include_generated_clocks {clk371}] \
-group [get_clocks -include_generated_clocks {dmaClk}]

set_clock_groups -asynchronous -group [get_clocks -of_objects [get_pins {U_HSIO/U_TimingRx/GEN_VEC[0].REAL_PCIE.U_GTY/LOCREF_G.U_TimingGtyCore/inst/gen_gtwizard_gtye4_top.TimingGty_fixedlat_gtwizard_gtye4_inst/gen_gtwizard_gtye4.gen_channel_container[3].gen_enabled_channel.gtye4_channel_wrapper_inst/channel_inst/gtye4_channel_gen.gen_gtye4_channel_inst[0].GTYE4_CHANNEL_PRIM_INST/TXOUTCLKPCS}]] -group [get_clocks -of_objects [get_pins {U_HSIO/U_TimingRx/GEN_VEC[0].U_refClkDiv2/O}]]
set_clock_groups -asynchronous -group [get_clocks -of_objects [get_pins {U_HSIO/U_TimingRx/GEN_VEC[0].REAL_PCIE.U_GTY/LOCREF_LCLS1_ONLY_G.U_TimingGtyCore/inst/gen_gtwizard_gtye4_top.TimingGty_fixedlat_Lcls1Only_gtwizard_gtye4_inst/gen_gtwizard_gtye4.gen_channel_container[3].gen_enabled_channel.gtye4_channel_wrapper_inst/channel_inst/gtye4_channel_gen.gen_gtye4_channel_inst[0].GTYE4_CHANNEL_PRIM_INST/TXOUTCLKPCS}]] -group [get_clocks -of_objects [get_pins {U_HSIO/U_TimingRx/GEN_VEC[0].U_refClkDiv2/O}]]
set_clock_groups -asynchronous -group [get_clocks -of_objects [get_pins {U_HSIO/U_TimingRx/GEN_VEC[1].REAL_PCIE.U_GTY/LOCREF_G.U_TimingGtyCore/inst/gen_gtwizard_gtye4_top.TimingGty_fixedlat_gtwizard_gtye4_inst/gen_gtwizard_gtye4.gen_channel_container[3].gen_enabled_channel.gtye4_channel_wrapper_inst/channel_inst/gtye4_channel_gen.gen_gtye4_channel_inst[0].GTYE4_CHANNEL_PRIM_INST/TXOUTCLKPCS}]] -group [get_clocks -of_objects [get_pins {U_HSIO/U_TimingRx/GEN_VEC[1].U_refClkDiv2/O}]]

set_clock_groups -asynchronous -group [get_clocks -of_objects [get_pins U_HSIO/U_TimingRx/U_stableClk/O]] -group [get_clocks -of_objects [get_pins U_axilClk/MmcmGen.U_Mmcm/CLKOUT0]]
11 changes: 7 additions & 4 deletions python/lcls2_pgp_fw_lib/shared/_TimingRx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import l2si_core

import lcls2_pgp_fw_lib.shared as shared
import surf.xilinx as xil

class TimingRx(pr.Device):
def __init__(
Expand All @@ -26,15 +27,15 @@ def __init__(
**kwargs):
super().__init__(**kwargs)

self.add(LclsTimingCore.GthRxAlignCheck(
name = "GthRxAlignCheck[0]",
self.add(xil.GtRxAlignCheck(
name = "GtRxAlignCheck[0]",
offset = 0x0000_0000,
expand = False,
hidden = False,
))

self.add(LclsTimingCore.GthRxAlignCheck(
name = "GthRxAlignCheck[1]",
self.add(xil.GtRxAlignCheck(
name = "GtRxAlignCheck[1]",
offset = 0x0001_0000,
expand = False,
hidden = False,
Expand Down Expand Up @@ -76,6 +77,7 @@ def ConfigLclsTimingV1():
self.TimingFrameRx.RxPllReset.set(0)
self.TimingFrameRx.ClkSel.set(0x0)
self.TimingFrameRx.C_RxReset()
self.TimingPhyMonitor.RxUserRst()
time.sleep(1.0)
self.TimingFrameRx.RxDown.set(0) # Reset the latching register

Expand All @@ -90,6 +92,7 @@ def ConfigLclsTimingV2():
self.TimingFrameRx.RxPllReset.set(0)
self.TimingFrameRx.ClkSel.set(0x1)
self.TimingFrameRx.C_RxReset()
self.TimingPhyMonitor.RxUserRst()
time.sleep(1.0)
self.TimingFrameRx.RxDown.set(0) # Reset the latching register

Expand Down
2 changes: 1 addition & 1 deletion shared/rtl/TimingPhyMonitor.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ architecture rtl of TimingPhyMonitor is
remTrigDropCnt => (others => (others => '0')),
loopback => "000",
cntRst => '0',
mmcmRst => '0',
mmcmRst => '1',
rxUserRst => '0',
txUserRst => '0',
txPhyReset => '0',
Expand Down
Loading

0 comments on commit 86e8e3d

Please sign in to comment.