Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include <unordered_map>
12 :
13 : #include "string_util.h"
14 : #include "ccu_microcode.h"
15 :
16 : namespace {
17 : constexpr uint16_t LOAD_TYPE = 0x0;
18 : constexpr uint16_t CTRL_TYPE = 0x1;
19 : constexpr uint16_t TRANS_TYPE = 0x2;
20 : constexpr uint16_t REDUCE_TYPE = 0x3;
21 :
22 : constexpr uint16_t LOADSQEARGSTOGSA_CODE = 0x0;
23 : constexpr uint16_t LOADSQEARGSTOXN_CODE = 0x1;
24 : constexpr uint16_t LOADIMDTOGSA_CODE = 0x2;
25 : constexpr uint16_t LOADIMDTOXN_CODE = 0x3;
26 : constexpr uint16_t LOADGSAXN_CODE = 0x4;
27 : constexpr uint16_t LOADGSAGSA_CODE = 0x5;
28 : constexpr uint16_t LOADXX_CODE = 0x6;
29 :
30 : constexpr uint16_t LOOP_CODE = 0x0;
31 : constexpr uint16_t LOOPGROUP_CODE = 0x1;
32 : constexpr uint16_t SETCKE_CODE = 0x2;
33 : constexpr uint16_t CLEARCKE_CODE = 0x4;
34 : constexpr uint16_t JMP_CODE = 0x5;
35 :
36 : constexpr uint16_t TRANSLOCMEMTOLOCMS_CODE = 0x0;
37 : constexpr uint16_t TRANSRMTMEMTOLOCMS_CODE = 0x1;
38 : constexpr uint16_t TRANSLOCMSTOLOCMEM_CODE = 0x2;
39 : constexpr uint16_t TRANSLOCMSTORMTMEM_CODE = 0x3;
40 : constexpr uint16_t TRANSRMTMSTOLOCMEM_CODE = 0x4;
41 : constexpr uint16_t TRANSLOCMSTOLOCMS_CODE = 0x5;
42 : constexpr uint16_t TRANSRMTMSTOLOCMS_CODE = 0x6;
43 : constexpr uint16_t TRANSLOCMSTORMTMS_CODE = 0x7;
44 : constexpr uint16_t TRANSRMTMEMTOLOCMEM_CODE = 0x8;
45 : constexpr uint16_t TRANSLOCMEMTORMTMEM_CODE = 0x9;
46 : constexpr uint16_t TRANSLOCMEMTOLOCMEM_CODE = 0xa;
47 : constexpr uint16_t SYNCCKE_CODE = 0xb;
48 : constexpr uint16_t SYNCGSA_CODE = 0xc;
49 : constexpr uint16_t SYNCXN_CODE = 0xd;
50 :
51 : constexpr uint16_t ADD_CODE = 0x0;
52 : constexpr uint16_t MAX_CODE = 0x1;
53 : constexpr uint16_t MIN_CODE = 0x2;
54 : } // namespace
55 :
56 : namespace Hccl {
57 : namespace CcuRep {
58 :
59 : // *GSAId = *sqeArgsId
60 1 : void LoadSqeArgsToGSAInstr(CcuInstr *instr, uint16_t gsaId, uint16_t sqeArgsId)
61 : {
62 1 : instr->header = InstrHeader(LOAD_TYPE, LOADSQEARGSTOGSA_CODE);
63 1 : instr->v1.loadSqeArgsToGSA.gsaId = gsaId;
64 1 : instr->v1.loadSqeArgsToGSA.sqeArgsId = sqeArgsId;
65 1 : }
66 :
67 : // *XnId = *sqeArgsId
68 91 : void LoadSqeArgsToXnInstr(CcuInstr *instr, uint16_t xnId, uint16_t sqeArgsId)
69 : {
70 91 : instr->header = InstrHeader(LOAD_TYPE, LOADSQEARGSTOXN_CODE);
71 91 : instr->v1.loadSqeArgsToXn.xnId = xnId;
72 91 : instr->v1.loadSqeArgsToXn.sqeArgsId = sqeArgsId;
73 91 : }
74 :
75 : // *GSAId = immediate
76 37 : void LoadImdToGSAInstr(CcuInstr *instr, uint16_t gsaId, uint64_t immediate)
77 : {
78 37 : instr->header = InstrHeader(LOAD_TYPE, LOADIMDTOGSA_CODE);
79 37 : instr->v1.loadImdToGSA.gsaId = gsaId;
80 37 : instr->v1.loadImdToGSA.immediate = immediate;
81 37 : }
82 :
83 : // *XnId = immediate,secFlag用于打印时判断immediate是否是敏感信息,如果是,请设置secFlag=CCU_LOAD_TO_XN_SEC_INFO
84 288 : void LoadImdToXnInstr(CcuInstr *instr, uint16_t xnId, uint64_t immediate, uint16_t secFlag)
85 : {
86 288 : instr->header = InstrHeader(LOAD_TYPE, LOADIMDTOXN_CODE);
87 288 : instr->v1.loadImdToXn.xnId = xnId;
88 288 : instr->v1.loadImdToXn.immediate = immediate;
89 288 : instr->v1.loadImdToXn.secFlag = secFlag;
90 288 : }
91 :
92 : // *GSAdId = *GSAmId + *XnId
93 137 : void LoadGSAXnInstr(CcuInstr *instr, uint16_t gsAdId, uint16_t gsAmId, uint16_t xnId)
94 : {
95 137 : instr->header = InstrHeader(LOAD_TYPE, LOADGSAXN_CODE);
96 137 : instr->v1.loadGSAXn.gsAdId = gsAdId;
97 137 : instr->v1.loadGSAXn.gsAmId = gsAmId;
98 137 : instr->v1.loadGSAXn.xnId = xnId;
99 137 : }
100 :
101 : // *GSAdId = *GSAmId + *GSAnId
102 49 : void LoadGSAGSAInstr(CcuInstr *instr, uint16_t gsAdId, uint16_t gsAmId, uint16_t gsAnId)
103 : {
104 49 : instr->header = InstrHeader(LOAD_TYPE, LOADGSAGSA_CODE);
105 49 : instr->v1.loadGSAGSA.gsAdId = gsAdId;
106 49 : instr->v1.loadGSAGSA.gsAmId = gsAmId;
107 49 : instr->v1.loadGSAGSA.gsAnId = gsAnId;
108 49 : }
109 :
110 : // *XdId = *XmId + *XnId
111 199 : void LoadXXInstr(CcuInstr *instr, uint16_t xdId, uint16_t xmId, uint16_t xnId)
112 : {
113 199 : instr->header = InstrHeader(LOAD_TYPE, LOADXX_CODE);
114 199 : instr->v1.loadXX.xdId = xdId;
115 199 : instr->v1.loadXX.xmId = xmId;
116 199 : instr->v1.loadXX.xnId = xnId;
117 199 : }
118 :
119 : // startInstrId ~ endInstrId之间的指令构成loop
120 : // Xn寄存器中的内容:LoopNum[61:55], RepeatNum[54:48], NoRepeatNum[47:41], LoopCtxId[40:33], Offset[32:13],
121 : // IterNum[12:0] loop执行IterNum次 loop每次执行, *GSA偏移为Offset loop在第LoopCtxId个LoopEngine上执行
122 10 : void LoopInstr(CcuInstr *instr, uint16_t startInstrId, uint16_t endInstrId, uint16_t xnId)
123 : {
124 10 : instr->header = InstrHeader(CTRL_TYPE, LOOP_CODE);
125 10 : instr->v1.loop.startInstrId = startInstrId;
126 10 : instr->v1.loop.endInstrId = endInstrId;
127 10 : instr->v1.loop.xnId = xnId;
128 10 : }
129 :
130 : // startLoopInstrId为LoopGroup所包含的Loop的起始地址
131 : // Xn寄存器中的内容:LoopNum[61:55], RepeatNum[54:48], NoRepeatNum[47:41], LoopCtxId[40:33], Offset[32:13],
132 : // IterNum[12:0] 不自动展开的Loop的个数:NoRepeatNum 自动展开的Loop的个数:RepeatNum 自动展开成LoopNum个Loop
133 7 : void LoopGroupInstr(CcuInstr *instr, uint16_t startLoopInstrId, uint16_t xnId, uint16_t xmId, uint16_t highPerfModeEn)
134 : {
135 7 : instr->header = InstrHeader(CTRL_TYPE, LOOPGROUP_CODE);
136 7 : instr->v1.loopGroup.startLoopInstrId = startLoopInstrId;
137 7 : instr->v1.loopGroup.xnId = xnId;
138 7 : instr->v1.loopGroup.xmId = xmId;
139 7 : instr->v1.loopGroup.highPerfModeEn = highPerfModeEn & 0x1;
140 7 : }
141 :
142 : // 后续函数中, 均需要wait到<waitCKEId, waitCKEMask>后, 再执行相关操作, 执行完之后再set<setCKEId, setCKEMask>
143 : // clearType = 1时, wait到之后需要对<waitCKEId, waitCKEMask>清零, 否则不清零
144 :
145 : // set<setCKEId, setCKEMask>
146 86 : void SetCKEInstr(CcuInstr *instr, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId, uint16_t waitCKEMask,
147 : uint16_t clearType)
148 : {
149 86 : instr->header = InstrHeader(CTRL_TYPE, SETCKE_CODE);
150 86 : instr->v1.setCKE.clearType = clearType & 0x1;
151 86 : instr->v1.setCKE.setCKEId = setCKEId;
152 86 : instr->v1.setCKE.setCKEMask = setCKEMask;
153 86 : instr->v1.setCKE.waitCKEId = waitCKEId;
154 86 : instr->v1.setCKE.waitCKEMask = waitCKEMask;
155 86 : }
156 :
157 : // clear<setCKEId, setCKEMask>
158 13 : void ClearCKEInstr(CcuInstr *instr, uint16_t clearCKEId, uint16_t clearMask, uint16_t waitCKEId, uint16_t waitCKEMask,
159 : uint16_t clearType)
160 : {
161 13 : instr->header = InstrHeader(CTRL_TYPE, CLEARCKE_CODE);
162 13 : instr->v1.clearCKE.clearType = clearType & 0x1;
163 13 : instr->v1.clearCKE.clearCKEId = clearCKEId;
164 13 : instr->v1.clearCKE.clearMask = clearMask;
165 13 : instr->v1.clearCKE.waitCKEId = waitCKEId;
166 13 : instr->v1.clearCKE.waitCKEMask = waitCKEMask;
167 13 : }
168 :
169 67 : void JumpInstr(CcuInstr *instr, uint16_t dstInstrXnId, uint16_t conditionXnId, uint64_t expectData)
170 : {
171 67 : instr->header = InstrHeader(CTRL_TYPE, JMP_CODE);
172 67 : instr->v1.jmp.dstInstrXnId = dstInstrXnId;
173 67 : instr->v1.jmp.conditionXnId = conditionXnId;
174 67 : instr->v1.jmp.expectData = expectData;
175 67 : }
176 :
177 : // 本端Memory传输到本端MS
178 : // locMSId: 本端MSId
179 : // <locGSAId, locXnId>: 本端Memory地址和Token
180 : // 数据长度: length
181 8 : void TransLocMemToLocMSInstr(CcuInstr *instr, uint16_t locMSId, uint16_t locGSAId, uint16_t locXnId,
182 : uint16_t lengthXnId, uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask,
183 : uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
184 : {
185 8 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMEMTOLOCMS_CODE);
186 8 : instr->v1.transLocMemToLocMS.locMSId = locMSId;
187 8 : instr->v1.transLocMemToLocMS.locGSAId = locGSAId;
188 8 : instr->v1.transLocMemToLocMS.locXnId = locXnId;
189 8 : instr->v1.transLocMemToLocMS.lengthXnId = lengthXnId;
190 8 : instr->v1.transLocMemToLocMS.channelId = channelId;
191 8 : instr->v1.transLocMemToLocMS.clearType = clearType & 0x1;
192 8 : instr->v1.transLocMemToLocMS.lengthEn = lengthEn & 0x1;
193 8 : instr->v1.transLocMemToLocMS.setCKEId = setCKEId;
194 8 : instr->v1.transLocMemToLocMS.setCKEMask = setCKEMask;
195 8 : instr->v1.transLocMemToLocMS.waitCKEId = waitCKEId;
196 8 : instr->v1.transLocMemToLocMS.waitCKEMask = waitCKEMask;
197 8 : }
198 :
199 : // 远端Memory传输到本端MS
200 : // locMSId: 本端MSId
201 : // <rmtGSAId, rmtXnId>: 远端Memory地址和Token
202 : // 数据长度: length
203 : // 路径: channelId
204 1 : void TransRmtMemToLocMSInstr(CcuInstr *instr, uint16_t locMSId, uint16_t rmtGSAId, uint16_t rmtXnId,
205 : uint16_t lengthXnId, uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask,
206 : uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
207 : {
208 1 : instr->header = InstrHeader(TRANS_TYPE, TRANSRMTMEMTOLOCMS_CODE);
209 1 : instr->v1.transRmtMemToLocMS.locMSId = locMSId;
210 1 : instr->v1.transRmtMemToLocMS.rmtGSAId = rmtGSAId;
211 1 : instr->v1.transRmtMemToLocMS.rmtXnId = rmtXnId;
212 1 : instr->v1.transRmtMemToLocMS.lengthXnId = lengthXnId;
213 1 : instr->v1.transRmtMemToLocMS.channelId = channelId;
214 1 : instr->v1.transRmtMemToLocMS.clearType = clearType & 0x1;
215 1 : instr->v1.transRmtMemToLocMS.lengthEn = lengthEn & 0x1;
216 1 : instr->v1.transRmtMemToLocMS.setCKEId = setCKEId;
217 1 : instr->v1.transRmtMemToLocMS.setCKEMask = setCKEMask;
218 1 : instr->v1.transRmtMemToLocMS.waitCKEId = waitCKEId;
219 1 : instr->v1.transRmtMemToLocMS.waitCKEMask = waitCKEMask;
220 1 : }
221 :
222 : // 本端MS传输到本端Memory
223 : // <locGSAId, locXnId>: 本端Memory地址和Token
224 : // locMSId: 本端MSId
225 : // 数据长度: length
226 8 : void TransLocMSToLocMemInstr(CcuInstr *instr, uint16_t locGSAId, uint16_t locXnId, uint16_t locMSId,
227 : uint16_t lengthXnId, uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask,
228 : uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
229 : {
230 8 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMSTOLOCMEM_CODE);
231 8 : instr->v1.transLocMSToLocMem.locGSAId = locGSAId;
232 8 : instr->v1.transLocMSToLocMem.locXnId = locXnId;
233 8 : instr->v1.transLocMSToLocMem.locMSId = locMSId;
234 8 : instr->v1.transLocMSToLocMem.lengthXnId = lengthXnId;
235 8 : instr->v1.transLocMSToLocMem.channelId = channelId;
236 8 : instr->v1.transLocMSToLocMem.clearType = clearType & 0x1;
237 8 : instr->v1.transLocMSToLocMem.lengthEn = lengthEn & 0x1;
238 8 : instr->v1.transLocMSToLocMem.setCKEId = setCKEId;
239 8 : instr->v1.transLocMSToLocMem.setCKEMask = setCKEMask;
240 8 : instr->v1.transLocMSToLocMem.waitCKEId = waitCKEId;
241 8 : instr->v1.transLocMSToLocMem.waitCKEMask = waitCKEMask;
242 8 : }
243 :
244 : // 本端MS传输到远端Memory
245 : // locMSId: 本端MSId
246 : // <rmtGSAId, rmtXnId>: 远端Memory地址和Token
247 : // 数据长度: length
248 : // 路径: channelId
249 15 : void TransLocMSToRmtMemInstr(CcuInstr *instr, uint16_t rmtGSAId, uint16_t rmtXnId, uint16_t locMSId,
250 : uint16_t lengthXnId, uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask,
251 : uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
252 : {
253 15 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMSTORMTMEM_CODE);
254 15 : instr->v1.transLocMSToRmtMem.rmtGSAId = rmtGSAId;
255 15 : instr->v1.transLocMSToRmtMem.rmtXnId = rmtXnId;
256 15 : instr->v1.transLocMSToRmtMem.locMSId = locMSId;
257 15 : instr->v1.transLocMSToRmtMem.lengthXnId = lengthXnId;
258 15 : instr->v1.transLocMSToRmtMem.channelId = channelId;
259 15 : instr->v1.transLocMSToRmtMem.clearType = clearType & 0x1;
260 15 : instr->v1.transLocMSToRmtMem.lengthEn = lengthEn & 0x1;
261 15 : instr->v1.transLocMSToRmtMem.setCKEId = setCKEId;
262 15 : instr->v1.transLocMSToRmtMem.setCKEMask = setCKEMask;
263 15 : instr->v1.transLocMSToRmtMem.waitCKEId = waitCKEId;
264 15 : instr->v1.transLocMSToRmtMem.waitCKEMask = waitCKEMask;
265 15 : }
266 :
267 : // 远端MS传输到本端Memory
268 : // <locGSAId, locXnId>: 本端Memory地址和Token
269 : // rmtMSId: 远端MSId
270 : // 数据长度: length
271 : // 路径: channelId
272 1 : void TransRmtMSToLocMemInstr(CcuInstr *instr, uint16_t locGSAId, uint16_t locXnId, uint16_t rmtMSId,
273 : uint16_t lengthXnId, uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask,
274 : uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
275 : {
276 1 : instr->header = InstrHeader(TRANS_TYPE, TRANSRMTMSTOLOCMEM_CODE);
277 1 : instr->v1.transRmtMSToLocMem.locGSAId = locGSAId;
278 1 : instr->v1.transRmtMSToLocMem.locXnId = locXnId;
279 1 : instr->v1.transRmtMSToLocMem.rmtMSId = rmtMSId;
280 1 : instr->v1.transRmtMSToLocMem.lengthXnId = lengthXnId;
281 1 : instr->v1.transRmtMSToLocMem.channelId = channelId;
282 1 : instr->v1.transRmtMSToLocMem.clearType = clearType & 0x1;
283 1 : instr->v1.transRmtMSToLocMem.lengthEn = lengthEn & 0x1;
284 1 : instr->v1.transRmtMSToLocMem.setCKEId = setCKEId;
285 1 : instr->v1.transRmtMSToLocMem.setCKEMask = setCKEMask;
286 1 : instr->v1.transRmtMSToLocMem.waitCKEId = waitCKEId;
287 1 : instr->v1.transRmtMSToLocMem.waitCKEMask = waitCKEMask;
288 1 : }
289 :
290 : // 本端MS传输到本端MS
291 : // dstMSId: 本端目的MSId
292 : // srcMSId: 本端源MSId
293 : // 数据长度: length
294 1 : void TransLocMSToLocMSInstr(CcuInstr *instr, uint16_t dstMSId, uint16_t srcMSId, uint16_t lengthXnId,
295 : uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId,
296 : uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
297 : {
298 1 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMSTOLOCMS_CODE);
299 1 : instr->v1.transLocMSToLocMS.dstMSId = dstMSId;
300 1 : instr->v1.transLocMSToLocMS.srcMSId = srcMSId;
301 1 : instr->v1.transLocMSToLocMS.lengthXnId = lengthXnId;
302 1 : instr->v1.transLocMSToLocMS.channelId = channelId;
303 1 : instr->v1.transLocMSToLocMS.clearType = clearType & 0x1;
304 1 : instr->v1.transLocMSToLocMS.lengthEn = lengthEn & 0x1;
305 1 : instr->v1.transLocMSToLocMS.setCKEId = setCKEId;
306 1 : instr->v1.transLocMSToLocMS.setCKEMask = setCKEMask;
307 1 : instr->v1.transLocMSToLocMS.waitCKEId = waitCKEId;
308 1 : instr->v1.transLocMSToLocMS.waitCKEMask = waitCKEMask;
309 1 : }
310 :
311 : // 远端MS传输到本端MS
312 : // locMSId: 本端MSId
313 : // rmtMSId: 远端MSId
314 : // 数据长度: length
315 : // 路径: channelId
316 1 : void TransRmtMSToLocMSInstr(CcuInstr *instr, uint16_t locMSId, uint16_t rmtMSId, uint16_t lengthXnId,
317 : uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId,
318 : uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
319 : {
320 1 : instr->header = InstrHeader(TRANS_TYPE, TRANSRMTMSTOLOCMS_CODE);
321 1 : instr->v1.transRmtMSToLocMS.locMSId = locMSId;
322 1 : instr->v1.transRmtMSToLocMS.rmtMSId = rmtMSId;
323 1 : instr->v1.transRmtMSToLocMS.lengthXnId = lengthXnId;
324 1 : instr->v1.transRmtMSToLocMS.channelId = channelId;
325 1 : instr->v1.transRmtMSToLocMS.clearType = clearType & 0x1;
326 1 : instr->v1.transRmtMSToLocMS.lengthEn = lengthEn & 0x1;
327 1 : instr->v1.transRmtMSToLocMS.setCKEId = setCKEId;
328 1 : instr->v1.transRmtMSToLocMS.setCKEMask = setCKEMask;
329 1 : instr->v1.transRmtMSToLocMS.waitCKEId = waitCKEId;
330 1 : instr->v1.transRmtMSToLocMS.waitCKEMask = waitCKEMask;
331 1 : }
332 :
333 1 : void TransLocMSToRmtMSInstr(CcuInstr *instr, uint16_t rmtMSId, uint16_t locMSId, uint16_t lengthXnId,
334 : uint16_t channelId, uint16_t setRmtCKEId, uint16_t setRmtCKEMask, uint16_t setCKEId,
335 : uint16_t setCKEMask, uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType,
336 : uint16_t lengthEn)
337 : {
338 1 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMSTORMTMS_CODE);
339 1 : instr->v1.transLocMSToRmtMS.rmtMSId = rmtMSId;
340 1 : instr->v1.transLocMSToRmtMS.locMSId = locMSId;
341 1 : instr->v1.transLocMSToRmtMS.lengthXnId = lengthXnId;
342 1 : instr->v1.transLocMSToRmtMS.channelId = channelId;
343 1 : instr->v1.transLocMSToRmtMS.setRmtCKEId = setRmtCKEId;
344 1 : instr->v1.transLocMSToRmtMS.setRmtCKEMask = setRmtCKEMask;
345 :
346 1 : instr->v1.transLocMSToRmtMS.clearType = clearType & 0x1;
347 1 : instr->v1.transLocMSToRmtMS.lengthEn = lengthEn & 0x1;
348 1 : instr->v1.transLocMSToRmtMS.setCKEId = setCKEId;
349 1 : instr->v1.transLocMSToRmtMS.setCKEMask = setCKEMask;
350 1 : instr->v1.transLocMSToRmtMS.waitCKEId = waitCKEId;
351 1 : instr->v1.transLocMSToRmtMS.waitCKEMask = waitCKEMask;
352 1 : }
353 :
354 : // 远端Memory传输到本端Memory
355 : // <locGSAId, locXnId>: 本端Memory地址和Token
356 : // <rmtGSAId, rmtXnId>: 远端Memory地址和Token
357 : // 数据长度: length
358 : // 路径: channelId
359 3 : void TransRmtMemToLocMemInstr(CcuInstr *instr, uint16_t locGSAId, uint16_t locXnId, uint16_t rmtGSAId, uint16_t rmtXnId,
360 : uint16_t lengthXnId, uint16_t channelId, uint16_t reduceDataType,
361 : uint16_t reduceOpCode, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId,
362 : uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn, uint16_t reduceEn)
363 : {
364 3 : instr->header = InstrHeader(TRANS_TYPE, TRANSRMTMEMTOLOCMEM_CODE);
365 3 : instr->v1.transRmtMemToLocMem.locGSAId = locGSAId;
366 3 : instr->v1.transRmtMemToLocMem.locXnId = locXnId;
367 3 : instr->v1.transRmtMemToLocMem.rmtGSAId = rmtGSAId;
368 3 : instr->v1.transRmtMemToLocMem.rmtXnId = rmtXnId;
369 3 : instr->v1.transRmtMemToLocMem.lengthXnId = lengthXnId;
370 3 : instr->v1.transRmtMemToLocMem.channelId = channelId;
371 3 : instr->v1.transRmtMemToLocMem.udfType = 0;
372 3 : instr->v1.transRmtMemToLocMem.reduceDataType = reduceDataType & 0xf;
373 3 : instr->v1.transRmtMemToLocMem.reduceOpCode = reduceOpCode & 0xf;
374 3 : instr->v1.transRmtMemToLocMem.clearType = clearType & 0x1;
375 3 : instr->v1.transRmtMemToLocMem.lengthEn = lengthEn & 0x1;
376 3 : instr->v1.transRmtMemToLocMem.reduceEn = reduceEn & 0x1;
377 3 : instr->v1.transRmtMemToLocMem.setCKEId = setCKEId;
378 3 : instr->v1.transRmtMemToLocMem.setCKEMask = setCKEMask;
379 3 : instr->v1.transRmtMemToLocMem.waitCKEId = waitCKEId;
380 3 : instr->v1.transRmtMemToLocMem.waitCKEMask = waitCKEMask;
381 3 : }
382 :
383 : // 本端Memory传输到远端Memory
384 : // <rmtGSAId, rmtXnId>: 远端Memory地址和Token
385 : // <locGSAId, locXnId>: 本端Memory地址和Token
386 : // 数据长度: length
387 : // 路径: channelId
388 13 : void TransLocMemToRmtMemInstr(CcuInstr *instr, uint16_t rmtGSAId, uint16_t rmtXnId, uint16_t locGSAId, uint16_t locXnId,
389 : uint16_t lengthXnId, uint16_t channelId, uint16_t reduceDataType,
390 : uint16_t reduceOpCode, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId,
391 : uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn, uint16_t reduceEn)
392 : {
393 13 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMEMTORMTMEM_CODE);
394 13 : instr->v1.transLocMemToRmtMem.rmtGSAId = rmtGSAId;
395 13 : instr->v1.transLocMemToRmtMem.rmtXnId = rmtXnId;
396 13 : instr->v1.transLocMemToRmtMem.locGSAId = locGSAId;
397 13 : instr->v1.transLocMemToRmtMem.locXnId = locXnId;
398 13 : instr->v1.transLocMemToRmtMem.lengthXnId = lengthXnId;
399 13 : instr->v1.transLocMemToRmtMem.channelId = channelId;
400 13 : instr->v1.transLocMemToRmtMem.udfType = 0;
401 13 : instr->v1.transLocMemToRmtMem.reduceDataType = reduceDataType & 0xf;
402 13 : instr->v1.transLocMemToRmtMem.reduceOpCode = reduceOpCode & 0xf;
403 13 : instr->v1.transLocMemToRmtMem.clearType = clearType & 0x1;
404 13 : instr->v1.transLocMemToRmtMem.lengthEn = lengthEn & 0x1;
405 13 : instr->v1.transLocMemToRmtMem.reduceEn = reduceEn & 0x1;
406 13 : instr->v1.transLocMemToRmtMem.setCKEId = setCKEId;
407 13 : instr->v1.transLocMemToRmtMem.setCKEMask = setCKEMask;
408 13 : instr->v1.transLocMemToRmtMem.waitCKEId = waitCKEId;
409 13 : instr->v1.transLocMemToRmtMem.waitCKEMask = waitCKEMask;
410 13 : }
411 :
412 14 : void TransLocMemToLocMemInstr(CcuInstr *instr, uint16_t dstGSAId, uint16_t dstXnId, uint16_t srcGSAId, uint16_t srcXnId,
413 : uint16_t lengthXnId, uint16_t channelId, uint16_t setCKEId, uint16_t setCKEMask,
414 : uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t lengthEn)
415 : {
416 14 : instr->header = InstrHeader(TRANS_TYPE, TRANSLOCMEMTOLOCMEM_CODE);
417 14 : instr->v1.transLocMemToLocMem.dstGSAId = dstGSAId;
418 14 : instr->v1.transLocMemToLocMem.dstXnId = dstXnId;
419 14 : instr->v1.transLocMemToLocMem.srcGSAId = srcGSAId;
420 14 : instr->v1.transLocMemToLocMem.srcXnId = srcXnId;
421 14 : instr->v1.transLocMemToLocMem.lengthXnId = lengthXnId;
422 14 : instr->v1.transLocMemToLocMem.channelId = channelId;
423 14 : instr->v1.transLocMemToLocMem.clearType = clearType & 0x1;
424 14 : instr->v1.transLocMemToLocMem.lengthEn = lengthEn & 0x1;
425 14 : instr->v1.transLocMemToLocMem.setCKEId = setCKEId;
426 14 : instr->v1.transLocMemToLocMem.setCKEMask = setCKEMask;
427 14 : instr->v1.transLocMemToLocMem.waitCKEId = waitCKEId;
428 14 : instr->v1.transLocMemToLocMem.waitCKEMask = waitCKEMask;
429 14 : }
430 :
431 : // 本端CKE同步到远端CKE
432 : // rmtCKEId: 远端CKEId
433 : // locCKEId: 本端CKEId
434 : // locCKEMask: mask
435 : // 路径: channelId
436 31 : void SyncCKEInstr(CcuInstr *instr, uint16_t rmtCKEId, uint16_t locCKEId, uint16_t locCKEMask, uint16_t channelId,
437 : uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType)
438 : {
439 31 : instr->header = InstrHeader(TRANS_TYPE, SYNCCKE_CODE);
440 31 : instr->v1.syncCKE.rmtCKEId = rmtCKEId;
441 31 : instr->v1.syncCKE.locCKEId = locCKEId;
442 31 : instr->v1.syncCKE.locCKEMask = locCKEMask;
443 31 : instr->v1.syncCKE.channelId = channelId;
444 31 : instr->v1.syncCKE.clearType = clearType & 0x1;
445 31 : instr->v1.syncCKE.setCKEId = setCKEId;
446 31 : instr->v1.syncCKE.setCKEMask = setCKEMask;
447 31 : instr->v1.syncCKE.waitCKEId = waitCKEId;
448 31 : instr->v1.syncCKE.waitCKEMask = waitCKEMask;
449 31 : }
450 :
451 : // 本端<locGSAId>同步到远端<rmtGSAId> 同步完成后, 置位远端的<setRmtCKEId, setRmtCKEMask>
452 1 : void SyncGSAInstr(CcuInstr *instr, uint16_t rmtGSAId, uint16_t locGSAId, uint16_t channelId, uint16_t setRmtCKEId,
453 : uint16_t setRmtCKEMask, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId,
454 : uint16_t waitCKEMask, uint16_t clearType)
455 : {
456 1 : instr->header = InstrHeader(TRANS_TYPE, SYNCGSA_CODE);
457 1 : instr->v1.syncGSA.rmtGSAId = rmtGSAId;
458 1 : instr->v1.syncGSA.locGSAId = locGSAId;
459 1 : instr->v1.syncGSA.channelId = channelId;
460 1 : instr->v1.syncGSA.setRmtCKEId = setRmtCKEId;
461 1 : instr->v1.syncGSA.setRmtCKEMask = setRmtCKEMask;
462 1 : instr->v1.syncGSA.clearType = clearType & 0x1;
463 1 : instr->v1.syncGSA.setCKEId = setCKEId;
464 1 : instr->v1.syncGSA.setCKEMask = setCKEMask;
465 1 : instr->v1.syncGSA.waitCKEId = waitCKEId;
466 1 : instr->v1.syncGSA.waitCKEMask = waitCKEMask;
467 1 : }
468 :
469 : // 本端<locInputXnId, locOutputXnId>同步到远端<rmtInputXnId, rmtOutputXnId> 同步完成后, 置位远端的<setRmtCKEId,
470 : // setRmtCKEMask>
471 41 : void SyncXnInstr(CcuInstr *instr, uint16_t rmtXnId, uint16_t locXnId, uint16_t channelId, uint16_t setRmtCKEId,
472 : uint16_t setRmtCKEMask, uint16_t setCKEId, uint16_t setCKEMask, uint16_t waitCKEId,
473 : uint16_t waitCKEMask, uint16_t clearType)
474 : {
475 41 : instr->header = InstrHeader(TRANS_TYPE, SYNCXN_CODE);
476 41 : instr->v1.syncXn.rmtXnId = rmtXnId;
477 41 : instr->v1.syncXn.locXnId = locXnId;
478 41 : instr->v1.syncXn.channelId = channelId;
479 41 : instr->v1.syncXn.setRmtCKEId = setRmtCKEId;
480 41 : instr->v1.syncXn.setRmtCKEMask = setRmtCKEMask;
481 41 : instr->v1.syncXn.clearType = clearType & 0x1;
482 41 : instr->v1.syncXn.setCKEId = setCKEId;
483 41 : instr->v1.syncXn.setCKEMask = setCKEMask;
484 41 : instr->v1.syncXn.waitCKEId = waitCKEId;
485 41 : instr->v1.syncXn.waitCKEMask = waitCKEMask;
486 41 : }
487 :
488 : // MSA~MSH Reduce到 MSA
489 : // count: 参与Reduce的MS数目
490 : // castEn: 输出是否截断
491 : // dataType: Reduce数据类型
492 5 : void AddInstr(CcuInstr *instr, uint16_t *msId, uint16_t count, uint16_t castEn, uint16_t dataType, uint16_t setCKEId,
493 : uint16_t setCKEMask, uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t XnIdLength)
494 : {
495 5 : count -= 2; // CCU指令中指定count数为实际参与运算的MS数减2
496 5 : instr->header = InstrHeader(REDUCE_TYPE, ADD_CODE);
497 45 : for (uint16_t index = 0; index < CCU_REDUCE_MAX_MS; index++) {
498 40 : instr->v1.add.msId[index] = msId[index];
499 : }
500 5 : instr->v1.add.XnIdLength = XnIdLength;
501 5 : instr->v1.add.count = count & 0x7;
502 5 : instr->v1.add.castEn = castEn & 0x3;
503 5 : instr->v1.add.dataType = dataType & 0x1f;
504 5 : instr->v1.add.clearType = clearType & 0x1;
505 5 : instr->v1.add.setCKEId = setCKEId;
506 5 : instr->v1.add.setCKEMask = setCKEMask;
507 5 : instr->v1.add.waitCKEId = waitCKEId;
508 5 : instr->v1.add.waitCKEMask = waitCKEMask;
509 5 : }
510 :
511 2 : void MaxInstr(CcuInstr *instr, uint16_t *msId, uint16_t count, uint16_t dataType, uint16_t setCKEId,
512 : uint16_t setCKEMask, uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t XnIdLength)
513 : {
514 2 : count -= 2; // CCU指令中指定count数为实际参与运算的MS数减2
515 2 : instr->header = InstrHeader(REDUCE_TYPE, MAX_CODE);
516 18 : for (uint16_t index = 0; index < CCU_REDUCE_MAX_MS; index++) {
517 16 : instr->v1.add.msId[index] = msId[index];
518 : }
519 2 : instr->v1.max.XnIdLength = XnIdLength;
520 2 : instr->v1.max.count = count & 0x7;
521 2 : instr->v1.max.dataType = dataType & 0x1f;
522 2 : instr->v1.max.clearType = clearType & 0x1;
523 2 : instr->v1.max.setCKEId = setCKEId;
524 2 : instr->v1.max.setCKEMask = setCKEMask;
525 2 : instr->v1.max.waitCKEId = waitCKEId;
526 2 : instr->v1.max.waitCKEMask = waitCKEMask;
527 2 : }
528 :
529 2 : void MinInstr(CcuInstr *instr, uint16_t *msId, uint16_t count, uint16_t dataType, uint16_t setCKEId,
530 : uint16_t setCKEMask, uint16_t waitCKEId, uint16_t waitCKEMask, uint16_t clearType, uint16_t XnIdLength)
531 : {
532 2 : count -= 2; // CCU指令中指定count数为实际参与运算的MS数减2
533 2 : instr->header = InstrHeader(REDUCE_TYPE, MIN_CODE);
534 18 : for (uint16_t index = 0; index < CCU_REDUCE_MAX_MS; index++) {
535 16 : instr->v1.add.msId[index] = msId[index];
536 : }
537 2 : instr->v1.max.XnIdLength = XnIdLength;
538 2 : instr->v1.min.count = count & 0x7;
539 2 : instr->v1.min.dataType = dataType & 0x1f;
540 2 : instr->v1.min.clearType = clearType & 0x1;
541 2 : instr->v1.min.setCKEId = setCKEId;
542 2 : instr->v1.min.setCKEMask = setCKEMask;
543 2 : instr->v1.min.waitCKEId = waitCKEId;
544 2 : instr->v1.min.waitCKEMask = waitCKEMask;
545 2 : }
546 :
547 1 : std::string ParseLoadSqeArgsToGSAInstr(const CcuInstr *instr)
548 : {
549 1 : uint16_t gsaId = instr->v1.loadSqeArgsToGSA.gsaId;
550 1 : uint16_t sqeArgsId = instr->v1.loadSqeArgsToGSA.sqeArgsId;
551 :
552 1 : return StringFormat("Load SqeArg[%u] to GSA[%u]", sqeArgsId, gsaId);
553 : }
554 :
555 177 : static std::string ParseLoadSqeArgsToXnInstr(const CcuInstr *instr)
556 : {
557 177 : uint16_t xnId = instr->v1.loadSqeArgsToXn.xnId;
558 177 : uint16_t sqeArgsId = instr->v1.loadSqeArgsToXn.sqeArgsId;
559 :
560 177 : return StringFormat("Load SqeArg[%u] to Xn[%u]", sqeArgsId, xnId);
561 : }
562 :
563 40 : static std::string ParseLoadImdToGSAInstr(const CcuInstr *instr)
564 : {
565 40 : uint16_t gsaId = instr->v1.loadImdToGSA.gsaId;
566 40 : uint64_t immediate = instr->v1.loadImdToGSA.immediate;
567 :
568 40 : return StringFormat("Load immediate[%llu] to GSA[%u]", immediate, gsaId);
569 : }
570 :
571 491 : static std::string ParseLoadImdToXnInstr(const CcuInstr *instr)
572 : {
573 491 : uint16_t xnId = instr->v1.loadImdToXn.xnId;
574 491 : uint64_t immediate = instr->v1.loadImdToXn.immediate;
575 :
576 491 : if (instr->v1.loadImdToXn.secFlag == CCU_LOAD_TO_XN_SEC_INFO) {
577 32 : return StringFormat("Load immediate[tokenInfo] to Xn[%u]", xnId);
578 : }
579 :
580 459 : return StringFormat("Load immediate[%llu] to Xn[%u]", immediate, xnId);
581 : }
582 :
583 271 : static std::string ParseLoadGSAXnInstr(const CcuInstr *instr)
584 : {
585 271 : uint16_t gsAdId = instr->v1.loadGSAXn.gsAdId;
586 271 : uint16_t gsAmId = instr->v1.loadGSAXn.gsAmId;
587 271 : uint16_t xnId = instr->v1.loadGSAXn.xnId;
588 :
589 271 : return StringFormat("Load GSA[%u] + Xn[%u] to GSA[%u]", gsAmId, xnId, gsAdId);
590 : }
591 :
592 97 : static std::string ParseLoadGSAGSAInstr(const CcuInstr *instr)
593 : {
594 97 : uint16_t gsAdId = instr->v1.loadGSAGSA.gsAdId;
595 97 : uint16_t gsAmId = instr->v1.loadGSAGSA.gsAmId;
596 97 : uint16_t gsAnId = instr->v1.loadGSAGSA.gsAnId;
597 :
598 97 : return StringFormat("Load GSA[%u] + GSA[%u] to GSA[%u]", gsAmId, gsAnId, gsAdId);
599 : }
600 :
601 393 : static std::string ParseLoadXXInstr(const CcuInstr *instr)
602 : {
603 393 : uint16_t xdId = instr->v1.loadXX.xdId;
604 393 : uint16_t xmId = instr->v1.loadXX.xmId;
605 393 : uint16_t xnId = instr->v1.loadXX.xnId;
606 :
607 393 : return StringFormat("Load Xn[%u] + Xn[%u] to Xn[%u]", xmId, xnId, xdId);
608 : }
609 :
610 19 : static std::string ParseLoopInstr(const CcuInstr *instr)
611 : {
612 19 : uint16_t startInstrId = instr->v1.loop.startInstrId;
613 19 : uint16_t endInstrId = instr->v1.loop.endInstrId;
614 19 : uint16_t xnId = instr->v1.loop.xnId;
615 :
616 19 : return StringFormat("Loop From startInstrId[%u] to endInstrId[%u] with loopXn[%u]", startInstrId, endInstrId, xnId);
617 : }
618 :
619 13 : static std::string ParseLoopGroupInstr(const CcuInstr *instr)
620 : {
621 13 : uint16_t startLoopInstrId = instr->v1.loopGroup.startLoopInstrId;
622 13 : uint16_t xnId = instr->v1.loopGroup.xnId;
623 13 : uint16_t xmId = instr->v1.loopGroup.xmId;
624 13 : uint16_t highPerfModeEn = instr->v1.loopGroup.highPerfModeEn;
625 :
626 : return StringFormat("LoopGroup From startLoopInstrId[%u] with loopGroupXn[%u], offsetXn[%u] and highPerfModeEn[%u]",
627 13 : startLoopInstrId, xnId, xmId, highPerfModeEn);
628 : }
629 :
630 134 : static std::string ParseSetCKEInstr(const CcuInstr *instr)
631 : {
632 134 : uint16_t clearType = instr->v1.setCKE.clearType;
633 134 : uint16_t setCKEId = instr->v1.setCKE.setCKEId;
634 134 : uint16_t setCKEMask = instr->v1.setCKE.setCKEMask;
635 134 : uint16_t waitCKEId = instr->v1.setCKE.waitCKEId;
636 134 : uint16_t waitCKEMask = instr->v1.setCKE.waitCKEMask;
637 :
638 : return StringFormat("Wait CKE[%u:%04x], Set CKE[%u:%04x], clearType[%u]", waitCKEId, waitCKEMask, setCKEId,
639 134 : setCKEMask, clearType);
640 : }
641 :
642 25 : static std::string ParseClearCKEInstr(const CcuInstr *instr)
643 : {
644 25 : uint16_t clearType = instr->v1.clearCKE.clearType;
645 25 : uint16_t clearCKEId = instr->v1.clearCKE.clearCKEId;
646 25 : uint16_t clearMask = instr->v1.clearCKE.clearMask;
647 25 : uint16_t waitCKEId = instr->v1.clearCKE.waitCKEId;
648 25 : uint16_t waitCKEMask = instr->v1.clearCKE.waitCKEMask;
649 :
650 : return StringFormat("Wait CKE[%u:%04x], Clear CKE[%u:%04x], clearType[%u]", waitCKEId, waitCKEMask, clearCKEId,
651 25 : clearMask, clearType);
652 : }
653 :
654 125 : static std::string ParseJumpInstr(const CcuInstr *instr)
655 : {
656 125 : uint16_t dstInstrXnId = instr->v1.jmp.dstInstrXnId;
657 125 : uint16_t conditionXnId = instr->v1.jmp.conditionXnId;
658 125 : uint64_t expectData = instr->v1.jmp.expectData;
659 :
660 : return StringFormat("When conditionXn[%u] not equal to expectData[%llu], Jump To InstrIdXn[%u]", conditionXnId,
661 125 : expectData, dstInstrXnId);
662 : }
663 :
664 13 : static std::string ParseTransLocMemToLocMSInstr(const CcuInstr *instr)
665 : {
666 13 : uint16_t locMSId = instr->v1.transLocMemToLocMS.locMSId;
667 13 : uint16_t locGSAId = instr->v1.transLocMemToLocMS.locGSAId;
668 13 : uint16_t locXnId = instr->v1.transLocMemToLocMS.locXnId;
669 13 : uint16_t lengthXnId = instr->v1.transLocMemToLocMS.lengthXnId;
670 13 : uint16_t channelId = instr->v1.transLocMemToLocMS.channelId;
671 13 : uint16_t clearType = instr->v1.transLocMemToLocMS.clearType;
672 13 : uint16_t lengthEn = instr->v1.transLocMemToLocMS.lengthEn;
673 13 : uint16_t setCKEId = instr->v1.transLocMemToLocMS.setCKEId;
674 13 : uint16_t setCKEMask = instr->v1.transLocMemToLocMS.setCKEMask;
675 13 : uint16_t waitCKEId = instr->v1.transLocMemToLocMS.waitCKEId;
676 13 : uint16_t waitCKEMask = instr->v1.transLocMemToLocMS.waitCKEMask;
677 :
678 : return StringFormat("Wait CKE[%u:%04x], Trans LocMem[%u:%u] To LocMS[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
679 : "CKE[%u:%04x], clearType[%u], lengthEn[%u]",
680 13 : waitCKEId, waitCKEMask, locGSAId, locXnId, locMSId / 0x8000, locMSId % 0x8000, lengthXnId,
681 13 : channelId, setCKEId, setCKEMask, clearType, lengthEn);
682 : }
683 :
684 1 : static std::string ParseTransRmtMemToLocMSInstr(const CcuInstr *instr)
685 : {
686 1 : uint16_t locMSId = instr->v1.transRmtMemToLocMS.locMSId;
687 1 : uint16_t rmtGSAId = instr->v1.transRmtMemToLocMS.rmtGSAId;
688 1 : uint16_t rmtXnId = instr->v1.transRmtMemToLocMS.rmtXnId;
689 1 : uint16_t lengthXnId = instr->v1.transRmtMemToLocMS.lengthXnId;
690 1 : uint16_t channelId = instr->v1.transRmtMemToLocMS.channelId;
691 1 : uint16_t clearType = instr->v1.transRmtMemToLocMS.clearType;
692 1 : uint16_t lengthEn = instr->v1.transRmtMemToLocMS.lengthEn;
693 1 : uint16_t setCKEId = instr->v1.transRmtMemToLocMS.setCKEId;
694 1 : uint16_t setCKEMask = instr->v1.transRmtMemToLocMS.setCKEMask;
695 1 : uint16_t waitCKEId = instr->v1.transRmtMemToLocMS.waitCKEId;
696 1 : uint16_t waitCKEMask = instr->v1.transRmtMemToLocMS.waitCKEMask;
697 :
698 : return StringFormat("Wait CKE[%u:%04x], Trans RmtMem[%u:%u] To LocMS[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
699 : "CKE[%u:%04x], clearType[%u], lengthEn[%u]",
700 1 : waitCKEId, waitCKEMask, rmtGSAId, rmtXnId, locMSId / 0x8000, locMSId % 0x8000, lengthXnId,
701 1 : channelId, setCKEId, setCKEMask, clearType, lengthEn);
702 : }
703 :
704 13 : static std::string ParseTransLocMSToLocMemInstr(const CcuInstr *instr)
705 : {
706 13 : uint16_t locGSAId = instr->v1.transLocMSToLocMem.locGSAId;
707 13 : uint16_t locXnId = instr->v1.transLocMSToLocMem.locXnId;
708 13 : uint16_t locMSId = instr->v1.transLocMSToLocMem.locMSId;
709 13 : uint16_t lengthXnId = instr->v1.transLocMSToLocMem.lengthXnId;
710 13 : uint16_t channelId = instr->v1.transLocMSToLocMem.channelId;
711 13 : uint16_t clearType = instr->v1.transLocMSToLocMem.clearType;
712 13 : uint16_t lengthEn = instr->v1.transLocMSToLocMem.lengthEn;
713 13 : uint16_t setCKEId = instr->v1.transLocMSToLocMem.setCKEId;
714 13 : uint16_t setCKEMask = instr->v1.transLocMSToLocMem.setCKEMask;
715 13 : uint16_t waitCKEId = instr->v1.transLocMSToLocMem.waitCKEId;
716 13 : uint16_t waitCKEMask = instr->v1.transLocMSToLocMem.waitCKEMask;
717 :
718 : return StringFormat("Wait CKE[%u:%04x], Trans LocMS[%u:%u] To LocMem[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
719 : "CKE[%u:%04x], clearType[%u], lengthEn[%u]",
720 13 : waitCKEId, waitCKEMask, locMSId / 0x8000, locMSId % 0x8000, locGSAId, locXnId, lengthXnId,
721 13 : channelId, setCKEId, setCKEMask, clearType, lengthEn);
722 : }
723 :
724 29 : static std::string ParseTransLocMSToRmtMemInstr(const CcuInstr *instr)
725 : {
726 29 : uint16_t rmtGSAId = instr->v1.transLocMSToRmtMem.rmtGSAId;
727 29 : uint16_t rmtXnId = instr->v1.transLocMSToRmtMem.rmtXnId;
728 29 : uint16_t locMSId = instr->v1.transLocMSToRmtMem.locMSId;
729 29 : uint16_t lengthXnId = instr->v1.transLocMSToRmtMem.lengthXnId;
730 29 : uint16_t channelId = instr->v1.transLocMSToRmtMem.channelId;
731 29 : uint16_t clearType = instr->v1.transLocMSToRmtMem.clearType;
732 29 : uint16_t lengthEn = instr->v1.transLocMSToRmtMem.lengthEn;
733 29 : uint16_t setCKEId = instr->v1.transLocMSToRmtMem.setCKEId;
734 29 : uint16_t setCKEMask = instr->v1.transLocMSToRmtMem.setCKEMask;
735 29 : uint16_t waitCKEId = instr->v1.transLocMSToRmtMem.waitCKEId;
736 29 : uint16_t waitCKEMask = instr->v1.transLocMSToRmtMem.waitCKEMask;
737 :
738 : return StringFormat("Wait CKE[%u:%04x], Trans LocMS[%u:%u] To RmtMem[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
739 : "CKE[%u:%04x], clearType[%u], lengthEn[%u]",
740 29 : waitCKEId, waitCKEMask, locMSId / 0x8000, locMSId % 0x8000, rmtGSAId, rmtXnId, lengthXnId,
741 29 : channelId, setCKEId, setCKEMask, clearType, lengthEn);
742 : }
743 :
744 1 : static std::string ParseTransRmtMSToLocMemInstr(const CcuInstr *instr)
745 : {
746 1 : uint16_t locGSAId = instr->v1.transRmtMSToLocMem.locGSAId;
747 1 : uint16_t locXnId = instr->v1.transRmtMSToLocMem.locXnId;
748 1 : uint16_t rmtMSId = instr->v1.transRmtMSToLocMem.rmtMSId;
749 1 : uint16_t lengthXnId = instr->v1.transRmtMSToLocMem.lengthXnId;
750 1 : uint16_t channelId = instr->v1.transRmtMSToLocMem.channelId;
751 1 : uint16_t clearType = instr->v1.transRmtMSToLocMem.clearType;
752 1 : uint16_t lengthEn = instr->v1.transRmtMSToLocMem.lengthEn;
753 1 : uint16_t setCKEId = instr->v1.transRmtMSToLocMem.setCKEId;
754 1 : uint16_t setCKEMask = instr->v1.transRmtMSToLocMem.setCKEMask;
755 1 : uint16_t waitCKEId = instr->v1.transRmtMSToLocMem.waitCKEId;
756 1 : uint16_t waitCKEMask = instr->v1.transRmtMSToLocMem.waitCKEMask;
757 :
758 : return StringFormat("Wait CKE[%u:%04x], Trans RmtMS[%u:%u] To LocMem[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
759 : "CKE[%u:%04x], clearType[%u], lengthEn[%u]",
760 1 : waitCKEId, waitCKEMask, rmtMSId / 0x8000, rmtMSId % 0x8000, locGSAId, locXnId, lengthXnId,
761 1 : channelId, setCKEId, setCKEMask, clearType, lengthEn);
762 : }
763 :
764 1 : static std::string ParseTransLocMSToLocMSInstr(const CcuInstr *instr)
765 : {
766 1 : uint16_t dstMSId = instr->v1.transLocMSToLocMS.dstMSId;
767 1 : uint16_t srcMSId = instr->v1.transLocMSToLocMS.srcMSId;
768 1 : uint16_t lengthXnId = instr->v1.transLocMSToLocMS.lengthXnId;
769 1 : uint16_t channelId = instr->v1.transLocMSToLocMS.channelId;
770 1 : uint16_t clearType = instr->v1.transLocMSToLocMS.clearType;
771 1 : uint16_t lengthEn = instr->v1.transLocMSToLocMS.lengthEn;
772 1 : uint16_t setCKEId = instr->v1.transLocMSToLocMS.setCKEId;
773 1 : uint16_t setCKEMask = instr->v1.transLocMSToLocMS.setCKEMask;
774 1 : uint16_t waitCKEId = instr->v1.transLocMSToLocMS.waitCKEId;
775 1 : uint16_t waitCKEMask = instr->v1.transLocMSToLocMS.waitCKEMask;
776 :
777 : return StringFormat("Wait CKE[%u:%04x], Trans LocMS[%u:%u] To LocMS[%u:%u] With LengthXn[%u] Use Channel[%u], "
778 : "Set CKE[%u:%04x], "
779 : "clearType[%u], lengthEn[%u]",
780 1 : waitCKEId, waitCKEMask, srcMSId / 0x8000, srcMSId % 0x8000, dstMSId / 0x8000, dstMSId % 0x8000,
781 1 : lengthXnId, channelId, setCKEId, setCKEMask, clearType, lengthEn);
782 : }
783 :
784 1 : static std::string ParseTransRmtMSToLocMSInstr(const CcuInstr *instr)
785 : {
786 1 : uint16_t locMSId = instr->v1.transRmtMSToLocMS.locMSId;
787 1 : uint16_t rmtMSId = instr->v1.transRmtMSToLocMS.rmtMSId;
788 1 : uint16_t lengthXnId = instr->v1.transRmtMSToLocMS.lengthXnId;
789 1 : uint16_t channelId = instr->v1.transRmtMSToLocMS.channelId;
790 1 : uint16_t clearType = instr->v1.transRmtMSToLocMS.clearType;
791 1 : uint16_t lengthEn = instr->v1.transRmtMSToLocMS.lengthEn;
792 1 : uint16_t setCKEId = instr->v1.transRmtMSToLocMS.setCKEId;
793 1 : uint16_t setCKEMask = instr->v1.transRmtMSToLocMS.setCKEMask;
794 1 : uint16_t waitCKEId = instr->v1.transRmtMSToLocMS.waitCKEId;
795 1 : uint16_t waitCKEMask = instr->v1.transRmtMSToLocMS.waitCKEMask;
796 :
797 : return StringFormat("Wait CKE[%u:%04x], Trans RmtMS[%u:%u] To LocMS[%u:%u] With LengthXn[%u] Use Channel[%u], "
798 : "Set CKE[%u:%04x], "
799 : "clearType[%u], lengthEn[%u]",
800 1 : waitCKEId, waitCKEMask, rmtMSId / 0x8000, rmtMSId % 0x8000, locMSId / 0x8000, locMSId % 0x8000,
801 1 : lengthXnId, channelId, setCKEId, setCKEMask, clearType, lengthEn);
802 : }
803 :
804 1 : static std::string ParseTransLocMSToRmtMSInstr(const CcuInstr *instr)
805 : {
806 1 : uint16_t rmtMSId = instr->v1.transLocMSToRmtMS.rmtMSId;
807 1 : uint16_t locMSId = instr->v1.transLocMSToRmtMS.locMSId;
808 1 : uint16_t lengthXnId = instr->v1.transLocMSToRmtMS.lengthXnId;
809 1 : uint16_t channelId = instr->v1.transLocMSToRmtMS.channelId;
810 1 : uint16_t setRmtCKEId = instr->v1.transLocMSToRmtMS.setRmtCKEId;
811 1 : uint16_t setRmtCKEMask = instr->v1.transLocMSToRmtMS.setRmtCKEMask;
812 :
813 1 : uint16_t clearType = instr->v1.transLocMSToRmtMS.clearType;
814 1 : uint16_t lengthEn = instr->v1.transLocMSToRmtMS.lengthEn;
815 1 : uint16_t setCKEId = instr->v1.transLocMSToRmtMS.setCKEId;
816 1 : uint16_t setCKEMask = instr->v1.transLocMSToRmtMS.setCKEMask;
817 1 : uint16_t waitCKEId = instr->v1.transLocMSToRmtMS.waitCKEId;
818 1 : uint16_t waitCKEMask = instr->v1.transLocMSToRmtMS.waitCKEMask;
819 :
820 : return StringFormat("Wait CKE[%u:%04x], Trans LocMS[%u:%u] To RmtMS[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
821 : "RmtCKE[%u:%04x], Set CKE[%u:%04x], clearType[%u], lengthEn[%u]",
822 1 : waitCKEId, waitCKEMask, locMSId / 0x8000, locMSId % 0x8000, rmtMSId / 0x8000, rmtMSId % 0x8000,
823 1 : lengthXnId, channelId, setRmtCKEId, setRmtCKEMask, setCKEId, setCKEMask, clearType, lengthEn);
824 : }
825 :
826 5 : static std::string ParseTransRmtMemToLocMemInstr(const CcuInstr *instr)
827 : {
828 5 : uint16_t locGSAId = instr->v1.transRmtMemToLocMem.locGSAId;
829 5 : uint16_t locXnId = instr->v1.transRmtMemToLocMem.locXnId;
830 5 : uint16_t rmtGSAId = instr->v1.transRmtMemToLocMem.rmtGSAId;
831 5 : uint16_t rmtXnId = instr->v1.transRmtMemToLocMem.rmtXnId;
832 5 : uint16_t lengthXnId = instr->v1.transRmtMemToLocMem.lengthXnId;
833 5 : uint16_t channelId = instr->v1.transRmtMemToLocMem.channelId;
834 5 : uint16_t reduceDataType = instr->v1.transRmtMemToLocMem.reduceDataType;
835 5 : uint16_t reduceOpCode = instr->v1.transRmtMemToLocMem.reduceOpCode;
836 5 : uint16_t clearType = instr->v1.transRmtMemToLocMem.clearType;
837 5 : uint16_t lengthEn = instr->v1.transRmtMemToLocMem.lengthEn;
838 5 : uint16_t reduceEn = instr->v1.transRmtMemToLocMem.reduceEn;
839 5 : uint16_t setCKEId = instr->v1.transRmtMemToLocMem.setCKEId;
840 5 : uint16_t setCKEMask = instr->v1.transRmtMemToLocMem.setCKEMask;
841 5 : uint16_t waitCKEId = instr->v1.transRmtMemToLocMem.waitCKEId;
842 5 : uint16_t waitCKEMask = instr->v1.transRmtMemToLocMem.waitCKEMask;
843 :
844 : return StringFormat(
845 : "Wait CKE[%u:%04x], Trans RmtMem[%u:%u] To LocMem[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
846 : "CKE[%u:%04x], clearType[%u], lengthEn[%u], DataType[%u], ReduceType[%u] reduceEn[%u]",
847 : waitCKEId, waitCKEMask, rmtGSAId, rmtXnId, locGSAId, locXnId, lengthXnId, channelId, setCKEId, setCKEMask,
848 5 : clearType, lengthEn, reduceDataType, reduceOpCode, reduceEn);
849 : }
850 :
851 23 : static std::string ParseTransLocMemToRmtMemInstr(const CcuInstr *instr)
852 : {
853 23 : uint16_t rmtGSAId = instr->v1.transLocMemToRmtMem.rmtGSAId;
854 23 : uint16_t rmtXnId = instr->v1.transLocMemToRmtMem.rmtXnId;
855 23 : uint16_t locGSAId = instr->v1.transLocMemToRmtMem.locGSAId;
856 23 : uint16_t locXnId = instr->v1.transLocMemToRmtMem.locXnId;
857 23 : uint16_t lengthXnId = instr->v1.transLocMemToRmtMem.lengthXnId;
858 23 : uint16_t channelId = instr->v1.transLocMemToRmtMem.channelId;
859 23 : uint16_t reduceDataType = instr->v1.transLocMemToRmtMem.reduceDataType;
860 23 : uint16_t reduceOpCode = instr->v1.transLocMemToRmtMem.reduceOpCode;
861 23 : uint16_t clearType = instr->v1.transLocMemToRmtMem.clearType;
862 23 : uint16_t lengthEn = instr->v1.transLocMemToRmtMem.lengthEn;
863 23 : uint16_t reduceEn = instr->v1.transLocMemToRmtMem.reduceEn;
864 23 : uint16_t setCKEId = instr->v1.transLocMemToRmtMem.setCKEId;
865 23 : uint16_t setCKEMask = instr->v1.transLocMemToRmtMem.setCKEMask;
866 23 : uint16_t waitCKEId = instr->v1.transLocMemToRmtMem.waitCKEId;
867 23 : uint16_t waitCKEMask = instr->v1.transLocMemToRmtMem.waitCKEMask;
868 :
869 : return StringFormat(
870 : "Wait CKE[%u:%04x], Trans LocMem[%u:%u] To RmtMem[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
871 : "CKE[%u:%04x], clearType[%u], lengthEn[%u], DataType[%u], ReduceType[%u] reduceEn[%u]",
872 : waitCKEId, waitCKEMask, locGSAId, locXnId, rmtGSAId, rmtXnId, lengthXnId, channelId, setCKEId, setCKEMask,
873 23 : clearType, lengthEn, reduceDataType, reduceOpCode, reduceEn);
874 : }
875 :
876 19 : static std::string ParseTransLocMemToLocMemInstr(const CcuInstr *instr)
877 : {
878 19 : uint16_t dstGSAId = instr->v1.transLocMemToLocMem.dstGSAId;
879 19 : uint16_t dstXnId = instr->v1.transLocMemToLocMem.dstXnId;
880 19 : uint16_t srcGSAId = instr->v1.transLocMemToLocMem.srcGSAId;
881 19 : uint16_t srcXnId = instr->v1.transLocMemToLocMem.srcXnId;
882 19 : uint16_t lengthXnId = instr->v1.transLocMemToLocMem.lengthXnId;
883 19 : uint16_t channelId = instr->v1.transLocMemToLocMem.channelId;
884 19 : uint16_t clearType = instr->v1.transLocMemToLocMem.clearType;
885 19 : uint16_t lengthEn = instr->v1.transLocMemToLocMem.lengthEn;
886 19 : uint16_t setCKEId = instr->v1.transLocMemToLocMem.setCKEId;
887 19 : uint16_t setCKEMask = instr->v1.transLocMemToLocMem.setCKEMask;
888 19 : uint16_t waitCKEId = instr->v1.transLocMemToLocMem.waitCKEId;
889 19 : uint16_t waitCKEMask = instr->v1.transLocMemToLocMem.waitCKEMask;
890 :
891 : return StringFormat(
892 : "Wait CKE[%u:%04x], Trans LocMem[%u:%u] To LocMem[%u:%u] With LengthXn[%u] Use Channel[%u], Set "
893 : "CKE[%u:%04x], clearType[%u], lengthEn[%u]",
894 : waitCKEId, waitCKEMask, srcGSAId, srcXnId, dstGSAId, dstXnId, lengthXnId, channelId, setCKEId, setCKEMask,
895 19 : clearType, lengthEn);
896 : }
897 :
898 59 : static std::string ParseSyncCKEInstr(const CcuInstr *instr)
899 : {
900 59 : uint16_t rmtCKEId = instr->v1.syncCKE.rmtCKEId;
901 59 : uint16_t locCKEId = instr->v1.syncCKE.locCKEId;
902 59 : uint16_t locCKEMask = instr->v1.syncCKE.locCKEMask;
903 59 : uint16_t channelId = instr->v1.syncCKE.channelId;
904 59 : uint16_t clearType = instr->v1.syncCKE.clearType;
905 59 : uint16_t setCKEId = instr->v1.syncCKE.setCKEId;
906 59 : uint16_t setCKEMask = instr->v1.syncCKE.setCKEMask;
907 59 : uint16_t waitCKEId = instr->v1.syncCKE.waitCKEId;
908 59 : uint16_t waitCKEMask = instr->v1.syncCKE.waitCKEMask;
909 :
910 : return StringFormat("Wait CKE[%u:%04x], Sync LocCKE[%u:%04x] To rmtCKE[%u:%04x] Use Channel[%u], Set "
911 : "CKE[%u:%04x], clearType[%u]",
912 : waitCKEId, waitCKEMask, locCKEId, locCKEMask, rmtCKEId, locCKEMask, channelId, setCKEId,
913 59 : setCKEMask, clearType);
914 : }
915 :
916 1 : static std::string ParseSyncGSAInstr(const CcuInstr *instr)
917 : {
918 1 : uint16_t rmtGSAId = instr->v1.syncGSA.rmtGSAId;
919 1 : uint16_t locGSAId = instr->v1.syncGSA.locGSAId;
920 1 : uint16_t channelId = instr->v1.syncGSA.channelId;
921 1 : uint16_t setRmtCKEId = instr->v1.syncGSA.setRmtCKEId;
922 1 : uint16_t setRmtCKEMask = instr->v1.syncGSA.setRmtCKEMask;
923 1 : uint16_t clearType = instr->v1.syncGSA.clearType;
924 1 : uint16_t setCKEId = instr->v1.syncGSA.setCKEId;
925 1 : uint16_t setCKEMask = instr->v1.syncGSA.setCKEMask;
926 1 : uint16_t waitCKEId = instr->v1.syncGSA.waitCKEId;
927 1 : uint16_t waitCKEMask = instr->v1.syncGSA.waitCKEMask;
928 :
929 : return StringFormat(
930 : "Wait CKE[%u:%04x], Sync locGSAId[%u] To rmtGSAId[%u] Use Channel[%u], Set rmtCKE[%u:%04x], Set "
931 : "CKE[%u:%04x], clearType[%u]",
932 : waitCKEId, waitCKEMask, locGSAId, rmtGSAId, channelId, setRmtCKEId, setRmtCKEMask, setCKEId, setCKEMask,
933 1 : clearType);
934 : }
935 :
936 79 : static std::string ParseSyncXnInstr(const CcuInstr *instr)
937 : {
938 79 : uint16_t rmtXnId = instr->v1.syncXn.rmtXnId;
939 79 : uint16_t locXnId = instr->v1.syncXn.locXnId;
940 79 : uint16_t channelId = instr->v1.syncXn.channelId;
941 79 : uint16_t setRmtCKEId = instr->v1.syncXn.setRmtCKEId;
942 79 : uint16_t setRmtCKEMask = instr->v1.syncXn.setRmtCKEMask;
943 79 : uint16_t clearType = instr->v1.syncXn.clearType;
944 79 : uint16_t setCKEId = instr->v1.syncXn.setCKEId;
945 79 : uint16_t setCKEMask = instr->v1.syncXn.setCKEMask;
946 79 : uint16_t waitCKEId = instr->v1.syncXn.waitCKEId;
947 79 : uint16_t waitCKEMask = instr->v1.syncXn.waitCKEMask;
948 :
949 : return StringFormat("Wait CKE[%u:%04x], Sync locXnId[%u] To rmtXnId[%u] Use Channel[%u], Set rmtCKE[%u:%04x], Set "
950 : "CKE[%u:%04x], clearType[%u]",
951 : waitCKEId, waitCKEMask, locXnId, rmtXnId, channelId, setRmtCKEId, setRmtCKEMask, setCKEId,
952 79 : setCKEMask, clearType);
953 : }
954 :
955 4 : static std::string ParseMSList(const CcuInstr *instr)
956 : {
957 : // 待实现,检查sqe类型
958 : uint16_t msId[CCU_REDUCE_MAX_MS];
959 4 : uint16_t count = instr->v1.add.count;
960 36 : for (uint16_t index = 0; index < CCU_REDUCE_MAX_MS; index++) {
961 32 : msId[index] = instr->v1.add.msId[index];
962 : }
963 :
964 : // CCU指令中指定count数为实际参与运算的MS数减2,因此当count + 2大于CCU_REDUCE_MAX_MS时,说明MS列表中的MS数量超过了CCU指令的最大支持数量,此时无法正确解析MS列表,直接返回"MS[]"
965 4 : if (count + 2 > CCU_REDUCE_MAX_MS) {
966 2 : return "MS[]";
967 : }
968 :
969 3 : std::string res = "MS[";
970 21 : for (uint16_t i = 0; i < count + 2; i++) { // 循环范围 0~count + 2
971 18 : if (i == count + 1) {
972 3 : res += std::to_string(msId[i] / 0x8000) + ":" + std::to_string(msId[i] % 0x8000) + "]";
973 : } else {
974 15 : res += std::to_string(msId[i] / 0x8000) + ":" + std::to_string(msId[i] % 0x8000) + ", ";
975 : }
976 : }
977 3 : return res;
978 3 : }
979 :
980 2 : static std::string ParseAddInstr(const CcuInstr *instr)
981 : {
982 2 : uint16_t count = instr->v1.add.count;
983 2 : uint16_t castEn = instr->v1.add.castEn;
984 2 : uint16_t dataType = instr->v1.add.dataType;
985 2 : uint16_t clearType = instr->v1.add.clearType;
986 2 : uint16_t setCKEId = instr->v1.add.setCKEId;
987 2 : uint16_t setCKEMask = instr->v1.add.setCKEMask;
988 2 : uint16_t waitCKEId = instr->v1.add.waitCKEId;
989 2 : uint16_t waitCKEMask = instr->v1.add.waitCKEMask;
990 :
991 : return StringFormat(
992 : "Wait CKE[%u:%04x], Add %s with Count[%u], DataType[%u] and CastEn[%u], Set CKE[%u:%04x], clearType[%u]",
993 4 : waitCKEId, waitCKEMask, ParseMSList(instr).c_str(), count, dataType, castEn, setCKEId, setCKEMask, clearType);
994 : }
995 :
996 1 : static std::string ParseMaxInstr(const CcuInstr *instr)
997 : {
998 1 : uint16_t count = instr->v1.max.count;
999 1 : uint16_t dataType = instr->v1.max.dataType;
1000 1 : uint16_t clearType = instr->v1.max.clearType;
1001 1 : uint16_t setCKEId = instr->v1.max.setCKEId;
1002 1 : uint16_t setCKEMask = instr->v1.max.setCKEMask;
1003 1 : uint16_t waitCKEId = instr->v1.max.waitCKEId;
1004 1 : uint16_t waitCKEMask = instr->v1.max.waitCKEMask;
1005 :
1006 : return StringFormat(
1007 : "Wait CKE[%u:%04x], Max %s with Count[%u], DataType[%u], Set CKE[%u:%04x], clearType[%u]",
1008 2 : waitCKEId, waitCKEMask, ParseMSList(instr).c_str(), count, dataType, setCKEId, setCKEMask, clearType);
1009 : }
1010 :
1011 1 : static std::string ParseMinInstr(const CcuInstr *instr)
1012 : {
1013 1 : uint16_t count = instr->v1.min.count;
1014 1 : uint16_t dataType = instr->v1.min.dataType;
1015 1 : uint16_t clearType = instr->v1.min.clearType;
1016 1 : uint16_t setCKEId = instr->v1.min.setCKEId;
1017 1 : uint16_t setCKEMask = instr->v1.min.setCKEMask;
1018 1 : uint16_t waitCKEId = instr->v1.min.waitCKEId;
1019 1 : uint16_t waitCKEMask = instr->v1.min.waitCKEMask;
1020 :
1021 : return StringFormat(
1022 : "Wait CKE[%u:%04x], Min %s with Count[%u], DataType[%u], Set CKE[%u:%04x], clearType[%u]",
1023 2 : waitCKEId, waitCKEMask, ParseMSList(instr).c_str(), count, dataType, setCKEId, setCKEMask, clearType);
1024 : }
1025 :
1026 : using ParseInstrFunc = std::string (*)(const CcuInstr *);
1027 :
1028 : static std::unordered_map<uint16_t, ParseInstrFunc> g_parseInstrSqeMap = {
1029 : {InstrHeader(LOAD_TYPE, LOADSQEARGSTOGSA_CODE).header, &ParseLoadSqeArgsToGSAInstr},
1030 : {InstrHeader(LOAD_TYPE, LOADSQEARGSTOXN_CODE).header, &ParseLoadSqeArgsToXnInstr},
1031 : {InstrHeader(LOAD_TYPE, LOADIMDTOGSA_CODE).header, &ParseLoadImdToGSAInstr},
1032 : {InstrHeader(LOAD_TYPE, LOADIMDTOXN_CODE).header, &ParseLoadImdToXnInstr},
1033 : {InstrHeader(LOAD_TYPE, LOADGSAXN_CODE).header, &ParseLoadGSAXnInstr},
1034 : {InstrHeader(LOAD_TYPE, LOADGSAGSA_CODE).header, &ParseLoadGSAGSAInstr},
1035 : {InstrHeader(LOAD_TYPE, LOADXX_CODE).header, &ParseLoadXXInstr},
1036 : {InstrHeader(CTRL_TYPE, LOOP_CODE).header, &ParseLoopInstr},
1037 : {InstrHeader(CTRL_TYPE, LOOPGROUP_CODE).header, &ParseLoopGroupInstr},
1038 : {InstrHeader(CTRL_TYPE, SETCKE_CODE).header, &ParseSetCKEInstr},
1039 : {InstrHeader(CTRL_TYPE, CLEARCKE_CODE).header, &ParseClearCKEInstr},
1040 : {InstrHeader(CTRL_TYPE, JMP_CODE).header, &ParseJumpInstr},
1041 : {InstrHeader(TRANS_TYPE, TRANSLOCMEMTOLOCMS_CODE).header, &ParseTransLocMemToLocMSInstr},
1042 : {InstrHeader(TRANS_TYPE, TRANSRMTMEMTOLOCMS_CODE).header, &ParseTransRmtMemToLocMSInstr},
1043 : {InstrHeader(TRANS_TYPE, TRANSLOCMSTOLOCMEM_CODE).header, &ParseTransLocMSToLocMemInstr},
1044 : {InstrHeader(TRANS_TYPE, TRANSLOCMSTORMTMEM_CODE).header, &ParseTransLocMSToRmtMemInstr},
1045 : {InstrHeader(TRANS_TYPE, TRANSRMTMSTOLOCMEM_CODE).header, &ParseTransRmtMSToLocMemInstr},
1046 : {InstrHeader(TRANS_TYPE, TRANSLOCMSTOLOCMS_CODE).header, &ParseTransLocMSToLocMSInstr},
1047 : {InstrHeader(TRANS_TYPE, TRANSRMTMSTOLOCMS_CODE).header, &ParseTransRmtMSToLocMSInstr},
1048 : {InstrHeader(TRANS_TYPE, TRANSLOCMSTORMTMS_CODE).header, &ParseTransLocMSToRmtMSInstr},
1049 : {InstrHeader(TRANS_TYPE, TRANSRMTMEMTOLOCMEM_CODE).header, &ParseTransRmtMemToLocMemInstr},
1050 : {InstrHeader(TRANS_TYPE, TRANSLOCMEMTORMTMEM_CODE).header, &ParseTransLocMemToRmtMemInstr},
1051 : {InstrHeader(TRANS_TYPE, TRANSLOCMEMTOLOCMEM_CODE).header, &ParseTransLocMemToLocMemInstr},
1052 : {InstrHeader(TRANS_TYPE, SYNCCKE_CODE).header, &ParseSyncCKEInstr},
1053 : {InstrHeader(TRANS_TYPE, SYNCGSA_CODE).header, &ParseSyncGSAInstr},
1054 : {InstrHeader(TRANS_TYPE, SYNCXN_CODE).header, &ParseSyncXnInstr},
1055 : {InstrHeader(REDUCE_TYPE, ADD_CODE).header, &ParseAddInstr},
1056 : {InstrHeader(REDUCE_TYPE, MAX_CODE).header, &ParseMaxInstr},
1057 : {InstrHeader(REDUCE_TYPE, MIN_CODE).header, &ParseMinInstr},
1058 : };
1059 :
1060 2037 : std::string ParseInstr(const CcuInstr *instr)
1061 : {
1062 2037 : if (g_parseInstrSqeMap.find(instr->header.header) == g_parseInstrSqeMap.end()) {
1063 1 : return StringFormat("Unsupported instruction with header: 0x%04x", instr->header.header);
1064 : }
1065 2036 : return g_parseInstrSqeMap[instr->header.header](instr);
1066 : }
1067 :
1068 : }; // namespace Ccu
1069 : }; // namespace Hccl
|