gem5 v24.0.0.0
Loading...
Searching...
No Matches
types.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 ARM Limited
3 * Copyright (c) 2014 Sven Karlsson
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2017 The University of Virginia
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef __ARCH_RISCV_TYPES_HH__
43#define __ARCH_RISCV_TYPES_HH__
44
45#include "base/bitunion.hh"
46
47namespace gem5
48{
49
50namespace RiscvISA
51{
52
53typedef uint32_t MachInst;
54
55// This should be further extend someday when we start to support 64b+ inst.
56// For now, we should be safe using the msbs to store extra information.
58 // Decoder state
59 Bitfield<63, 62> rv_type;
60 Bitfield<61> compressed;
61 // More bits for vector extension
62 Bitfield<57, 41> vl; // [0, 2**16]
63 Bitfield<40> vill;
64 SubBitUnion(vtype8, 39, 32) // exclude vill
65 Bitfield<39> vma;
66 Bitfield<38> vta;
67 Bitfield<37, 35> vsew;
68 Bitfield<34, 32> vlmul;
70 // Common
71 uint32_t instBits;
72 Bitfield< 1, 0> quadRant;
73 Bitfield< 6, 2> opcode5;
74 Bitfield< 6, 0> opcode;
75 // R-Type
76 Bitfield<31, 0> all;
77 Bitfield<11, 7> rd;
78 Bitfield<14, 12> funct3;
79 Bitfield<19, 15> rs1;
80 Bitfield<24, 20> rs2;
81 Bitfield<31, 25> funct7;
82 // Bit shifts
83 Bitfield<30> srType;
84 Bitfield<24, 20> shamt5;
85 Bitfield<25, 20> shamt6;
86 // I-Type
87 Bitfield<31, 20> imm12;
88 // Sync
89 Bitfield<23, 20> succ;
90 Bitfield<27, 24> pred;
91 // S-Type
92 Bitfield<11, 7> imm5;
93 Bitfield<31, 25> imm7;
94 // U-Type
95 Bitfield<31, 12> imm20;
96 // SB-Type
97 Bitfield<7> bimm12bit11;
98 Bitfield<11, 8> bimm12bits4to1;
99 Bitfield<30, 25> bimm12bits10to5;
100 Bitfield<31> immsign;
101 // UJ-Type
102 Bitfield<30, 21> ujimmbits10to1;
103 Bitfield<20> ujimmbit11;
104 Bitfield<19, 12> ujimmbits19to12;
105 // System
106 Bitfield<31, 20> funct12;
107 Bitfield<19, 15> csrimm;
108 // Floating point
109 Bitfield<11, 7> fd;
110 Bitfield<19, 15> fs1;
111 Bitfield<24, 20> fs2;
112 Bitfield<31, 27> fs3;
113 Bitfield<14, 12> round_mode;
114 Bitfield<24, 20> conv_sgn;
115 Bitfield<26, 25> funct2;
116 // AMO
117 Bitfield<31, 27> amofunct;
118 Bitfield<26> aq;
119 Bitfield<25> rl;
120 // Compressed
121 Bitfield<15, 13> copcode;
122 Bitfield<12> cfunct1;
123 Bitfield<11, 10> cfunct2high;
124 Bitfield< 6, 5> cfunct2low;
125 Bitfield<11, 7> rc1;
126 Bitfield< 6, 2> rc2;
127 Bitfield< 9, 7> rp1;
128 Bitfield< 4, 2> rp2;
129 Bitfield<11, 7> fc1;
130 Bitfield< 6, 2> fc2;
131 Bitfield< 4, 2> fp2;
132 Bitfield<12, 2> cjumpimm;
133 Bitfield< 5, 3> cjumpimm3to1;
134 Bitfield<11, 11> cjumpimm4to4;
135 Bitfield< 2, 2> cjumpimm5to5;
136 Bitfield< 7, 7> cjumpimm6to6;
137 Bitfield< 6, 6> cjumpimm7to7;
138 Bitfield<10, 9> cjumpimm9to8;
139 Bitfield< 8, 8> cjumpimm10to10;
140 Bitfield<12> cjumpimmsign;
141 Bitfield<12, 5> cimm8;
142 Bitfield<12, 7> cimm6;
143 Bitfield< 6, 2> cimm5;
144 Bitfield<12, 10> cimm3;
145 Bitfield< 6, 5> cimm2;
146 Bitfield<12> cimm1;
147 // Pseudo instructions
148 Bitfield<31, 25> m5func;
149 // vector
150 Bitfield<31, 26> vfunct6;
151 Bitfield<31, 27> vfunct5;
152 Bitfield<27, 25> vfunct3;
153 Bitfield<26, 25> vfunct2;
154 Bitfield<31, 29> nf;
155 Bitfield<28> mew;
156 Bitfield<27, 26> mop;
157 Bitfield<25> vm;
158 Bitfield<24, 20> lumop;
159 Bitfield<24, 20> sumop;
160 Bitfield<14, 12> width;
161 Bitfield<24, 20> vs2;
162 Bitfield<19, 15> vs1;
163 Bitfield<11, 7> vd;
164 Bitfield<11, 7> vs3;
165 Bitfield<19, 15> vecimm;
166 Bitfield<17, 15> simm3;
167 // vsetvli
168 Bitfield<31> bit31;
169 Bitfield<30> bit30;
170 Bitfield<30, 20> zimm_vsetvli;
171 // vsetivli
172 Bitfield<31, 30> bit31_30;
173 Bitfield<29, 20> zimm_vsetivli;
174 Bitfield<19, 15> uimm_vsetivli;
175 // vsetvl
176 Bitfield<31, 25> bit31_25;
177
179
180constexpr unsigned MaxVecLenInBits = 65536;
181constexpr unsigned MaxVecLenInBytes = MaxVecLenInBits >> 3;
182
183
184} // namespace RiscvISA
185} // namespace gem5
186
187#endif // __ARCH_RISCV_TYPES_HH__
#define BitUnion64(name)
Use this to define conveniently sized values overlayed with bitfields.
Definition bitunion.hh:494
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
#define SubBitUnion(name, first, last)
Regular bitfields These define macros for read/write regular bitfield based subbitfields.
Definition bitunion.hh:470
#define EndSubBitUnion(name)
This closes off the union created above and gives it a name.
Definition bitunion.hh:455
uint32_t instBits
Definition types.hh:87
Bitfield< 31, 0 > all
Definition types.hh:76
Bitfield< 31, 25 > funct7
Definition types.hh:81
Bitfield< 7 > bimm12bit11
Definition types.hh:97
Bitfield< 6, 0 > opcode
Definition types.hh:74
Bitfield< 12, 7 > cimm6
Definition types.hh:142
Bitfield< 11, 7 > fc1
Definition types.hh:129
Bitfield< 23, 20 > succ
Definition types.hh:89
Bitfield< 7 > vma
Definition vector.hh:79
Bitfield< 10, 9 > cjumpimm9to8
Definition types.hh:138
Bitfield< 11, 10 > cfunct2high
Definition types.hh:123
Bitfield< 6, 2 > cimm5
Definition types.hh:143
Bitfield< 24, 20 > sumop
Definition types.hh:159
Bitfield< 11, 7 > fd
Definition types.hh:109
Bitfield< 40 > vill
Definition types.hh:63
Bitfield< 6 > vta
Definition vector.hh:80
Bitfield< 6, 5 > cfunct2low
Definition types.hh:124
Bitfield< 31, 27 > amofunct
Definition types.hh:117
Bitfield< 6, 5 > cimm2
Definition types.hh:145
Bitfield< 19, 15 > csrimm
Definition types.hh:107
Bitfield< 14, 12 > width
Definition types.hh:160
Bitfield< 4, 2 > fp2
Definition types.hh:131
Bitfield< 24, 20 > shamt5
Definition types.hh:84
Bitfield< 9, 7 > rp1
Definition types.hh:127
Bitfield< 27, 24 > pred
Definition types.hh:90
Bitfield< 15, 13 > copcode
Definition types.hh:121
Bitfield< 14, 12 > funct3
Definition types.hh:78
Bitfield< 5, 3 > vsew
Definition vector.hh:81
Bitfield< 61 > compressed
Definition types.hh:60
Bitfield< 11, 8 > bimm12bits4to1
Definition types.hh:98
Bitfield< 31, 30 > bit31_30
Definition types.hh:172
Bitfield< 2, 2 > cjumpimm5to5
Definition types.hh:135
Bitfield< 31 > immsign
Definition types.hh:100
Bitfield< 19, 15 > vs1
Definition types.hh:162
Bitfield< 31, 29 > nf
Definition types.hh:154
Bitfield< 11, 7 > imm5
Definition types.hh:92
Bitfield< 26 > aq
Definition types.hh:118
Bitfield< 29, 20 > zimm_vsetivli
Definition types.hh:173
Bitfield< 19, 12 > ujimmbits19to12
Definition types.hh:104
Bitfield< 12, 2 > cjumpimm
Definition types.hh:132
Bitfield< 24, 20 > rs2
Definition types.hh:80
Bitfield< 31, 27 > fs3
Definition types.hh:112
Bitfield< 11, 7 > vd
Definition types.hh:163
Bitfield< 12, 10 > cimm3
Definition types.hh:144
Bitfield< 31, 20 > funct12
Definition types.hh:106
Bitfield< 6, 2 > opcode5
Definition types.hh:73
Bitfield< 1, 0 > quadRant
Definition types.hh:72
Bitfield< 26, 25 > funct2
Definition types.hh:115
Bitfield< 24, 20 > lumop
Definition types.hh:158
Bitfield< 27, 26 > mop
Definition types.hh:156
Bitfield< 31, 26 > vfunct6
Definition types.hh:150
Bitfield< 25, 20 > shamt6
Definition types.hh:85
Bitfield< 57, 41 > vl
Definition types.hh:62
Bitfield< 20 > ujimmbit11
Definition types.hh:103
Bitfield< 12 > cjumpimmsign
Definition types.hh:140
Bitfield< 24, 20 > conv_sgn
Definition types.hh:114
Bitfield< 4, 2 > rp2
Definition types.hh:128
Bitfield< 24, 20 > fs2
Definition types.hh:111
Bitfield< 31, 25 > imm7
Definition types.hh:93
Bitfield< 6, 2 > fc2
Definition types.hh:130
Bitfield< 30 > srType
Definition types.hh:83
Bitfield< 30 > bit30
Definition types.hh:169
Bitfield< 26, 25 > vfunct2
Definition types.hh:153
Bitfield< 12 > cfunct1
Definition types.hh:122
Bitfield< 19, 15 > uimm_vsetivli
Definition types.hh:174
Bitfield< 31, 12 > imm20
Definition types.hh:95
Bitfield< 30, 20 > zimm_vsetvli
Definition types.hh:170
Bitfield< 14, 12 > round_mode
Definition types.hh:113
Bitfield< 30, 21 > ujimmbits10to1
Definition types.hh:102
Bitfield< 7, 7 > cjumpimm6to6
Definition types.hh:136
Bitfield< 28 > mew
Definition types.hh:155
Bitfield< 19, 15 > rs1
Definition types.hh:79
Bitfield< 11, 7 > rd
Definition types.hh:77
uint32_t MachInst
Definition types.hh:53
Bitfield< 24, 20 > vs2
Definition types.hh:161
Bitfield< 12, 5 > cimm8
Definition types.hh:141
Bitfield< 30, 25 > bimm12bits10to5
Definition types.hh:99
Bitfield< 19, 15 > fs1
Definition types.hh:110
Bitfield< 11, 7 > vs3
Definition types.hh:164
Bitfield< 6, 2 > rc2
Definition types.hh:126
constexpr unsigned MaxVecLenInBytes
Definition types.hh:181
Bitfield< 31, 20 > imm12
Definition types.hh:87
Bitfield< 2, 0 > vlmul
Definition vector.hh:82
Bitfield< 25 > vm
Definition types.hh:157
Bitfield< 31, 27 > vfunct5
Definition types.hh:151
Bitfield< 11, 7 > rc1
Definition types.hh:125
Bitfield< 12 > cimm1
Definition types.hh:146
Bitfield< 31, 25 > m5func
Definition types.hh:148
Bitfield< 25 > rl
Definition types.hh:119
Bitfield< 6, 6 > cjumpimm7to7
Definition types.hh:137
Bitfield< 5, 3 > cjumpimm3to1
Definition types.hh:133
Bitfield< 31, 25 > bit31_25
Definition types.hh:176
Bitfield< 19, 15 > vecimm
Definition types.hh:165
Bitfield< 8, 8 > cjumpimm10to10
Definition types.hh:139
Bitfield< 7, 0 > vtype8
Definition vector.hh:78
Bitfield< 17, 15 > simm3
Definition types.hh:166
Bitfield< 11, 11 > cjumpimm4to4
Definition types.hh:134
Bitfield< 27, 25 > vfunct3
Definition types.hh:152
Bitfield< 31 > bit31
Definition types.hh:168
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0