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 216

Go to most recent revision | 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
        EOPERATION_OUT
96
 
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
typedef enum
111
{
112
        EROT_NONE = 0,
113
        EROT_SRC0_LEFT =1,
114
        EROT_SRC1_LEFT =2,
115
        EROT_SRC1_SCR0_LEFT = 3,
116
        EROT_SRC0_RIGHT=9,
117
        EROT_SRC1_RIGHT=10,
118
        EROT_SRC1_SRC0_RIGHT=11,
119
        EROT_RESULT_RIGHT=12
120
} EROTATION;
121
 
122
typedef enum
123
{
124
EBRANCH_ALWAYS=0,
125
EBRANCH_IF_ZERO,
126
EBRANCH_IF_NOT_ZERO,
127
EBRANCH_IF_SIGN,
128
EBRANCH_IF_NOT_SIGN,
129
EBRANCH_IF_ZERO_OR_SIGN,
130
EBRANCH_IF_ZERO_OR_NOT_SIGN
131
 
132
} EBRANCHTYPE;
133
 
134
class Instruction
135
{
136
  public:
137
        Instruction();
138
        ~Instruction();
139
  public:
140
        std::string PrintHex();
141
        std::string PrintBin();
142
        std::string PrintAssembly();
143
        void PrintFields();
144
        std::string PrintHex32();
145
        void Clear( void );
146
        bool mBisonFlagTrippleConstAssign;
147
 
148
  public:
149
    void SetFields( unsigned int aOperation, unsigned int aDestination, unsigned int aSrc1, unsigned int aSrc0 );
150
        void SetCode( EOPERATION aCode );
151
        void SetImm( unsigned int aLiteral );
152
        void SetImmBit( bool aImm );
153
        void SetDestZero( bool aZero );
154
        void SetSrc0Displace( bool aDisplace );
155
        void SetSrc1Displace( bool aDisplace );
156
        void SetLogicOperation(ELOGIC_OPERATION aOperation );
157
        void SetAddressingMode( bool, bool, bool  );
158
 
159
        void SetEofFlag( bool aEof );
160
        void SetWriteChannel( ECHANNEL aChannel );
161
        void ClearWriteChannel();
162
        void SetDestinationAddress( unsigned int aDestinationAddress );
163
        void SetDestination( std::bitset<DESTINATION_SIZE> aDestination );
164
        void SetDestinationSymbol( std::string aSymbol );
165
        void SetBranchFlag( bool aBranch );
166
        void SetBranchType( EBRANCHTYPE aType );
167
        //Source 1
168
        void SetSrc1SignX( bool aSign );
169
        void SetSrc1SignY( bool aSign );
170
        void SetSrc1SignZ( bool aSign );
171
        void SetSrc1SwizzleX( ESWIZZLE_X aChannel );
172
        void SetSrc1SwizzleY( ESWIZZLE_Y aChannel );
173
        void SetSrc1SwizzleZ( ESWIZZLE_Z aChannel );
174
        void SetSrc1Address( unsigned int aAddress );
175
        void SetSrc1Rotation( EROTATION aRotation );
176
        //Source 0
177
        void SetSrc0SignX( bool aSign );
178
        void SetSrc0SignY( bool aSign );
179
        void SetSrc0SignZ( bool aSign );
180
        void SetSrc0SwizzleX( ESWIZZLE_X aChannel );
181
        void SetSrc0SwizzleY( ESWIZZLE_Y aChannel );
182
        void SetSrc0SwizzleZ( ESWIZZLE_Z aChannel );
183
        void SetSrc0Address( unsigned int aAddress );
184
        void SetSrc0Rotation( EROTATION aRotation );
185
 
186
        std::bitset<DESTINATION_SIZE> GetDestination( void );
187
        unsigned int GetOperation( void );
188
        unsigned int GetAddressingMode( void );
189
        unsigned int GetDestinationAddress( void );
190
        bool         GetImm( void);
191
        ECHANNEL        GetWriteChannel( void );
192
 
193
  private:
194
        std::bitset<OPERATION_SIZE>   mOperation;
195
        std::string                   mOperationString;
196
        std::bitset<DESTINATION_SIZE> mDestination;
197
        std::bitset<SOURCE1_SIZE>     mSource1;
198
        std::bitset<SOURCE0_SIZE>     mSource0;
199
        unsigned int                  mLiteral;
200
        bool                          mDestinationIsSymbol;
201
        std::string                   mDestinationSymbol;
202
public:
203
        int                               mSourceLine;
204
        std::string                   mComment;
205
  private:
206
        //std::ofstream                 mOutputFile;
207
};
208
 
209
#endif

powered by: WebSVN 2.1.0

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