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.cpp] - Diff between revs 216 and 230

Only display areas with differences | Details | Blame | View Log

Rev 216 Rev 230
 
 
/**********************************************************************************
/**********************************************************************************
Theia, Ray Cast Programable graphic Processing Unit.
Theia, Ray Cast Programable graphic Processing Unit.
Copyright (C) 2012  Diego Valverde (diego.valverde.g@gmail.com)
Copyright (C) 2012  Diego Valverde (diego.valverde.g@gmail.com)
 
 
This program is free software; you can redistribute it and/or
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
of the License, or (at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
***********************************************************************************/
***********************************************************************************/
 
 
 
 
#include "Instruction.h"
#include "Instruction.h"
#include <sstream>
#include <sstream>
#include <iostream>
#include <iostream>
#include <iomanip>
#include <iomanip>
//----------------------------------------------------------------
//----------------------------------------------------------------
#define OP_SIZE        16            
#define OP_SIZE        16            
 
 
#define OP_RNG         63,48         
#define OP_RNG         63,48         
#define OP_BIT_IMM     15
#define OP_BIT_IMM     15
#define OP_SCALE_RNG   14,11
#define OP_SCALE_RNG   14,11
#define OP_EOF         10
#define OP_EOF         10
#define OP_BRANCH      9
#define OP_BRANCH      9
#define OP_BTYPE_RNG   8,6
#define OP_BTYPE_RNG   8,6
 
 
#define OP_CODE_RNG    2,0
#define OP_CODE_RNG    2,0
 
 
#define DST_ADDR            7,0
#define DST_ADDR            7,0
#define DST_WE_RNG      10,8
#define DST_WE_RNG      10,8
#define DST_WE_Z        8
#define DST_WE_Z        8
#define DST_WE_Y        9
#define DST_WE_Y        9
#define DST_WE_X        10
#define DST_WE_X        10
 
 
#define DST_ZERO            13
#define DST_ZERO            13
#define SRC1_DISPLACED      12
#define SRC1_DISPLACED      12
#define SRC0_DISPLACED      11
#define SRC0_DISPLACED      11
#define ADDRMODE_RNG            13,11
#define ADDRMODE_RNG            13,11
 
 
#define DST_RNG             47,34
#define DST_RNG             47,34
#define SCR1_RNG            33,17
#define SCR1_RNG            33,17
#define SRC0_RNG            16,0
#define SRC0_RNG            16,0
// Source0 structure
// Source0 structure
#define SRC0_SIZE           17
#define SRC0_SIZE           17
#define SRC0_RNG            16,0
#define SRC0_RNG            16,0
#define SRC0_ADDR_SIZE      8
#define SRC0_ADDR_SIZE      8
#define SRC0_SIGN_RNG       16,14
#define SRC0_SIGN_RNG       16,14
#define SRC0_SIGN_X         16
#define SRC0_SIGN_X         16
#define SRC0_SIGN_Y         15
#define SRC0_SIGN_Y         15
#define SRC0_SIGN_Z         14
#define SRC0_SIGN_Z         14
#define SRC0_SWZX_RNG       13,8  
#define SRC0_SWZX_RNG       13,8  
#define SRC0_SWZ_X          13,12  
#define SRC0_SWZ_X          13,12  
#define SRC0_SWZ_Y          11,10
#define SRC0_SWZ_Y          11,10
#define SRC0_SWZ_Z          9,8
#define SRC0_SWZ_Z          9,8
#define SRC0_ADDR_RNG       7,0
#define SRC0_ADDR_RNG       7,0
// Source1 structure 
// Source1 structure 
#define SRC1_SIZE           17
#define SRC1_SIZE           17
#define SRC1_RNG            33,17
#define SRC1_RNG            33,17
#define SRC1_ADDR_SIZE      8
#define SRC1_ADDR_SIZE      8
#define SRC1_SIGN_RNG       16,14
#define SRC1_SIGN_RNG       16,14
#define SRC1_SIGN_X         16
#define SRC1_SIGN_X         16
#define SRC1_SIGN_Y         15
#define SRC1_SIGN_Y         15
#define SRC1_SIGN_Z         14
#define SRC1_SIGN_Z         14
#define SRC1_SWZX_RNG       13,8
#define SRC1_SWZX_RNG       13,8
#define SRC1_SWZ_X          13,12  
#define SRC1_SWZ_X          13,12  
#define SRC1_SWZ_Y          11,10
#define SRC1_SWZ_Y          11,10
#define SRC1_SWZ_Z          9,8
#define SRC1_SWZ_Z          9,8
#define SRC1_ADDR_RNG       7,0
#define SRC1_ADDR_RNG       7,0
 
 
 
 
std::string gOperationStrings[] =
std::string gOperationStrings[] =
{
{
        "NOP",
        "NOP",
        "ADD",
        "ADD",
        "DIV",
        "DIV",
        "MUL",
        "MUL",
        "SQRT",
        "SQRT",
        "LOGIC",
        "LOGIC",
        "OUT"
        "IO"
};
};
 
 
std::string gBranchTypeStrings[] =
std::string gBranchTypeStrings[] =
{
{
"ALWAYS",
"ALWAYS",
"ZERO",
"ZERO",
"NOT_ZERO",
"NOT_ZERO",
"SIGN",
"SIGN",
"NOT_SIGN",
"NOT_SIGN",
"ZERO_OR_SIGN",
"ZERO_OR_SIGN",
"ZERO_OR_NOT_SIGN"
"ZERO_OR_NOT_SIGN"
};
};
 
 
std::string gSwizzleXTypeStrings[] =
std::string gSwizzleXTypeStrings[] =
{
{
"x",
"x",
"z",
"z",
"y"
"y"
};
};
 
 
std::string gSwizzleYTypeStrings[] =
std::string gSwizzleYTypeStrings[] =
{
{
"y",
"y",
"z",
"z",
"x"
"x"
};
};
 
 
std::string gSwizzleZTypeStrings[] =
std::string gSwizzleZTypeStrings[] =
{
{
"z",
"z",
"y",
"y",
"x"
"x"
};
};
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
template <std::size_t N >
template <std::size_t N >
inline void SetbitRange( std::bitset<N> & aBitset , unsigned int aEnd, unsigned int aStart, unsigned int aValue)
inline void SetbitRange( std::bitset<N> & aBitset , unsigned int aEnd, unsigned int aStart, unsigned int aValue)
{
{
        unsigned long mask = 1;
        unsigned long mask = 1;
        unsigned long result = 0;
        unsigned long result = 0;
        for (int i = aStart; i <= aEnd; ++i)
        for (int i = aStart; i <= aEnd; ++i)
        {
        {
                aBitset[i] =  ( mask & aValue );
                aBitset[i] =  ( mask & aValue );
                mask <<= 1;
                mask <<= 1;
        }
        }
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
template <std::size_t N >
template <std::size_t N >
inline unsigned int GetbitRange( std::bitset<N> & aBitset , unsigned int aEnd, unsigned int aStart)
inline unsigned int GetbitRange( std::bitset<N> & aBitset , unsigned int aEnd, unsigned int aStart)
{
{
 
 
        unsigned long Result = 0;
        unsigned long Result = 0;
        int j = 0;
        int j = 0;
        for (int i = aStart; i <= aEnd; ++i)
        for (int i = aStart; i <= aEnd; ++i)
        {
        {
                Result |=  ( aBitset[i] << j++);
                Result |=  ( aBitset[i] << j++);
 
 
        }
        }
 
 
        return Result;
        return Result;
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
const char lookuparrbin2hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
const char lookuparrbin2hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
 
 
char convert_bin2hex(std::string bits)
char convert_bin2hex(std::string bits)
{
{
        unsigned int result = 0;
        unsigned int result = 0;
        unsigned int shifter0 = 0;
        unsigned int shifter0 = 0;
        unsigned int shifter1 = 1;
        unsigned int shifter1 = 1;
 
 
        for(int n=0; n < bits.length(); n++)
        for(int n=0; n < bits.length(); n++)
        {
        {
                result <<= 1; //shift result to the left by 1
                result <<= 1; //shift result to the left by 1
                if(bits[n] == '1') result = (result | shifter1);
                if(bits[n] == '1') result = (result | shifter1);
                else result = (result | shifter0);
                else result = (result | shifter0);
        }
        }
        return lookuparrbin2hex[result];
        return lookuparrbin2hex[result];
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
 
 
std::string BinStringToHexString(std::string aBinString )
std::string BinStringToHexString(std::string aBinString )
{
{
        std::string endresult = "";
        std::string endresult = "";
        for(int i = 0; i < aBinString.length(); i = i+4)
        for(int i = 0; i < aBinString.length(); i = i+4)
        {
        {
                endresult += convert_bin2hex(aBinString.substr(i,4));
                endresult += convert_bin2hex(aBinString.substr(i,4));
        }
        }
        return endresult;
        return endresult;
}
}
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
Instruction::Instruction()
Instruction::Instruction()
{
{
mDestinationIsSymbol = false;
mDestinationIsSymbol = false;
mBisonFlagTrippleConstAssign = false;
mBisonFlagTrippleConstAssign = false;
mSourceLine = -1;
mSourceLine = -1;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
Instruction::~Instruction()
Instruction::~Instruction()
{
{
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetFields( unsigned int aOperation, unsigned int aDestination, unsigned int aSrc1, unsigned int aSrc0 )
void Instruction::SetFields( unsigned int aOperation, unsigned int aDestination, unsigned int aSrc1, unsigned int aSrc0 )
{
{
        SetbitRange<16>(mOperation,16,0,aOperation);
        SetbitRange<16>(mOperation,16,0,aOperation);
        SetbitRange<14>(mDestination,14,0,aDestination);
        SetbitRange<14>(mDestination,14,0,aDestination);
        SetbitRange<17>(mSource1,17,0,aSrc1);
        SetbitRange<17>(mSource1,17,0,aSrc1);
        SetbitRange<17>(mSource0,17,0,aSrc0);
        SetbitRange<17>(mSource0,17,0,aSrc0);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::Clear()
void Instruction::Clear()
{
{
        mOperation.reset();
        mOperation.reset();
        mDestination.reset();
        mDestination.reset();
        mSource1.reset();
        mSource1.reset();
        mSource0.reset();
        mSource0.reset();
        mComment.clear();
        mComment.clear();
        mDestinationIsSymbol = false;
        mDestinationIsSymbol = false;
        mBisonFlagTrippleConstAssign = false;
        mBisonFlagTrippleConstAssign = false;
        mSourceLine = -1;
        mSourceLine = -1;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
 
 
std::string Instruction::PrintHex32()
std::string Instruction::PrintHex32()
{
{
        std::string Bits = PrintBin();
        std::string Bits = PrintBin();
 
 
 
 
        std::bitset<32> BitsetH(Bits.substr(0,32));
        std::bitset<32> BitsetH(Bits.substr(0,32));
        std::bitset<32> BitsetL(Bits.substr(32,32));
        std::bitset<32> BitsetL(Bits.substr(32,32));
 
 
        //std::cout << "!!! F" << Bits << " \n";
        //std::cout << "!!! F" << Bits << " \n";
        //std::cout << "!!! H" << BitsetH.to_string() << BitsetL.to_string() << " \n";
        //std::cout << "!!! H" << BitsetH.to_string() << BitsetL.to_string() << " \n";
 
 
 
 
        return BinStringToHexString( BitsetH.to_string() ) + " " + BinStringToHexString( BitsetL.to_string() ) ;
        return BinStringToHexString( BitsetH.to_string() ) + " " + BinStringToHexString( BitsetL.to_string() ) ;
 
 
}
}
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
std::string Instruction::PrintHex()
std::string Instruction::PrintHex()
{
{
        std::string  I;
        std::string  I;
        if (mDestinationIsSymbol)
        if (mDestinationIsSymbol)
        {
        {
                std::ostringstream oss;
                std::ostringstream oss;
                oss << std::hex << mOperation.to_ulong() << " ";
                oss << std::hex << mOperation.to_ulong() << " ";
                oss << mDestinationSymbol;
                oss << mDestinationSymbol;
                oss << " " << mSource1.to_ulong() << " " << mSource0.to_ulong();
                oss << " " << mSource1.to_ulong() << " " << mSource0.to_ulong();
                return oss.str();
                return oss.str();
        }
        }
        I =  BinStringToHexString( PrintBin() );
        I =  BinStringToHexString( PrintBin() );
 
 
        return I;
        return I;
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
unsigned int Instruction::GetOperation()
unsigned int Instruction::GetOperation()
{
{
 
 
        return GetbitRange<16>(mOperation,OP_CODE_RNG);
        return GetbitRange<16>(mOperation,OP_CODE_RNG);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
bool Instruction::GetImm( void)
bool Instruction::GetImm( void)
{
{
return mOperation[OP_BIT_IMM];
return mOperation[OP_BIT_IMM];
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
unsigned int Instruction::GetAddressingMode( void )
unsigned int Instruction::GetAddressingMode( void )
{
{
 
 
return GetbitRange<14>(mDestination,ADDRMODE_RNG);
return GetbitRange<14>(mDestination,ADDRMODE_RNG);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
std::string Instruction::PrintAssembly()
std::string Instruction::PrintAssembly()
{
{
 
 
        unsigned int Scale = GetbitRange<16>(mOperation,OP_SCALE_RNG);
        unsigned int Scale = GetbitRange<16>(mOperation,OP_SCALE_RNG);
        std::bitset<4> bScale( Scale );
        std::bitset<4> bScale( Scale );
 
 
        std::ostringstream oss,oss2;
        std::ostringstream oss,oss2;
        #if 1           
        #if 1           
        oss << std::hex << mOperation.to_ulong() << " ";
        oss << std::hex << mOperation.to_ulong() << " ";
        if (mDestinationIsSymbol)
        if (mDestinationIsSymbol)
                oss << mDestinationSymbol;
                oss << mDestinationSymbol;
        else
        else
                oss << mDestination.to_ulong();
                oss << mDestination.to_ulong();
 
 
        oss << " " << mSource1.to_ulong() << " " << mSource0.to_ulong();
        oss << " " << mSource1.to_ulong() << " " << mSource0.to_ulong();
 
 
        #else
        #else
        oss << PrintHex();
        oss << PrintHex();
 
 
        #endif
        #endif
 
 
        std::string tmpString = oss.str();
        std::string tmpString = oss.str();
        while (tmpString.size() < 50) tmpString.push_back(' ');
        while (tmpString.size() < 50) tmpString.push_back(' ');
        oss2 << tmpString << "//\t" << PrintHex() << "\t";
        oss2 << tmpString << "//\t" << PrintHex() << "\t";
 
 
        oss2 << mOperationString << " ";
        oss2 << mOperationString << " ";
        if (mOperation[OP_BRANCH])
        if (mOperation[OP_BRANCH])
        {
        {
 
 
                oss2 << "<BRANCH." << gBranchTypeStrings[ GetbitRange<16>(mOperation,OP_BTYPE_RNG) ] << "> ";
                oss2 << "<BRANCH." << gBranchTypeStrings[ GetbitRange<16>(mOperation,OP_BTYPE_RNG) ] << "> ";
        }
        }
 
 
        if (mDestinationIsSymbol)
        if (mDestinationIsSymbol)
                oss2 << mDestinationSymbol;
                oss2 << mDestinationSymbol;
        else
        else
        {
        {
                if (bScale[2] && bScale[3])
                if (bScale[2] && bScale[3])
                        oss2 << "(unscaled) ";
                        oss2 << "(unscaled) ";
                else if (bScale[2])
                else if (bScale[2])
                        oss2 << "(scaled) ";
                        oss2 << "(scaled) ";
 
 
                if (mOperation[OP_BIT_IMM])
                if (mOperation[OP_BIT_IMM])
                {
                {
                        unsigned int AddressingMode = GetbitRange<14>(mDestination,ADDRMODE_RNG);
                        unsigned int AddressingMode = GetbitRange<14>(mDestination,ADDRMODE_RNG);
                        unsigned int DestinationIndex = GetbitRange<14>(mDestination,DST_ADDR);
                        unsigned int DestinationIndex = GetbitRange<14>(mDestination,DST_ADDR);
                        std::string Reg =  ((mOperation[OP_BRANCH])?"@*R[":"R[");
                        std::string Reg =  ((mOperation[OP_BRANCH])?"@*R[":"R[");
                        switch ( AddressingMode )
                        switch ( AddressingMode )
                        {
                        {
                                case 0: oss2 << Reg << DestinationIndex << "]";break;
                                case 0: oss2 << Reg << DestinationIndex << "]";break;
                                case 1: oss2 << Reg << DestinationIndex << " + offset ]"; break;
                                case 1: oss2 << Reg << DestinationIndex << " + offset ]"; break;
                                case 2: oss2 << Reg << DestinationIndex << " + offset ]"; break;
                                case 2: oss2 << Reg << DestinationIndex << " + offset ]"; break;
                                case 3: oss2 << Reg << DestinationIndex << "+ R[" << mSource1.to_ulong()  << " + offset] + offset ]";break;
                                case 3: oss2 << Reg << DestinationIndex << "+ R[" << mSource1.to_ulong()  << " + offset] + offset ]";break;
                                case 4: oss2 << Reg << DestinationIndex << "]"; break;
                                case 4: oss2 << Reg << DestinationIndex << "]"; break;
                                case 5: oss2 << Reg << DestinationIndex << " + offset ]"; break;
                                case 5: oss2 << Reg << DestinationIndex << " + offset ]"; break;
                                case 6: oss2 << Reg << DestinationIndex << " + offset ]";break;
                                case 6: oss2 << Reg << DestinationIndex << " + offset ]";break;
                                case 7: oss2 << Reg << DestinationIndex << " + offset ]";break;
                                case 7: oss2 << Reg << DestinationIndex << " + offset ]";break;
                                default: oss2 << "??";
                                default: oss2 << "??";
                        }
                        }
 
 
                /*
                /*
                        if (mDestination[SRC0_DISPLACED])
                        if (mDestination[SRC0_DISPLACED])
                        {
                        {
                                oss2 << ((mOperation[OP_BRANCH])?"@*R[":"R[") <<  GetbitRange<14>(mDestination,DST_ADDR) << "+ offset";
                                oss2 << ((mOperation[OP_BRANCH])?"@*R[":"R[") <<  GetbitRange<14>(mDestination,DST_ADDR) << "+ offset";
 
 
                                if (mDestination[SRC1_DISPLACED])
                                if (mDestination[SRC1_DISPLACED])
                                        oss2 << " + R[" << mSource1.to_ulong() << " + offset]";
                                        oss2 << " + R[" << mSource1.to_ulong() << " + offset]";
                                oss2 << "]";
                                oss2 << "]";
                        } else
                        } else
                                oss2 << ((mOperation[OP_BRANCH])?"@*R":"R") <<  GetbitRange<14>(mDestination,DST_ADDR);
                                oss2 << ((mOperation[OP_BRANCH])?"@*R":"R") <<  GetbitRange<14>(mDestination,DST_ADDR);
                                */
                                */
                }
                }
                else
                else
                {
                {
                        if (mDestination[DST_ZERO])
                        if (mDestination[DST_ZERO])
                                oss2 << ((mOperation[OP_BRANCH])?"@[":"R[") <<  GetbitRange<14>(mDestination,DST_ADDR) << "+ offset]";
                                oss2 << ((mOperation[OP_BRANCH])?"@[":"R[") <<  GetbitRange<14>(mDestination,DST_ADDR) << "+ offset]";
                        else
                        else
                                oss2 << ((mOperation[OP_BRANCH])?"@":"R") <<  GetbitRange<14>(mDestination,DST_ADDR);
                                oss2 << ((mOperation[OP_BRANCH])?"@":"R") <<  GetbitRange<14>(mDestination,DST_ADDR);
                }
                }
        }
        }
        //Now print the write channels
        //Now print the write channels
        oss2 << ".";
        oss2 << ".";
        if (mDestination[DST_WE_X])
        if (mDestination[DST_WE_X])
                oss2 << "x";
                oss2 << "x";
        else
        else
                oss2 << "_";
                oss2 << "_";
 
 
        if (mDestination[DST_WE_Y])
        if (mDestination[DST_WE_Y])
                oss2 << "y";
                oss2 << "y";
        else
        else
                oss2 << "_";
                oss2 << "_";
 
 
        if (mDestination[DST_WE_Z])
        if (mDestination[DST_WE_Z])
                oss2 << "z";
                oss2 << "z";
        else
        else
                oss2 << "_";
                oss2 << "_";
 
 
        oss2 << " ";
        oss2 << " ";
 
 
        if (mOperation[OP_BIT_IMM])
        if (mOperation[OP_BIT_IMM])
        {
        {
                unsigned int AddressingMode = GetbitRange<14>(mDestination,ADDRMODE_RNG);
                unsigned int AddressingMode = GetbitRange<14>(mDestination,ADDRMODE_RNG);
                unsigned int ImmediateValue = (mSource0.to_ulong() + (mSource1.to_ulong() << 17));
                unsigned int ImmediateValue = (mSource0.to_ulong() + (mSource1.to_ulong() << 17));
                switch (AddressingMode)
                switch (AddressingMode)
                {
                {
                        case 0: oss2 << std::hex << "I(" << ImmediateValue << ") R[DST]" ; break;
                        case 0: oss2 << std::hex << "I(" << ImmediateValue << ") R[DST]" ; break;
                        case 1: oss2 << std::hex << "I(" << ImmediateValue << ") R[DST+offset]" << " *** " << mSource1.to_ulong() << " , " << mSource1.to_ulong();break;
                        case 1: oss2 << std::hex << "I(" << ImmediateValue << ") R[DST+offset]" << " *** " << mSource1.to_ulong() << " , " << mSource1.to_ulong();break;
                        case 2: oss2 << "??????";break;
                        case 2: oss2 << "??????";break;
                        case 3: oss2 << std::dec << "0 R[" << mSource0.to_ulong() << " + offset]"; break;
                        case 3: oss2 << std::dec << "0 R[" << mSource0.to_ulong() << " + offset]"; break;
                        case 4: oss2 << std::hex << "I(" << ImmediateValue << ") 0" ;break;
                        case 4: oss2 << std::hex << "I(" << ImmediateValue << ") 0" ;break;
                        case 5: oss2 << std::hex << "I(" << ImmediateValue << ") 0" ;break;
                        case 5: oss2 << std::hex << "I(" << ImmediateValue << ") 0" ;break;
                        case 6: oss2 << std::dec << " R[" << mSource1.to_ulong() << " + offset + index] 0";break;
                        case 6: oss2 << std::dec << " R[" << mSource1.to_ulong() << " + offset + index] 0";break;
                        case 7: oss2 << std::dec << " R[" << mSource1.to_ulong() << " + offset + index] R[" << mSource0.to_ulong() << " + offset]"; break;
                        case 7: oss2 << std::dec << " R[" << mSource1.to_ulong() << " + offset + index] R[" << mSource0.to_ulong() << " + offset]"; break;
                        default:
                        default:
                                oss2 << "??";
                                oss2 << "??";
                }
                }
                /*if (mDestination[SRC1_DISPLACED] && mDestination[SRC0_DISPLACED] && !mDestination[DST_ZERO])
                /*if (mDestination[SRC1_DISPLACED] && mDestination[SRC0_DISPLACED] && !mDestination[DST_ZERO])
                {
                {
                        oss2 << std::dec << " R[" << mSource0.to_ulong() << " + offset] 0";
                        oss2 << std::dec << " R[" << mSource0.to_ulong() << " + offset] 0";
                } else if (mDestination[SRC1_DISPLACED] && mDestination[SRC0_DISPLACED] && mDestination[DST_ZERO])
                } else if (mDestination[SRC1_DISPLACED] && mDestination[SRC0_DISPLACED] && mDestination[DST_ZERO])
                {
                {
                        oss2 << std::dec << " R[" << mSource0.to_ulong() << " + offset + index] R[" << mSource0.to_ulong() << " + offset]";
                        oss2 << std::dec << " R[" << mSource0.to_ulong() << " + offset + index] R[" << mSource0.to_ulong() << " + offset]";
                }
                }
                else
                else
                {
                {
                        oss2 << std::hex << "I(" << (mSource0.to_ulong() + (mSource1.to_ulong() << 17)) << ") ";
                        oss2 << std::hex << "I(" << (mSource0.to_ulong() + (mSource1.to_ulong() << 17)) << ") ";
 
 
                        if (mDestination[DST_ZERO])
                        if (mDestination[DST_ZERO])
                                oss2 << "0";
                                oss2 << "0";
                        else
                        else
                                oss2 << "R[DST]";
                                oss2 << "R[DST]";
                }*/
                }*/
        } else {
        } else {
 
 
 
 
                if (bScale[0] && bScale[3])
                if (bScale[0] && bScale[3])
                        oss2 << "(unscaled) ";
                        oss2 << "(unscaled) ";
                else if (bScale[0])
                else if (bScale[0])
                        oss2 << "(scaled) ";
                        oss2 << "(scaled) ";
 
 
 
 
                oss2 << "R";
                oss2 << "R";
                if (mDestination[SRC1_DISPLACED])
                if (mDestination[SRC1_DISPLACED])
                        oss2 << "[" << GetbitRange<17>(mSource1,SRC1_ADDR_RNG) << " + offset]";
                        oss2 << "[" << GetbitRange<17>(mSource1,SRC1_ADDR_RNG) << " + offset]";
                else
                else
                        oss2 << GetbitRange<17>(mSource1,SRC1_ADDR_RNG);
                        oss2 << GetbitRange<17>(mSource1,SRC1_ADDR_RNG);
 
 
                oss2 << "."
                oss2 << "."
 
 
                << ((mSource1[SRC1_SIGN_X]) ? "-":"") << gSwizzleXTypeStrings[ GetbitRange<17>(mSource1,SRC1_SWZ_X) ]
                << ((mSource1[SRC1_SIGN_X]) ? "-":"") << gSwizzleXTypeStrings[ GetbitRange<17>(mSource1,SRC1_SWZ_X) ]
                << ((mSource1[SRC1_SIGN_Y]) ? "-":"") <<gSwizzleYTypeStrings[ GetbitRange<17>(mSource1,SRC1_SWZ_Y) ]
                << ((mSource1[SRC1_SIGN_Y]) ? "-":"") <<gSwizzleYTypeStrings[ GetbitRange<17>(mSource1,SRC1_SWZ_Y) ]
                << ((mSource1[SRC1_SIGN_Z]) ? "-":"") <<gSwizzleZTypeStrings[ GetbitRange<17>(mSource1,SRC1_SWZ_Z) ] << " ";
                << ((mSource1[SRC1_SIGN_Z]) ? "-":"") <<gSwizzleZTypeStrings[ GetbitRange<17>(mSource1,SRC1_SWZ_Z) ] << " ";
 
 
 
 
                if (bScale[1] && bScale[3])
                if (bScale[1] && bScale[3])
                        oss2 << "(unscaled) ";
                        oss2 << "(unscaled) ";
                else if (bScale[1])
                else if (bScale[1])
                        oss2 << "(scaled) ";
                        oss2 << "(scaled) ";
 
 
                oss2 << "R";
                oss2 << "R";
                if (mDestination[SRC0_DISPLACED])
                if (mDestination[SRC0_DISPLACED])
                        oss2 << "[" << GetbitRange<17>(mSource0,SRC0_ADDR_RNG) << " + offset]";
                        oss2 << "[" << GetbitRange<17>(mSource0,SRC0_ADDR_RNG) << " + offset]";
                else
                else
                        oss2 << GetbitRange<17>(mSource0,SRC0_ADDR_RNG);
                        oss2 << GetbitRange<17>(mSource0,SRC0_ADDR_RNG);
 
 
                oss2 << "."
                oss2 << "."
 
 
                << ((mSource0[SRC0_SIGN_X]) ? "-":"") << gSwizzleXTypeStrings[ GetbitRange<17>(mSource0,SRC0_SWZ_X) ]
                << ((mSource0[SRC0_SIGN_X]) ? "-":"") << gSwizzleXTypeStrings[ GetbitRange<17>(mSource0,SRC0_SWZ_X) ]
                << ((mSource0[SRC0_SIGN_Y]) ? "-":"") << gSwizzleYTypeStrings[ GetbitRange<17>(mSource0,SRC0_SWZ_Y) ]
                << ((mSource0[SRC0_SIGN_Y]) ? "-":"") << gSwizzleYTypeStrings[ GetbitRange<17>(mSource0,SRC0_SWZ_Y) ]
                << ((mSource0[SRC0_SIGN_Z]) ? "-":"") << gSwizzleZTypeStrings[ GetbitRange<17>(mSource0,SRC0_SWZ_Z) ];
                << ((mSource0[SRC0_SIGN_Z]) ? "-":"") << gSwizzleZTypeStrings[ GetbitRange<17>(mSource0,SRC0_SWZ_Z) ];
        }
        }
 
 
 
 
        return oss2.str();
        return oss2.str();
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
unsigned int Instruction::GetDestinationAddress()
unsigned int Instruction::GetDestinationAddress()
{
{
        return GetbitRange<14>(mDestination,DST_ADDR);
        return GetbitRange<14>(mDestination,DST_ADDR);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetImmBit( bool aImm )
void Instruction::SetImmBit( bool aImm )
{
{
        mOperation[OP_BIT_IMM] = aImm;
        mOperation[OP_BIT_IMM] = aImm;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::PrintFields()
void Instruction::PrintFields()
{
{
        if (mOperation[OP_BRANCH])
        if (mOperation[OP_BRANCH])
        {
        {
                std::cout << "BRANCH to " << mDestination.to_ulong() << "\n";
                std::cout << "BRANCH to " << mDestination.to_ulong() << "\n";
        }
        }
        std::cout << "Imm      :" << mOperation[OP_BIT_IMM] << "\n";
        std::cout << "Imm      :" << mOperation[OP_BIT_IMM] << "\n";
        std::cout << "Branch   :" << mOperation[OP_BRANCH] << "\n";
        std::cout << "Branch   :" << mOperation[OP_BRANCH] << "\n";
        std::cout << "WE.x     :" << mDestination[DST_WE_X] << "\n";
        std::cout << "WE.x     :" << mDestination[DST_WE_X] << "\n";
        std::cout << "WE.y     :" << mDestination[DST_WE_Y] << "\n";
        std::cout << "WE.y     :" << mDestination[DST_WE_Y] << "\n";
        std::cout << "WE.z     :" << mDestination[DST_WE_Z] << "\n";
        std::cout << "WE.z     :" << mDestination[DST_WE_Z] << "\n";
        std::cout << "EOF      :" << mOperation[OP_EOF] << "\n";
        std::cout << "EOF      :" << mOperation[OP_EOF] << "\n";
 
 
        std::cout << "OP       :" << mOperation.to_string() << "\n";
        std::cout << "OP       :" << mOperation.to_string() << std::hex << " " <<  mOperation.to_ulong() << "\n";
        if (mDestinationIsSymbol)
        if (mDestinationIsSymbol)
                std::cout << "DST      :" << mDestinationSymbol << "\n";
                std::cout << "DST      :" << mDestinationSymbol << "\n";
        else
        else
                std::cout << "DST      :" << mDestination.to_string() << "\n";
                std::cout << "DST      :" << mDestination.to_string() << std::hex << " " <<  mDestination.to_ulong() << "\n";
        std::cout << "DSTZERO   :" <<   mDestination[DST_ZERO] << "\n";
        std::cout << "DSTZERO   :" <<   mDestination[DST_ZERO] << "\n";
        std::cout << "SRC1     :" << mSource1.to_string() << " (" << mSource1.to_ulong() << ")\n";
        std::cout << "SRC1     :" << mSource1.to_string() << " (" << mSource1.to_ulong() << ")\n";
        std::cout << "SRC0     :" << mSource0.to_string() << " (" << mSource0.to_ulong() << ")\n";
        std::cout << "SRC0     :" << mSource0.to_string() << " (" << mSource0.to_ulong() << ")\n";
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
std::string Instruction::PrintBin()
std::string Instruction::PrintBin()
{
{
 
 
        std::bitset<64> Bitset;
        std::bitset<64> Bitset;
 
 
 
 
        SetbitRange<64>(Bitset,OP_RNG,mOperation.to_ulong());
        SetbitRange<64>(Bitset,OP_RNG,mOperation.to_ulong());
        SetbitRange<64>(Bitset,DST_RNG,mDestination.to_ulong());
        SetbitRange<64>(Bitset,DST_RNG,mDestination.to_ulong());
        SetbitRange<64>(Bitset,SRC1_RNG,mSource1.to_ulong());
        SetbitRange<64>(Bitset,SRC1_RNG,mSource1.to_ulong());
        SetbitRange<64>(Bitset,SRC0_RNG,mSource0.to_ulong());
        SetbitRange<64>(Bitset,SRC0_RNG,mSource0.to_ulong());
        return Bitset.to_string();
        return Bitset.to_string();
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetEofFlag( bool aEof )
void Instruction::SetEofFlag( bool aEof )
{
{
        mOperation[ OP_EOF ] = aEof;
        mOperation[ OP_EOF ] = aEof;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetCode( EOPERATION aCode )
void Instruction::SetCode( EOPERATION aCode )
{
{
        SetbitRange<16>(mOperation,OP_CODE_RNG,aCode);
        SetbitRange<16>(mOperation,OP_CODE_RNG,aCode);
        mOperationString = gOperationStrings[aCode];
        mOperationString = gOperationStrings[aCode];
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetImm( unsigned int aLiteral )
void Instruction::SetImm( unsigned int aLiteral )
{
{
 
 
 
 
        mOperation[OP_BIT_IMM] = true;
        mOperation[OP_BIT_IMM] = true;
        mSource0 = aLiteral;
        mSource0 = aLiteral;
        mSource1 = (aLiteral >> SOURCE0_SIZE);
        mSource1 = (aLiteral >> SOURCE0_SIZE);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetAddressingMode( bool aDstZero, bool aSrc1Dsp , bool  aSrc0Dsp)
void Instruction::SetAddressingMode( bool aDstZero, bool aSrc1Dsp , bool  aSrc0Dsp)
{
{
                        SetDestZero( aDstZero );
                        SetDestZero( aDstZero );
                        SetSrc1Displace( aSrc1Dsp );
                        SetSrc1Displace( aSrc1Dsp );
                        SetSrc0Displace( aSrc0Dsp );
                        SetSrc0Displace( aSrc0Dsp );
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
/*void SetAddressingMode( EADDRESSINGTYPE aAddressMode )
/*void SetAddressingMode( EADDRESSINGTYPE aAddressMode )
{
{
        std::bitset<4> AddressingMode( aAddressMode );
        std::bitset<4> AddressingMode( aAddressMode );
        AddressingMode[3] = mOperation[OP_BIT_IMM] ;
        AddressingMode[3] = mOperation[OP_BIT_IMM] ;
 
 
        switch ( AddressingMode )
        switch ( AddressingMode )
        {
        {
                case EDIRECT_ADDRESSING:
                case EDIRECT_ADDRESSING:
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                case EDIRECT_DISP_SRC0:
                case EDIRECT_DISP_SRC0:
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( true );
                        SetSrc0Displace( true );
                        break;
                        break;
                EDIRECT_DISP_SRC1:
                EDIRECT_DISP_SRC1:
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( true );
                        SetSrc1Displace( true );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                EDIRECT_DISP_SRC1_SRC0:
                EDIRECT_DISP_SRC1_SRC0:
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( true );
                        SetSrc1Displace( true );
                        SetSrc0Displace( true );
                        SetSrc0Displace( true );
                        break;
                        break;
                EDIRECT_DISP_DST:
                EDIRECT_DISP_DST:
                        SetDestZero( true );
                        SetDestZero( true );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                EDIRECT_DISP_DST_SRC0:
                EDIRECT_DISP_DST_SRC0:
                        SetDestZero( true );
                        SetDestZero( true );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( true );
                        SetSrc0Displace( true );
                        break;
                        break;
                case EDIRECT_DISP_DST_SRC1:
                case EDIRECT_DISP_DST_SRC1:
                        SetDestZero( true );
                        SetDestZero( true );
                        SetSrc1Displace( true );
                        SetSrc1Displace( true );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                case EDIRECT_DISP_DST_SRC1_SRC0:
                case EDIRECT_DISP_DST_SRC1_SRC0:
                        SetDestZero( true );
                        SetDestZero( true );
                        SetSrc1Displace( true );
                        SetSrc1Displace( true );
                        SetSrc0Displace( true );
                        SetSrc0Displace( true );
                        break;
                        break;
                EDIRECT_IMM:                            //R[DSTINDEX ] = IMMV op R[DSTINDEX]
                EDIRECT_IMM:                            //R[DSTINDEX ] = IMMV op R[DSTINDEX]
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                EDIRECT_IMM_ZERO:                       //R[DSTINDEX ] = IMMV op 32'b0
                EDIRECT_IMM_ZERO:                       //R[DSTINDEX ] = IMMV op 32'b0
                        SetDestZero( true );
                        SetDestZero( true );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                EDIRECT_IMM_DISPALCE:           //R[DSTINDEX + offset] = IMMV op R[DSTINDEX]
                EDIRECT_IMM_DISPALCE:           //R[DSTINDEX + offset] = IMMV op R[DSTINDEX]
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( true );
                        SetSrc0Displace( true );
                        break;
                        break;
                EDIRECT_IMM_DISPALCE_ZERO: //R[DSTINDEX + offset] = IMMV op 32'b0
                EDIRECT_IMM_DISPALCE_ZERO: //R[DSTINDEX + offset] = IMMV op 32'b0
                        SetDestZero( true );
                        SetDestZero( true );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( true );
                        SetSrc0Displace( true );
                        break;
                        break;
                EINDIRECT_IMM_DISP:             // DST = R[ DSTINDEX ] + OFFSET
                EINDIRECT_IMM_DISP:             // DST = R[ DSTINDEX ] + OFFSET
                        SetDestZero( false );
                        SetDestZero( false );
                        SetSrc1Displace( false );
                        SetSrc1Displace( false );
                        SetSrc0Displace( false );
                        SetSrc0Displace( false );
                        break;
                        break;
                break;
                break;
                EINDIRECT_IMM_DISP_ZERO:
                EINDIRECT_IMM_DISP_ZERO:
                break;
                break;
                EINDIRECT_NO_IMM:
                EINDIRECT_NO_IMM:
                break;
                break;
                EINDIRECT_NO_IMM_DISP:
                EINDIRECT_NO_IMM_DISP:
                break;
                break;
        }
        }
}*/
}*/
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetDestZero(  bool aZero )
void Instruction::SetDestZero(  bool aZero )
{
{
        mDestination[DST_ZERO] = aZero;
        mDestination[DST_ZERO] = aZero;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0Displace( bool aDisplace )
void Instruction::SetSrc0Displace( bool aDisplace )
{
{
        mDestination[SRC0_DISPLACED] = aDisplace;
        mDestination[SRC0_DISPLACED] = aDisplace;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1Displace( bool aDisplace )
void Instruction::SetSrc1Displace( bool aDisplace )
{
{
        mDestination[SRC1_DISPLACED] = aDisplace;
        mDestination[SRC1_DISPLACED] = aDisplace;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetBranchFlag( bool aBranch )
void Instruction::SetBranchFlag( bool aBranch )
{
{
        mOperation[OP_BRANCH] = aBranch;
        mOperation[OP_BRANCH] = aBranch;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetBranchType( EBRANCHTYPE aBranchType )
void Instruction::SetBranchType( EBRANCHTYPE aBranchType )
{
{
        SetbitRange<16>(mOperation,OP_BTYPE_RNG,aBranchType);
        SetbitRange<16>(mOperation,OP_BTYPE_RNG,aBranchType);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::ClearWriteChannel()
void Instruction::ClearWriteChannel()
{
{
 
 
        mDestination[DST_WE_X] = false;
        mDestination[DST_WE_X] = false;
        mDestination[DST_WE_Y] = false;
        mDestination[DST_WE_Y] = false;
        mDestination[DST_WE_Z] = false;
        mDestination[DST_WE_Z] = false;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetWriteChannel( ECHANNEL aChannel )
void Instruction::SetWriteChannel( ECHANNEL aChannel )
{
{
 
 
        if (aChannel == ECHANNEL_XYZ)
        if (aChannel == ECHANNEL_XYZ)
        {
        {
                mDestination[DST_WE_X] = true;
                mDestination[DST_WE_X] = true;
                mDestination[DST_WE_Y] = true;
                mDestination[DST_WE_Y] = true;
                mDestination[DST_WE_Z] = true;
                mDestination[DST_WE_Z] = true;
                return;
                return;
        }
        }
 
 
        switch ( aChannel )
        switch ( aChannel )
        {
        {
                case ECHANNEL_X:
                case ECHANNEL_X:
                mDestination[DST_WE_X] = true;
                mDestination[DST_WE_X] = true;
                break;
                break;
                case ECHANNEL_Y:
                case ECHANNEL_Y:
                mDestination[DST_WE_Y] = true;
                mDestination[DST_WE_Y] = true;
                break;
                break;
                case ECHANNEL_Z:
                case ECHANNEL_Z:
                mDestination[DST_WE_Z] = true;
                mDestination[DST_WE_Z] = true;
                break;
                break;
        }
        }
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetDestinationAddress( unsigned int aAddress )
void Instruction::SetDestinationAddress( unsigned int aAddress )
{
{
 
 
        SetbitRange<14>(mDestination,DST_ADDR,aAddress);
        SetbitRange<14>(mDestination,DST_ADDR,aAddress);
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetDestinationSymbol( std::string aSymbol )
void Instruction::SetDestinationSymbol( std::string aSymbol )
{
{
        mDestinationIsSymbol = true;
        mDestinationIsSymbol = true;
        mDestinationSymbol = aSymbol;
        mDestinationSymbol = aSymbol;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1SignX( bool aSign )
void Instruction::SetSrc1SignX( bool aSign )
{
{
        mSource1[SRC1_SIGN_X] = aSign;
        mSource1[SRC1_SIGN_X] = aSign;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1SignY( bool aSign )
void Instruction::SetSrc1SignY( bool aSign )
{
{
        mSource1[SRC1_SIGN_Y] = aSign;
        mSource1[SRC1_SIGN_Y] = aSign;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1SignZ( bool aSign )
void Instruction::SetSrc1SignZ( bool aSign )
{
{
        mSource1[SRC1_SIGN_Z] = aSign;
        mSource1[SRC1_SIGN_Z] = aSign;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1SwizzleX(ESWIZZLE_X aChannel)
void Instruction::SetSrc1SwizzleX(ESWIZZLE_X aChannel)
{
{
        SetbitRange<17>(mSource1,SRC1_SWZ_X,aChannel);
        SetbitRange<17>(mSource1,SRC1_SWZ_X,aChannel);
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1SwizzleY(ESWIZZLE_Y aChannel)
void Instruction::SetSrc1SwizzleY(ESWIZZLE_Y aChannel)
{
{
        SetbitRange<17>(mSource1,SRC1_SWZ_Y,aChannel);
        SetbitRange<17>(mSource1,SRC1_SWZ_Y,aChannel);
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1SwizzleZ(ESWIZZLE_Z aChannel)
void Instruction::SetSrc1SwizzleZ(ESWIZZLE_Z aChannel)
{
{
        SetbitRange<17>(mSource1,SRC1_SWZ_Z,aChannel);
        SetbitRange<17>(mSource1,SRC1_SWZ_Z,aChannel);
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1Address(unsigned int aAddress )
void Instruction::SetSrc1Address(unsigned int aAddress )
{
{
        SetbitRange<17>(mSource1,SRC1_ADDR_RNG,aAddress);
        SetbitRange<17>(mSource1,SRC1_ADDR_RNG,aAddress);
}
}
 
//--------------------------------------------------------------
 
void Instruction::SetIOOperation( EIO_OPERATION aOperation )
 
{
 
        SetbitRange<16>(mOperation,OP_SCALE_RNG,aOperation);
 
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetLogicOperation(ELOGIC_OPERATION aOperation )
void Instruction::SetLogicOperation(ELOGIC_OPERATION aOperation )
{
{
        SetbitRange<16>(mOperation,OP_SCALE_RNG,aOperation);
        SetbitRange<16>(mOperation,OP_SCALE_RNG,aOperation);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc1Rotation( EROTATION aRotation )
void Instruction::SetSrc1Rotation( EROTATION aRotation )
{
{
        unsigned int OldVal = GetbitRange<16>(mOperation,OP_SCALE_RNG);
        unsigned int OldVal = GetbitRange<16>(mOperation,OP_SCALE_RNG);
 
 
        SetbitRange<16>(mOperation,OP_SCALE_RNG,(OldVal | aRotation) );
        SetbitRange<16>(mOperation,OP_SCALE_RNG,(OldVal | aRotation) );
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0Rotation( EROTATION aRotation )
void Instruction::SetSrc0Rotation( EROTATION aRotation )
{
{
        unsigned int OldVal = GetbitRange<16>(mOperation,OP_SCALE_RNG);
        unsigned int OldVal = GetbitRange<16>(mOperation,OP_SCALE_RNG);
 
 
        SetbitRange<16>(mOperation,OP_SCALE_RNG,(OldVal | aRotation ) );
        SetbitRange<16>(mOperation,OP_SCALE_RNG,(OldVal | aRotation ) );
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0SignX( bool aSign )
void Instruction::SetSrc0SignX( bool aSign )
{
{
        mSource0[SRC0_SIGN_X] = aSign;
        mSource0[SRC0_SIGN_X] = aSign;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0SignY( bool aSign )
void Instruction::SetSrc0SignY( bool aSign )
{
{
        mSource0[SRC0_SIGN_Y] = aSign;
        mSource0[SRC0_SIGN_Y] = aSign;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0SignZ( bool aSign )
void Instruction::SetSrc0SignZ( bool aSign )
{
{
        mSource0[SRC0_SIGN_Z] = aSign;
        mSource0[SRC0_SIGN_Z] = aSign;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0SwizzleX(ESWIZZLE_X aChannel)
void Instruction::SetSrc0SwizzleX(ESWIZZLE_X aChannel)
{
{
SetbitRange<17>(mSource0,SRC0_SWZ_X,aChannel);
SetbitRange<17>(mSource0,SRC0_SWZ_X,aChannel);
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0SwizzleY(ESWIZZLE_Y aChannel)
void Instruction::SetSrc0SwizzleY(ESWIZZLE_Y aChannel)
{
{
        SetbitRange<17>(mSource0,SRC0_SWZ_Y,aChannel);
        SetbitRange<17>(mSource0,SRC0_SWZ_Y,aChannel);
 
 
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0SwizzleZ(ESWIZZLE_Z aChannel)
void Instruction::SetSrc0SwizzleZ(ESWIZZLE_Z aChannel)
{
{
SetbitRange<17>(mSource0,SRC0_SWZ_Z,aChannel);
SetbitRange<17>(mSource0,SRC0_SWZ_Z,aChannel);
 
 
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
void Instruction::SetSrc0Address(unsigned int aAddress )
void Instruction::SetSrc0Address(unsigned int aAddress )
{
{
        SetbitRange<17>(mSource0,SRC0_ADDR_RNG,aAddress);
        SetbitRange<17>(mSource0,SRC0_ADDR_RNG,aAddress);
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
 std::bitset<DESTINATION_SIZE> Instruction::GetDestination( )
 std::bitset<DESTINATION_SIZE> Instruction::GetDestination( )
{
{
        return mDestination;
        return mDestination;
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
ECHANNEL Instruction::GetWriteChannel(  )
ECHANNEL Instruction::GetWriteChannel(  )
{
{
        //std::cout << "Ecahhhannel " << GetbitRange<DESTINATION_SIZE>(mDestination,DST_WE_RNG) << "\n";
        //std::cout << "Ecahhhannel " << GetbitRange<DESTINATION_SIZE>(mDestination,DST_WE_RNG) << "\n";
 
 
        return ((ECHANNEL)GetbitRange<DESTINATION_SIZE>(mDestination,DST_WE_RNG));
        return ((ECHANNEL)GetbitRange<DESTINATION_SIZE>(mDestination,DST_WE_RNG));
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
/*
/*
void Instruction::SetDestination( std::bitset<DESTINATION_SIZE> aDestination )
void Instruction::SetDestination( std::bitset<DESTINATION_SIZE> aDestination )
{
{
        mDestination = aDestination;
        mDestination = aDestination;
}
}
*/
*/
 
 

powered by: WebSVN 2.1.0

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