OpenASIP  2.0
GCUState.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file GCUState.cc
26  *
27  * Definition of GCUState class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005,2010
31  * @note rating: red
32  */
33 
34 #include "GCUState.hh"
35 #include "SequenceTools.hh"
36 #include "OperationContext.hh"
37 #include "Application.hh"
38 #include "OperationExecutor.hh"
39 
40 using std::string;
41 
42 /**
43  * Constructor.
44  *
45  * @param latency Latency of the unit.
46  * @param nww Natural word width as MAUs.
47  * @param lock Global lock signal.
48  */
50  int latency,
51  int nww,
52  int cuDelaySlots,
53  int instructionAddressIncrement) :
54  naturalWordWidth_(nww), returnAddressRegister_(64),
55  latency_(latency),
56  branchDelayCycles_(cuDelaySlots),
57  operationContext_(
58  NULL, programCounter_, returnAddressRegister_,
59  branchDelayCycles_),
60  instructionAddressIncrement_(instructionAddressIncrement) {
61  reset();
62 }
63 
64 void
66  programCounter_ = 0;
69  operationPending_ = false;
71 }
72 
73 /**
74  * Destructor.
75  */
77 }
78 
79 /**
80  * Returns the operation context.
81  *
82  * This is basically a "template method" to allow differently initialized
83  * OperationContext-classes in FUState subclasses.
84  *
85  * @return The operation context for the FU.
86  */
89  return operationContext_;
90 }
91 
92 /**
93  * Handles the actions when clock is advanced.
94  *
95  * The value of program counter is updated. Pipeline is advanced.
96  */
97 void
99 
100  // For call and jump operations
101  if (operationPending_) {
103  }
106  operationPending_ = false;
107  }
108 
109  // Special handling for Loop Buffer Setup operation
110  if (!context().isEmpty()) {
111  idle_ = false;
112  context().advanceClock();
113  } else {
115  }
116 }
GCUState::~GCUState
virtual ~GCUState()
Definition: GCUState.cc:76
GCUState.hh
GCUState::returnAddressRegister_
SimValue returnAddressRegister_
The return address register.
Definition: GCUState.hh:75
OperationContext
Definition: OperationContext.hh:56
SequenceTools.hh
GCUState::operationPending_
bool operationPending_
If this this is true, there's a control flow operation pending.
Definition: GCUState.hh:87
GCUState::operationContext_
OperationContext operationContext_
The operation context for this FU.
Definition: GCUState.hh:93
GCUState::programCounter_
InstructionAddress programCounter_
Program counter.
Definition: GCUState.hh:77
GCUState::reset
virtual void reset()
this is called at (re)initialization of the simulation
Definition: GCUState.cc:65
OperationExecutor.hh
Application.hh
GCUState::newProgramCounter_
InstructionAddress newProgramCounter_
In case an control flow operation is pending, this variable contains the program counter value that s...
Definition: GCUState.hh:81
GCUState::advanceClock
virtual void advanceClock()
Definition: GCUState.cc:98
GCUState::operationPendingTime_
int operationPendingTime_
This indicates how many cycles the operation has been pending, when this reaches the latency,...
Definition: GCUState.hh:91
GCUState::GCUState
GCUState(int latency, int nww, int cuDelaySlots, int instructionAddressIncrement=1)
Definition: GCUState.cc:49
FUState::idle_
bool idle_
The idle status of the FU. The derived classes should alway set this to true when possible to avoid u...
Definition: FUState.hh:95
GCUState::context
virtual OperationContext & context()
Definition: GCUState.cc:88
OperationContext::advanceClock
void advanceClock()
Definition: OperationContext.cc:108
OperationContext.hh