##############################################################################
## This file is part of 'SLAC Firmware Standard 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 'SLAC Firmware Standard Library', 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 TPGMiniCore.yaml

TPGMiniCore: &TPGMiniCore
  class: MMIODev
  configPrio: 1
  description: Embedded timing pattern generator
  size: 0x10000
  metadata:
    NARRAYSBSA: &NARRAYSBSA 2
  children:
    #########################################################
    TxPolarity:
      at:
        offset: 0x0000
      class: IntField
      sizeBits: 1
      lsBit: 1
      mode: RW
      description: Invert transmit link polarity
    #########################################################
    TxLoopback:
      at:
        offset: 0x0000
      class: IntField
      sizeBits: 3
      lsBit: 2
      mode: RW
      description: Set transmit link loopback
    #########################################################
    TxInhibit:
      at:
        offset: 0x0000
      class: IntField
      sizeBits: 1
      lsBit: 5
      mode: RW
      description: Set transmit link inhibit
    #########################################################
    BaseControl:
      at:
        offset: 0x0004
      class: IntField
      sizeBits: 16
      lsBit: 0
      mode: RW
      description: Base rate trigger divisor
    #########################################################
    PulseIdWr:
      at:
        offset: 0x0058
      class: IntField
      sizeBits: 64
      mode: RW
      description: Pulse ID write
    #########################################################
    PulseIdRd:
      at:
        offset: 0x0008
      class: IntField
      sizeBits: 64
      mode: RO
      description: Pulse ID read
    #########################################################
    PulseIdSet:
      at:
        offset: 0x0070
      class: IntField
      sizeBits: 1
      lsBit: 0
      mode: RW
      description: Activates PulseId register value
    #########################################################
    TStampWr:
      at:
        offset: 0x0060
      class: IntField
      sizeBits: 64
      mode: RW
      description: Time stamp write
    #########################################################
    TStampRd:
      at:
        offset: 0x0010
      class: IntField
      sizeBits: 64
      mode: RO
      description: Time stamp read
    #########################################################
    TStampSet:
      at:
        offset: 0x0074
      class: IntField
      sizeBits: 1
      lsBit: 0
      mode: RW
      description: Activates Timestamp register value
    #########################################################
    FixedRateDiv:
      at:
        offset: 0x0018
        stride: 4
        nelms: 10
      class: IntField
      sizeBits: 32
      mode: RW
      description: Fixed rate marker divisors
    #########################################################
    RateReload:
      at:
        offset: 0x0040
      class: IntField
      sizeBits: 1
      mode: RW
      description: Loads cached fixed rate marker divisors
    #########################################################
    NBeamSeq:
      at:
        offset: 0x004C
      class: IntField
      sizeBits: 6
      lsBit: 0
      mode: RO
      description: Number of beam request engines
    #########################################################
    NControlSeq:
      at:
        offset: 0x004C
      class: IntField
      sizeBits: 8
      lsBit: 6
      mode: RO
      description: Number of control sequence engines
    #########################################################
    NArraysBsa:
      at:
        offset: 0x004D
      class: IntField
      sizeBits: 8
      lsBit: 6
      mode: RO
      description: Number of BSA arrays
    #########################################################
    SeqAddrLen:
      at:
        offset: 0x004E
      class: IntField
      sizeBits: 4
      lsBit: 6
      mode: RO
      description: Number of beam sequence engines
    #########################################################
    NAllowSeq:
      at:
        offset: 0x004F
      class: IntField
      sizeBits: 6
      lsBit: 2
      mode: RO
      description: Number of beam allow engines
    #########################################################
    TxReset:
      at:
        offset: 0x0068
      class: IntField
      sizeBits: 1
      lsBit: 0
      mode: RW
      description: Reset transmit link
    #########################################################
    CountIntervalReset:
      at:
        offset: 0x006C
      class: IntField
      sizeBits: 1
      lsBit: 0
      mode: RW
      description: Count Interval Reset
    #########################################################
    Lcls1BsaNumSamples:
      at:
        offset: 0x0078
      class: IntField
      sizeBits: 12
      mode: RW
      description: "Lcls-1 BSA Number of Samples - 1"
    #########################################################
    Lcls1BsaRate:
      at:
        offset: 0x0079
      class: IntField
      sizeBits:  3
      lsBit:     4
      mode: RW
      description: "Lcls-1 BSA Rate"
      enums:
        - { name: "120Hz", value: 0 }
        - { name: "60Hz",  value: 1 }
        - { name: "30Hz",  value: 2 }
        - { name: "10Hz",  value: 3 }
        - { name: "5Hz",   value: 4 }
        - { name: "1Hz",   value: 5 }
        - { name: "0.5Hz", value: 6 }
    #########################################################
    Lcls1BsaTimeSlot:
      at:
        offset: 0x0079
      class: IntField
      sizeBits: 3
      lsBit:    7
      mode: RW
      description: "Lcls-1 BSA Time Slot"
      enums:
        - { name: "TS1", value: 0 }
        - { name: "TS2", value: 1 }
        - { name: "TS3", value: 2 }
        - { name: "TS4", value: 3 }
        - { name: "TS5", value: 4 }
        - { name: "TS6", value: 5 }
    #########################################################
    Lcls1BsaSeverity:
      at:
        offset: 0x007a
      class: IntField
      sizeBits:  2
      lsBit:     2
      mode: RW
      description: "Lcls-1 BSA Rejection Severity Threshold"
      enums:
        - { name: "INVALID", value: 0 }
        - { name: "MAJOR",   value: 2 }
        - { name: "MINOR",   value: 1 }
    #########################################################
    Lcls1BsaEdefSlot:
      at:
        offset: 0x007a
      class: IntField
      sizeBits:  4
      lsBit:     4
      mode: RW
      description: "Lcls-1 BSA EDEF Slot Number"
    #########################################################
    Lcls1BsaNumAvgs:
      at:
        offset: 0x007b
      class: IntField
      sizeBits:  8
      lsBit:     0
      mode: RW
      description: "Lcls-1 BSA Number of Values to Average per Sample - 1"
    #########################################################
    Lcls1BsaStart:
      at:
        offset: 0x007c
      class: IntField
      sizeBits:  32
      lsBit:     0
      mode: RW
      description: "Lcls-1 BSA Started by Writing any Value Here"
    #########################################################
    BsaCompleteWr:
      at:
        offset: 0x0050
      class: IntField
      sizeBits: 64
      mode: RW
      description: BSA complete clear
    #########################################################
    BsaCompleteRd:
      at:
        offset: 0x0050
      class: IntField
      sizeBits: 64
      mode: RO
      description: BSA complete read
    #########################################################
    BsaActive:
      at:
        offset: 0x01FC
        stride: 1
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 1
      lsBit: 0
      mode: RW
      description: Activates/Deactivates BSA EDEF
    #########################################################
    BsaRateSelMode:
      at:
        offset: 0x0200
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 2
      lsBit: 0
      mode: RW
      description: BSA def rate mode selection
      enums:
        - { name: "FixedRate", value: 0 }
        - { name: "ACRate"   , value: 1 }
        - { name: "Sequencer", value: 2 }
    #########################################################
    BsaFixedRate:
      at:
        offset: 0x0200
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 4
      lsBit: 2
      mode: RW
      description: BSA fixed rate mode selection
      enums:
        - { name: "  1 MHz", value: 0 }
        - { name: " 71 kHz", value: 1 }
        - { name: " 10 kHz", value: 2 }
        - { name: "  1 kHz", value: 3 }
        - { name: "100 Hz" , value: 4 }
        - { name: " 10 Hz" , value: 5 }
        - { name: "  1 Hz" , value: 6 }
    #########################################################
    BsaACRate:
      at:
        offset: 0x0200
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 3
      lsBit: 6
      mode: RW
      description: BSA AC rate mode selection
      enums:
        - { name: " 60 Hz", value: 0 }
        - { name: " 30 Hz", value: 1 }
        - { name: " 10 Hz", value: 2 }
        - { name: "  5 Hz", value: 3 }
        - { name: "  1 Hz", value: 4 }
        - { name: "1/2 Hz" ,value: 5 }
    #########################################################
    BsaACTSMask:
      at:
        offset: 0x0201
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 6
      lsBit: 1
      mode: RW
      description: BSA AC timeslot mask selection
    #########################################################
    BsaSequenceSelect:
      at:
        offset: 0x0201
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 5
      lsBit: 7
      mode: RW
      description: BSA sequencer selection
    #########################################################
    BsaSequenceBitSelect:
      at:
        offset: 0x0202
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 4
      lsBit: 4
      mode: RW
      description: BSA sequencer bit selection
    #########################################################
    BsaDestMode:
      at:
        offset: 0x0203
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 2
      lsBit: 0
      mode: RW
      description: BSA destination mode
      enums:
        - { name: "Dont_Care", value: 0 }
        - { name: "Inclusive", value: 1 }
        - { name: "Exclusive", value: 2 }
    #########################################################
    BsaDestInclusiveMask:
      at:
        offset: 0x0204
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 16
      lsBit: 0
      mode: RW
      description: BSA inclusive destination mask
    #########################################################
    BsaDestExclusiveMask:
      at:
        offset: 0x0206
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 16
      lsBit: 0
      mode: RW
      description: BSA exclusive destination mask
    #########################################################
    BsaNtoAvg:
      at:
        offset: 0x0208
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 13
      lsBit: 0
      mode: RW
      description: BSA def num acquisitions to average
    #########################################################
    BsaAvgToWr:
      at:
        offset: 0x020A
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 16
      lsBit: 0
      mode: RW
      description: BSA def num averages to record
    #########################################################
    BsaMaxSeverity:
      at:
        offset: 0x0209
        stride: 16
        nelms: *NARRAYSBSA
      class: IntField
      sizeBits: 2
      lsBit: 6
      mode: RW
      description: BSA def max alarm severity
      enums:
        - { name: "NoAlarm"  , value: 0 }
        - { name: "Minor"    , value: 1 }
        - { name: "Major"    , value: 2 }
        - { name: "Invalid"  , value: 3 }
    #########################################################
    PllCnt:
      at:
        offset: 0x0500
      class: IntField
      sizeBits: 32
      mode: RO
      description: Count of PLL status changes
    #########################################################
    ClkCnt:
      at:
        offset: 0x0504
      class: IntField
      sizeBits: 32
      mode: RO
      description: Count of local 186M clock
    #########################################################
    SyncErrCnt:
      at:
        offset: 0x0508
      class: IntField
      sizeBits: 32
      mode: RO
      description: Count of 71k sync errors
    #########################################################
    CountInterval:
      at:
        offset: 0x050C
      class: IntField
      sizeBits: 32
      mode: RW
      description: Interval counters update period
    #########################################################
    BaseRateCount:
      at:
        offset: 0x0510
      class: IntField
      sizeBits: 32
      mode: RO
      description: Count of base rate triggers
    #########################################################
