// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2016.1
// Copyright (C) 1986-2016 Xilinx, Inc. All Rights Reserved.
// 
// ==============================================================

#ifndef XTRACE_CNTRL_H
#define XTRACE_CNTRL_H

#ifdef __cplusplus
extern "C" {
#endif

/***************************** Include Files *********************************/
#ifndef __linux__
#include "xil_types.h"
#include "xil_assert.h"
#include "xstatus.h"
#include "xil_io.h"
#else
#include <stdint.h>
#include <assert.h>
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stddef.h>
#endif
#include "xtrace_cntrl_hw.h"

/**************************** Type Definitions ******************************/
#ifdef __linux__
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
#else
typedef struct {
    u16 DeviceId;
    u32 Trace_cntrl_BaseAddress;
} XTrace_cntrl_Config;
#endif

typedef struct {
    u32 Trace_cntrl_BaseAddress;
    u32 IsReady;
} XTrace_cntrl;

/***************** Macros (Inline Functions) Definitions *********************/
#ifndef __linux__
#define XTrace_cntrl_WriteReg(BaseAddress, RegOffset, Data) \
    Xil_Out32((BaseAddress) + (RegOffset), (u32)(Data))
#define XTrace_cntrl_ReadReg(BaseAddress, RegOffset) \
    Xil_In32((BaseAddress) + (RegOffset))
#else
#define XTrace_cntrl_WriteReg(BaseAddress, RegOffset, Data) \
    *(volatile u32*)((BaseAddress) + (RegOffset)) = (u32)(Data)
#define XTrace_cntrl_ReadReg(BaseAddress, RegOffset) \
    *(volatile u32*)((BaseAddress) + (RegOffset))

#define Xil_AssertVoid(expr)    assert(expr)
#define Xil_AssertNonvoid(expr) assert(expr)

#define XST_SUCCESS             0
#define XST_DEVICE_NOT_FOUND    2
#define XST_OPEN_DEVICE_FAILED  3
#define XIL_COMPONENT_IS_READY  1
#endif

/************************** Function Prototypes *****************************/
#ifndef __linux__
int XTrace_cntrl_Initialize(XTrace_cntrl *InstancePtr, u16 DeviceId);
XTrace_cntrl_Config* XTrace_cntrl_LookupConfig(u16 DeviceId);
int XTrace_cntrl_CfgInitialize(XTrace_cntrl *InstancePtr, XTrace_cntrl_Config *ConfigPtr);
#else
int XTrace_cntrl_Initialize(XTrace_cntrl *InstancePtr, const char* InstanceName);
int XTrace_cntrl_Release(XTrace_cntrl *InstancePtr);
#endif

void XTrace_cntrl_Start(XTrace_cntrl *InstancePtr);
u32 XTrace_cntrl_IsDone(XTrace_cntrl *InstancePtr);
u32 XTrace_cntrl_IsIdle(XTrace_cntrl *InstancePtr);
u32 XTrace_cntrl_IsReady(XTrace_cntrl *InstancePtr);
void XTrace_cntrl_EnableAutoRestart(XTrace_cntrl *InstancePtr);
void XTrace_cntrl_DisableAutoRestart(XTrace_cntrl *InstancePtr);

void XTrace_cntrl_Set_data_compare_V(XTrace_cntrl *InstancePtr, u64 Data);
u64 XTrace_cntrl_Get_data_compare_V(XTrace_cntrl *InstancePtr);
void XTrace_cntrl_Set_length_r(XTrace_cntrl *InstancePtr, u32 Data);
u32 XTrace_cntrl_Get_length_r(XTrace_cntrl *InstancePtr);
void XTrace_cntrl_Set_sample_rate(XTrace_cntrl *InstancePtr, u32 Data);
u32 XTrace_cntrl_Get_sample_rate(XTrace_cntrl *InstancePtr);

void XTrace_cntrl_InterruptGlobalEnable(XTrace_cntrl *InstancePtr);
void XTrace_cntrl_InterruptGlobalDisable(XTrace_cntrl *InstancePtr);
void XTrace_cntrl_InterruptEnable(XTrace_cntrl *InstancePtr, u32 Mask);
void XTrace_cntrl_InterruptDisable(XTrace_cntrl *InstancePtr, u32 Mask);
void XTrace_cntrl_InterruptClear(XTrace_cntrl *InstancePtr, u32 Mask);
u32 XTrace_cntrl_InterruptGetEnabled(XTrace_cntrl *InstancePtr);
u32 XTrace_cntrl_InterruptGetStatus(XTrace_cntrl *InstancePtr);

#ifdef __cplusplus
}
#endif

#endif
