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