gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
29#ifndef __ARCH_MIPS_DSP_HH__
30#define __ARCH_MIPS_DSP_HH__
31
32#include "arch/mips/types.hh"
33#include "base/logging.hh"
34#include "base/types.hh"
35
36namespace gem5
37{
38
39class ThreadContext;
40
41namespace MipsISA {
42
43// SIMD formats
44enum
45{
46 SIMD_FMT_L, // long word
47 SIMD_FMT_W, // word
48 SIMD_FMT_PH, // paired halfword
49 SIMD_FMT_QB, // quad byte
51};
52
53// DSPControl Fields
54enum
55{
56 DSP_POS, // insertion bitfield position
57 DSP_SCOUNT, // insertion bitfield size
58 DSP_C, // carry bit
59 DSP_OUFLAG, // overflow-underflow flag
60 DSP_CCOND, // condition code
61 DSP_EFI, // extract fail indicator bit
63};
64
65// compare instruction operations
66enum
67{
68 CMP_EQ, // equal
69 CMP_LT, // less than
70 CMP_LE // less than or equal
71};
72
73// SIMD operation order modes
74enum
75{
76 MODE_L, // left
77 MODE_R, // right
78 MODE_LA, // left-alternate
79 MODE_RA, // right-alternate
80 MODE_X // cross
81};
82
83// dsp operation parameters
84enum { UNSIGNED, SIGNED };
86enum { NOROUND, ROUND };
87
88// DSPControl field positions and masks
89const uint32_t DSP_CTL_POS[DSP_NUM_FIELDS] = { 0, 7, 13, 16, 24, 14 };
91{ 0x0000003f, 0x00001f80, 0x00002000,
92 0x00ff0000, 0x0f000000, 0x00004000 };
93
94/*
95 * SIMD format constants
96 */
97
98// maximum values per register
99const uint32_t SIMD_MAX_VALS = 4;
100// number of values in fmt
101const uint32_t SIMD_NVALS[SIMD_NUM_FMTS] = { 1, 1, 2, 4 };
102// number of bits per value
103const uint32_t SIMD_NBITS[SIMD_NUM_FMTS] = { 64, 32, 16, 8 };
104// log2(bits per value)
105const uint32_t SIMD_LOG2N[SIMD_NUM_FMTS] = { 6, 5, 4, 3 };
106
107
108// DSP maximum values
109const uint64_t FIXED_L_SMAX = 0x7fffffffffffffffULL;
110const uint64_t FIXED_W_SMAX = 0x000000007fffffffULL;
111const uint64_t FIXED_H_SMAX = 0x0000000000007fffULL;
112const uint64_t FIXED_B_SMAX = 0x000000000000007fULL;
113const uint64_t FIXED_L_UMAX = 0xffffffffffffffffULL;
114const uint64_t FIXED_W_UMAX = 0x00000000ffffffffULL;
115const uint64_t FIXED_H_UMAX = 0x000000000000ffffULL;
116const uint64_t FIXED_B_UMAX = 0x00000000000000ffULL;
121
122// DSP minimum values
123const uint64_t FIXED_L_SMIN = 0x8000000000000000ULL;
124const uint64_t FIXED_W_SMIN = 0xffffffff80000000ULL;
125const uint64_t FIXED_H_SMIN = 0xffffffffffff8000ULL;
126const uint64_t FIXED_B_SMIN = 0xffffffffffffff80ULL;
127const uint64_t FIXED_L_UMIN = 0x0000000000000000ULL;
128const uint64_t FIXED_W_UMIN = 0x0000000000000000ULL;
129const uint64_t FIXED_H_UMIN = 0x0000000000000000ULL;
130const uint64_t FIXED_B_UMIN = 0x0000000000000000ULL;
135
136// DSP utility functions
137int32_t bitrev(int32_t value);
138uint64_t dspSaturate(uint64_t value, int32_t fmt, int32_t sign,
139 uint32_t *overflow);
140uint64_t checkOverflow(uint64_t value, int32_t fmt, int32_t sign,
141 uint32_t *overflow);
142uint64_t signExtend(uint64_t value, int32_t signpos);
143uint64_t addHalfLsb(uint64_t value, int32_t lsbpos);
144int32_t dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl);
145int32_t dspAdd(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
146 int32_t sign, uint32_t *dspctl);
147int32_t dspAddh(int32_t a, int32_t b, int32_t fmt, int32_t round,
148 int32_t sign);
149int32_t dspSub(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
150 int32_t sign, uint32_t *dspctl);
151int32_t dspSubh(int32_t a, int32_t b, int32_t fmt, int32_t round,
152 int32_t sign);
153int32_t dspShll(int32_t a, uint32_t sa, int32_t fmt, int32_t saturate,
154 int32_t sign, uint32_t *dspctl);
155int32_t dspShrl(int32_t a, uint32_t sa, int32_t fmt, int32_t sign);
156int32_t dspShra(int32_t a, uint32_t sa, int32_t fmt, int32_t round,
157 int32_t sign, uint32_t *dspctl);
158int32_t dspMul(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
159 uint32_t *dspctl);
160int32_t dspMulq(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
161 int32_t round, uint32_t *dspctl);
162int32_t dspMuleu(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl);
163int32_t dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl);
164int64_t dspDpaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
165 int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode,
166 uint32_t *dspctl);
167int64_t dspDpsq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
168 int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode,
169 uint32_t *dspctl);
170int64_t dspDpa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
171 int32_t sign, int32_t mode);
172int64_t dspDps(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
173 int32_t sign, int32_t mode);
174int64_t dspMaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
175 int32_t fmt, int32_t mode, int32_t saturate, uint32_t *dspctl);
176int64_t dspMulsa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt);
177int64_t dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
178 uint32_t *dspctl);
179void dspCmp(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op,
180 uint32_t *dspctl);
181int32_t dspCmpg(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op);
182int32_t dspCmpgd(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op,
183 uint32_t *dspctl);
184int32_t dspPrece(int32_t a, int32_t infmt, int32_t insign, int32_t outfmt,
185 int32_t outsign, int32_t mode);
186int32_t dspPrecrqu(int32_t a, int32_t b, uint32_t *dspctl);
187int32_t dspPrecrq(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl);
188int32_t dspPrecrSra(int32_t a, int32_t b, int32_t sa, int32_t fmt,
189 int32_t round);
190int32_t dspPick(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl);
191int32_t dspPack(int32_t a, int32_t b, int32_t fmt);
192int32_t dspExtr(int64_t dspac, int32_t fmt, int32_t sa, int32_t round,
193 int32_t saturate, uint32_t *dspctl);
194int32_t dspExtp(int64_t dspac, int32_t size, uint32_t *dspctl);
195int32_t dspExtpd(int64_t dspac, int32_t size, uint32_t *dspctl);
196
197// SIMD pack/unpack utility functions
198void simdPack(uint64_t *values_ptr, int32_t *reg, int32_t fmt);
199void simdUnpack(int32_t reg, uint64_t *values_ptr, int32_t fmt, int32_t sign);
200
201// DSPControl r/w utility functions
202void writeDSPControl(uint32_t *dspctl, uint32_t value, uint32_t mask);
203uint32_t readDSPControl(uint32_t *dspctl, uint32_t mask);
204
205} // namespace MipsISA
206} // namespace gem5
207
208#endif // __ARCH_MIPS_DSP_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Bitfield< 7 > b
void simdUnpack(int32_t reg, uint64_t *values_ptr, int32_t fmt, int32_t sign)
Definition dsp.cc:1139
const uint32_t DSP_CTL_POS[DSP_NUM_FIELDS]
Definition dsp.hh:89
const uint64_t FIXED_SMIN[SIMD_NUM_FMTS]
Definition dsp.hh:131
const uint64_t FIXED_SMAX[SIMD_NUM_FMTS]
Definition dsp.hh:117
const uint64_t FIXED_W_SMAX
Definition dsp.hh:110
@ DSP_NUM_FIELDS
Definition dsp.hh:62
@ DSP_SCOUNT
Definition dsp.hh:57
@ DSP_OUFLAG
Definition dsp.hh:59
@ DSP_CCOND
Definition dsp.hh:60
const uint64_t FIXED_W_UMIN
Definition dsp.hh:128
const uint32_t SIMD_MAX_VALS
Definition dsp.hh:99
int32_t dspPrecrqu(int32_t a, int32_t b, uint32_t *dspctl)
Definition dsp.cc:914
const uint64_t FIXED_B_SMIN
Definition dsp.hh:126
@ SIMD_FMT_W
Definition dsp.hh:47
@ SIMD_FMT_PH
Definition dsp.hh:48
@ SIMD_FMT_QB
Definition dsp.hh:49
@ SIMD_NUM_FMTS
Definition dsp.hh:50
@ SIMD_FMT_L
Definition dsp.hh:46
uint64_t checkOverflow(uint64_t value, int32_t fmt, int32_t sign, uint32_t *overflow)
Definition dsp.cc:90
Bitfield< 13 > a
const uint64_t FIXED_B_UMIN
Definition dsp.hh:130
int32_t dspCmpgd(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op, uint32_t *dspctl)
Definition dsp.cc:835
uint64_t signExtend(uint64_t value, int32_t signpos)
Definition dsp.cc:113
int32_t bitrev(int32_t value)
Definition dsp.cc:42
int64_t dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, uint32_t *dspctl)
Definition dsp.cc:741
int32_t dspPack(int32_t a, int32_t b, int32_t fmt)
Definition dsp.cc:1021
const uint64_t FIXED_B_SMAX
Definition dsp.hh:112
const uint64_t FIXED_H_SMAX
Definition dsp.hh:111
void simdPack(uint64_t *values_ptr, int32_t *reg, int32_t fmt)
Definition dsp.cc:1127
const uint64_t FIXED_L_SMAX
Definition dsp.hh:109
int32_t dspPrece(int32_t a, int32_t infmt, int32_t insign, int32_t outfmt, int32_t outsign, int32_t mode)
Definition dsp.cc:872
int32_t dspAddh(int32_t a, int32_t b, int32_t fmt, int32_t round, int32_t sign)
Definition dsp.cc:197
uint64_t addHalfLsb(uint64_t value, int32_t lsbpos)
Definition dsp.cc:128
int32_t dspSubh(int32_t a, int32_t b, int32_t fmt, int32_t round, int32_t sign)
Definition dsp.cc:252
int64_t dspMulsa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt)
Definition dsp.cc:727
Bitfield< 11, 7 > mode
void writeDSPControl(uint32_t *dspctl, uint32_t value, uint32_t mask)
Definition dsp.cc:1161
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:655
int32_t dspMuleu(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
Definition dsp.cc:422
int32_t dspMul(int32_t a, int32_t b, int32_t fmt, int32_t saturate, uint32_t *dspctl)
Definition dsp.cc:390
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:560
int32_t dspShra(int32_t a, uint32_t sa, int32_t fmt, int32_t round, int32_t sign, uint32_t *dspctl)
Definition dsp.cc:325
const uint64_t FIXED_H_SMIN
Definition dsp.hh:125
const uint64_t FIXED_H_UMAX
Definition dsp.hh:115
int32_t dspAdd(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
Definition dsp.cc:165
int32_t dspMulq(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t round, uint32_t *dspctl)
Definition dsp.cc:349
const uint32_t SIMD_NBITS[SIMD_NUM_FMTS]
Definition dsp.hh:103
const uint32_t SIMD_NVALS[SIMD_NUM_FMTS]
Definition dsp.hh:101
int32_t dspPick(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl)
Definition dsp.cc:996
int32_t dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl)
Definition dsp.cc:134
int32_t dspShrl(int32_t a, uint32_t sa, int32_t fmt, int32_t sign)
Definition dsp.cc:306
int32_t dspExtr(int64_t dspac, int32_t fmt, int32_t sa, int32_t round, int32_t saturate, uint32_t *dspctl)
Definition dsp.cc:1040
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:683
const uint64_t FIXED_L_UMIN
Definition dsp.hh:127
const uint64_t FIXED_W_UMAX
Definition dsp.hh:114
int32_t dspShll(int32_t a, uint32_t sa, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
Definition dsp.cc:277
const uint64_t FIXED_W_SMIN
Definition dsp.hh:124
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:493
const uint64_t FIXED_UMIN[SIMD_NUM_FMTS]
Definition dsp.hh:133
int32_t dspCmpg(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op)
Definition dsp.cc:803
const uint64_t FIXED_H_UMIN
Definition dsp.hh:129
const uint64_t FIXED_UMAX[SIMD_NUM_FMTS]
Definition dsp.hh:119
int32_t dspSub(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
Definition dsp.cc:221
const uint64_t FIXED_L_SMIN
Definition dsp.hh:123
int32_t dspExtp(int64_t dspac, int32_t size, uint32_t *dspctl)
Definition dsp.cc:1083
const uint64_t FIXED_L_UMAX
Definition dsp.hh:113
const uint32_t DSP_CTL_MASK[DSP_NUM_FIELDS]
Definition dsp.hh:90
uint64_t dspSaturate(uint64_t value, int32_t fmt, int32_t sign, uint32_t *overflow)
Definition dsp.cc:60
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:627
int32_t dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
Definition dsp.cc:456
@ NOSATURATE
Definition dsp.hh:85
int32_t dspPrecrSra(int32_t a, int32_t b, int32_t sa, int32_t fmt, int32_t round)
Definition dsp.cc:968
uint32_t readDSPControl(uint32_t *dspctl, uint32_t mask)
Definition dsp.cc:1178
void dspCmp(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op, uint32_t *dspctl)
Definition dsp.cc:770
const uint64_t FIXED_B_UMAX
Definition dsp.hh:116
int32_t dspPrecrq(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl)
Definition dsp.cc:943
int32_t dspExtpd(int64_t dspac, int32_t size, uint32_t *dspctl)
Definition dsp.cc:1103
const uint32_t SIMD_LOG2N[SIMD_NUM_FMTS]
Definition dsp.hh:105
Bitfield< 3, 0 > sa
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 4 > op
Definition types.hh:83
Bitfield< 18 > ac
Definition misc.hh:576
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0