StdLogicVector
0.1
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Friends
Pages
StdLogicVector.h
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* An implementation of the std_logic_vector VHDL data type in C++
4
* Copyright (C) 2014 ETHZ Zurich, Integrated Systems Laboratory
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*****************************************************************************/
20
37
#ifndef STDLOGICVECTOR_H_
38
#define STDLOGICVECTOR_H_
39
40
#include <string>
41
#include <gmp.h>
42
#include <gmpxx.h>
43
44
using namespace
std;
45
62
class
StdLogicVector
{
63
64
private
:
65
// **************************************************************************
66
// Members
67
// **************************************************************************
68
mpz_t value_;
69
int
length_;
70
bool
isDontCare_;
71
72
// **************************************************************************
73
// Utility functions
74
// **************************************************************************
75
string
Zeros(
int
_length);
76
string
Ones(
int
_length);
77
78
public
:
79
// **************************************************************************
80
// Constructors/Destructors
81
// **************************************************************************
82
83
// Constructors
84
StdLogicVector
();
85
StdLogicVector
(
unsigned
int
_length);
86
StdLogicVector
(
unsigned
long
long
_value,
unsigned
int
_length);
87
StdLogicVector
(
string
_value,
int
_base,
unsigned
int
_length);
88
StdLogicVector
(
string
_value,
int
_base,
unsigned
int
_length,
bool
_isDontCare);
89
StdLogicVector
(
unsigned
char
*_value,
int
_size,
unsigned
int
_length);
90
91
// Copy-constructor
92
StdLogicVector
(
const
StdLogicVector
& _other);
93
94
// Destructor
95
virtual
~
StdLogicVector
();
96
97
98
99
// **************************************************************************
100
// Getter/Setter functions
101
// **************************************************************************
102
const
mpz_t & getValue()
const
;
103
int
getLength()
const
;
104
bool
isDontCare()
const
;
105
106
107
// **************************************************************************
108
// Utility functions
109
// **************************************************************************
110
unsigned
long
long
ToULL();
111
unsigned
long
long
ToULL()
const
;
112
113
string
ToString();
114
string
ToString(
bool
_pad);
115
string
ToString(
int
_base);
116
string
ToString(
int
_base)
const
;
117
string
ToString(
int
_base,
bool
_pad);
118
string
ToString(
int
_base,
bool
_pad)
const
;
119
120
void
ToByteArray(
unsigned
char
_byteArray[])
const
;
121
122
// **************************************************************************
123
// Operator overloadings
124
// **************************************************************************
125
bool
operator==(
const
StdLogicVector
& _input)
const
;
126
bool
operator!=(
const
StdLogicVector
& _input)
const
;
127
friend
ostream &
operator<<
(ostream & _os,
const
StdLogicVector
& _stdLogicVec);
128
129
130
// **************************************************************************
131
// Bitwise operations
132
// **************************************************************************
133
int
TestBit(
int
_index)
const
;
134
135
StdLogicVector
& ShiftLeft(
int
_bits);
136
StdLogicVector
& ShiftRight(
int
_bits);
137
StdLogicVector
& And(
const
StdLogicVector
& _operand);
138
StdLogicVector
& Or(
const
StdLogicVector
& _operand);
139
StdLogicVector
& Xor(
const
StdLogicVector
& _operand);
140
141
StdLogicVector
& TruncateAfter(
int
_width);
142
StdLogicVector
& ReplaceBits(
int
_begin,
const
StdLogicVector
& _input);
143
StdLogicVector
& PadRightZeros(
int
_width);
144
StdLogicVector
& ReverseBitOrder();
145
146
147
// **************************************************************************
148
// Arithmetic operations
149
// **************************************************************************
150
StdLogicVector
& Add(
const
StdLogicVector
& _operand);
151
StdLogicVector
& Add(
const
StdLogicVector
& _operand,
bool
_truncateCarry);
152
};
153
154
#endif
/* STDLOGICVECTOR_H_ */
operator<<
ostream & operator<<(ostream &_os, const StdLogicVector &_stdLogicVec)
Provide a nice stream output showing the value of the StdLogicVector in hexadecimal representation an...
Definition:
StdLogicVector.cpp:232
StdLogicVector
An implementation of the std_logic_vector VHDL data type in C++.
Definition:
StdLogicVector.h:62
include
StdLogicVector.h
Generated by
1.8.6