⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cordic.h

📁 这个包里面包含了对Cordic算法的基本函数实现。通过Dformat类来控制系统的数据格式
💻 H
字号:
/*	Class Cordic provides interfaces to CORDIC algorithm
	As we know, CORDIC algorithm is discovered and issued by J.S Volder
	firstly, and then extended by Walther.As the development of computer
	technology and FPGA, CORDIC was found attractive in many projects.
	Thereafter, lots of derivative algorithms were developed.
	
	However, this projects only focus on the conventional CORDIC algorithm.
	And piles of thesis may be referred to in your project.
*/

#ifndef CORDIC_DECLARE
#define CORDIC_DECLARE

// pi
#ifndef PI
#define PI 3.141592653589793
#endif

#include <fstream>

using std::ostream;

#include "Dformat.h"

const Dformat DATAFORMAT;		// default data format

class Cordic
{
public:
	// default constructor---------------------------------------------------
	Cordic( const Dformat& CDf=DATAFORMAT,int m=1,char dv_n='z',
			double x0=0,double y0=0,double z0=0 );	

	// setting functions-----------------------------------------------------
	void set( const Dformat& CDf,
			  const int m,const char dv_n,
			  const double x0,
			  const double y0,
			  const double z0 );
	void set( const unsigned M,const unsigned N,
			  const int m,const char dv_n,
			  const double x0,
			  const double y0,
			  const double z0 );
	void set( const unsigned M,const unsigned N );
	void set( const int m );
	void set( const char dv_n );
	void set( const double x0,const double y0,const double z0 );
	//
	// trigonometric functions--------------------------------------------------------
	double Sin();
	double Cos();
	double Abs();
	double Atan();
	double Mult();
	double Dev();
	double Sinh();
	double Cosh();
	double Sqrt();
	double Atanh();
	//
	// getting functions-----------------------------------------------------
	const double& getx( void ) const;		// get the final result
	const double& gety( void ) const;
	const double& getz( void ) const;
	// print parameters------------------------------------------------------
	void print( ostream& ) const;
	// save the results into files-----------
	void save( ostream& ) const;
	// default destructor----------------------------------------------------
	~Cordic( void );
private:
	Dformat		CORDIC_Dfmt;	// codic data format
	int			mode;			// mode: circular\linear\hyperbolic
	char		dv_name;		// decision variable name
	double		x;				// initial state
	double		y;
	double		z;
	// utility functions-----------------------------------------------------
	bool validator( const double x0,const double y0,const double z0 ) const;
	// validate intial state
	bool terminator( const long dv ) const;
	// core functions
	void cordic( const int m,const char dv_n );
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -