LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/interface - ccu_datatype_v1.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 10 10
Test Date: 2026-08-17 10:19:35 Functions: 90.9 % 11 10

            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       129827 :         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       142936 :         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           91 :         CcuRepContext* GetCurContext() { return context; }
      47              : 
      48           91 :         std::shared_ptr<CcuPhyRes> GetCurPhyRes() { return phyRes; }
      49              : 
      50              :     protected:
      51              :         std::shared_ptr<CcuPhyRes> phyRes{nullptr};
      52              :         CcuRepContext* context{nullptr};
      53              :     };
      54              : 
      55              :     class Variable : public CcuVirRes {
      56              :     public:
      57              :         explicit Variable(CcuRepContext* context = nullptr);
      58              :         Variable(const Variable& other);
      59              :         void operator=(Variable&& other);
      60              : 
      61              :         void operator=(uint64_t immediate);
      62              :         void operator=(const Variable& other);
      63              :         void operator=(CcuArithmeticOperator<Variable, Variable> op);
      64              :         void operator=(CcuArithmeticOperator<Variable, uint16_t> op);
      65              :         void operator=(CcuArithmeticOperator<Address, uint16_t> op);
      66              :         void operator=(CcuArithmeticOperator<Address, Address> op);
      67              : 
      68              :         void operator=(CcuLogicOperator<Variable, Variable> op);
      69              :         void operator=(CcuLogicOperator<Variable> op);
      70              : 
      71              :         void operator=(CcuShiftOperator<Variable, Variable> op);
      72              : 
      73              :         CcuArithmeticOperator<Variable, Variable> operator+(const Variable& varB) const;
      74              :         CcuArithmeticOperator<Variable, uint16_t> operator+(const uint16_t offset) const;
      75              :         CcuArithmeticOperator<Variable, Address> operator+(const Address& addrB) const;
      76              : 
      77              :         CcuArithmeticOperator<Variable, Variable> operator*(const Variable& varB) const;
      78              :         CcuArithmeticOperator<Variable, uint16_t> operator*(const uint16_t offset) const;
      79              :         CcuArithmeticOperator<Variable, Address> operator*(const Address& addrB) const;
      80              : 
      81              :         CcuArithmeticOperator<Variable, Variable> operator-(const Variable& varB) const;
      82              :         CcuArithmeticOperator<Variable, Address> operator-(const Address& addrB) const;
      83              :         CcuArithmeticOperator<Variable, uint16_t> operator-(const uint16_t offset) const;
      84              : 
      85              :         void operator+=(const Variable& other);
      86              :         void operator+=(const uint16_t immediate);
      87              :         void operator+=(const Address& addrB);
      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              :         CcuRelationalOperator<Variable, uint64_t> operator!=(uint64_t immediate) const;
      95              :         CcuRelationalOperator<Variable, uint64_t> operator==(uint64_t immediate) const;
      96              :         CcuRelationalOperator<Variable, uint64_t> operator<=(uint64_t immediate) const;
      97              :         CcuRelationalOperator<Variable, uint64_t> operator>(uint64_t immediate) const;
      98              :         CcuRelationalOperator<Variable, Variable> operator<=(const Variable& varB) const;
      99              :         CcuRelationalOperator<Variable, Variable> operator>(const Variable& varB) const;
     100              : 
     101              :         CcuLogicOperator<Variable, Variable> operator&(const Variable& varB) const;
     102              :         CcuLogicOperator<Variable, Address> operator&(const Address& addrB) const;
     103              :         CcuLogicOperator<Variable, Variable> operator|(const Variable& varB) const;
     104              :         CcuLogicOperator<Variable, Address> operator|(const Address& addrB) const;
     105              :         CcuLogicOperator<Variable, Variable> operator^(const Variable& varB) const;
     106              :         CcuLogicOperator<Variable, Address> operator^(const Address& addrB) const;
     107              :         CcuLogicOperator<Variable> operator~() const;
     108              : 
     109              :         void operator&=(const Variable& other);
     110              :         void operator&=(const Address& addrB);
     111              :         void operator|=(const Variable& other);
     112              :         void operator|=(const Address& addrB);
     113              :         void operator^=(const Variable& other);
     114              :         void operator^=(const Address& addrB);
     115              : 
     116              :         CcuShiftOperator<Variable, Variable> operator<<(const Variable& other) const;
     117              :         void operator<<=(const Variable& other) const;
     118              :         CcuShiftOperator<Variable, Variable> operator>>(const Variable& other) const;
     119              :         void operator>>=(const Variable& other) const;
     120              : 
     121              :         void VarVarAppendToContext(CcuArithmeticOperator<Variable, Variable> op);
     122              :         void VarImmedAppendToContext(CcuArithmeticOperator<Variable, uint16_t> op);
     123              :         void AddrImmedAppendToContext(CcuArithmeticOperator<Address, uint16_t> op);
     124              :         void AddrAddrAppendToContext(CcuArithmeticOperator<Address, Address> op);
     125              : 
     126              :         void VarVarLogicAppendToContext(CcuLogicOperator<Variable, Variable> op);
     127              :         void AddrLogicAppendToContext(CcuLogicOperator<Variable> op);
     128              :     };
     129              : 
     130              :     class Address : public CcuVirRes {
     131              :     public:
     132              :         explicit Address(CcuRepContext* context = nullptr);
     133              :         Address(const Address& other);
     134              :         Address(Variable&& other);
     135              :         void operator=(Address&& other);
     136              : 
     137              :         void operator=(uint64_t immediate);
     138              :         void operator=(const Address& other);
     139              :         void operator=(const Variable& other);
     140              : 
     141              :         void operator=(CcuArithmeticOperator<Variable, Address> op);
     142              :         void operator=(CcuArithmeticOperator<Address, Address> op);
     143              :         void operator=(CcuArithmeticOperator<Address, uint16_t> op);
     144              :         void operator=(CcuArithmeticOperator<Variable, Variable> op);
     145              :         void operator=(CcuArithmeticOperator<Variable, uint16_t> op);
     146              : 
     147              :         void operator=(CcuLogicOperator<Variable, Address> op);
     148              :         void operator=(CcuLogicOperator<Address, Address> op);
     149              :         void operator=(CcuLogicOperator<Variable, Variable> op);
     150              :         void operator=(CcuLogicOperator<Variable> op);
     151              :         void operator=(CcuShiftOperator<Variable, Variable> op);
     152              : 
     153              :         CcuArithmeticOperator<Address, uint16_t> operator+(const uint16_t offset) const;
     154              :         CcuArithmeticOperator<Variable, Address> operator+(const Variable& varB) const;
     155              :         CcuArithmeticOperator<Address, Address> operator+(const Address& addrB) const;
     156              :         CcuArithmeticOperator<Address, Address> operator*(const Address& varB) const;
     157              :         CcuArithmeticOperator<Variable, Address> operator*(const Variable& addrB) const;
     158              :         CcuArithmeticOperator<Address, uint16_t> operator*(const uint16_t offset) const;
     159              : 
     160              :         CcuArithmeticOperator<Variable, Address> operator-(const Variable& varB) const;
     161              :         CcuArithmeticOperator<Address, Address> operator-(const Address& addrB) const;
     162              :         CcuArithmeticOperator<Address, uint16_t> operator-(const uint16_t offset) const;
     163              : 
     164              :         void operator+=(const Variable& other);
     165              :         void operator+=(const uint16_t immediate);
     166              :         void operator*=(const Variable& other);
     167              :         void operator*=(const uint16_t immediate);
     168              :         void operator-=(const Variable& other);
     169              :         void operator-=(const uint16_t immediate);
     170              : 
     171              :         CcuLogicOperator<Variable, Address> operator&(const Variable& varB) const;
     172              :         CcuLogicOperator<Address, Address> operator&(const Address& addrB) const;
     173              :         CcuLogicOperator<Variable, Address> operator|(const Variable& varB) const;
     174              :         CcuLogicOperator<Address, Address> operator|(const Address& addrB) const;
     175              :         CcuLogicOperator<Variable, Address> operator^(const Variable& varB) const;
     176              :         CcuLogicOperator<Address, Address> operator^(const Address& addrB) const;
     177              : 
     178              :         CcuShiftOperator<Variable, Variable> operator<<(const Variable& other) const;
     179              :         void operator<<=(const Variable& other) const;
     180              :         CcuShiftOperator<Variable, Variable> operator>>(const Variable& other) const;
     181              :         void operator>>=(const Variable& other) const;
     182              : 
     183              :         void VarAddrAppendToContext(CcuArithmeticOperator<Variable, Address> op);
     184              :         void AddrAddrAppendToContext(CcuArithmeticOperator<Address, Address> op);
     185              :         void VarImmedAppendToContext(CcuArithmeticOperator<Variable, uint16_t> op);
     186              :         void AddrImmedAppendToContext(CcuArithmeticOperator<Address, uint16_t> op);
     187              :         void VarVarAppendToContext(CcuArithmeticOperator<Variable, Variable> op);
     188              :     };
     189              : 
     190              :     class MaskSignal : public CcuVirRes {
     191              :     public:
     192              :         explicit MaskSignal(CcuRepContext* context = nullptr);
     193              :     };
     194              : 
     195              :     class CcuBuffer : public CcuVirRes {
     196              :     public:
     197              :         explicit CcuBuffer(CcuRepContext* context = nullptr);
     198              :         uint16_t Id() const override;
     199              :         static constexpr uint16_t CCUBUFFER_DIE_ID_BIT = 0x8000; // bit15 表示MS所在的IO Die id
     200              :     };
     201              : 
     202              :     class CcuBuf : public CcuVirRes {
     203              :     public:
     204              :         explicit CcuBuf(CcuRepContext* context = nullptr);
     205              :         uint16_t Id() const override;
     206              :         static constexpr uint16_t CCUBUFFER_DIE_ID_BIT = 0x8000; // bit15 表示MS所在的IO Die id
     207              :     };
     208              : 
     209              :     class Executor : public CcuVirRes {
     210              :     public:
     211              :         explicit Executor(CcuRepContext* context = nullptr);
     212              :     };
     213              : 
     214              :     class Memory {
     215              :     public:
     216           44 :         Memory() = default;
     217            6 :         Memory(Address addr, Variable token) : addr(addr), token(token) {}
     218              :         Address addr;
     219              :         Variable token;
     220              :     };
     221              : 
     222              :     /*------------------将Memory改为LocalAddr与RemoteAddr------------------------*/
     223              :     class LocalAddr {
     224              :     public:
     225           42 :         LocalAddr() = default;
     226          190 :         LocalAddr(Address addr, Variable token) : addr(addr), token(token) {}
     227              : 
     228              :         Address addr;
     229              :         Variable token;
     230              :     };
     231              : 
     232              :     class RemoteAddr {
     233              :     public:
     234           44 :         RemoteAddr() = default;
     235           63 :         RemoteAddr(Address addr, Variable token) : addr(addr), token(token) {}
     236              : 
     237              :         Address addr;
     238              :         Variable token;
     239              :     };
     240              : 
     241              :     /*------------------将MaskSignal改为LocalNotify------------------------*/
     242              :     class LocalNotify : public CcuVirRes {
     243              :     public:
     244              :         explicit LocalNotify(CcuRepContext* context = nullptr);
     245              :     };
     246              : 
     247              :     // CompletedEvent 退化为纯虚拟资源句柄持有者;
     248              :     // mask 由调用方(Rep / CcuKernel / C API / wrapper 各层)作为独立参数传入,
     249              :     // 不再绑定到 Event 上。
     250              :     class CompletedEvent : public CcuVirRes {
     251              :     public:
     252              :         explicit CompletedEvent(CcuRepContext* context = nullptr);
     253              :     };
     254              : 
     255              : }; // namespace CcuRep
     256              : }; // namespace hcomm
     257              : #endif // HCOMM_CCU_DATATYPE_H
        

Generated by: LCOV version 2.0-1