src/Sim/Pipeline/Pipeline.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/Pipeline/Pipeline.h"
00035 #include "Sim/Pipeline/PipelineNodeIF.h"
00036 #include "Sim/Op/Op.h"
00037 #include "Sim/Dumper/Dumper.h"
00038 
00039 using namespace std;
00040 using namespace Onikiri;
00041 
00042 //
00043 // An event writing an op to a pipeline latch.
00044 //
00045 class OpPipelineProcessEndEvent :
00046     public EventBase<OpPipelineProcessEndEvent>
00047 {
00048 protected:
00049     OpIterator m_op;
00050     Pipeline*  m_pipe;
00051     PipelineNodeIF* m_lowerNode;
00052 
00053 public:
00054     OpPipelineProcessEndEvent( OpIterator op, Pipeline* pipe, PipelineNodeIF* lowerNode ) : 
00055         m_op  ( op ),
00056         m_pipe( pipe ),
00057         m_lowerNode( lowerNode )
00058     {
00059     }
00060 
00061     virtual void Update()
00062     {
00063         m_pipe->ExitPipeline( m_op, m_lowerNode );
00064     }
00065 };
00066 
00067 
00068 Pipeline::Pipeline() :
00069     m_enableDumpStall(true)
00070 {
00071 }
00072 
00073 Pipeline::~Pipeline()
00074 {
00075 }
00076 
00077 
00078 void Pipeline::EnterPipeline( OpIterator op, int time, PipelineNodeIF* lowerNode )
00079 {
00080     m_opList.push_back( op );
00081     EventPtr evnt( OpPipelineProcessEndEvent::Construct( op, this, lowerNode ) );
00082     if( time == 0 ){
00083         evnt->Update();
00084     }
00085     else{
00086         op->AddEvent( evnt, this, time );
00087     }
00088 }
00089 
00090 void Pipeline::ExitPipeline( OpIterator op, PipelineNodeIF* lowerNode )
00091 {
00092     lowerNode->ExitUpperPipeline( op );
00093     for( size_t i = 0; i < m_upperPipelineNodes.size(); i++ ){
00094         m_upperPipelineNodes[i]->ExitLowerPipeline( op );
00095     }
00096     m_opList.remove( op );
00097 }
00098 
00099 void Pipeline::AddUpperPipelineNode( PipelineNodeIF* node )
00100 {
00101     m_upperPipelineNodes.push_back( node );
00102 }
00103 
00104 int Pipeline::GetOpCount()
00105 {
00106     return (int)m_opList.size();
00107 }
00108 
00109 void Pipeline::Retire( OpIterator op )
00110 {
00111     m_opList.remove( op );
00112 }
00113 
00114 void Pipeline::Flush( OpIterator op )
00115 {
00116     m_opList.remove( op );
00117 }
00118 
00119 void Pipeline::BeginStall()
00120 {
00121     if( !g_dumper.IsEnabled() || !m_enableDumpStall )
00122         return;
00123 
00124     for( List::iterator i = m_opList.begin(); i != m_opList.end(); ++i ){
00125         g_dumper.DumpStallBegin( *i );
00126     }
00127 }
00128 
00129 void Pipeline::EndStall()
00130 {
00131     if( !g_dumper.IsEnabled() || !m_enableDumpStall )
00132         return;
00133 
00134     for( List::iterator i = m_opList.begin(); i != m_opList.end(); ++i ){
00135         g_dumper.DumpStallEnd( *i );
00136     }
00137 }
00138 
00139 
00140 void Pipeline::EnableDumpStall( bool enable )
00141 {
00142     m_enableDumpStall = enable;
00143 }

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