gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dsp.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 MIPS Technologies, Inc.
3  * All rights reserved.
4  *
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.
15  *
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.
27  *
28  * Authors: Brett Miller
29  */
30 
31 #ifndef __ARCH_MIPS_DSP_HH__
32 #define __ARCH_MIPS_DSP_HH__
33 
34 #include "arch/mips/isa_traits.hh"
35 #include "arch/mips/types.hh"
36 #include "base/misc.hh"
37 #include "base/types.hh"
38 
39 class ThreadContext;
40 
41 namespace MipsISA {
42 
43 // SIMD formats
44 enum {
45  SIMD_FMT_L, // long word
46  SIMD_FMT_W, // word
47  SIMD_FMT_PH, // paired halfword
48  SIMD_FMT_QB, // quad byte
50 };
51 
52 // DSPControl Fields
53 enum {
54  DSP_POS, // insertion bitfield position
55  DSP_SCOUNT, // insertion bitfield size
56  DSP_C, // carry bit
57  DSP_OUFLAG, // overflow-underflow flag
58  DSP_CCOND, // condition code
59  DSP_EFI, // extract fail indicator bit
61 };
62 
63 // compare instruction operations
64 enum {
65  CMP_EQ, // equal
66  CMP_LT, // less than
67  CMP_LE // less than or equal
68 };
69 
70 // SIMD operation order modes
71 enum {
72  MODE_L, // left
73  MODE_R, // right
74  MODE_LA, // left-alternate
75  MODE_RA, // right-alternate
76  MODE_X // cross
77 };
78 
79 // dsp operation parameters
80 enum { UNSIGNED, SIGNED };
81 enum { NOSATURATE, SATURATE };
82 enum { NOROUND, ROUND };
83 
84 // DSPControl field positions and masks
85 const uint32_t DSP_CTL_POS[DSP_NUM_FIELDS] = { 0, 7, 13, 16, 24, 14 };
86 const uint32_t DSP_CTL_MASK[DSP_NUM_FIELDS] =
87 { 0x0000003f, 0x00001f80, 0x00002000,
88  0x00ff0000, 0x0f000000, 0x00004000 };
89 
90 /*
91  * SIMD format constants
92  */
93 
94 // maximum values per register
95 const uint32_t SIMD_MAX_VALS = 4;
96 // number of values in fmt
97 const uint32_t SIMD_NVALS[SIMD_NUM_FMTS] = { 1, 1, 2, 4 };
98 // number of bits per value
99 const uint32_t SIMD_NBITS[SIMD_NUM_FMTS] = { 64, 32, 16, 8 };
100 // log2(bits per value)
101 const uint32_t SIMD_LOG2N[SIMD_NUM_FMTS] = { 6, 5, 4, 3 };
102 
103 
104 // DSP maximum values
105 const uint64_t FIXED_L_SMAX = ULL(0x7fffffffffffffff);
106 const uint64_t FIXED_W_SMAX = ULL(0x000000007fffffff);
107 const uint64_t FIXED_H_SMAX = ULL(0x0000000000007fff);
108 const uint64_t FIXED_B_SMAX = ULL(0x000000000000007f);
109 const uint64_t FIXED_L_UMAX = ULL(0xffffffffffffffff);
110 const uint64_t FIXED_W_UMAX = ULL(0x00000000ffffffff);
111 const uint64_t FIXED_H_UMAX = ULL(0x000000000000ffff);
112 const uint64_t FIXED_B_UMAX = ULL(0x00000000000000ff);
113 const uint64_t FIXED_SMAX[SIMD_NUM_FMTS] =
115 const uint64_t FIXED_UMAX[SIMD_NUM_FMTS] =
117 
118 // DSP minimum values
119 const uint64_t FIXED_L_SMIN = ULL(0x8000000000000000);
120 const uint64_t FIXED_W_SMIN = ULL(0xffffffff80000000);
121 const uint64_t FIXED_H_SMIN = ULL(0xffffffffffff8000);
122 const uint64_t FIXED_B_SMIN = ULL(0xffffffffffffff80);
123 const uint64_t FIXED_L_UMIN = ULL(0x0000000000000000);
124 const uint64_t FIXED_W_UMIN = ULL(0x0000000000000000);
125 const uint64_t FIXED_H_UMIN = ULL(0x0000000000000000);
126 const uint64_t FIXED_B_UMIN = ULL(0x0000000000000000);
127 const uint64_t FIXED_SMIN[SIMD_NUM_FMTS] =
129 const uint64_t FIXED_UMIN[SIMD_NUM_FMTS] =
131 
132 // DSP utility functions
133 int32_t bitrev(int32_t value);
134 uint64_t dspSaturate(uint64_t value, int32_t fmt, int32_t sign,
135  uint32_t *overflow);
136 uint64_t checkOverflow(uint64_t value, int32_t fmt, int32_t sign,
137  uint32_t *overflow);
138 uint64_t signExtend(uint64_t value, int32_t signpos);
139 uint64_t addHalfLsb(uint64_t value, int32_t lsbpos);
140 int32_t dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl);
141 int32_t dspAdd(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
142  int32_t sign, uint32_t *dspctl);
143 int32_t dspAddh(int32_t a, int32_t b, int32_t fmt, int32_t round,
144  int32_t sign);
145 int32_t dspSub(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
146  int32_t sign, uint32_t *dspctl);
147 int32_t dspSubh(int32_t a, int32_t b, int32_t fmt, int32_t round,
148  int32_t sign);
149 int32_t dspShll(int32_t a, uint32_t sa, int32_t fmt, int32_t saturate,
150  int32_t sign, uint32_t *dspctl);
151 int32_t dspShrl(int32_t a, uint32_t sa, int32_t fmt, int32_t sign);
152 int32_t dspShra(int32_t a, uint32_t sa, int32_t fmt, int32_t round,
153  int32_t sign, uint32_t *dspctl);
154 int32_t dspMul(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
155  uint32_t *dspctl);
156 int32_t dspMulq(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
157  int32_t round, uint32_t *dspctl);
158 int32_t dspMuleu(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl);
159 int32_t dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl);
160 int64_t dspDpaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
161  int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode,
162  uint32_t *dspctl);
163 int64_t dspDpsq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
164  int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode,
165  uint32_t *dspctl);
166 int64_t dspDpa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
167  int32_t sign, int32_t mode);
168 int64_t dspDps(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
169  int32_t sign, int32_t mode);
170 int64_t dspMaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
171  int32_t fmt, int32_t mode, int32_t saturate, uint32_t *dspctl);
172 int64_t dspMulsa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt);
173 int64_t dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
174  uint32_t *dspctl);
175 void dspCmp(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op,
176  uint32_t *dspctl);
177 int32_t dspCmpg(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op);
178 int32_t dspCmpgd(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op,
179  uint32_t *dspctl);
180 int32_t dspPrece(int32_t a, int32_t infmt, int32_t insign, int32_t outfmt,
181  int32_t outsign, int32_t mode);
182 int32_t dspPrecrqu(int32_t a, int32_t b, uint32_t *dspctl);
183 int32_t dspPrecrq(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl);
184 int32_t dspPrecrSra(int32_t a, int32_t b, int32_t sa, int32_t fmt,
185  int32_t round);
186 int32_t dspPick(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl);
187 int32_t dspPack(int32_t a, int32_t b, int32_t fmt);
188 int32_t dspExtr(int64_t dspac, int32_t fmt, int32_t sa, int32_t round,
189  int32_t saturate, uint32_t *dspctl);
190 int32_t dspExtp(int64_t dspac, int32_t size, uint32_t *dspctl);
191 int32_t dspExtpd(int64_t dspac, int32_t size, uint32_t *dspctl);
192 
193 // SIMD pack/unpack utility functions
194 void simdPack(uint64_t *values_ptr, int32_t *reg, int32_t fmt);
195 void simdUnpack(int32_t reg, uint64_t *values_ptr, int32_t fmt, int32_t sign);
196 
197 // DSPControl r/w utility functions
198 void writeDSPControl(uint32_t *dspctl, uint32_t value, uint32_t mask);
199 uint32_t readDSPControl(uint32_t *dspctl, uint32_t mask);
200 
201 } // namespace MipsISA
202 
203 #endif // __ARCH_MIPS_DSP_HH__
const uint32_t SIMD_MAX_VALS
Definition: dsp.hh:95
void dspCmp(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op, uint32_t *dspctl)
Definition: dsp.cc:771
Bitfield< 5, 3 > reg
Definition: types.hh:89
int32_t dspShll(int32_t a, uint32_t sa, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
Definition: dsp.cc:278
const uint64_t FIXED_L_UMIN
Definition: dsp.hh:123
const uint32_t SIMD_LOG2N[SIMD_NUM_FMTS]
Definition: dsp.hh:101
int64_t dspDpa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, int32_t sign, int32_t mode)
Definition: dsp.cc:628
const uint64_t FIXED_B_SMIN
Definition: dsp.hh:122
uint64_t dspSaturate(uint64_t value, int32_t fmt, int32_t sign, uint32_t *overflow)
Definition: dsp.cc:61
int32_t dspPrecrSra(int32_t a, int32_t b, int32_t sa, int32_t fmt, int32_t round)
Definition: dsp.cc:969
int32_t dspExtp(int64_t dspac, int32_t size, uint32_t *dspctl)
Definition: dsp.cc:1084
int32_t dspPick(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl)
Definition: dsp.cc:997
const uint32_t SIMD_NVALS[SIMD_NUM_FMTS]
Definition: dsp.hh:97
uint64_t checkOverflow(uint64_t value, int32_t fmt, int32_t sign, uint32_t *overflow)
Definition: dsp.cc:91
int64_t dspMaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, int32_t mode, int32_t saturate, uint32_t *dspctl)
Definition: dsp.cc:684
int64_t dspDpsq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode, uint32_t *dspctl)
Definition: dsp.cc:561
int32_t dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl)
Definition: dsp.cc:135
const uint64_t FIXED_H_UMIN
Definition: dsp.hh:125
int32_t dspMulq(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t round, uint32_t *dspctl)
Definition: dsp.cc:350
const uint64_t FIXED_B_SMAX
Definition: dsp.hh:108
int32_t dspMul(int32_t a, int32_t b, int32_t fmt, int32_t saturate, uint32_t *dspctl)
Definition: dsp.cc:391
ThreadContext is the external interface to all thread state for anything outside of the CPU...
const uint64_t FIXED_B_UMAX
Definition: dsp.hh:112
int32_t dspExtpd(int64_t dspac, int32_t size, uint32_t *dspctl)
Definition: dsp.cc:1104
Bitfield< 7 > b
Definition: miscregs.hh:1564
uint64_t signExtend(uint64_t value, int32_t signpos)
Definition: dsp.cc:114
const uint64_t FIXED_W_SMAX
Definition: dsp.hh:106
int32_t dspPrecrq(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl)
Definition: dsp.cc:944
const uint32_t DSP_CTL_POS[DSP_NUM_FIELDS]
Definition: dsp.hh:85
Bitfield< 3, 0 > sa
void simdUnpack(int32_t reg, uint64_t *values_ptr, int32_t fmt, int32_t sign)
Definition: dsp.cc:1140
Bitfield< 18 > ac
Definition: misc.hh:562
const uint32_t DSP_CTL_MASK[DSP_NUM_FIELDS]
Definition: dsp.hh:86
int32_t dspPrece(int32_t a, int32_t infmt, int32_t insign, int32_t outfmt, int32_t outsign, int32_t mode)
Definition: dsp.cc:873
int32_t dspCmpg(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op)
Definition: dsp.cc:804
void simdPack(uint64_t *values_ptr, int32_t *reg, int32_t fmt)
Definition: dsp.cc:1128
int32_t dspSub(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
Definition: dsp.cc:222
const uint64_t FIXED_UMAX[SIMD_NUM_FMTS]
Definition: dsp.hh:115
const uint64_t FIXED_W_SMIN
Definition: dsp.hh:120
const uint64_t FIXED_L_SMAX
Definition: dsp.hh:105
int32_t dspAdd(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
Definition: dsp.cc:166
uint32_t readDSPControl(uint32_t *dspctl, uint32_t mask)
Definition: dsp.cc:1179
int32_t dspPrecrqu(int32_t a, int32_t b, uint32_t *dspctl)
Definition: dsp.cc:915
const uint64_t FIXED_H_SMAX
Definition: dsp.hh:107
int32_t dspShra(int32_t a, uint32_t sa, int32_t fmt, int32_t round, int32_t sign, uint32_t *dspctl)
Definition: dsp.cc:326
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
int32_t dspCmpgd(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op, uint32_t *dspctl)
Definition: dsp.cc:836
#define ULL(N)
uint64_t constant
Definition: types.hh:50
void writeDSPControl(uint32_t *dspctl, uint32_t value, uint32_t mask)
Definition: dsp.cc:1162
int32_t dspShrl(int32_t a, uint32_t sa, int32_t fmt, int32_t sign)
Definition: dsp.cc:307
const uint64_t FIXED_SMIN[SIMD_NUM_FMTS]
Definition: dsp.hh:127
const uint64_t FIXED_W_UMAX
Definition: dsp.hh:110
const uint64_t FIXED_L_UMAX
Definition: dsp.hh:109
const uint64_t FIXED_H_UMAX
Definition: dsp.hh:111
int64_t dspDpaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode, uint32_t *dspctl)
Definition: dsp.cc:494
const uint64_t FIXED_H_SMIN
Definition: dsp.hh:121
int32_t bitrev(int32_t value)
Definition: dsp.cc:43
int size()
Definition: pagetable.hh:146
const uint32_t SIMD_NBITS[SIMD_NUM_FMTS]
Definition: dsp.hh:99
int64_t dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, uint32_t *dspctl)
Definition: dsp.cc:742
int32_t dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
Definition: dsp.cc:457
Bitfield< 11, 7 > mode
Definition: dt_constants.hh:97
int32_t dspSubh(int32_t a, int32_t b, int32_t fmt, int32_t round, int32_t sign)
Definition: dsp.cc:253
const uint64_t FIXED_UMIN[SIMD_NUM_FMTS]
Definition: dsp.hh:129
uint64_t addHalfLsb(uint64_t value, int32_t lsbpos)
Definition: dsp.cc:129
Bitfield< 13 > a
Definition: mt_constants.hh:92
const uint64_t FIXED_SMAX[SIMD_NUM_FMTS]
Definition: dsp.hh:113
Bitfield< 4 > op
Definition: types.hh:80
const uint64_t FIXED_B_UMIN
Definition: dsp.hh:126
const uint64_t FIXED_L_SMIN
Definition: dsp.hh:119
int64_t dspMulsa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt)
Definition: dsp.cc:728
int32_t dspExtr(int64_t dspac, int32_t fmt, int32_t sa, int32_t round, int32_t saturate, uint32_t *dspctl)
Definition: dsp.cc:1041
int64_t dspDps(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, int32_t sign, int32_t mode)
Definition: dsp.cc:656
int32_t dspMuleu(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
Definition: dsp.cc:423
int32_t dspAddh(int32_t a, int32_t b, int32_t fmt, int32_t round, int32_t sign)
Definition: dsp.cc:198
const uint64_t FIXED_W_UMIN
Definition: dsp.hh:124
int32_t dspPack(int32_t a, int32_t b, int32_t fmt)
Definition: dsp.cc:1022

Generated on Fri Jun 9 2017 13:03:39 for gem5 by doxygen 1.8.6