##############################################################################
## 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 DacSigGen.yaml
#include GenericMemory.yaml

DacSigGen: &DacSigGen 
  name: DacSigGen
  description: Signal generator module
  class: MMIODev
  configPrio: 1
  size: 0x10000000
  metadata:
    numOfChs: &numOfChs 2
    ramWidth: &ramWidth 16
    buffSize: &buffSize 0x200
  #########             
  children:
    #########################################################
    EnableMask:
      at:
        offset: 0x000
      class: IntField
      name: EnableMask
      sizeBits: *numOfChs
      mode: RW
      description: "Mask Enable channels."
    #########################################################    
    ModeMask: 
      at:
        offset: 0x004
      class: IntField
      name: ModeMask
      sizeBits: *numOfChs
      mode: RW
      description: "Mask select Mode: 0 - Triggered Mode. 1 - Periodic Mode"
    #########################################################    
    SignFormat: 
      at:
        offset: 0x008
      class: IntField
      name: SignFormat
      sizeBits: *numOfChs
      mode: RW
      description: "Mask select Sign: 0 - Signed 2's complement, 1 - Offset binary (Currently Applies only to zero data)"
    #########################################################    
    SoftwareTrigger: 
      at:
        offset: 0x00C
      class: IntField
      name: SoftwareTrigger
      sizeBits: *numOfChs
      mode: RW
      description: "Mask Software trigger (applies in triggered mode, Internal edge detector)"
    #########################################################    
    HoldLastValue: 
      at:
        offset: 0x010
      class: IntField
      name: HoldLastValue
      sizeBits: *numOfChs
      mode: RW
      description: "BitMask: 1 to hold the last pattern value, 0 to zere out data at the end of pattern"    
    #########################################################    
    Running: 
      at:
        offset: 0x020
      class: IntField
      name: Running
      sizeBits: *numOfChs
      mode: RO
      description: "Mask Running status"
    #########################################################    
    Underflow: 
      at:
        offset: 0x024
      class: IntField
      name: Underflow
      sizeBits: *numOfChs
      mode: RO
      description: "Mask Underflow status: 16bit to 32bit conversion underflow (applies in 32bit interface)."
    #########################################################    
    Overflow: 
      at:
        offset: 0x028
      class: IntField
      name: Overflow
      sizeBits: *numOfChs
      mode: RO
      description: "Mask Overflow status: 16bit to 32bit conversion underflow (applies in 32bit interface)."
    #########################################################    
    MaxWaveformSize: 
      at:
        offset: 0x02C
      class: IntField
      name: MaxWaveformSize
      mode: RO
      description: "Max Waveform size (2**ADDR_WIDTH_G)"
   #########################################################    
    PeriodSize:     
      at:
        offset: 0x040
        stride: 4
        nelms: *numOfChs
      class: IntField
      name: PeriodSize
      sizeBits: 32
      mode: RW
      description: "In Periodic mode: Period size (Zero inclusive). In Triggered mode: Waveform size (Zero inclusive). Separate values for separate channels."
    #########################################################
    #    Channel waveforms  
    #########################################################
    Waveform:
      class: MMIODev
      at:
        offset: 0x01000000
        stride: 0x01000000
        nelms: *numOfChs
      size: 0x01000000       
      description: "Waveform Lookup Table"     
      children:
        MemoryArray:
          <<: *MemoryArray
          sizeBits: *ramWidth
          mode: RW
          at:
            offset: 0x0
            stride: 0x4
            nelms: *buffSize
    #########################################################
    #    Commands
    #########################################################
    SwTrigger:
      name: SwTrigger
      class: SequenceCommand
      at:
        offset: 0x0
      description: Trigger waveform from software (All channels. Triggerd mode).
      sequence:
      - entry: SoftwareTrigger
        value: 0x7F
      - entry: SoftwareTrigger
        value: 0x0
    #########################################################
