src/Sim/Predictor/BPred/RAS.cpp

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #include <pch.h>
00033 
00034 #include "Sim/Predictor/BPred/RAS.h"
00035 #include "Sim/ISAInfo.h"
00036 #include "Sim/Foundation/SimPC.h"
00037 
00038 using namespace Onikiri;
00039 
00040 RAS::RAS()
00041 {
00042     m_checkpointMaster = 0;
00043 }
00044 
00045 RAS::~RAS()
00046 {
00047     ReleaseParam();
00048 }
00049 
00050 void RAS::Initialize(InitPhase phase)
00051 {
00052     if(phase == INIT_PRE_CONNECTION){
00053         LoadParam();
00054 
00055         ASSERT(m_stackSize >= MAX_BACKUP_SIZE,
00056             "The size of backup of RAS must be the same or smaller than that of RAS itself.");
00057 
00058         ASSERT(MAX_BACKUP_SIZE > 0,
00059             "MAX_BACKUP_SIZE must be larger than 0.");
00060 
00061         // pcStack
00062         m_stack.resize( m_stackSize, PC() );
00063     }
00064     else if(phase == INIT_POST_CONNECTION){
00065 
00066         // checkpointMaster Zbg`FbN
00067         CheckNodeInitialized( "checkpointMaster", m_checkpointMaster );
00068 
00069         m_stackTop.Initialize(
00070             m_checkpointMaster,
00071             CheckpointMaster::SLOT_FETCH
00072         );
00073         *m_stackTop = 0;
00074 
00075         m_backupStackTop.Initialize(
00076             m_checkpointMaster,
00077             CheckpointMaster::SLOT_FETCH
00078             );
00079         *m_backupStackTop = 0;
00080         m_backupStack.Initialize(
00081             m_checkpointMaster,
00082             CheckpointMaster::SLOT_FETCH
00083             );
00084 
00085     }
00086     
00087 }
00088 
00089 // callPCPush
00090 void RAS::Push(const SimPC& pc)
00091 {
00092     if (m_enableBackup)
00093     {
00094         // Set the oldest PC in the checkpointed stack to the actual RAS.
00095         int setRasStackPos = PointStackPos(*m_stackTop, GetStackSize(), -MAX_BACKUP_SIZE);
00096         m_stack[setRasStackPos] = (*m_backupStack)[*m_backupStackTop];
00097 
00098         // Push a new PC.
00099         (*m_backupStack)[*m_backupStackTop] = pc.Next();
00100         *m_backupStackTop = PointStackPos(*m_backupStackTop, MAX_BACKUP_SIZE, 1);
00101     }
00102 
00103     // Push a new PC.
00104     m_stack[*m_stackTop] = pc.Next();
00105     *m_stackTop = PointStackPos(*m_stackTop, GetStackSize(), 1);
00106 }
00107 
00108 // returnPCPOP
00109 SimPC RAS::Pop()
00110 {
00111     // Pop the latest PC.
00112     *m_stackTop = PointStackPos(*m_stackTop, GetStackSize(), -1);
00113     PC popPC = m_stack[*m_stackTop];
00114 
00115     if ( m_enableBackup )
00116     {
00117         // Pop the latest PC.
00118         *m_backupStackTop = PointStackPos(*m_backupStackTop, MAX_BACKUP_SIZE, -1);
00119         popPC = (*m_backupStack)[*m_backupStackTop];
00120 
00121         // Set the latest PC that the checkpointed does not have.
00122         int setBackupStackPos = PointStackPos(*m_stackTop, GetStackSize(), -MAX_BACKUP_SIZE);
00123         (*m_backupStack)[*m_backupStackTop] = m_stack[setBackupStackPos];
00124     }
00125 
00126     return popPC;
00127 }

Onikiri2に対してTue Jun 18 14:34:25 2013に生成されました。  doxygen 1.4.7