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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [new_compiler/] [Instruction.h] - Blame information for rev 201

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 201 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_ADDRESS_REGISTER 31
33
#define RETURN_VALUE_REGISTER   1
34
#define SPR_CONTROL_REGISTER  30
35
typedef enum
36
{
37
        ECHANNEL_X=4,
38
        ECHANNEL_Y=2,
39
        ECHANNEL_Z=1,
40
        ECHANNEL_XYZ=7
41
 
42
} ECHANNEL;
43
 
44
typedef enum
45
{
46
        SWX_X=0,
47
        SWX_Z,
48
        SWX_Y
49
} ESWIZZLE_X;
50
 
51
typedef enum
52
{
53
        SWY_Y=0,
54
        SWY_Z,
55
        SWY_X
56
} ESWIZZLE_Y;
57
 
58
typedef enum
59
{
60
        SWZ_Z=0,
61
        SWZ_Y,
62
        SWZ_X
63
} ESWIZZLE_Z;
64
 
65
typedef enum
66
{
67
        EOPERATION_ADD=1,
68
        EOPERATION_DIV,
69
        EOPERATION_MUL,
70
        EOPERATION_SQRT
71
 
72
} EOPERATION;
73
 
74
typedef enum
75
{
76
        EROT_NONE = 0,
77
        EROT_SRC0_LEFT =1,
78
        EROT_SRC1_LEFT =2,
79
        EROT_SRC1_SCR0_LEFT = 3,
80
        EROT_SRC0_RIGHT=9,
81
        EROT_SRC1_RIGHT=10,
82
        EROT_SRC1_SRC0_RIGHT=11,
83
        EROT_RESULT_RIGHT=12
84
} EROTATION;
85
 
86
typedef enum
87
{
88
EBRANCH_ALWAYS=0,
89
EBRANCH_IF_ZERO,
90
EBRANCH_IF_NOT_ZERO,
91
EBRANCH_IF_SIGN,
92
EBRANCH_IF_NOT_SIGN,
93
EBRANCH_IF_ZERO_OR_SIGN,
94
EBRANCH_IF_ZERO_OR_NOT_SIGN
95
 
96
} EBRANCHTYPE;
97
/*
98
typedef enum
99
{
100
        EDIRECT_ADDRESSING = 0,
101
        EDIRECT_DISP_SRC0,
102
        EDIRECT_DISP_SRC1,
103
        EDIRECT_DISP_SRC1_SRC0,
104
        EDIRECT_DISP_DST,
105
        EDIRECT_DISP_DST_SRC0,
106
        EDIRECT_DISP_DST_SRC1,
107
        EDIRECT_DISP_DST_SRC1_SRC0,
108
        EDIRECT_IMM,=0
109
        EDIRECT_IMM_ZERO,
110
        EINDIRECT_IMM,  //SRC0 = R[DSTINDEX]
111
        EINDIRECT_IMM_ZERO,
112
        EINDIRECT_IMM_DISP, // DST = R[ DSTINDEX ] + OFFSET
113
        EINDIRECT_IMM_DISP_ZERO,
114
        EINDIRECT_NO_IMM,
115
        EINDIRECT_NO_IMM_DISP
116
} EADDRESSINGTYPE;
117
*/
118
class Instruction
119
{
120
  public:
121
        Instruction();
122
        ~Instruction();
123
  public:
124
        std::string PrintHex();
125
        std::string PrintBin();
126
        std::string PrintAssembly();
127
        void PrintFields();
128
        void Clear( void );
129
 
130
  public:
131
    void SetFields( unsigned int aOperation, unsigned int aDestination, unsigned int aSrc1, unsigned int aSrc0 );
132
        void SetCode( EOPERATION aCode );
133
        void SetImm( unsigned int aLiteral );
134
        void SetDestZero( bool aZero );
135
        void SetSrc0Displace( bool aDisplace );
136
        void SetSrc1Displace( bool aDisplace );
137
//      void SetAddressingMode( EADDRESSINGTYPE aAddressMode );
138
 
139
        void SetEofFlag( bool aEof );
140
        void SetWriteChannel( ECHANNEL aChannel );
141
        void ClearWriteChannel();
142
        void SetDestinationAddress( unsigned int aDestinationAddress );
143
        void SetDestination( std::bitset<DESTINATION_SIZE> aDestination );
144
        void SetDestinationSymbol( std::string aSymbol );
145
        void SetBranchFlag( bool aBranch );
146
        void SetBranchType( EBRANCHTYPE aType );
147
        //Source 1
148
        void SetSrc1SignX( bool aSign );
149
        void SetSrc1SignY( bool aSign );
150
        void SetSrc1SignZ( bool aSign );
151
        void SetSrc1SwizzleX( ESWIZZLE_X aChannel );
152
        void SetSrc1SwizzleY( ESWIZZLE_Y aChannel );
153
        void SetSrc1SwizzleZ( ESWIZZLE_Z aChannel );
154
        void SetSrc1Address( unsigned int aAddress );
155
        void SetSrc1Rotation( EROTATION aRotation );
156
        //Source 0
157
        void SetSrc0SignX( bool aSign );
158
        void SetSrc0SignY( bool aSign );
159
        void SetSrc0SignZ( bool aSign );
160
        void SetSrc0SwizzleX( ESWIZZLE_X aChannel );
161
        void SetSrc0SwizzleY( ESWIZZLE_Y aChannel );
162
        void SetSrc0SwizzleZ( ESWIZZLE_Z aChannel );
163
        void SetSrc0Address( unsigned int aAddress );
164
        void SetSrc0Rotation( EROTATION aRotation );
165
 
166
        std::bitset<DESTINATION_SIZE> GetDestination( void );
167
        ECHANNEL        GetWriteChannel( void );
168
 
169
  private:
170
        std::bitset<OPERATION_SIZE>   mOperation;
171
        std::string                   mOperationString;
172
        std::bitset<DESTINATION_SIZE> mDestination;
173
        std::bitset<SOURCE1_SIZE>     mSource1;
174
        std::bitset<SOURCE0_SIZE>     mSource0;
175
        unsigned int                  mLiteral;
176
        bool                          mDestinationIsSymbol;
177
        std::string                   mDestinationSymbol;
178
public:
179
        int                               mSourceLine;
180
        std::string                   mComment;
181
  private:
182
        //std::ofstream                 mOutputFile;
183
};
184
 
185
#endif

powered by: WebSVN 2.1.0

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