

#ifndef __CFG_H__
#define __CFG_H__

#include <assert.h>

//default to Nios2 as target
#if !defined(PC_TARGET) && !defined(NIOS2_TARGET)
	#define NIOS2_TARGET
#endif


//uncomment the following line to enable the software normalization function on the NIOS II
//#define USE_SOFTWARE_IMPLEMENTATION
// uncomment to change which mul function is used in v3norm
//#define SW_MUL
//#define SW_DIV
//#define SW_SQRT

#define MUL 0
#define HW_MUL(a, b) (fix16_t)ALT_CI_CI_MUL_0((a), (b))

#define DIV 1
#define DIV_ENQUEUE 0
#define DIV_DEQUEUE 1
#define HW_DIV_WRITE(a, b) (void)ALT_CI_CI_DIV_0(DIV_ENQUEUE, (a), (b))
#define HW_DIV_READ() (fix16_t)ALT_CI_CI_DIV_0(DIV_DEQUEUE, 0, 0)

#define CALCULATION_METHOD MUL

#if defined(NIOS2_TARGET)
	#include "system.h"
	#include "altera_avalon_timer_regs.h"
	#include "sys/alt_stdio.h"
	#include "sys/alt_irq.h"
	#include "v3norm.h"
	
	#define QUAUX(X) #X
	#define QU(X) QUAUX(X)
#endif


//Just to be on the safe side with the casts for scanf/printf
static_assert(sizeof(unsigned int) == sizeof(fix16_t), "unsigned int does not seem to be 32 bits");
static_assert(sizeof(uint32_t) == sizeof(fix16_t), "unsigned int does not seem to be 32 bits");


#endif


