##############################################################################
## This file is part of 'LCLS2 Common Carrier Core'.
## 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 Common Carrier Core', including this file,
## may be copied, modified, propagated, or distributed except according to
## the terms contained in the LICENSE.txt file.
##############################################################################
#schemaversion 3.0.0
#once    000TopLevel.yaml
#include AmcCarrierCore.yaml
#include AppTop.yaml
#include AmcCarrierDRAM.yaml
#include RssiConfiguration.yaml

# It is important to use the same parameters
# for shared protocol modules (e.g., all RSSI
# on the same port is in fact one single, shared
# module)
#
connectionParameters:
  udpPri:     &udpPri      80
  udpThreads: &udpThreads   4
  rssi: &rssiParams
    retransmissionTimeoutUS: 100000
    cumulativeAckTimeoutUS:   50000
    threadPriority:             82

#MMIO range, will be attached to FPGA
mmio: &mmio
  size: 0x100000000 # 4GB of address space
  class: MMIODev
  configPrio: 1
  ########
  children:
  ########
    AmcCarrierCore:
      <<: *AmcCarrierCore
      at:
        offset: 0x00000000
    ##################################################
    AppTop:
      <<: *AppTop
      at:
        offset: 0x80000000
      children:
        AppTopJesd:
          children:
            JesdRx:
              instantiate: true
              metadata:
                numRxLanes: &numRxLanes 4
            JesdTx:
              instantiate: false
              metadata:
                numTxLanes: &numTxLanes 0
    ##################################################

stream: &stream
    SRP:
      protocolVersion: SRP_UDP_NONE
    UDP:
      port: *udpPortNumber1
      numRxThreads: 2
      threadPriority: *udpPri
    RSSI:
        <<: *rssiParams
        threadPriority: 81
        inpQueueDepth: 32
    depack:
      protocolVersion: *depacketizerProtocolVersion
    TDESTMux:
      TDEST: 0x80
      stripHeader: yes

debugStream: &debugStream
    <<: *stream
    UDP:
      port: *udpPortNumber0
      threadPriority: *udpPri

bldstream: &bldstream 
    SRP:
      protocolVersion: SRP_UDP_NONE
    UDP:
      port: 8198
      numRxThreads: *udpThreads
      threadPriority:  *udpPri
      pollSecs: 1

NetIODev: &BPMNetIODev
  ipAddr: 10.0.1.102
  class: NetIODev
  configPrio: 1
  children:
     mmio:
       <<: *mmio
       at:
         SRP:
           protocolVersion: SRP_UDP_V3
           timeoutUS:  1000000
         UDP:
           port: *udpPortNumber0
           threadPriority: *udpPri
         RSSI:
           <<: *rssiParams
           threadPriority: 81
           inpQueueDepth: 32
         depack:
           protocolVersion: *depacketizerProtocolVersion
         TDESTMux:
           TDEST: 0
     BsaRam:
       <<: *AmcCarrierDRAM
       at:
         SRP:
           protocolVersion: SRP_UDP_V3
           timeoutUS:  1000000
           retryCount: 10
         UDP:
           port: *udpPortNumber1
           threadPriority: *udpPri
         RSSI:
           <<: *rssiParams
           threadPriority: 81
           inpQueueDepth: 32
         depack:
           protocolVersion: *depacketizerProtocolVersion
         TDESTMux:
           TDEST: 0x04
     Stream0:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x80
     Stream1:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x81
     Stream2:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x82
     Stream3:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x83
     Stream4:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x84
     Stream5:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x85
     Stream6:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x86
     Stream7:
       class: Field
       at:
         <<: *stream
         TDESTMux:
           TDEST: 0x87
     BPM_A_Stream:
       class: Field
       at:
         <<: *debugStream
         TDESTMux:
           TDEST: 0xC0
     BPM_B_Stream:
       class: Field
       at:
         <<: *debugStream
         TDESTMux:
           TDEST: 0xC1
     Lcls1TimingStream:
       class: Field
       at:
         SRP:
           protocolVersion: SRP_UDP_NONE
         UDP:
           port: 8197
           numRxThreads: 1
           # timing stream silences after 2^29 axilClk cycles (156.25MHz)
           pollSecs: 2
           threadPriority: *udpPri
     bldstream:
         class: Field
         at:
           <<: *bldstream
