2011-01-31 18:25:29 +01:00
|
|
|
#ifndef __vhdlreal_h
|
|
|
|
|
#define __vhdlreal_h
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2011-02-04 17:51:51 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <cmath>
|
2011-01-31 18:25:29 +01:00
|
|
|
|
2011-02-04 17:51:51 +01:00
|
|
|
using namespace std;
|
|
|
|
|
/*
|
|
|
|
|
* This class holds a floating point decimal number. The number is
|
|
|
|
|
* stored as double. All based numbers are converted by an external
|
|
|
|
|
* function to a double and then stored as class instance.
|
|
|
|
|
*/
|
|
|
|
|
class vhdlreal
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
friend ostream& operator<< (ostream&, const vhdlreal&);
|
|
|
|
|
friend vhdlreal operator+ (const vhdlreal&, const vhdlreal&);
|
|
|
|
|
friend vhdlreal operator- (const vhdlreal&, const vhdlreal&);
|
|
|
|
|
friend vhdlreal operator* (const vhdlreal&, const vhdlreal&);
|
|
|
|
|
friend vhdlreal operator/ (const vhdlreal&, const vhdlreal&);
|
|
|
|
|
friend vhdlreal operator% (const vhdlreal&, const vhdlreal&);
|
|
|
|
|
friend vhdlreal pow(const vhdlreal&, const vhdlreal&);
|
|
|
|
|
// Unary minus.
|
|
|
|
|
friend vhdlreal operator- (const vhdlreal&);
|
2011-01-31 18:25:29 +01:00
|
|
|
|
2011-02-04 17:51:51 +01:00
|
|
|
explicit vhdlreal();
|
|
|
|
|
explicit vhdlreal(const char*text);
|
|
|
|
|
explicit vhdlreal(const double& val);
|
|
|
|
|
vhdlreal(const vhdlreal& val);
|
|
|
|
|
virtual ~vhdlreal() {};
|
|
|
|
|
|
|
|
|
|
double as_double() const
|
|
|
|
|
{
|
|
|
|
|
return value_;
|
|
|
|
|
}
|
|
|
|
|
protected:
|
|
|
|
|
double value_;
|
|
|
|
|
};
|
|
|
|
|
#endif
|