scc  2024.06
SystemC components library
chi_tlm.h
1 /*
2  * Copyright 2020 Arteris IP
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <array>
20 #include <cstdint>
21 #include <tlm>
22 #include <type_traits>
23 
25 namespace chi {
29 template <typename Enum> struct enable_for_enum { static const bool value = false; };
35 template <typename E> inline E into(typename std::underlying_type<E>::type t);
41 template <
42 typename E, typename ULT = typename std::underlying_type<E>::type,
43 typename X = typename std::enable_if<std::is_enum<E>::value && !std::is_convertible<E, ULT>::value, bool>::type>
44 inline constexpr ULT to_int(E t) {
45  return static_cast<typename std::underlying_type<E>::type>(t);
46 }
52 template <typename E> const char* to_char(E t);
59 template <typename E, typename std::enable_if<enable_for_enum<E>::value, bool>::type>
60 inline std::ostream& operator<<(std::ostream& os, E e) {
61  os << to_char(e);
62  return os;
63 }
64 
65 std::ostream& operator<<(std::ostream& os, tlm::tlm_generic_payload const& t);
66 
67 // REQ channel request type enumeration class
68 enum class req_optype_e : uint8_t {
69  // Table 12-14 REQ channel opcodes and Page No:318
70  ReqLCrdReturn = 0x00,
71  ReadShared = 0x01,
72  ReadClean = 0x02,
73  ReadOnce = 0x03,
74  ReadNoSnp = 0x04,
75  PCrdReturn = 0x05,
76  Reserved = 0x06,
77  ReadUnique = 0x07,
78  CleanShared = 0x08,
79  CleanInvalid = 0x09,
80  MakeInvalid = 0x0A,
81  CleanUnique = 0x0B,
82  MakeUnique = 0x0C,
83  Evict = 0x0D,
84  EOBarrier = 0x0E,
85  ECBarrier = 0x0F,
86  // RESERVED 0x10
87  ReadNoSnpSep = 0x11, //CHI-E
88  // RESERVED 0x12
89  CleanSharedPersistSep = 0x13, //CHI-E
90  DVMOp = 0x14,
91  WriteEvictFull = 0x15,
92  WriteCleanPtl = 0x16, // As per CHI issue-A
93  WriteCleanFull = 0x17,
94  WriteUniquePtl = 0x18,
95  WriteUniqueFull = 0x19,
96  WriteBackPtl = 0x1A,
97  WriteBackFull = 0x1B,
98  WriteNoSnpPtl = 0x1C,
99  WriteNoSnpFull = 0x1D,
100  // RESERVED 0x1E-0x1F
101  WriteUniqueFullStash = 0x20,
102  WriteUniquePtlStash = 0x21,
103  StashOnceShared = 0x22,
104  StashOnceUnique = 0x23,
105  ReadOnceCleanInvalid = 0x24,
106  ReadOnceMakeInvalid = 0x25,
107  ReadNotSharedDirty = 0x26,
108  CleanSharedPersist = 0x27,
109  AtomicStoreAdd = 0x28,
110  AtomicStoreClr = 0x29,
111  AtomicStoreEor = 0x2A,
112  AtomicStoreSet = 0x2B,
113  AtomicStoreSmax = 0x2C,
114  AtomicStoreSmin = 0x2D,
115  AtomicStoreUmax = 0x2E,
116  AtomicStoreUmin = 0x2F,
117  AtomicLoadAdd = 0x30,
118  AtomicLoadClr = 0x31,
119  AtomicLoadEor = 0x32,
120  AtomicLoadSet = 0x33,
121  AtomicLoadSmax = 0x34,
122  AtomicLoadSmin = 0x35,
123  AtomicLoadUmax = 0x36,
124  AtomicLoadUmin = 0x37,
125  AtomicSwap = 0x38,
126  AtomicCompare = 0x39,
127  PrefetchTgt = 0x3A,
128  // RESERVED = 0x3B to 0x40
129  // all CHI-E from here on
130  MakeReadUnique = 0x41,
131  WriteEvictOrEvict = 0x42,
132  WriteUniqueZero = 0x43,
133  WriteNoSnpZero = 0x44,
134  // RESERVED = 0x45 to 0x46
135  StashOnceSepShared = 0x47,
136  StashOnceSepUnique = 0x48,
137  // RESERVED = 0x49 to 0x4b
138  ReadPreferUnique = 0x4c,
139  // RESERVED = 0x4d to 0x4F
140  WriteNoSnpFullCleanSh = 0x50,
141  WriteNoSnpFullCleanInv = 0x51,
142  WriteNoSnpFullCleanShPerSep = 0x52,
143  // RESERVED = 0x52
144  WriteUniqueFullCleanSh = 0x54,
145  // RESERVED = 0x55
146  WriteUniqueFullCleanShPerSep = 0x56,
147  // RESERVED = 0x57
148  WriteBackFullCleanSh = 0x58,
149  WriteBackFullCleanInv = 0x59,
150  WriteBackFullCleanShPerSep = 0x5A,
151  // RESERVED = 0x5B
152  WriteCleanFullCleanSh = 0x5c,
153  // RESERVED = 0x5d
154  WriteCleanFullCleanShPerSep = 0x5e,
155  // RESERVED = 0x3f
156  WriteNoSnpPtlCleanSh = 0x60,
157  WriteNoSnpPtlCleanInv = 0x61,
158  WriteNoSnpPtlCleanShPerSep = 0x62,
159  // RESERVED = 0x63
160  WriteUniquePtlCleanSh = 0x64,
161  // RESERVED = 0x3B to 0x40
162  WriteUniquePtlCleanShPerSep = 0x66,
163  // RESERVED = 0x67 to 0x7f
164  ILLEGAL = 0xFF
165 };
166 
167 // the Snp_Req channel request type enumeration class acc. Table 12-17 SNP channel opcodes and Page No:321
168 enum class snp_optype_e : uint8_t {
169  SnpLCrdReturn = 0x00,
170  SnpShared = 0x01,
171  SnpClean = 0x02,
172  SnpOnce = 0x03,
173  SnpNotSharedDirty = 0x04,
174  SnpUniqueStash = 0x05,
175  SnpMakeInvalidStash = 0x06,
176  SnpUnique = 0x07,
177  SnpCleanShared = 0x08,
178  SnpCleanInvalid = 0x09,
179  SnpMakeInvalid = 0x0A,
180  SnpStashUnique = 0x0B,
181  SnpStashShared = 0x0c,
182  SnpDVMOp = 0x0D,
183  SnpQuery = 0x10,
184  SnpSharedFwd = 0x11,
185  SnpCleanFwd = 0x12,
186  SnpOnceFwd = 0x13,
187  SnpNotSharedDirtyFwd = 0x14,
188  SnpPreferUnique = 0x15,
189  SnpPreferUniqueFwd = 0x16,
190  SnpUniqueFwd = 0x17,
191  // Reserved = 0x0E-0x0F
192  // Reserved = 0x18-0x1F
193  ILLEGAL = 0x20
194 };
195 
196 // the Dat type enumeration class acc. Table 12-18 DAT channel opcodes and Page No:322
197 enum class dat_optype_e : uint8_t {
198  DataLCrdReturn = 0x0,
199  SnpRespData = 0x1,
200  CopyBackWrData = 0x2,
201  NonCopyBackWrData = 0x3,
202  CompData = 0x4,
203  SnpRespDataPtl = 0x5,
204  SnpRespDataFwded = 0x6,
205  WriteDataCancel = 0x7,
206  DataSepResp = 0xB,
207  NCBWrDataCompAck = 0xC,
208  // Reserved = 0x8-0xA
209  // Reserved = 0xD-0xF
210  // Table 4-9 Permitted Non-forward type data opcode
211  SnpRespData_I = 0x1,
212  SnpRespData_UC = 0x1,
213  SnpRespData_UD = 0x1,
214  SnpRespData_SC = 0x1,
215  SnpRespData_SD = 0x1,
216  SnpRespData_I_PD = 0x1,
217  SnpRespData_UC_PD = 0x1,
218  SnpRespData_SC_PD = 0x1,
219  SnpRespDataPtl_I_PD = 0x5,
220  SnpRespDataPtl_UD = 0x5,
221  // Table 4-10 Permitted Forward data opcode
222  SnpRespData_I_Fwded_SC = 0x6,
223  SnpRespData_I_Fwded_SD_PD = 0x6,
224  SnpRespData_SC_Fwded_SC = 0x6,
225  SnpRespData_SC_Fwded_SD_PD = 0x6,
226  SnpRespData_SD_Fwded_SC = 0x6,
227  SnpRespData_I_PD_Fwded_I = 0x6,
228  SnpRespData_I_PD_Fwded_SC = 0x6,
229  SnpRespData_SC_PD_Fwded_I = 0x6,
230  SnpRespData_SC_PD_Fwded_SC = 0x6
231 };
232 
233 // the dat response 'resp' field type enumeration class acc. sec 4.5 Response types
234 enum class dat_resptype_e : uint8_t {
235  // Read and Atomic Completion
236  CompData_I = 0b000, // Copy of cacheline cannot be kept
237  CompData_SC = 0b001,
238  CompData_UC = 0b010, // Final state of cacheline can be UC or UCE or SC or I
239  CompData_UD_PD = 0b110,
240  CompData_SD_PD = 0b111,
241  DataSepResp_I = 0b000,
242  DataSepResp_SC = 0b001,
243  DataSepResp_UC = 0b010,
244  RespSepData_I = 0b000, // Not applicable
245  RespSepData_SC = 0b001,
246  RespSepData_UC = 0b010,
247  // Table 4-9 Permitted Non-forward type snoop responses with data(Dat opcode =0x1)
248  SnpRespData_I = 0b000,
249  SnpRespData_UC = 0b010,
250  SnpRespData_UD = 0b010,
251  SnpRespData_SC = 0b001,
252  SnpRespData_SD = 0b011,
253  SnpRespData_I_PD = 0b100,
254  SnpRespData_UC_PD = 0b110,
255  SnpRespData_SC_PD = 0b101,
256  SnpRespDataPtl_I_PD = 0b100,
257  SnpRespDataPtl_UD = 0b010,
258 
259  // Dataless transactions
260  Comp_I = 0b000, // final state must be I
261  Comp_UC = 0b010, // final state can be UC, UCE,SC or I
262  Comp_SC = 0b001, // final state SC or I
263  // Write and Atomic completion
264  CopyBackWrData_I = 0b000, // if cache state when data sent is I
265  CopyBackWrData_UC = 0b010, // Cache line = UC
266  CopyBackWrData_SC = 0b001,
267  CopyBackWrData_UD_PD = 0b110, // cacheline state UD or UDP
268  CopyBackWrData_SD_PD = 0b111,
269  NonCopyBackWrData = 0b000,
270  NCBWrDataCompAck = 0b000
271 };
272 
273 // response type enumeration class according to Table 12-16 RSP channel opcodes and Page No :320
274 enum class rsp_optype_e : uint8_t {
275  RespLCrdReturn = 0x0,
276  SnpResp = 0x1,
277  CompAck = 0x2,
278  RetryAck = 0x3,
279  Comp = 0x4,
280  CompDBIDResp = 0x5,
281  DBIDResp = 0x6,
282  PCrdGrant = 0x7,
283  ReadReceipt = 0x8,
284  SnpRespFwded = 0x9,
285  TagMatch = 0xA,
286  RespSepData = 0xB,
287  Persist =0xC,
288  CompPersist = 0xD,
289  DBIDRespOrd = 0xE,
290  // Reserved = 0xF
291  StashDone = 0x10,
292  CompStashDone = 0x11,
293  // Reserved = 0x12-0x13
294  CompCMO = 0x14,
295  // Reserved = 0x15-0x1f
296  INVALID = 0x20
297 };
298 
299 enum class rsp_resptype_e : uint8_t {
300  // Table 4-7 Permitted Non-forward type snoop responses without data
301  SnpResp_I = 0b000,
302  SnpResp_SC = 0b001,
303  SnpResp_UC = 0b010,
304  SnpResp_UD = 0b010,
305  SnpResp_SD = 0b011,
306  // Table 4-7 Permitted Dataless transaction completion
307  Comp_I = 0b000, // final state must be I
308  Comp_UC = 0b010, // final state can be UC, UCE,SC or I
309  Comp_SC = 0b001, // final state SC or I
310  Comp_UD_PD = 0b110, // final state SC or I
311  // Table 4-11 Permitted Non-forward type snoop responses with data
312  SnpRespData_I = 0b000, // dat opcode =0x1 Snoop response with data.
313  SnpRespData_UC = 0b010,
314  SnpRespData_UD = 0b010, // dat opcode = 0x1 Snoop response with data. Cache line state is UC or UD.
315  SnpRespData_SC = 0b001, // dat opcode = 0x1 Snoop response with data. Cache line state is SC.
316  SnpRespData_SD = 0b011, // dat opcode = 0x1 Snoop response with data. Cache line state is SD.
317  SnpRespData_I_PD = 0b100, // dat opcode = 0x1 Snoop response with data. Cache line state is I. Responsibility for updating the memory is passed to the Home.
318  SnpRespData_UC_PD = 0b110, // dat opcode = 0x1 Snoop response with data. Cache line state is UC. Responsibility for updating the memory is passed to the Home.
319  SnpRespData_SC_PD = 0b101, // dat opcode = 0x1 Snoop response with data. Cache line state is SC. Responsibility for updating the memory is passed to the Home.
320  SnpRespDataPtl_I_PD = 0b100, // dat opcode = 0x5 Snoop response with partial data. Cache line state is I. Responsibility for updating the memory is passed to the Home.
321  SnpRespDataPtl_UD = 0b010, // dat opcode = 0x5 Snoop response with partial data.
322 };
323 
324 enum class rsp_resperrtype_e : uint8_t {
325  OK = 0b00,
326  EXOK = 0b01,
327  DERR = 0b10,
328  NDERR = 0b11
329 };
330 
331 enum class credit_type_e : uint8_t {
332  LINK,
333  REQ, // RN->HN: snoop, HN->RN: req
334  RESP, // RN->HN: cresp, HN->RN: sresp
335  DATA, // RN->HN: rxdata, HN->RN: txdata
336 };
337 
338 enum class dvm_e {
339  DVMOpSize = 0x3,
340  PacketNumShift = 3, // In the request's address
341 
342  // DVM operations
343  TLBI = 0x0,
344  BranchPredictorInvalidate = 0x1,
345  PICI = 0x2,
346  VICI = 0x3,
347  Sync = 0x4,
348 
349  //
350  // Address bits with information [40:4] (37 bits), 8.2.2 [1]
351  //
352  AddressBits = 37,
353 
354  DVMOpMask = 0x7,
355  DVMOpShift = 11,
356 
357  DVMVAValidMask = 0x1,
358  DVMVAValidShift = 4,
359 };
360 
365 struct common {
366 public:
367  void reset();
368 
370  common() = default;
372 
377  common& operator=(const common& o) {
378  qos = o.qos;
379  txn_id = o.txn_id;
380  src_id = o.src_id;
381  return *this;
382  }
383 
386  // A transaction request includes a TxnID that is used to identify the transaction from a given Requester
387  void set_txn_id(unsigned int);
388 
391  unsigned int get_txn_id() const;
392 
395  void set_src_id(unsigned int);
396 
399  unsigned int get_src_id() const;
400 
403  void set_qos(uint8_t qos);
404 
407  unsigned int get_qos() const;
408 
409 private:
410  uint32_t qos{0};
411  uint16_t src_id{0};
412  uint16_t txn_id{0};
413 };
414 
419 struct request {
420  // request() { }
421  // A transaction request includes a TgtID that identifies the target node
422  void set_tgt_id(uint8_t);
423  uint8_t get_tgt_id() const;
424  /*Logical Processor ID. Used in conjunction with the SrcID field to uniquely
425  identify the logical processor that generated the request. */
426  void set_lp_id(uint8_t);
427  uint8_t get_lp_id() const;
428  /*Return Transaction ID. The unique transaction ID that conveys the value of
429  TxnID in the data response from the Slave*/
430  void set_return_txn_id(uint8_t);
431  uint8_t get_return_txn_id() const;
432  // Stash Logical Processor ID. The ID of the logical processor at the Stash target.
433  void set_stash_lp_id(uint8_t);
434  uint8_t get_stash_lp_id() const;
435  /*Data size. Specifies the size of the data associated with the transaction. This
436  determines the number of data packets within the transaction */
437  void set_size(uint8_t);
438  uint8_t get_size() const;
439  /*Max number of flits in current transaction. The number is determined based on data length and bus width
440  * The number is required to identify the last flit in data transaction. */
441  void set_max_flit(uint8_t data_id);
442  uint8_t get_max_flit() const;
443  /* Memory attribute. Determines the memory attributes associated with the transaction. */
444  void set_mem_attr(uint8_t);
445  uint8_t get_mem_attr() const;
446  /* Device memory type must be used for locations that exhibit side-effects. */
447  void set_device(bool is_device);
448  bool is_device() const;
449  /* EWA indicates whether the write completion response for a transaction */
450  void set_ewa(bool is_device);
451  bool is_ewa() const;
452  /* The Allocate attribute is a an allocation hint. It indicates the recommended allocation policy for a transaction */
453  void set_allocate(bool is_device);
454  bool is_allocate() const;
455  /* The Cacheable attribute indicates if a transaction must perform a cache lookup */
456  void set_cacheable(bool is_device);
457  bool is_cacheable() const;
458  /* Protocol Credit Type. Indicates the type of Protocol Credit being used by a
459  request that has the AllowRetry field deasserted */
460  void set_pcrd_type(uint8_t);
461  uint8_t get_pcrd_type() const;
462  // Endianness. Indicates the endianness of Data in the Data packet.
463  void set_endian(bool);
464  bool is_endian() const;
465  /*Order requirement. Determines the ordering requirement for this request with
466  respect to other transactions from the same agent.*/
467  void set_order(uint8_t);
468  uint8_t get_order() const;
469  /*Trace Tag. Provides additional support for the debugging, tracing, and
470  performance measurement of systems. */
471  void set_trace_tag(bool tg = true);
472  bool is_trace_tag() const;
473  void set_opcode(chi::req_optype_e op);
474  chi::req_optype_e get_opcode() const;
475  // Return Node ID. The node ID that the response with Data is to be sent to.
476  void set_return_n_id(uint16_t);
477  uint16_t get_return_n_id() const;
478  // Stash Node ID is the node ID of the Stash target.
479  void set_stash_n_id(uint16_t);
480  uint16_t get_stash_n_id() const;
481  /* Stash Node ID Valid. Indicates that the StashNID field has a valid Stash target
482  value. */
483  void set_stash_n_id_valid(bool = true);
484  bool is_stash_n_id_valid() const;
485  /*Stash Logical Processor ID. The ID of the logical processor at the Stash target.*/
486  void set_stash_lp_id_valid(bool = true);
487  bool is_stash_lp_id_valid() const;
488  /*Secure and Non-secure transactions are defined to support Secure and
489  Non-secure operating states.*/
490  void set_non_secure(bool = true);
491  bool is_non_secure() const;
492  /* Expect CompAck. Indicates that the transaction will include a Completion
493  Acknowledge message*/
494  void set_exp_comp_ack(bool = true);
495  bool is_exp_comp_ack() const;
496  /* Allow Retry determines if the target is permitted to give a Retry response.*/
497  void set_allow_retry(bool = true);
498  bool is_allow_retry() const;
499  /* Snoop attribute specifies the snoop attributes associated with the transaction.*/
500  void set_snp_attr(bool = true);
501  bool is_snp_attr() const;
502  /*Exclusive access. Indicates that the corresponding transaction is an Exclusive
503  access transaction.*/
504  void set_excl(bool = true);
505  bool is_excl() const;
506  /* Snoop Me. Indicates that Home must determine whether to send a snoop to the
507  Requester.*/
508  void set_snoop_me(bool = true);
509  bool is_snoop_me() const;
510  /*The LikelyShared attribute is a cache allocation hint. When asserted this attribute indicates
511  that the requested data is likely to be shared by other Request Nodes within the system */
512  void set_likely_shared(bool = true);
513  bool is_likely_shared() const;
514  /* Indicates the operation to be performed on the tags present in
515  the corresponding DAT channel */
516  void set_tag_op(uint8_t);
517  uint8_t get_tag_op() const;
518  /* Precise contents are IMPLEMENTATION DEFINED. Typically
519  expected to contain Exception Level, TTBR value, and CPU identifier */
520  void set_tag_group_id(uint32_t);
521  uint32_t get_tag_group_id() const;
522  /* Memory System Performance Resource Partitioning and Monitoring.
523  Efficiently utilizes the memory resources among users and monitors their use */
524  void set_mpam(uint16_t);
525  uint16_t get_mpam() const;
526  /* Reserved for customer use. Any value is valid in a Protocol flit. Propagation of this field through the
527  interconnect is IMPLEMENTATION DEFINED.*/
528  void set_rsvdc(uint32_t);
529  uint32_t get_rsvdc() const; // Reserved for customer use.
530 
531 private:
532  uint8_t tgt_id{0}, lp_id{0}, return_txn_id{0}, stash_lp_id{0}, size{0}, max_flit{0}, mem_attr{0}, pcrd_type{0},
533  order{0};
534  bool endian{false}, trace_tag{false};
535  uint16_t return_n_id{0}, stash_n_id{0};
536  req_optype_e opcode{req_optype_e::ReqLCrdReturn};
537  bool stash_n_id_valid{false}, stash_lp_id_valid{false}, ns{false}, exp_comp_ack{false}, allow_retry{false},
538  snp_attr{false}, excl{false}, snoop_me{false}, likely_shared{false};
539  uint32_t rsvdc{0}, tag_group_id{0};
540  uint16_t mpam{0};
541  uint8_t tag_op{0};
542 };
543 
548 struct snp_request {
549  /*Forward Transaction ID. The transaction ID used in the Request by the original
550  Requester.*/
551  void set_fwd_txn_id(uint8_t);
552  uint8_t get_fwd_txn_id() const;
553  /*Stash Logical Processor ID. The ID of the logical processor at the Stash target.*/
554  void set_stash_lp_id(uint8_t);
555  uint8_t get_stash_lp_id() const;
556  /* Stash Node ID Valid. Indicates that the StashNID field has a valid Stash target
557  value. */
558  void set_stash_lp_id_valid(bool = true);
559  bool is_stash_lp_id_valid() const;
560  /* Virtual Machine ID Extension use in DVM Operation types*/
561  void set_vm_id_ext(uint8_t);
562  uint8_t get_vm_id_ext() const;
563  /* Set the opcode of Snoop Request */
564  void set_opcode(snp_optype_e opcode);
565  snp_optype_e get_opcode() const;
566  /*Forward Node ID is Node ID of the original Requester */
567  void set_fwd_n_id(uint16_t);
568  uint16_t get_fwd_n_id() const;
569  /*Secure and Non-secure transactions are defined to support Secure and
570  Non-secure operating states.*/
571  void set_non_secure(bool = true); // NS bit
572  bool is_non_secure() const; // NS bit
573  /* Do Not Go To SD state controls Snoopee use of SD state.It specifies that
574  the Snoopee must not transition to SD state as a result of the Snoop request.*/
575  void set_do_not_goto_sd(bool = true);
576  bool is_do_not_goto_sd() const;
577  /*Do Not Data Pull. Instructs the Snoopee that it is not permitted to use the
578  Data Pull feature associated with Stash requests*/
579  void set_do_not_data_pull(bool = true);
580  bool is_do_not_data_pull() const;
581  /*Return to Source. Instructs the receiver of the snoop to return Data with
582  the Snoop response.*/
583  void set_ret_to_src(bool);
584  bool is_ret_to_src() const;
585  /*Trace Tag. Provides additional support for the debugging, tracing, and
586  performance measurement of systems*/
587  void set_trace_tag(bool = true);
588  bool is_trace_tag() const;
589 
590 private:
591  uint8_t fwd_txn_id{0}, stash_lp_id{0}, vm_id_ext{0};
592  bool stash_lp_id_valid{false};
593  snp_optype_e opcode;
594  uint16_t fwd_n_id{0};
595  bool ns{false}, do_not_goto_sd{false}, do_not_data_pull{false}, ret_to_src{false}, trace_tag{false};
596 };
597 
603 struct data {
604  /* Data Buffer ID. The ID provided to be used as the TxnID in the response to this message*/
605  void set_db_id(uint8_t);
606  uint8_t get_db_id() const;
607  /* Set the opcode of Data packet */
608  void set_opcode(dat_optype_e opcode);
609  dat_optype_e get_opcode() const;
610  /*Response Error status. Indicates the error status associated with a data transfer*/
611  void set_resp_err(rsp_resperrtype_e);
612  rsp_resperrtype_e get_resp_err() const;
613  /*Response status. Indicates the cache line state associated with a data transfer*/
614  void set_resp(dat_resptype_e);
615  dat_resptype_e get_resp() const;
616  /*Forward State. Indicates the cache line state associated with a data transfer
617  to the Requester from the receiver of the snoop*/
618  void set_fwd_state(uint8_t);
619  uint8_t get_fwd_state() const;
620  /*Data Pull. Indicates the inclusion of an implied Read request in the Data
621  response*/
622  void set_data_pull(uint8_t);
623  uint8_t get_data_pull() const;
624  /* Data Source. The value indicates the source of the data in a read Data
625  response*/
626  void set_data_source(uint8_t);
627  uint8_t get_data_source() const;
628  /* Critical Chunk Identifier. Replicates the address offset of the original
629  transaction reques*/
630  void set_cc_id(uint8_t);
631  uint8_t get_cc_id() const;
632  /*Data Identifier. Provides the address offset of the data provided in the packet*/
633  void set_data_id(uint8_t);
634  uint8_t get_data_id() const;
635  /*Poison. Indicates that a set of data bytes has previously been corrupted*/
636  void set_poison(uint8_t);
637  uint8_t get_poison() const;
638  /*A transaction request includes a TgtID that identifies the target node*/
639  void set_tgt_id(uint16_t);
640  uint16_t get_tgt_id() const;
641  /*Home Node ID. The Node ID of the target of the CompAck response to be
642  sent from the Requester*/
643  void set_home_n_id(uint16_t);
644  uint16_t get_home_n_id() const;
645  /*Reserved for customer use. Any value is valid in a Protocol flit. Propagation of this field through the
646  interconnect is IMPLEMENTATION DEFINED*/
647  void set_rsvdc(uint32_t);
648  uint32_t get_rsvdc() const;
649  /*Data Check. Detects data errors in the DAT packet*/
650  void set_data_check(uint64_t);
651  uint64_t get_data_check() const;
652  /*Trace Tag. Provides additional support for the debugging, tracing, and
653  performance measurement of systems*/
654  void set_trace_tag(bool);
655  bool is_trace_tag() const;
656  /* Indicates the operation to be performed on the tags present in
657  the corresponding DAT channel */
658  void set_tag_op(uint8_t);
659  uint8_t get_tag_op() const;
660  /* Provides up to 8 sets of 4-bit tags, each associated with a 16-byte, aligned address location. */
661  void set_tag(uint64_t);
662  uint64_t get_tag() const;
663  /* Indicates which of the Allocation Tags must be updated*/
664  void set_tu(uint16_t);
665  uint16_t get_tu() const;
666 
667 private:
668  uint8_t db_id{0};
669  rsp_resperrtype_e resp_err{rsp_resperrtype_e::OK};
670  dat_resptype_e resp{dat_resptype_e::CompData_I};
671  uint8_t fwd_state{0}, data_pull{0}, data_source{0}, cc_id{0}, data_id{0}, poison{0};
672  uint16_t tgt_id{0}, home_n_id{0};
673  dat_optype_e opcode{dat_optype_e::DataLCrdReturn};
674  uint32_t rsvdc{0};
675  uint64_t data_check{0};
676  uint64_t tag{0};
677  uint16_t tu{0};
678  uint8_t tag_op{0};
679  bool trace_tag{false};
680 };
681 
686 struct response {
687  /* Data Buffer ID. The ID provided to be used as the TxnID in the response to
688  this message*/
689  void set_db_id(uint8_t);
690  uint8_t get_db_id() const;
691  /*The PCrdType field indicates the credit type associated with the request*/
692  void set_pcrd_type(uint8_t);
693  uint8_t get_pcrd_type() const;
694  /* Set the opcode of response packet */
695  void set_opcode(rsp_optype_e opcode);
696  rsp_optype_e get_opcode() const;
697  /*Response Error status. Indicates the error status associated with request*/
698  void set_resp_err(rsp_resperrtype_e);
699  rsp_resperrtype_e get_resp_err() const;
700  /*Response status. Indicates the response associated with a request*/
701  void set_resp(rsp_resptype_e);
702  rsp_resptype_e get_resp() const;
703  /*Forward State. Indicates the cache line state associated with a data transfer
704  to the Requester from the receiver of the snoop*/
705  void set_fwd_state(uint8_t);
706  uint8_t get_fwd_state() const;
707  /*Data Pull. Indicates the inclusion of an implied Read request in the Data response*/
708  void set_data_pull(bool);
709  bool get_data_pull() const;
710  /*A transaction request includes a TgtID that identifies the target node*/
711  void set_tgt_id(uint16_t);
712  uint16_t get_tgt_id() const;
713  /* Indicates the operation to be performed on the tags present in
714  the corresponding DAT channel */
715  void set_tag_op(uint8_t);
716  uint8_t get_tag_op() const;
717  /* Precise contents are IMPLEMENTATION DEFINED. Typically
718  expected to contain Exception Level, TTBR value, and CPU identifier */
719  void set_tag_group_id(uint32_t);
720  uint32_t get_tag_group_id() const;
721  /*Trace Tag. Provides additional support for the debugging, tracing, and performance measurement of systems*/
722  void set_trace_tag(bool);
723  bool is_trace_tag() const;
724 
725 private:
726  uint8_t db_id{0}, pcrd_type{0}, fwd_state{0};
727  rsp_resperrtype_e resp_err{rsp_resperrtype_e::OK};
728  bool data_pull{false};
729  rsp_optype_e opcode{rsp_optype_e::INVALID};
730  rsp_resptype_e resp{rsp_resptype_e::SnpResp_I};
731  uint32_t tag_group_id{0};
732  uint16_t tgt_id{0};
733  uint8_t tag_op{0};
734  bool trace_tag{false};
735 };
736 
737 struct credit {
738  credit() = default;
739  credit(short unsigned count, chi::credit_type_e type)
740  : count(count)
741  , type(type) {}
742  unsigned short count{1};
743  credit_type_e type{credit_type_e::LINK};
744 };
745 
746 struct chi_ctrl_extension : public tlm::tlm_extension<chi_ctrl_extension> {
750  chi_ctrl_extension() = default;
760  tlm::tlm_extension_base* clone() const { return new chi_ctrl_extension(*this); }
765  void copy_from(tlm::tlm_extension_base const& ext) {
766  *this = static_cast<const chi_ctrl_extension&>(ext);
767  } // use assignment operator
768 
769  void set_txn_id(unsigned int id) { cmn.set_txn_id(id); }
770 
771  unsigned int get_txn_id() const { return cmn.get_txn_id(); }
772 
773  void set_src_id(unsigned int id) { cmn.set_src_id(id); }
774 
775  unsigned int get_src_id() const { return cmn.get_src_id(); }
776 
777  void set_qos(uint8_t qos) { cmn.set_qos(qos); }
778 
779  unsigned int get_qos() const { return cmn.get_qos(); }
780 
781  common cmn;
782  request req;
783  response resp;
784 };
785 
786 struct chi_snp_extension : public tlm::tlm_extension<chi_snp_extension> {
790  chi_snp_extension() = default;
800  tlm::tlm_extension_base* clone() const { return new chi_snp_extension(*this); };
805  void copy_from(tlm::tlm_extension_base const& ext) { *this = static_cast<const chi_snp_extension&>(ext); }
806 
807  void set_txn_id(unsigned int id) { cmn.set_txn_id(id); }
808 
809  unsigned int get_txn_id() const { return cmn.get_txn_id(); }
810 
811  void set_src_id(unsigned int id) { cmn.set_src_id(id); }
812 
813  unsigned int get_src_id() const { return cmn.get_src_id(); }
814 
815  void set_qos(uint8_t qos) { cmn.set_qos(qos); }
816 
817  unsigned int get_qos() const { return cmn.get_qos(); }
818 
819  common cmn;
820  snp_request req;
821  response resp;
822 };
823 
824 struct chi_data_extension : public tlm::tlm_extension<chi_data_extension> {
828  chi_data_extension() = default;
838  tlm::tlm_extension_base* clone() const { return new chi_data_extension(*this); }
843  void copy_from(tlm::tlm_extension_base const& ext) {
844  *this = static_cast<const chi_data_extension&>(ext);
845  } // use assignment operator
846 
847  void set_txn_id(unsigned int id) { cmn.set_txn_id(id); }
848 
849  unsigned int get_txn_id() const { return cmn.get_txn_id(); }
850 
851  void set_src_id(unsigned int id) { cmn.set_src_id(id); }
852 
853  unsigned int get_src_id() const { return cmn.get_src_id(); }
854 
855  void set_qos(uint8_t qos) { cmn.set_qos(qos); }
856 
857  unsigned int get_qos() const { return cmn.get_qos(); }
858 
859  common cmn{};
860  data dat{};
861 };
862 
863 struct chi_credit_extension : public tlm::tlm_extension<chi_credit_extension>, public credit {
867  chi_credit_extension() = default;
868 
869  chi_credit_extension(credit_type_e type, unsigned short count = 1)
870  : credit(count, type) {}
880  tlm::tlm_extension_base* clone() const { return new chi_credit_extension(*this); };
885  void copy_from(tlm::tlm_extension_base const& ext) {
886  *this = static_cast<const chi_credit_extension&>(ext);
887  } // use assignment operator
888 };
889 
891 using chi_payload = tlm::tlm_generic_payload;
892 using chi_phase = tlm::tlm_phase;
898  typedef chi_payload tlm_payload_type;
899  typedef chi_phase tlm_phase_type;
900 };
901 
905 DECLARE_EXTENDED_PHASE(BEGIN_PARTIAL_DATA);
906 DECLARE_EXTENDED_PHASE(END_PARTIAL_DATA);
907 DECLARE_EXTENDED_PHASE(BEGIN_DATA);
908 DECLARE_EXTENDED_PHASE(END_DATA);
910 
912 template <typename TYPES = chi::chi_protocol_types> using chi_fw_transport_if = tlm::tlm_fw_transport_if<TYPES>;
914 // template <typename TYPES = chi::chi_protocol_types> using chi_bw_transport_if = tlm::tlm_bw_transport_if<TYPES>;
915 
919 template <typename TRANS = tlm::tlm_generic_payload>
920 class bw_blocking_transport_if : public virtual sc_core::sc_interface {
921 public:
927  virtual void b_snoop(TRANS& trans, sc_core::sc_time& t) = 0;
928 };
929 
933 template <typename TYPES = chi::chi_protocol_types>
934 class chi_bw_transport_if : public tlm::tlm_bw_transport_if<TYPES>,
936 
937 #if SC_VERSION_MAJOR<3
938  using type_index = sc_core::sc_type_index;
939 #else
940  using type_index = std::type_index;
941 #endif
942 
947 template <unsigned int BUSWIDTH = 32, typename TYPES = chi_protocol_types, int N = 1,
948  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
950  : public tlm::tlm_base_initiator_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL> {
952  using base_type =
953  tlm::tlm_base_initiator_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL>;
958  : base_type() {}
963  explicit chi_initiator_socket(const char* name)
964  : base_type(name) {}
969  const char* kind() const override { return "chi_trx_initiator_socket"; }
970 #if SYSTEMC_VERSION >= 20181013 // not the right version but we assume TLM is always bundled with SystemC
975  type_index get_protocol_types() const override { return typeid(TYPES); }
976 #endif
977 };
978 
983 template <unsigned int BUSWIDTH = 32, typename TYPES = chi_protocol_types, int N = 1,
984  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
986  : public tlm::tlm_base_target_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL> {
988  using base_type =
989  tlm::tlm_base_target_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL>;
994  : base_type() {}
999  explicit chi_target_socket(const char* name)
1000  : base_type(name) {}
1005  const char* kind() const override { return "chi_trx_target_socket"; }
1006 #if SYSTEMC_VERSION >= 20181013
1011  type_index get_protocol_types() const override { return typeid(TYPES); }
1012 #endif
1013 };
1014 /*****************************************************************************
1015  * free function easing handling of transactions and extensions
1016  *****************************************************************************/
1017 
1018 template <typename EXT> inline bool is_valid(EXT& ext) { return is_valid_msg(&ext) == nullptr; }
1019 
1020 template <typename EXT> bool is_valid(EXT* ext) { return is_valid_msg(ext) == nullptr; }
1021 
1022 template <typename EXT> char const* is_valid_msg(EXT* ext);
1023 
1024 inline bool is_dataless(const chi::chi_ctrl_extension* req_e) {
1025  switch(req_e->req.get_opcode()) {
1026  case chi::req_optype_e::CleanUnique:
1027  case chi::req_optype_e::MakeUnique:
1028  case chi::req_optype_e::Evict :
1029  case chi::req_optype_e::StashOnceUnique:
1030  case chi::req_optype_e::StashOnceSepUnique:
1031  case chi::req_optype_e::StashOnceShared:
1032  case chi::req_optype_e::StashOnceSepShared:
1033  case chi::req_optype_e::CleanShared:
1034  case chi::req_optype_e::CleanSharedPersist:
1035  case chi::req_optype_e::CleanSharedPersistSep:
1036  case chi::req_optype_e::CleanInvalid:
1037  case chi::req_optype_e::MakeInvalid:
1038  case chi::req_optype_e::WriteNoSnpZero:
1039  case chi::req_optype_e::WriteUniqueZero:
1040  return true;
1041  case chi::req_optype_e::MakeReadUnique:
1042  switch(req_e->resp.get_opcode()) {
1043  case chi::rsp_optype_e::Comp: // Response to dataless MakeReadUnique request (4.5.1 Completion response of IHI0050E
1044  case chi::rsp_optype_e::CompPersist:
1045  case chi::rsp_optype_e::CompCMO:
1046  case chi::rsp_optype_e::CompStashDone:
1047  return true;
1048  default:
1049  break;
1050  }
1051  break;
1052  default:
1053  break;
1054  }
1055  return false;
1056 }
1057 
1058 inline bool is_atomic(const chi::chi_ctrl_extension* req_e) {
1059  return req_e->req.get_opcode()>=chi::req_optype_e::AtomicStoreAdd && req_e->req.get_opcode()<=chi::req_optype_e::AtomicCompare;
1060 }
1061 
1062 inline bool is_request_order(const chi::chi_ctrl_extension* req_e) {
1063  if(req_e->req.get_order()==2) {
1064  switch(req_e->req.get_opcode()) {
1065  case chi::req_optype_e::ReadNoSnp:
1066  case chi::req_optype_e::ReadNoSnpSep:
1067  case chi::req_optype_e::ReadOnce :
1068  case chi::req_optype_e::ReadOnceCleanInvalid:
1069  case chi::req_optype_e::ReadOnceMakeInvalid:
1070  case chi::req_optype_e::WriteNoSnpFull:
1071  case chi::req_optype_e::WriteNoSnpFullCleanInv:
1072  case chi::req_optype_e::WriteNoSnpFullCleanSh:
1073  case chi::req_optype_e::WriteNoSnpFullCleanShPerSep:
1074  case chi::req_optype_e::WriteNoSnpPtl:
1075  case chi::req_optype_e::WriteNoSnpPtlCleanInv:
1076  case chi::req_optype_e::WriteNoSnpPtlCleanSh:
1077  case chi::req_optype_e::WriteNoSnpPtlCleanShPerSep:
1078  case chi::req_optype_e::WriteUniqueFull:
1079  case chi::req_optype_e::WriteUniqueFullCleanSh:
1080  case chi::req_optype_e::WriteUniqueFullCleanShPerSep:
1081  case chi::req_optype_e::WriteUniqueFullStash:
1082  case chi::req_optype_e::WriteUniquePtl:
1083  case chi::req_optype_e::WriteUniquePtlCleanSh:
1084  case chi::req_optype_e::WriteUniquePtlCleanShPerSep:
1085  case chi::req_optype_e::WriteUniquePtlStash:
1086  case chi::req_optype_e::WriteUniqueZero:
1087  return true;
1088  default:
1089  break;
1090  }
1091  return is_atomic(req_e);
1092  } else
1093  return false;
1094 }
1095 /*****************************************************************************
1096  * Implementation details
1097  *****************************************************************************/
1098 template <> struct enable_for_enum<req_optype_e> { static const bool enable = true; };
1099 template <> struct enable_for_enum<snp_optype_e> { static const bool enable = true; };
1100 template <> struct enable_for_enum<dat_optype_e> { static const bool enable = true; };
1101 template <> struct enable_for_enum<dat_resptype_e> { static const bool enable = true; };
1102 template <> struct enable_for_enum<rsp_optype_e> { static const bool enable = true; };
1103 template <> struct enable_for_enum<rsp_resptype_e> { static const bool enable = true; };
1104 template <> struct enable_for_enum<rsp_resperrtype_e> { static const bool enable = true; };
1105 
1106 template <> inline req_optype_e into<req_optype_e>(typename std::underlying_type<req_optype_e>::type t) {
1107  assert(t <= static_cast<std::underlying_type<req_optype_e>::type>(req_optype_e::ILLEGAL));
1108  return static_cast<req_optype_e>(t);
1109 }
1110 
1111 template <> inline snp_optype_e into<snp_optype_e>(typename std::underlying_type<snp_optype_e>::type t) {
1112  assert(t <= static_cast<std::underlying_type<snp_optype_e>::type>(snp_optype_e::ILLEGAL));
1113  return static_cast<snp_optype_e>(t);
1114 }
1115 
1116 template <> inline dat_optype_e into<dat_optype_e>(typename std::underlying_type<dat_optype_e>::type t) {
1117  assert(t <= static_cast<std::underlying_type<dat_optype_e>::type>(dat_optype_e::NCBWrDataCompAck));
1118  return static_cast<dat_optype_e>(t);
1119 }
1120 
1121 template <> inline dat_resptype_e into<dat_resptype_e>(typename std::underlying_type<dat_resptype_e>::type t) {
1122  assert(t <= static_cast<std::underlying_type<dat_resptype_e>::type>(dat_resptype_e::CopyBackWrData_SD_PD));
1123  return static_cast<dat_resptype_e>(t);
1124 }
1125 
1126 template <> inline rsp_optype_e into<rsp_optype_e>(typename std::underlying_type<rsp_optype_e>::type t) {
1127  assert(t >= static_cast<typename std::underlying_type<rsp_optype_e>::type>(rsp_optype_e::RespLCrdReturn) &&
1128  t < static_cast<std::underlying_type<rsp_optype_e>::type>(rsp_optype_e::INVALID));
1129  return static_cast<rsp_optype_e>(t);
1130 }
1131 
1132 template <> inline rsp_resptype_e into<rsp_resptype_e>(typename std::underlying_type<rsp_resptype_e>::type t) {
1133  assert(t <= static_cast<std::underlying_type<rsp_resptype_e>::type>(rsp_resptype_e::SnpResp_SD));
1134  return static_cast<rsp_resptype_e>(t);
1135 }
1136 
1137 template <> inline rsp_resperrtype_e into<rsp_resperrtype_e>(typename std::underlying_type<rsp_resperrtype_e>::type t) {
1138  assert(t <= static_cast<std::underlying_type<rsp_resperrtype_e>::type>(rsp_resperrtype_e::NDERR));
1139  return static_cast<rsp_resperrtype_e>(t);
1140 }
1141 
1142 // [1] Implementation of 'request' structure member functions
1143 
1146 // A transaction request includes a TxnID that is used to identify the transaction from a given Requester
1147 inline void common::set_txn_id(unsigned int txn_id) {
1148  sc_assert(txn_id <= 4096); // TxnID field is defined to accommodate up to 1024 outstanding transactions.
1149  this->txn_id = txn_id;
1150 }
1151 
1154 inline unsigned int common::get_txn_id() const { return txn_id; }
1155 
1158 inline void common::set_src_id(unsigned int src_id) { this->src_id = src_id; }
1159 
1162 inline unsigned int common::get_src_id() const { return src_id; }
1163 
1166 inline void common::set_qos(uint8_t qos) { this->qos = qos; }
1167 
1170 inline unsigned int common::get_qos() const { return qos; }
1171 
1172 // [1] End of Implementation of 'common'
1173 
1174 // [2] Implementation of 'request' structure member functions
1175 
1176 // A transaction request includes a TgtID that identifies the target node
1177 inline void request::set_tgt_id(uint8_t id) { tgt_id = id; }
1178 inline uint8_t request::get_tgt_id() const { return tgt_id; }
1179 
1180 /*Logical Processor ID. Used in conjunction with the SrcID field to uniquely
1181 identify the logical processor that generated the request. */
1182 inline void request::set_lp_id(uint8_t id) { lp_id = id; }
1183 inline uint8_t request::get_lp_id() const { return lp_id; }
1184 
1185 /*Return Transaction ID. The unique transaction ID that conveys the value of
1186 TxnID in the data response from the Slave*/
1187 inline void request::set_return_txn_id(uint8_t id) { return_txn_id = id; }
1188 inline uint8_t request::get_return_txn_id() const { return return_txn_id; }
1189 
1190 // Stash Logical Processor ID. The ID of the logical processor at the Stash target.
1191 inline void request::set_stash_lp_id(uint8_t id) { stash_lp_id = id; }
1192 inline uint8_t request::get_stash_lp_id() const { return stash_lp_id; }
1193 
1194 /*Data size. Specifies the size of the data associated with the transaction. This
1195  determines the number of data packets within the transaction */
1196 inline void request::set_size(uint8_t sz) {
1197  assert(sz <= 8);
1198  size = sz;
1199 }
1200 inline uint8_t request::get_size() const { return size; }
1201 
1202 /*Max number of flits in current transaction. The number determined based on data length and bus width*/
1203 inline void request::set_max_flit(uint8_t data_id) { max_flit = data_id; }
1204 inline uint8_t request::get_max_flit() const { return max_flit; }
1205 
1206 /* Memory attribute. Determines the memory attributes associated with the
1207 transaction. */
1208 inline void request::set_mem_attr(uint8_t mem_attr) {
1209  assert(mem_attr < 16);
1210  this->mem_attr = mem_attr;
1211 }
1212 inline uint8_t request::get_mem_attr() const { return mem_attr; }
1213 
1214 inline void request:: set_device(bool is_device) {if(is_device) this->mem_attr |= 2 ; else this->mem_attr &= ~2U;}
1215 inline bool request::is_device() const { return this->mem_attr & 2; }
1216 inline void request:: set_ewa(bool is_device) {if(is_device) this->mem_attr |= 1 ; else this->mem_attr &= ~1U;}
1217 inline bool request::is_ewa() const { return this->mem_attr & 1; }
1218 inline void request:: set_allocate(bool is_device) {if(is_device) this->mem_attr |= 8 ; else this->mem_attr &= ~8U;}
1219 inline bool request::is_allocate() const { return this->mem_attr & 8; }
1220 inline void request:: set_cacheable(bool is_device) {if(is_device) this->mem_attr |= 4 ; else this->mem_attr &= ~4U;}
1221 inline bool request::is_cacheable() const { return this->mem_attr & 4; }
1222 
1223 /* Protocol Credit Type. Indicates the type of Protocol Credit being used by a
1224  request that has the AllowRetry field deasserted */
1225 inline void request::set_pcrd_type(uint8_t pcrd_type) { this->pcrd_type = pcrd_type; }
1226 inline uint8_t request::get_pcrd_type() const { return pcrd_type; }
1227 
1228 // Endianness. Indicates the endianness of Data in the Data packet.
1229 inline void request::set_endian(bool endian) { this->endian = endian; }
1230 inline bool request::is_endian() const { return this->endian; }
1231 
1232 /*Order requirement. Determines the ordering requirement for this request with
1233  respect to other transactions from the same agent.*/
1234 inline void request::set_order(uint8_t order) { this->order = order; }
1235 inline uint8_t request::get_order() const { return this->order; }
1236 
1237 /*Trace Tag. Provides additional support for the debugging, tracing, and
1238  performance measurement of systems. */
1239 inline void request::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1240 inline bool request::is_trace_tag() const { return trace_tag; }
1241 
1242 inline void request::set_opcode(req_optype_e opcode) { this->opcode = opcode; }
1243 inline req_optype_e request::get_opcode() const { return opcode; }
1244 
1245 // Return Node ID. The node ID that the response with Data is to be sent to.
1246 inline void request::set_return_n_id(uint16_t return_n_id) { this->return_n_id = return_n_id; }
1247 inline uint16_t request::get_return_n_id() const { return return_n_id; }
1248 
1249 // Stash Node ID is the node ID of the Stash target.
1250 inline void request::set_stash_n_id(uint16_t stash_n_id) { this->stash_n_id = stash_n_id; }
1251 inline uint16_t request::get_stash_n_id() const { return stash_n_id; }
1252 
1253 /* Stash Node ID Valid. Indicates that the StashNID field has a valid Stash target
1254 value. */
1255 inline void request::set_stash_n_id_valid(bool stash_n_id_valid) { this->stash_n_id_valid = stash_n_id_valid; }
1256 inline bool request::is_stash_n_id_valid() const { return stash_n_id_valid; }
1257 
1258 /*Stash Logical Processor ID. The ID of the logical processor at the Stash target.*/
1259 inline void request::set_stash_lp_id_valid(bool stash_lp_id_valid) { this->stash_lp_id_valid = stash_lp_id_valid; }
1260 inline bool request::is_stash_lp_id_valid() const { return stash_lp_id_valid; }
1261 
1262 /*Secure and Non-secure transactions are defined to support Secure and
1263 Non-secure operating states.*/
1264 inline void request::set_non_secure(bool ns) { this->ns = ns; }
1265 inline bool request::is_non_secure() const { return ns; }
1266 
1267 /* Expect CompAck. Indicates that the transaction will include a Completion
1268  Acknowledge message*/
1269 inline void request::set_exp_comp_ack(bool exp_comp_ack) { this->exp_comp_ack = exp_comp_ack; }
1270 inline bool request::is_exp_comp_ack() const { return exp_comp_ack; }
1271 
1272 /* Allow Retry determines if the target is permitted to give a Retry response.*/
1273 inline void request::set_allow_retry(bool allow_retry) { this->allow_retry = allow_retry; }
1274 inline bool request::is_allow_retry() const { return allow_retry; }
1275 
1276 /* Snoop attribute specifies the snoop attributes associated with the transaction.*/
1277 inline void request::set_snp_attr(bool snp_attr) { this->snp_attr = snp_attr; }
1278 inline bool request::is_snp_attr() const { return snp_attr; }
1279 
1280 /*Exclusive access. Indicates that the corresponding transaction is an Exclusive
1281  access transaction.*/
1282 inline void request::set_excl(bool excl) { this->excl = excl; }
1283 inline bool request::is_excl() const { return this->excl; }
1284 
1285 /* Snoop Me. Indicates that Home must determine whether to send a snoop to the
1286 Requester.*/
1287 inline void request::set_snoop_me(bool snoop_me) { this->snoop_me = snoop_me; }
1288 inline bool request::is_snoop_me() const { return snoop_me; }
1289 
1290 /*The LikelyShared attribute is a cache allocation hint. When asserted this attribute indicates
1291 that the requested data is likely to be shared by other Request Nodes within the system */
1292 inline void request::set_likely_shared(bool likely_shared) { this->likely_shared = likely_shared; }
1293 inline bool request::is_likely_shared() const { return likely_shared; }
1294 
1295 /* Reserved for customer use. Any value is valid in a Protocol flit. Propagation of this field through the interconnect
1296  is IMPLEMENTATION DEFINED.*/
1297 inline void request::set_rsvdc(uint32_t rsvdc) { this->rsvdc = rsvdc; }
1298 inline uint32_t request::get_rsvdc() const { return rsvdc; }
1299 
1300 inline void request::set_tag_op(uint8_t tag_op){ this->tag_op = tag_op; }
1301 inline uint8_t request::get_tag_op() const { return tag_op; }
1302 inline void request::set_tag_group_id(uint32_t tag_group_id){ this->tag_group_id = tag_group_id; }
1303 inline uint32_t request::get_tag_group_id() const { return tag_group_id; }
1304 inline void request::set_mpam(uint16_t mpam){ this->mpam = mpam; }
1305 inline uint16_t request::get_mpam() const { return mpam; }
1306 
1307 //===== End of [2] request
1308 
1309 //==== [3] Starting of snp_request
1310 
1311 inline void snp_request::set_fwd_txn_id(uint8_t fwd_txn_id) { this->fwd_txn_id = fwd_txn_id; }
1312 inline uint8_t snp_request::get_fwd_txn_id() const { return fwd_txn_id; }
1313 
1314 /*Stash Logical Processor ID. The ID of the logical processor at the Stash target.*/
1315 inline void snp_request::set_stash_lp_id(uint8_t stash_lp_id) { this->stash_lp_id = stash_lp_id; }
1316 inline uint8_t snp_request::get_stash_lp_id() const { return stash_lp_id; }
1317 
1318 /* Stash Node ID Valid. Indicates that the StashNID field has a valid Stash target value. */
1319 inline void snp_request::set_stash_lp_id_valid(bool stash_lp_id_valid) { this->stash_lp_id_valid = stash_lp_id_valid; }
1320 inline bool snp_request::is_stash_lp_id_valid() const { return stash_lp_id_valid; }
1321 
1322 /* Virtual Machine ID Extension use in DVM Operation types*/
1323 inline void snp_request::set_vm_id_ext(uint8_t vm_id_ext) { this->vm_id_ext = vm_id_ext; }
1324 inline uint8_t snp_request::get_vm_id_ext() const { return vm_id_ext; }
1325 
1326 /*Forward Node ID is Node ID of the original Requester */
1327 inline void snp_request::set_fwd_n_id(uint16_t fwd_n_id) { this->fwd_n_id = fwd_n_id; }
1328 inline uint16_t snp_request::get_fwd_n_id() const { return fwd_n_id; }
1329 
1330 inline void snp_request::set_opcode(snp_optype_e opcode) {
1331  // Check opcode validity
1332  this->opcode = opcode;
1333 }
1334 inline snp_optype_e snp_request::get_opcode() const { return opcode; }
1335 
1336 /*Secure and Non-secure transactions are defined to support Secure and
1337 Non-secure operating states.*/
1338 inline void snp_request::set_non_secure(bool non_secure) // NS bit
1339 {
1340  this->ns = non_secure;
1341 }
1342 inline bool snp_request::is_non_secure() const // NS bit
1343 {
1344  return ns;
1345 }
1346 
1347 /* Do Not Go To SD state controls Snoopee use of SD state.It specifies that
1348 the Snoopee must not transition to SD state as a result of the Snoop request.*/
1349 inline void snp_request::set_do_not_goto_sd(bool do_not_goto_sd) { this->do_not_goto_sd = do_not_goto_sd; }
1350 inline bool snp_request::is_do_not_goto_sd() const { return do_not_goto_sd; }
1351 
1352 /*Do Not Data Pull. Instructs the Snoopee that it is not permitted to use the
1353 Data Pull feature associated with Stash requests*/
1354 inline void snp_request::set_do_not_data_pull(bool do_not_data_pull) { this->do_not_data_pull = do_not_data_pull; }
1355 inline bool snp_request::is_do_not_data_pull() const { return do_not_data_pull; }
1356 
1357 /*Return to Source. Instructs the receiver of the snoop to return Data with
1358 the Snoop response.*/
1359 inline void snp_request::set_ret_to_src(bool ret_to_src) { this->ret_to_src = ret_to_src; }
1360 inline bool snp_request::is_ret_to_src() const { return ret_to_src; }
1361 
1362 /*Trace Tag. Provides additional support for the debugging, tracing, and
1363 performance measurement of systems*/
1364 inline void snp_request::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1365 inline bool snp_request::is_trace_tag() const { return trace_tag; }
1366 
1367 //===== End of [3] snp_request
1368 
1369 //==== [4] Starting of structure 'data' member functions
1370 
1371 /* Data Buffer ID. The ID provided to be used as the TxnID in the response to
1372 this message*/
1373 inline void data::set_db_id(uint8_t db_id) { this->db_id = db_id; }
1374 inline uint8_t data::get_db_id() const { return db_id; }
1375 
1376 /*Response Error status. Indicates the error status associated with a data
1377  transfer*/
1378 inline void data::set_resp_err(rsp_resperrtype_e resp_err) { this->resp_err = resp_err; }
1379 inline rsp_resperrtype_e data::get_resp_err() const { return resp_err; }
1380 
1381 /*Response status. Indicates the cache line state associated with a data transfer*/
1382 inline void data::set_resp(dat_resptype_e resp) { this->resp = resp; }
1383 inline dat_resptype_e data::get_resp() const { return resp; }
1384 /*Forward State. Indicates the cache line state associated with a data transfer
1385  to the Requester from the receiver of the snoop*/
1386 inline void data::set_fwd_state(uint8_t fwd_state) { this->fwd_state = fwd_state; }
1387 inline uint8_t data::get_fwd_state() const { return fwd_state; }
1388 
1389 /*Data Pull. Indicates the inclusion of an implied Read request in the Data
1390  response*/
1391 inline void data::set_data_pull(uint8_t data_pull) { this->data_pull = data_pull; }
1392 inline uint8_t data::get_data_pull() const { return data_pull; }
1393 /* Data Source. The value indicates the source of the data in a read Data
1394  response*/
1395 inline void chi::data::set_data_source(uint8_t data_source) { this->data_source = data_source; }
1396 inline uint8_t data::get_data_source() const { return data_source; }
1397 
1398 /* Critical Chunk Identifier. Replicates the address offset of the original
1399  transaction reques*/
1400 inline void data::set_cc_id(uint8_t cc_id) { this->cc_id = cc_id; }
1401 inline uint8_t data::get_cc_id() const { return cc_id; }
1402 /*Data Identifier. Provides the address offset of the data provided in the packet*/
1403 
1404 inline void data::set_data_id(uint8_t data_id) { this->data_id = data_id; }
1405 inline uint8_t data::get_data_id() const { return data_id; }
1406 
1407 /*Poison. Indicates that a set of data bytes has previously been corrupted*/
1408 inline void data::set_poison(uint8_t poison) { this->poison = poison; }
1409 inline uint8_t data::get_poison() const { return poison; }
1410 
1411 /*A transaction request includes a TgtID that identifies the target node*/
1412 inline void data::set_tgt_id(uint16_t tgt_id) { this->tgt_id = tgt_id; }
1413 inline uint16_t data::get_tgt_id() const { return tgt_id; }
1414 
1415 /*Home Node ID. The Node ID of the target of the CompAck response to be
1416  sent from the Requester*/
1417 inline void data::set_home_n_id(uint16_t home_n_id) { this->home_n_id = home_n_id; }
1418 inline uint16_t data::get_home_n_id() const { return home_n_id; }
1419 
1420 /*Reserved for customer use. Any value is valid in a Protocol flit. Propagation of this field through the interconnect
1421  is IMPLEMENTATION DEFINED*/
1422 inline void data::set_rsvdc(uint32_t rsvdc) { this->rsvdc = rsvdc; }
1423 inline uint32_t data::get_rsvdc() const { return rsvdc; }
1424 
1425 /*Data Check. Detects data errors in the DAT packet*/
1426 inline void data::set_data_check(uint64_t data_check) { this->data_check = data_check; }
1427 inline uint64_t data::get_data_check() const { return data_check; }
1428 
1429 inline void data::set_opcode(dat_optype_e opcode) { this->opcode = opcode; }
1430 inline dat_optype_e data::get_opcode() const { return opcode; }
1431 
1432 /*Trace Tag. Provides additional support for the debugging, tracing, and
1433  performance measurement of systems*/
1434 inline void data::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1435 inline bool data::is_trace_tag() const { return trace_tag; }
1436 
1437 inline void data::set_tag_op(uint8_t tag_op) { this->tag_op = tag_op; }
1438 inline uint8_t data::get_tag_op() const { return tag_op; }
1439 inline void data::set_tag(uint64_t tag) { this->tag = tag; }
1440 inline uint64_t data::get_tag() const { return tag; }
1441 inline void data::set_tu(uint16_t tu) { this->tu = tu; }
1442 inline uint16_t data::get_tu() const { return tu; }
1443 
1444 //===== End of [4] data
1445 
1446 //==== [5] Starting of structure 'response' member functions
1447 
1448 /* Data Buffer ID. The ID provided to be used as the TxnID in the response to
1449  this message*/
1450 inline void response::set_db_id(uint8_t db_id) { this->db_id = db_id; }
1451 inline uint8_t response::get_db_id() const { return db_id; }
1452 
1453 /*The PCrdType field indicates the credit type associated with the request*/
1454 inline void response::set_pcrd_type(uint8_t pcrd_type) { this->pcrd_type = pcrd_type; }
1455 inline uint8_t response::get_pcrd_type() const { return pcrd_type; }
1456 
1457 /*Response Error status. Indicates the error status associated with a data
1458 transfer*/
1459 inline void response::set_resp_err(rsp_resperrtype_e resp_err) { this->resp_err = resp_err; }
1460 inline rsp_resperrtype_e response::get_resp_err() const { return resp_err; }
1461 
1462 /*Response status. Indicates the cache line state associated with a data transfer*/
1463 inline void response::set_resp(rsp_resptype_e resp) { this->resp = resp; }
1464 inline rsp_resptype_e response::get_resp() const { return resp; }
1465 /*Forward State. Indicates the cache line state associated with a data transfer
1466 to the Requester from the receiver of the snoop*/
1467 inline void response::set_fwd_state(uint8_t fwd_state) { this->fwd_state = fwd_state; }
1468 inline uint8_t response::get_fwd_state() const { return fwd_state; }
1469 
1470 /*Data Pull. Indicates the inclusion of an implied Read request in the Data
1471 response*/
1472 inline void response::set_data_pull(bool data_pull) { this->data_pull = data_pull; }
1473 inline bool response::get_data_pull() const { return data_pull; }
1474 
1475 /*A transaction request includes a TgtID that identifies the target node*/
1476 inline void response::set_tgt_id(uint16_t tgt_id) { this->tgt_id = tgt_id; }
1477 inline uint16_t response::get_tgt_id() const { return tgt_id; }
1478 inline void response::set_opcode(rsp_optype_e opcode) { this->opcode = opcode; }
1479 inline rsp_optype_e response::get_opcode() const { return opcode; }
1480 
1481 inline void response::set_tag_op(uint8_t tag_op) { this->tag_op = tag_op; }
1482 inline uint8_t response::get_tag_op() const{ return tag_op; }
1483 inline void response::set_tag_group_id(uint32_t tag_group_id) { this->tag_group_id = tag_group_id; }
1484 inline uint32_t response::get_tag_group_id() const{ return tag_group_id; }
1485 /*Trace Tag. Provides additional support for the debugging, tracing, and
1486 performance measurement of systems*/
1487 inline void response::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1488 inline bool response::is_trace_tag() const { return trace_tag; }
1489 
1490 //===== End of [5] response
1491 
1492 } // end of namespace chi
virtual void b_snoop(TRANS &trans, sc_core::sc_time &t)=0
snoop access to a snooped master
TLM2.0 components modeling CHI.
Definition: chi_tlm.cpp:21
constexpr ULT to_int(E t)
Definition: chi_tlm.h:44
DECLARE_EXTENDED_PHASE(BEGIN_PARTIAL_DATA)
E into(typename std::underlying_type< E >::type t)
tlm::tlm_fw_transport_if< TYPES > chi_fw_transport_if
alias declaration for the forward interface
Definition: chi_tlm.h:912
tlm::tlm_generic_payload chi_payload
aliases for payload and phase types
Definition: chi_tlm.h:891
const char * to_char(E t)
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition: chi_tlm.h:885
chi_credit_extension()=default
the default constructor
tlm::tlm_extension_base * clone() const
the copy constructor
Definition: chi_tlm.h:880
chi_ctrl_extension()=default
the default constructor
chi_ctrl_extension(const chi_ctrl_extension &o)=default
the copy constructor
tlm::tlm_extension_base * clone() const
the clone function to create deep copies of
Definition: chi_tlm.h:760
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition: chi_tlm.h:765
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition: chi_tlm.h:843
tlm::tlm_extension_base * clone() const
the copy constructor
Definition: chi_tlm.h:838
chi_data_extension()=default
the default constructor
chi_initiator_socket()
default constructor using a generated instance name
Definition: chi_tlm.h:957
tlm::tlm_base_initiator_socket< BUSWIDTH, chi_fw_transport_if< TYPES >, chi_bw_transport_if< TYPES >, N, POL > base_type
base type alias
Definition: chi_tlm.h:953
chi_initiator_socket(const char *name)
constructor with instance name
Definition: chi_tlm.h:963
const char * kind() const override
get the kind of this sc_object
Definition: chi_tlm.h:969
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...
Definition: chi_tlm.h:897
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition: chi_tlm.h:805
chi_snp_extension()=default
the default constructor
tlm::tlm_extension_base * clone() const
the copy constructor
Definition: chi_tlm.h:800
const char * kind() const override
get the kind of this sc_object
Definition: chi_tlm.h:1005
chi_target_socket()
default constructor using a generated instance name
Definition: chi_tlm.h:993
tlm::tlm_base_target_socket< BUSWIDTH, chi_fw_transport_if< TYPES >, chi_bw_transport_if< TYPES >, N, POL > base_type
base type alias
Definition: chi_tlm.h:989
chi_target_socket(const char *name)
constructor with instance name
Definition: chi_tlm.h:999
void set_src_id(unsigned int)
Definition: chi_tlm.h:1158
unsigned int get_src_id() const
Definition: chi_tlm.h:1162
common & operator=(const common &o)
reset all data member to their default
Definition: chi_tlm.h:377
common()=default
the constructori
void set_txn_id(unsigned int)
Definition: chi_tlm.h:1147
void set_qos(uint8_t qos)
Definition: chi_tlm.h:1166
unsigned int get_qos() const
Definition: chi_tlm.h:1170
unsigned int get_txn_id() const
Definition: chi_tlm.h:1154