Line data Source code
1 : /*
2 : * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
3 : * Description: ccu representation base header file
4 : * Create: 2025-02-18
5 : */
6 :
7 : #ifndef HCOMM_CCU_DATATYPE_H
8 : #define HCOMM_CCU_DATATYPE_H
9 :
10 : #include <memory>
11 :
12 : #include "ccu_rep_base_v1.h"
13 : #include "ccu_operator_v1.h"
14 : #include "ccu_rep_context_v1.h"
15 :
16 : namespace hcomm {
17 : namespace CcuRep {
18 :
19 : class Variable;
20 : class Address;
21 :
22 : class CcuPhyRes {
23 : public:
24 42651 : CcuPhyRes() = default;
25 : ~CcuPhyRes() = default;
26 : void Reset(uint16_t id);
27 : void SetDieId(uint16_t dieId);
28 : uint16_t Id() const;
29 : uint16_t DieId() const;
30 :
31 : private:
32 : uint16_t dieId{0};
33 : uint16_t id{0};
34 : };
35 :
36 : class CcuVirRes {
37 : public:
38 : CcuVirRes(CcuRepContext *context);
39 46978 : virtual ~CcuVirRes() = default;
40 : void Reset(uint16_t id);
41 : void Reset(uint16_t id, uint16_t dieId);
42 : void SetDieId(uint16_t dieId);
43 : virtual uint16_t Id() const;
44 : uint16_t DieId() const;
45 :
46 0 : CcuRepContext* GetCurContext() {
47 0 : return context;
48 : }
49 :
50 0 : std::shared_ptr<CcuPhyRes> GetCurPhyRes() {
51 0 : return phyRes;
52 : }
53 : protected:
54 : std::shared_ptr<CcuPhyRes> phyRes{nullptr};
55 : CcuRepContext *context{nullptr};
56 : };
57 :
58 : class Variable : public CcuVirRes {
59 : public:
60 : explicit Variable(CcuRepContext *context = nullptr);
61 : Variable(const Variable& other);
62 : void operator=(Variable&& other);
63 :
64 : void operator=(uint64_t immediate);
65 : void operator=(const Variable &other);
66 : void operator=(CcuArithmeticOperator<Variable, Variable> op);
67 : void operator=(CcuArithmeticOperator<Variable, uint16_t> op);
68 : void operator=(CcuArithmeticOperator<Address, uint16_t> op);
69 : void operator=(CcuArithmeticOperator<Address, Address> op);
70 :
71 : void operator=(CcuLogicOperator<Variable, Variable> op);
72 : void operator=(CcuLogicOperator<Variable> op);
73 :
74 : void operator=(CcuShiftOperator<Variable, Variable> op);
75 :
76 : CcuArithmeticOperator<Variable, Variable> operator+(const Variable &varB) const;
77 : CcuArithmeticOperator<Variable, uint16_t> operator+(const uint16_t offset) const;
78 : CcuArithmeticOperator<Variable, Address> operator+(const Address &addrB) const;
79 :
80 : CcuArithmeticOperator<Variable, Variable> operator*(const Variable &varB) const;
81 : CcuArithmeticOperator<Variable, uint16_t> operator*(const uint16_t offset) const;
82 : CcuArithmeticOperator<Variable, Address> operator*(const Address &addrB) const;
83 :
84 : CcuArithmeticOperator<Variable, Variable> operator-(const Variable &varB) const;
85 : CcuArithmeticOperator<Variable, Address> operator-(const Address &addrB) const;
86 : CcuArithmeticOperator<Variable, uint16_t> operator-(const uint16_t offset) const;
87 :
88 : void operator+=(const Variable &other);
89 : void operator+=(const uint16_t immediate);
90 : void operator+=(const Address& addrB);
91 : void operator*=(const Variable &other);
92 : void operator*=(const uint16_t immediate);
93 : void operator*=(const Address& addrB);
94 : void operator-=(const Variable &other);
95 : void operator-=(const uint16_t immediate);
96 : void operator-=(const Address& addrB);
97 : CcuRelationalOperator<Variable, uint64_t> operator!=(uint64_t immediate) const;
98 : CcuRelationalOperator<Variable, uint64_t> operator==(uint64_t immediate) const;
99 : CcuRelationalOperator<Variable, uint64_t> operator<=(uint64_t immediate) const;
100 : CcuRelationalOperator<Variable, uint64_t> operator>(uint64_t immediate) const;
101 : CcuRelationalOperator<Variable, Variable> operator<=(const Variable &varB) const;
102 : CcuRelationalOperator<Variable, Variable> operator>(const Variable &varB) const;
103 :
104 : CcuLogicOperator<Variable, Variable> operator&(const Variable &varB) const;
105 : CcuLogicOperator<Variable, Address> operator&(const Address &addrB) const;
106 : CcuLogicOperator<Variable, Variable> operator|(const Variable &varB) const;
107 : CcuLogicOperator<Variable, Address> operator|(const Address &addrB) const;
108 : CcuLogicOperator<Variable, Variable> operator^(const Variable &varB) const;
109 : CcuLogicOperator<Variable, Address> operator^(const Address &addrB) const;
110 : CcuLogicOperator<Variable> operator~() const;
111 :
112 : void operator&=(const Variable &other);
113 : void operator&=(const Address &addrB);
114 : void operator|=(const Variable &other);
115 : void operator|=(const Address &addrB);
116 : void operator^=(const Variable &other);
117 : void operator^=(const Address &addrB);
118 :
119 : CcuShiftOperator<Variable, Variable> operator<<(const Variable &other) const;
120 : void operator<<=(const Variable &other) const;
121 : CcuShiftOperator<Variable, Variable> operator>>(const Variable &other) const;
122 : void operator>>=(const Variable &other) const;
123 :
124 : void VarVarAppendToContext(CcuArithmeticOperator<Variable, Variable> op);
125 : void VarImmedAppendToContext(CcuArithmeticOperator<Variable, uint16_t> op);
126 : void AddrImmedAppendToContext(CcuArithmeticOperator<Address, uint16_t> op);
127 : void AddrAddrAppendToContext(CcuArithmeticOperator<Address, Address> op);
128 :
129 : void VarVarLogicAppendToContext(CcuLogicOperator<Variable, Variable> op);
130 : void AddrLogicAppendToContext(CcuLogicOperator<Variable> op);
131 : };
132 :
133 : class Address : public CcuVirRes {
134 : public:
135 : explicit Address(CcuRepContext *context = nullptr);
136 : Address(const Address& other);
137 : Address(Variable &&other);
138 : void operator=(Address&& other);
139 :
140 : void operator=(uint64_t immediate);
141 : void operator=(const Address &other);
142 : void operator=(const Variable &other);
143 :
144 : void operator=(CcuArithmeticOperator<Variable, Address> op);
145 : void operator=(CcuArithmeticOperator<Address, Address> op);
146 : void operator=(CcuArithmeticOperator<Address, uint16_t> op);
147 : void operator=(CcuArithmeticOperator<Variable, Variable> op);
148 : void operator=(CcuArithmeticOperator<Variable, uint16_t> op);
149 :
150 : void operator=(CcuLogicOperator<Variable, Address> op);
151 : void operator=(CcuLogicOperator<Address, Address> op);
152 : void operator=(CcuLogicOperator<Variable, Variable> op);
153 : void operator=(CcuLogicOperator<Variable> op);
154 : void operator=(CcuShiftOperator<Variable, Variable> op);
155 :
156 : CcuArithmeticOperator<Address, uint16_t> operator+(const uint16_t offset) const;
157 : CcuArithmeticOperator<Variable, Address> operator+(const Variable &varB) const;
158 : CcuArithmeticOperator<Address, Address> operator+(const Address &addrB) const;
159 : CcuArithmeticOperator<Address, Address> operator*(const Address &varB) const;
160 : CcuArithmeticOperator<Variable, Address> operator*(const Variable &addrB) const;
161 : CcuArithmeticOperator<Address, uint16_t> operator*(const uint16_t offset) const;
162 :
163 : CcuArithmeticOperator<Variable, Address> operator-(const Variable &varB) const;
164 : CcuArithmeticOperator<Address, Address> operator-(const Address &addrB) const;
165 : CcuArithmeticOperator<Address, uint16_t> operator-(const uint16_t offset) const;
166 :
167 : void operator+=(const Variable &other);
168 : void operator+=(const uint16_t immediate);
169 : void operator*=(const Variable &other);
170 : void operator*=(const uint16_t immediate);
171 : void operator-=(const Variable &other);
172 : void operator-=(const uint16_t immediate);
173 :
174 : CcuLogicOperator<Variable, Address> operator&(const Variable &varB) const;
175 : CcuLogicOperator<Address, Address> operator&(const Address &addrB) const;
176 : CcuLogicOperator<Variable, Address> operator|(const Variable &varB) const;
177 : CcuLogicOperator<Address, Address> operator|(const Address &addrB) const;
178 : CcuLogicOperator<Variable, Address> operator^(const Variable &varB) const;
179 : CcuLogicOperator<Address, Address> operator^(const Address &addrB) const;
180 :
181 : CcuShiftOperator<Variable, Variable> operator<<(const Variable &other) const;
182 : void operator<<=(const Variable &other) const;
183 : CcuShiftOperator<Variable, Variable> operator>>(const Variable &other) const;
184 : void operator>>=(const Variable &other) const;
185 :
186 : void VarAddrAppendToContext(CcuArithmeticOperator<Variable, Address> op);
187 : void AddrAddrAppendToContext(CcuArithmeticOperator<Address, Address> op);
188 : void VarImmedAppendToContext(CcuArithmeticOperator<Variable, uint16_t> op);
189 : void AddrImmedAppendToContext(CcuArithmeticOperator<Address, uint16_t> op);
190 : void VarVarAppendToContext(CcuArithmeticOperator<Variable, Variable> op);
191 : };
192 :
193 : class MaskSignal : public CcuVirRes {
194 : public:
195 : explicit MaskSignal(CcuRepContext *context = nullptr);
196 : };
197 :
198 : class CcuBuffer : public CcuVirRes {
199 : public:
200 : explicit CcuBuffer(CcuRepContext *context = nullptr);
201 : uint16_t Id() const override;
202 : static constexpr uint16_t CCUBUFFER_DIE_ID_BIT = 0x8000; // bit15 表示MS所在的IO Die id
203 : };
204 :
205 : class CcuBuf : public CcuVirRes {
206 : public:
207 : explicit CcuBuf(CcuRepContext *context = nullptr);
208 : uint16_t Id() const override;
209 : static constexpr uint16_t CCUBUFFER_DIE_ID_BIT = 0x8000; // bit15 表示MS所在的IO Die id
210 : };
211 :
212 : class Executor : public CcuVirRes {
213 : public:
214 : explicit Executor(CcuRepContext *context = nullptr);
215 : };
216 :
217 : class Memory {
218 : public:
219 44 : Memory() = default;
220 6 : Memory(Address addr, Variable token) : addr(addr), token(token)
221 : {
222 6 : }
223 : Address addr;
224 : Variable token;
225 : };
226 :
227 : /*------------------将Memory改为LocalAddr与RemoteAddr------------------------*/
228 : class LocalAddr {
229 : public:
230 42 : LocalAddr() = default;
231 113 : LocalAddr(Address addr, Variable token) : addr(addr), token(token)
232 : {
233 113 : }
234 :
235 : Address addr;
236 : Variable token;
237 : };
238 :
239 : class RemoteAddr {
240 : public:
241 44 : RemoteAddr() = default;
242 42 : RemoteAddr(Address addr, Variable token) : addr(addr), token(token)
243 : {
244 42 : }
245 :
246 : Address addr;
247 : Variable token;
248 : };
249 :
250 : /*------------------将MaskSignal改为LocalNotify------------------------*/
251 : class LocalNotify : public CcuVirRes {
252 : public:
253 : explicit LocalNotify(CcuRepContext *context = nullptr);
254 : };
255 :
256 : // CompletedEvent 退化为纯虚拟资源句柄持有者;
257 : // mask 由调用方(Rep / CcuKernel / C API / wrapper 各层)作为独立参数传入,
258 : // 不再绑定到 Event 上。
259 : class CompletedEvent : public CcuVirRes {
260 : public:
261 : explicit CompletedEvent(CcuRepContext *context = nullptr);
262 : };
263 :
264 : }; // namespace CcuRep
265 : }; // namespace hcomm
266 : #endif // HCOMM_CCU_DATATYPE_H
|