00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <pch.h>
00033 #include "Sim/System/EmulationSystem/EmulationOp.h"
00034
00035 using namespace std;
00036 using namespace Onikiri;
00037
00038
00039 EmulationOp::EmulationOp( MemIF* mainMem ) :
00040 m_opInfo ( NULL ),
00041 m_taken ( false ),
00042 m_mem( mainMem )
00043 {
00044 }
00045
00046 EmulationOp::EmulationOp( const EmulationOp& op ) :
00047 m_pc ( op.m_pc ),
00048 m_opInfo ( op.m_opInfo ),
00049 m_takenPC( op.m_takenPC ),
00050 m_taken ( op.m_taken ),
00051 m_mem( op.m_mem ),
00052 m_dstReg ( op.m_dstReg ),
00053 m_srcReg ( op.m_srcReg )
00054 {
00055 }
00056
00057 EmulationOp::~EmulationOp()
00058 {
00059 }
00060
00061 void EmulationOp::SetPC( const PC& pc ) {
00062 m_pc = pc;
00063 }
00064
00065 void EmulationOp::SetOpInfo( OpInfo* opInfo ) {
00066 m_opInfo = opInfo;
00067 }
00068
00069 const OpInfo* EmulationOp::GetOpInfo() const
00070 {
00071 return m_opInfo;
00072 }
00073
00074 void EmulationOp::SetMem( MemIF* mem )
00075 {
00076 m_mem = mem;
00077 }
00078
00079
00080 PC EmulationOp::GetPC() const
00081 {
00082 return m_pc;
00083 }
00084
00085 const u64 EmulationOp::GetSrc( const int index ) const
00086 {
00087 return m_srcReg[index];
00088 }
00089
00090 void EmulationOp::SetSrc( const int index, const u64 value )
00091 {
00092 m_srcReg[index] = value;
00093 }
00094
00095 const u64 EmulationOp::GetDst( const int index ) const
00096 {
00097 return m_dstReg[index];
00098 }
00099
00100
00101 void EmulationOp::SetDst( const int index, const u64 value )
00102 {
00103 m_dstReg[index] = value;
00104 }
00105
00106 void EmulationOp::SetTakenPC( const PC takenPC )
00107 {
00108 m_takenPC = takenPC;
00109 }
00110
00111 PC EmulationOp::GetTakenPC() const
00112 {
00113 return m_takenPC;
00114 }
00115
00116 void EmulationOp::SetTaken( const bool taken )
00117 {
00118 m_taken = taken;
00119 }
00120
00121 bool EmulationOp::GetTaken() const
00122 {
00123 return m_taken;
00124 }
00125
00126
00127 void EmulationOp::Read( MemAccess* access )
00128 {
00129 ASSERT( m_mem != NULL );
00130
00131
00132 access->address.tid = m_pc.tid;
00133
00134 m_mem->Read( access );
00135 if( access->result != MemAccess::MAR_SUCCESS ){
00136 RUNTIME_WARNING( "An access violation occurs.\n%s", access->ToString().c_str() );
00137 }
00138 }
00139
00140 void EmulationOp::Write( MemAccess* access )
00141 {
00142 ASSERT( m_mem != NULL );
00143
00144
00145 access->address.tid = m_pc.tid;
00146
00147 m_mem->Write( access );
00148 if( access->result != MemAccess::MAR_SUCCESS ){
00149 RUNTIME_WARNING( "An access violation occurs.\n%s", access->ToString().c_str() );
00150 }
00151 }