2 * Copyright (c) 2005-2006 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Korey Sewell
32 #include "config/the_isa.hh"
33 #include "cpu/o3/scoreboard.hh"
34 #include "debug/Scoreboard.hh"
36 Scoreboard::Scoreboard(unsigned activeThreads
,
37 unsigned _numLogicalIntRegs
,
38 unsigned _numPhysicalIntRegs
,
39 unsigned _numLogicalFloatRegs
,
40 unsigned _numPhysicalFloatRegs
,
41 unsigned _numMiscRegs
,
43 : numLogicalIntRegs(_numLogicalIntRegs
),
44 numPhysicalIntRegs(_numPhysicalIntRegs
),
45 numLogicalFloatRegs(_numLogicalFloatRegs
),
46 numPhysicalFloatRegs(_numPhysicalFloatRegs
),
47 numMiscRegs(_numMiscRegs
),
48 zeroRegIdx(_zeroRegIdx
)
51 numLogicalRegs
= numLogicalIntRegs
+ numLogicalFloatRegs
;
52 numPhysicalRegs
= numPhysicalIntRegs
+ numPhysicalFloatRegs
;
54 //Resize scoreboard appropriately
55 resize(numPhysicalRegs
+ (numMiscRegs
* activeThreads
));
58 for (int i
=0; i
< numLogicalIntRegs
* activeThreads
; i
++) {
59 assert(indexInBounds(i
));
63 for (int i
= numPhysicalIntRegs
;
64 i
< numPhysicalIntRegs
+ (numLogicalFloatRegs
* activeThreads
);
66 assert(indexInBounds(i
));
70 for (int i
= numPhysicalRegs
;
71 i
< numPhysicalRegs
+ (numMiscRegs
* activeThreads
);
73 assert(indexInBounds(i
));
79 Scoreboard::name() const
81 return "cpu.scoreboard";
85 Scoreboard::getReg(PhysRegIndex phys_reg
)
87 #if THE_ISA == ALPHA_ISA
88 // Always ready if int or fp zero reg.
89 if (phys_reg
== zeroRegIdx
||
90 phys_reg
== (zeroRegIdx
+ numPhysicalIntRegs
)) {
94 // Always ready if int zero reg.
95 if (phys_reg
== zeroRegIdx
) {
100 assert(indexInBounds(phys_reg
));
101 return regScoreBoard
[phys_reg
];
105 Scoreboard::setReg(PhysRegIndex phys_reg
)
107 DPRINTF(Scoreboard
, "Setting reg %i as ready\n", phys_reg
);
109 assert(indexInBounds(phys_reg
));
110 regScoreBoard
[phys_reg
] = 1;
114 Scoreboard::unsetReg(PhysRegIndex ready_reg
)
116 #if THE_ISA == ALPHA_ISA
117 if (ready_reg
== zeroRegIdx
||
118 ready_reg
== (zeroRegIdx
+ numPhysicalIntRegs
)) {
119 // Don't do anything if int or fp zero reg.
123 if (ready_reg
== zeroRegIdx
) {
124 // Don't do anything if int zero reg.
129 assert(indexInBounds(ready_reg
));
130 regScoreBoard
[ready_reg
] = 0;