OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [compiler/] [src/] [vp_compiler/] [Instruction.h] - Blame information for rev 230

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 216 diegovalve
#ifndef INSTRUCTION_H
2
#define INSTRUCTION_H
3
 
4
/**********************************************************************************
5
Theia, Ray Cast Programable graphic Processing Unit.
6
Copyright (C) 2012  Diego Valverde (diego.valverde.g@gmail.com)
7
 
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
 
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
 
22
***********************************************************************************/
23
 
24
#include <bitset>
25
#include <string>
26
#include <fstream>
27
 
28
#define OPERATION_SIZE 16
29
#define DESTINATION_SIZE 14
30
#define SOURCE1_SIZE 17
31
#define SOURCE0_SIZE 17
32
#define RETURN_VALUE_REGISTER   1
33
#define RETURN_ADDRESS_REGISTER 2//31
34
#define SPR_CONTROL_REGISTER    3  //30
35
#define SPR_CONTROL_REGISTER0   2
36
 
37
//----------------------------------------------------------------------------------
38
//#define DEBUG 1
39
//Use this macro instead of std::cout, it is easier to turn off
40
class NullStream
41
{
42
    public:
43
    NullStream() { }
44
    template<typename T> NullStream& operator<<(T const&) { return *this; }
45
};
46
 
47
 
48
#ifdef DEBUG
49
        #define DCOUT std::cout
50
#else
51
        #define DCOUT NullStream()
52
#endif
53
//----------------------------------------------------------------------------------
54
 
55
 
56
 
57
typedef enum
58
{
59
        ECHANNEL_X=4,
60
        ECHANNEL_Y=2,
61
        ECHANNEL_Z=1,
62
        ECHANNEL_XYZ=7
63
 
64
} ECHANNEL;
65
 
66
typedef enum
67
{
68
        SWX_X=0,
69
        SWX_Z,
70
        SWX_Y
71
} ESWIZZLE_X;
72
 
73
typedef enum
74
{
75
        SWY_Y=0,
76
        SWY_Z,
77
        SWY_X
78
} ESWIZZLE_Y;
79
 
80
typedef enum
81
{
82
        SWZ_Z=0,
83
        SWZ_Y,
84
        SWZ_X
85
} ESWIZZLE_Z;
86
 
87
typedef enum
88
{
89
        EOPERATION_NOP=0,
90
        EOPERATION_ADD=1,
91
        EOPERATION_DIV,
92
        EOPERATION_MUL,
93
        EOPERATION_SQRT,
94
        EOPERATION_LOGIC,
95 230 diegovalve
        EOPERATION_IO
96 216 diegovalve
 
97
} EOPERATION;
98
 
99
 
100
typedef enum
101
{
102
ELOGIC_AND = 0,
103
ELOGIC_OR,
104
ELOGIC_NOT,
105
ELOGIC_SHL,
106
ELOGIC_SHR
107
 
108
}       ELOGIC_OPERATION;
109
 
110 230 diegovalve
 
111 216 diegovalve
typedef enum
112
{
113 230 diegovalve
        EIO_OMWRITE,
114
        EIO_TMREAD,
115
        EIO_MAILBOX,
116
 
117
} EIO_OPERATION;
118
 
119
 
120
typedef enum
121
{
122 216 diegovalve
        EROT_NONE = 0,
123
        EROT_SRC0_LEFT =1,
124
        EROT_SRC1_LEFT =2,
125
        EROT_SRC1_SCR0_LEFT = 3,
126
        EROT_SRC0_RIGHT=9,
127
        EROT_SRC1_RIGHT=10,
128
        EROT_SRC1_SRC0_RIGHT=11,
129
        EROT_RESULT_RIGHT=12
130
} EROTATION;
131
 
132
typedef enum
133
{
134
EBRANCH_ALWAYS=0,
135
EBRANCH_IF_ZERO,
136
EBRANCH_IF_NOT_ZERO,
137
EBRANCH_IF_SIGN,
138
EBRANCH_IF_NOT_SIGN,
139
EBRANCH_IF_ZERO_OR_SIGN,
140
EBRANCH_IF_ZERO_OR_NOT_SIGN
141
 
142
} EBRANCHTYPE;
143
 
144
class Instruction
145
{
146
  public:
147
        Instruction();
148
        ~Instruction();
149
  public:
150
        std::string PrintHex();
151
        std::string PrintBin();
152
        std::string PrintAssembly();
153
        void PrintFields();
154
        std::string PrintHex32();
155
        void Clear( void );
156
        bool mBisonFlagTrippleConstAssign;
157
 
158
  public:
159
    void SetFields( unsigned int aOperation, unsigned int aDestination, unsigned int aSrc1, unsigned int aSrc0 );
160
        void SetCode( EOPERATION aCode );
161
        void SetImm( unsigned int aLiteral );
162
        void SetImmBit( bool aImm );
163
        void SetDestZero( bool aZero );
164
        void SetSrc0Displace( bool aDisplace );
165
        void SetSrc1Displace( bool aDisplace );
166
        void SetLogicOperation(ELOGIC_OPERATION aOperation );
167 230 diegovalve
        void SetIOOperation( EIO_OPERATION aOperation );
168 216 diegovalve
        void SetAddressingMode( bool, bool, bool  );
169
 
170
        void SetEofFlag( bool aEof );
171
        void SetWriteChannel( ECHANNEL aChannel );
172
        void ClearWriteChannel();
173
        void SetDestinationAddress( unsigned int aDestinationAddress );
174
        void SetDestination( std::bitset<DESTINATION_SIZE> aDestination );
175
        void SetDestinationSymbol( std::string aSymbol );
176
        void SetBranchFlag( bool aBranch );
177
        void SetBranchType( EBRANCHTYPE aType );
178
        //Source 1
179
        void SetSrc1SignX( bool aSign );
180
        void SetSrc1SignY( bool aSign );
181
        void SetSrc1SignZ( bool aSign );
182
        void SetSrc1SwizzleX( ESWIZZLE_X aChannel );
183
        void SetSrc1SwizzleY( ESWIZZLE_Y aChannel );
184
        void SetSrc1SwizzleZ( ESWIZZLE_Z aChannel );
185
        void SetSrc1Address( unsigned int aAddress );
186
        void SetSrc1Rotation( EROTATION aRotation );
187
        //Source 0
188
        void SetSrc0SignX( bool aSign );
189
        void SetSrc0SignY( bool aSign );
190
        void SetSrc0SignZ( bool aSign );
191
        void SetSrc0SwizzleX( ESWIZZLE_X aChannel );
192
        void SetSrc0SwizzleY( ESWIZZLE_Y aChannel );
193
        void SetSrc0SwizzleZ( ESWIZZLE_Z aChannel );
194
        void SetSrc0Address( unsigned int aAddress );
195
        void SetSrc0Rotation( EROTATION aRotation );
196
 
197
        std::bitset<DESTINATION_SIZE> GetDestination( void );
198
        unsigned int GetOperation( void );
199
        unsigned int GetAddressingMode( void );
200
        unsigned int GetDestinationAddress( void );
201
        bool         GetImm( void);
202
        ECHANNEL        GetWriteChannel( void );
203
 
204
  private:
205
        std::bitset<OPERATION_SIZE>   mOperation;
206
        std::string                   mOperationString;
207
        std::bitset<DESTINATION_SIZE> mDestination;
208
        std::bitset<SOURCE1_SIZE>     mSource1;
209
        std::bitset<SOURCE0_SIZE>     mSource0;
210
        unsigned int                  mLiteral;
211
        bool                          mDestinationIsSymbol;
212
        std::string                   mDestinationSymbol;
213
public:
214
        int                               mSourceLine;
215
        std::string                   mComment;
216
  private:
217
        //std::ofstream                 mOutputFile;
218
};
219
 
220
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.