2 * Copyright (c) 2007 MIPS Technologies, Inc.
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 #ifndef __CPU_INORDER_MULT_DIV_UNIT_HH__
33 #define __CPU_INORDER_MULT_DIV_UNIT_HH__
39 #include "cpu/inorder/first_stage.hh"
40 #include "cpu/inorder/inorder_dyn_inst.hh"
41 #include "cpu/inorder/resource.hh"
42 #include "cpu/func_unit.hh"
43 #include "cpu/op_class.hh"
47 class MultDivUnit : public Resource {
49 typedef ThePipeline::DynInstPtr DynInstPtr;
58 MultDivUnit(std::string res_name, int res_id, int res_width,
59 int res_latency, InOrderCPU *_cpu,
60 ThePipeline::Params *params);
63 /** Override default Resource getSlot(). Will only getSlot if
64 * valid mult/div sequence is being maintained
66 int getSlot(DynInstPtr inst);
70 /** Get Operand Size For A Division Operation */
71 int getDivOpSize(DynInstPtr inst);
73 /** Override default Resource execute */
74 void execute(int slot_num);
76 void exeMulDiv(int slot_num);
78 /** Register extra resource stats */
81 void requestAgain(DynInstPtr inst, bool &try_request);
83 void squash(DynInstPtr inst, int stage_num, InstSeqNum squash_seq_num,
87 /** Latency & Repeat Rate for Multiply Insts */
88 unsigned multRepeatRate;
91 /** Latency & Repeat Rate for 8-bit Divide Insts */
92 unsigned div8RepeatRate;
95 /** Latency & Repeat Rate for 16-bit Divide Insts */
96 unsigned div16RepeatRate;
97 unsigned div16Latency;
99 /** Latency & Repeat Rate for 24-bit Divide Insts */
100 unsigned div24RepeatRate;
101 unsigned div24Latency;
103 /** Latency & Repeat Rate for 32-bit Divide Insts */
104 unsigned div32RepeatRate;
105 unsigned div32Latency;
107 /** Last cycle that MDU was used */
110 /** Last type of instruction MDU started processing */
113 /** Last Division Operand of instruction MDU was processing */
114 uint32_t lastDivSize;
116 /** Last instruction name the MDU used */
117 std::string lastInstName;
119 /** Number of Multiplies */
120 Stats::Scalar multiplies;
122 /** Number of Divides */
123 Stats::Scalar divides;
128 class MDUEvent : public ResourceEvent
139 #endif //__CPU_INORDER_MULT_DIV_UNIT_HH__