/*
*===============================================================================
*
* d/wilson_d520/common.h
*
*-------------------------------------------------------------------------------
*
* Copyright (C) 2010 Thomas Streuer 
*
* This file is part of BQCD -- Berlin Quantum ChromoDynamics program
*
* BQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BQCD.  If not, see <http:*www.gnu.org/licenses/>.
*
*-------------------------------------------------------------------------------
*/
#ifndef COMMON_H

#define COMMON_H

#include <inttypes.h>
#include <spi/kernel_interface.h>
#include <spi/DMA_Counter.h>
#include <spi/DMA_InjFifo.h>


typedef struct
{
  uint16_t* neighb;
  uint32_t volh;
  uint32_t volh3;
  uint32_t pref_offset;
  double* U;
  double* comm_buffer;
  DMA_CounterHw_t* inj_counter_hw;
  DMA_CounterHw_t* rec_counter_hw;
  int fifo_size[8];
  DMA_FifoHW_t* fifo_hw[8];         // pointer to hw fifo
  uint32_t pa_head[8];              // pa_head to be put into fifo_hw[i]->ps_head
  uint32_t pa_tail[8];              // pa_head to be put into fifo_hw[i]->ps_tail
  uint32_t ctr_init[4];
} wilson_data_t;

typedef struct
{
  uint32_t mod2_ctr;               // counts D applications
  wilson_data_t w_data[2][2][2];   // [d/s][e/o][c]   (0=dbl,1=sng | 0=even, 1=odd | ctr % 2)
} global_wilson_data_t;


#define NB_ARRAY_RECV_BIT     15
#define NB_ARRAY_IDX_MASK     0x7fff

#define T0_LAST 1

#endif
