scc 2025.09
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 credit {
736 credit() = default;
737 credit(short unsigned count, chi::credit_type_e type)
738 : count(count)
739 , type(type) {}
740 unsigned short count{1};
741 credit_type_e type{credit_type_e::LINK};
742};
743
744struct chi_ctrl_extension : public tlm::tlm_extension<chi_ctrl_extension> {
758 tlm::tlm_extension_base* clone() const { return new chi_ctrl_extension(*this); }
763 void copy_from(tlm::tlm_extension_base const& ext) { *this = static_cast<const chi_ctrl_extension&>(ext); } // use assignment operator
764
765 void set_txn_id(unsigned int id) { cmn.set_txn_id(id); }
766
767 unsigned int get_txn_id() const { return cmn.get_txn_id(); }
768
769 void set_src_id(unsigned int id) { cmn.set_src_id(id); }
770
771 unsigned int get_src_id() const { return cmn.get_src_id(); }
772
773 void set_qos(uint8_t qos) { cmn.set_qos(qos); }
774
775 unsigned int get_qos() const { return cmn.get_qos(); }
776
777 common cmn;
778 request req;
779 response resp;
780};
781
782struct chi_snp_extension : public tlm::tlm_extension<chi_snp_extension> {
786 chi_snp_extension() = default;
796 tlm::tlm_extension_base* clone() const { return new chi_snp_extension(*this); };
801 void copy_from(tlm::tlm_extension_base const& ext) { *this = static_cast<const chi_snp_extension&>(ext); }
802
803 void set_txn_id(unsigned int id) { cmn.set_txn_id(id); }
804
805 unsigned int get_txn_id() const { return cmn.get_txn_id(); }
806
807 void set_src_id(unsigned int id) { cmn.set_src_id(id); }
808
809 unsigned int get_src_id() const { return cmn.get_src_id(); }
810
811 void set_qos(uint8_t qos) { cmn.set_qos(qos); }
812
813 unsigned int get_qos() const { return cmn.get_qos(); }
814
815 common cmn;
816 snp_request req;
817 response resp;
818};
819
820struct chi_data_extension : public tlm::tlm_extension<chi_data_extension> {
834 tlm::tlm_extension_base* clone() const { return new chi_data_extension(*this); }
839 void copy_from(tlm::tlm_extension_base const& ext) { *this = static_cast<const chi_data_extension&>(ext); } // use assignment operator
840
841 void set_txn_id(unsigned int id) { cmn.set_txn_id(id); }
842
843 unsigned int get_txn_id() const { return cmn.get_txn_id(); }
844
845 void set_src_id(unsigned int id) { cmn.set_src_id(id); }
846
847 unsigned int get_src_id() const { return cmn.get_src_id(); }
848
849 void set_qos(uint8_t qos) { cmn.set_qos(qos); }
850
851 unsigned int get_qos() const { return cmn.get_qos(); }
852
853 common cmn{};
854 data dat{};
855};
856
857struct chi_credit_extension : public tlm::tlm_extension<chi_credit_extension>, public credit {
862
863 chi_credit_extension(credit_type_e type, unsigned short count = 1)
864 : credit(count, type) {}
874 tlm::tlm_extension_base* clone() const { return new chi_credit_extension(*this); };
879 void copy_from(tlm::tlm_extension_base const& ext) { *this = static_cast<const chi_credit_extension&>(ext); } // use assignment operator
880};
881
883using chi_payload = tlm::tlm_generic_payload;
884using chi_phase = tlm::tlm_phase;
890 typedef chi_payload tlm_payload_type;
891 typedef chi_phase tlm_phase_type;
892};
893
897DECLARE_EXTENDED_PHASE(BEGIN_PARTIAL_DATA);
898DECLARE_EXTENDED_PHASE(END_PARTIAL_DATA);
899DECLARE_EXTENDED_PHASE(BEGIN_DATA);
900DECLARE_EXTENDED_PHASE(END_DATA);
902
904template <typename TYPES = chi::chi_protocol_types> using chi_fw_transport_if = tlm::tlm_fw_transport_if<TYPES>;
906// template <typename TYPES = chi::chi_protocol_types> using chi_bw_transport_if = tlm::tlm_bw_transport_if<TYPES>;
907
911template <typename TRANS = tlm::tlm_generic_payload> class bw_blocking_transport_if : public virtual sc_core::sc_interface {
912public:
918 virtual void b_snoop(TRANS& trans, sc_core::sc_time& t) = 0;
919};
920
924template <typename TYPES = chi::chi_protocol_types>
925class chi_bw_transport_if : public tlm::tlm_bw_transport_if<TYPES>,
927
928#if SC_VERSION_MAJOR < 3
929using type_index = sc_core::sc_type_index;
930#else
931using type_index = std::type_index;
932#endif
933
938template <unsigned int BUSWIDTH = 32, typename TYPES = chi_protocol_types, int N = 1,
939 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
941: public tlm::tlm_base_initiator_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL> {
943 using base_type = tlm::tlm_base_initiator_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL>;
949
953 explicit chi_initiator_socket(const char* name)
954 : base_type(name) {}
955
959 const char* kind() const override { return "chi_trx_initiator_socket"; }
960#if SYSTEMC_VERSION >= 20181013 || defined(NCSC) // not the right version but we assume TLM is always bundled with SystemC
965 type_index get_protocol_types() const override { return typeid(TYPES); }
966#endif
967};
968
973template <unsigned int BUSWIDTH = 32, typename TYPES = chi_protocol_types, int N = 1,
974 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
975struct chi_target_socket : public tlm::tlm_base_target_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL> {
977 using base_type = tlm::tlm_base_target_socket<BUSWIDTH, chi_fw_transport_if<TYPES>, chi_bw_transport_if<TYPES>, N, POL>;
983
987 explicit chi_target_socket(const char* name)
988 : base_type(name) {}
989
993 const char* kind() const override { return "chi_trx_target_socket"; }
994#if SYSTEMC_VERSION >= 20181013 || defined(NCSC)
999 type_index get_protocol_types() const override { return typeid(TYPES); }
1000#endif
1001};
1002/*****************************************************************************
1003 * free function easing handling of transactions and extensions
1004 *****************************************************************************/
1005
1006template <typename EXT> inline bool is_valid(EXT& ext) { return is_valid_msg(&ext) == nullptr; }
1007
1008template <typename EXT> bool is_valid(EXT* ext) { return is_valid_msg(ext) == nullptr; }
1009
1010template <typename EXT> char const* is_valid_msg(EXT* ext);
1011
1012inline bool is_dataless(const chi::chi_ctrl_extension* req_e) {
1013 switch(req_e->req.get_opcode()) {
1014 case chi::req_optype_e::CleanUnique:
1015 case chi::req_optype_e::MakeUnique:
1016 case chi::req_optype_e::Evict:
1017 case chi::req_optype_e::StashOnceUnique:
1018 case chi::req_optype_e::StashOnceSepUnique:
1019 case chi::req_optype_e::StashOnceShared:
1020 case chi::req_optype_e::StashOnceSepShared:
1021 case chi::req_optype_e::CleanShared:
1022 case chi::req_optype_e::CleanSharedPersist:
1023 case chi::req_optype_e::CleanSharedPersistSep:
1024 case chi::req_optype_e::CleanInvalid:
1025 case chi::req_optype_e::MakeInvalid:
1026 case chi::req_optype_e::WriteNoSnpZero:
1027 case chi::req_optype_e::WriteUniqueZero:
1028 return true;
1029 case chi::req_optype_e::MakeReadUnique:
1030 switch(req_e->resp.get_opcode()) {
1031 case chi::rsp_optype_e::Comp: // Response to dataless MakeReadUnique request (4.5.1 Completion response of IHI0050E
1032 case chi::rsp_optype_e::CompPersist:
1033 case chi::rsp_optype_e::CompCMO:
1034 case chi::rsp_optype_e::CompStashDone:
1035 return true;
1036 default:
1037 break;
1038 }
1039 break;
1040 default:
1041 break;
1042 }
1043 return false;
1044}
1045
1046inline bool is_dataless(const chi::chi_snp_extension* req_e) {
1047 switch(req_e->req.get_opcode()) {
1048 case snp_optype_e::SnpLCrdReturn:
1049 case snp_optype_e::SnpShared:
1050 case snp_optype_e::SnpClean:
1051 case snp_optype_e::SnpOnce:
1052 case snp_optype_e::SnpNotSharedDirty:
1053 case snp_optype_e::SnpUnique:
1054 case snp_optype_e::SnpCleanShared:
1055 case snp_optype_e::SnpCleanInvalid:
1056 case snp_optype_e::SnpMakeInvalid:
1057 case snp_optype_e::SnpDVMOp:
1058 case snp_optype_e::SnpQuery:
1059 case snp_optype_e::SnpPreferUnique:
1060 case snp_optype_e::SnpPreferUniqueFwd:
1061 case snp_optype_e::SnpUniqueFwd:
1062 return false;
1063 case snp_optype_e::SnpSharedFwd:
1064 case snp_optype_e::SnpCleanFwd:
1065 case snp_optype_e::SnpOnceFwd:
1066 case snp_optype_e::SnpNotSharedDirtyFwd:
1067 case snp_optype_e::SnpUniqueStash:
1068 case snp_optype_e::SnpMakeInvalidStash:
1069 case snp_optype_e::SnpStashUnique:
1070 case snp_optype_e::SnpStashShared:
1071 return true;
1072 default:
1073 return false;
1074 }
1075}
1076
1077inline bool is_atomic(const chi::chi_ctrl_extension* req_e) {
1078 return req_e->req.get_opcode() >= chi::req_optype_e::AtomicStoreAdd && req_e->req.get_opcode() <= chi::req_optype_e::AtomicCompare;
1079}
1080
1081inline bool is_request_order(const chi::chi_ctrl_extension* req_e) {
1082 if(req_e->req.get_order() == 2) {
1083 switch(req_e->req.get_opcode()) {
1084 case chi::req_optype_e::ReadNoSnp:
1085 case chi::req_optype_e::ReadNoSnpSep:
1086 case chi::req_optype_e::ReadOnce:
1087 case chi::req_optype_e::ReadOnceCleanInvalid:
1088 case chi::req_optype_e::ReadOnceMakeInvalid:
1089 case chi::req_optype_e::WriteNoSnpFull:
1090 case chi::req_optype_e::WriteNoSnpFullCleanInv:
1091 case chi::req_optype_e::WriteNoSnpFullCleanSh:
1092 case chi::req_optype_e::WriteNoSnpFullCleanShPerSep:
1093 case chi::req_optype_e::WriteNoSnpPtl:
1094 case chi::req_optype_e::WriteNoSnpPtlCleanInv:
1095 case chi::req_optype_e::WriteNoSnpPtlCleanSh:
1096 case chi::req_optype_e::WriteNoSnpPtlCleanShPerSep:
1097 case chi::req_optype_e::WriteUniqueFull:
1098 case chi::req_optype_e::WriteUniqueFullCleanSh:
1099 case chi::req_optype_e::WriteUniqueFullCleanShPerSep:
1100 case chi::req_optype_e::WriteUniqueFullStash:
1101 case chi::req_optype_e::WriteUniquePtl:
1102 case chi::req_optype_e::WriteUniquePtlCleanSh:
1103 case chi::req_optype_e::WriteUniquePtlCleanShPerSep:
1104 case chi::req_optype_e::WriteUniquePtlStash:
1105 case chi::req_optype_e::WriteUniqueZero:
1106 return true;
1107 default:
1108 break;
1109 }
1110 return is_atomic(req_e);
1111 } else
1112 return false;
1113}
1114/*****************************************************************************
1115 * Implementation details
1116 *****************************************************************************/
1117template <> struct enable_for_enum<req_optype_e> { static const bool enable = true; };
1118template <> struct enable_for_enum<snp_optype_e> { static const bool enable = true; };
1119template <> struct enable_for_enum<dat_optype_e> { static const bool enable = true; };
1120template <> struct enable_for_enum<dat_resptype_e> { static const bool enable = true; };
1121template <> struct enable_for_enum<rsp_optype_e> { static const bool enable = true; };
1122template <> struct enable_for_enum<rsp_resptype_e> { static const bool enable = true; };
1123template <> struct enable_for_enum<rsp_resperrtype_e> { static const bool enable = true; };
1124
1125template <> inline req_optype_e into<req_optype_e>(typename std::underlying_type<req_optype_e>::type t) {
1126 assert(t <= static_cast<std::underlying_type<req_optype_e>::type>(req_optype_e::ILLEGAL));
1127 return static_cast<req_optype_e>(t);
1128}
1129
1130template <> inline snp_optype_e into<snp_optype_e>(typename std::underlying_type<snp_optype_e>::type t) {
1131 assert(t <= static_cast<std::underlying_type<snp_optype_e>::type>(snp_optype_e::ILLEGAL));
1132 return static_cast<snp_optype_e>(t);
1133}
1134
1135template <> inline dat_optype_e into<dat_optype_e>(typename std::underlying_type<dat_optype_e>::type t) {
1136 assert(t <= static_cast<std::underlying_type<dat_optype_e>::type>(dat_optype_e::NCBWrDataCompAck));
1137 return static_cast<dat_optype_e>(t);
1138}
1139
1140template <> inline dat_resptype_e into<dat_resptype_e>(typename std::underlying_type<dat_resptype_e>::type t) {
1141 assert(t <= static_cast<std::underlying_type<dat_resptype_e>::type>(dat_resptype_e::CopyBackWrData_SD_PD));
1142 return static_cast<dat_resptype_e>(t);
1143}
1144
1145template <> inline rsp_optype_e into<rsp_optype_e>(typename std::underlying_type<rsp_optype_e>::type t) {
1146 assert(t >= static_cast<typename std::underlying_type<rsp_optype_e>::type>(rsp_optype_e::RespLCrdReturn) &&
1147 t < static_cast<std::underlying_type<rsp_optype_e>::type>(rsp_optype_e::INVALID));
1148 return static_cast<rsp_optype_e>(t);
1149}
1150
1151template <> inline rsp_resptype_e into<rsp_resptype_e>(typename std::underlying_type<rsp_resptype_e>::type t) {
1152 assert(t <= static_cast<std::underlying_type<rsp_resptype_e>::type>(rsp_resptype_e::SnpResp_SD));
1153 return static_cast<rsp_resptype_e>(t);
1154}
1155
1156template <> inline rsp_resperrtype_e into<rsp_resperrtype_e>(typename std::underlying_type<rsp_resperrtype_e>::type t) {
1157 assert(t <= static_cast<std::underlying_type<rsp_resperrtype_e>::type>(rsp_resperrtype_e::NDERR));
1158 return static_cast<rsp_resperrtype_e>(t);
1159}
1160
1161// [1] Implementation of 'request' structure member functions
1162
1165// A transaction request includes a TxnID that is used to identify the transaction from a given Requester
1166inline void common::set_txn_id(unsigned int txn_id) {
1167 sc_assert(txn_id <= 4096); // TxnID field is defined to accommodate up to 1024 outstanding transactions.
1168 this->txn_id = txn_id;
1169}
1170
1173inline unsigned int common::get_txn_id() const { return txn_id; }
1174
1177inline void common::set_src_id(unsigned int src_id) { this->src_id = src_id; }
1178
1181inline unsigned int common::get_src_id() const { return src_id; }
1182
1185inline void common::set_qos(uint8_t qos) { this->qos = qos; }
1186
1189inline unsigned int common::get_qos() const { return qos; }
1190
1191// [1] End of Implementation of 'common'
1192
1193// [2] Implementation of 'request' structure member functions
1194
1195// A transaction request includes a TgtID that identifies the target node
1196inline void request::set_tgt_id(uint8_t id) { tgt_id = id; }
1197inline uint8_t request::get_tgt_id() const { return tgt_id; }
1198
1199/*Logical Processor ID. Used in conjunction with the SrcID field to uniquely
1200identify the logical processor that generated the request. */
1201inline void request::set_lp_id(uint8_t id) { lp_id = id; }
1202inline uint8_t request::get_lp_id() const { return lp_id; }
1203
1204/*Return Transaction ID. The unique transaction ID that conveys the value of
1205TxnID in the data response from the Slave*/
1206inline void request::set_return_txn_id(uint8_t id) { return_txn_id = id; }
1207inline uint8_t request::get_return_txn_id() const { return return_txn_id; }
1208
1209// Stash Logical Processor ID. The ID of the logical processor at the Stash target.
1210inline void request::set_stash_lp_id(uint8_t id) { stash_lp_id = id; }
1211inline uint8_t request::get_stash_lp_id() const { return stash_lp_id; }
1212
1213/*Data size. Specifies the size of the data associated with the transaction. This
1214 determines the number of data packets within the transaction */
1215inline void request::set_size(uint8_t sz) {
1216 assert(sz <= 8);
1217 size = sz;
1218}
1219inline uint8_t request::get_size() const { return size; }
1220
1221/*Max number of flits in current transaction. The number determined based on data length and bus width*/
1222inline void request::set_max_flit(uint8_t data_id) { max_flit = data_id; }
1223inline uint8_t request::get_max_flit() const { return max_flit; }
1224
1225/* Memory attribute. Determines the memory attributes associated with the
1226transaction. */
1227inline void request::set_mem_attr(uint8_t mem_attr) {
1228 assert(mem_attr < 16);
1229 this->mem_attr = mem_attr;
1230}
1231inline uint8_t request::get_mem_attr() const { return mem_attr; }
1232
1233inline void request::set_device(bool is_device) {
1234 if(is_device)
1235 this->mem_attr |= 2;
1236 else
1237 this->mem_attr &= ~2U;
1238}
1239inline bool request::is_device() const { return this->mem_attr & 2; }
1240inline void request::set_ewa(bool is_device) {
1241 if(is_device)
1242 this->mem_attr |= 1;
1243 else
1244 this->mem_attr &= ~1U;
1245}
1246inline bool request::is_ewa() const { return this->mem_attr & 1; }
1247inline void request::set_allocate(bool is_device) {
1248 if(is_device)
1249 this->mem_attr |= 8;
1250 else
1251 this->mem_attr &= ~8U;
1252}
1253inline bool request::is_allocate() const { return this->mem_attr & 8; }
1254inline void request::set_cacheable(bool is_device) {
1255 if(is_device)
1256 this->mem_attr |= 4;
1257 else
1258 this->mem_attr &= ~4U;
1259}
1260inline bool request::is_cacheable() const { return this->mem_attr & 4; }
1261
1262/* Protocol Credit Type. Indicates the type of Protocol Credit being used by a
1263 request that has the AllowRetry field deasserted */
1264inline void request::set_pcrd_type(uint8_t pcrd_type) { this->pcrd_type = pcrd_type; }
1265inline uint8_t request::get_pcrd_type() const { return pcrd_type; }
1266
1267// Endianness. Indicates the endianness of Data in the Data packet.
1268inline void request::set_endian(bool endian) { this->endian = endian; }
1269inline bool request::is_endian() const { return this->endian; }
1270
1271/*Order requirement. Determines the ordering requirement for this request with
1272 respect to other transactions from the same agent.*/
1273inline void request::set_order(uint8_t order) { this->order = order; }
1274inline uint8_t request::get_order() const { return this->order; }
1275
1276/*Trace Tag. Provides additional support for the debugging, tracing, and
1277 performance measurement of systems. */
1278inline void request::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1279inline bool request::is_trace_tag() const { return trace_tag; }
1280
1281inline void request::set_opcode(req_optype_e opcode) { this->opcode = opcode; }
1282inline req_optype_e request::get_opcode() const { return opcode; }
1283
1284// Return Node ID. The node ID that the response with Data is to be sent to.
1285inline void request::set_return_n_id(uint16_t return_n_id) { this->return_n_id = return_n_id; }
1286inline uint16_t request::get_return_n_id() const { return return_n_id; }
1287
1288// Stash Node ID is the node ID of the Stash target.
1289inline void request::set_stash_n_id(uint16_t stash_n_id) { this->stash_n_id = stash_n_id; }
1290inline uint16_t request::get_stash_n_id() const { return stash_n_id; }
1291
1292/* Stash Node ID Valid. Indicates that the StashNID field has a valid Stash target
1293value. */
1294inline void request::set_stash_n_id_valid(bool stash_n_id_valid) { this->stash_n_id_valid = stash_n_id_valid; }
1295inline bool request::is_stash_n_id_valid() const { return stash_n_id_valid; }
1296
1297/*Stash Logical Processor ID. The ID of the logical processor at the Stash target.*/
1298inline void request::set_stash_lp_id_valid(bool stash_lp_id_valid) { this->stash_lp_id_valid = stash_lp_id_valid; }
1299inline bool request::is_stash_lp_id_valid() const { return stash_lp_id_valid; }
1300
1301/*Secure and Non-secure transactions are defined to support Secure and
1302Non-secure operating states.*/
1303inline void request::set_non_secure(bool ns) { this->ns = ns; }
1304inline bool request::is_non_secure() const { return ns; }
1305
1306/* Expect CompAck. Indicates that the transaction will include a Completion
1307 Acknowledge message*/
1308inline void request::set_exp_comp_ack(bool exp_comp_ack) { this->exp_comp_ack = exp_comp_ack; }
1309inline bool request::is_exp_comp_ack() const { return exp_comp_ack; }
1310
1311/* Allow Retry determines if the target is permitted to give a Retry response.*/
1312inline void request::set_allow_retry(bool allow_retry) { this->allow_retry = allow_retry; }
1313inline bool request::is_allow_retry() const { return allow_retry; }
1314
1315/* Snoop attribute specifies the snoop attributes associated with the transaction.*/
1316inline void request::set_snp_attr(bool snp_attr) { this->snp_attr = snp_attr; }
1317inline bool request::is_snp_attr() const { return snp_attr; }
1318
1319/*Exclusive access. Indicates that the corresponding transaction is an Exclusive
1320 access transaction.*/
1321inline void request::set_excl(bool excl) { this->excl = excl; }
1322inline bool request::is_excl() const { return this->excl; }
1323
1324/* Snoop Me. Indicates that Home must determine whether to send a snoop to the
1325Requester.*/
1326inline void request::set_snoop_me(bool snoop_me) { this->snoop_me = snoop_me; }
1327inline bool request::is_snoop_me() const { return snoop_me; }
1328
1329/*The LikelyShared attribute is a cache allocation hint. When asserted this attribute indicates
1330that the requested data is likely to be shared by other Request Nodes within the system */
1331inline void request::set_likely_shared(bool likely_shared) { this->likely_shared = likely_shared; }
1332inline bool request::is_likely_shared() const { return likely_shared; }
1333
1334/* Reserved for customer use. Any value is valid in a Protocol flit. Propagation of this field through the interconnect
1335 is IMPLEMENTATION DEFINED.*/
1336inline void request::set_rsvdc(uint32_t rsvdc) { this->rsvdc = rsvdc; }
1337inline uint32_t request::get_rsvdc() const { return rsvdc; }
1338
1339inline void request::set_tag_op(uint8_t tag_op) { this->tag_op = tag_op; }
1340inline uint8_t request::get_tag_op() const { return tag_op; }
1341inline void request::set_tag_group_id(uint32_t tag_group_id) { this->tag_group_id = tag_group_id; }
1342inline uint32_t request::get_tag_group_id() const { return tag_group_id; }
1343inline void request::set_mpam(uint16_t mpam) { this->mpam = mpam; }
1344inline uint16_t request::get_mpam() const { return mpam; }
1345
1346//===== End of [2] request
1347
1348//==== [3] Starting of snp_request
1349
1350inline void snp_request::set_fwd_txn_id(uint8_t fwd_txn_id) { this->fwd_txn_id = fwd_txn_id; }
1351inline uint8_t snp_request::get_fwd_txn_id() const { return fwd_txn_id; }
1352
1353/*Stash Logical Processor ID. The ID of the logical processor at the Stash target.*/
1354inline void snp_request::set_stash_lp_id(uint8_t stash_lp_id) { this->stash_lp_id = stash_lp_id; }
1355inline uint8_t snp_request::get_stash_lp_id() const { return stash_lp_id; }
1356
1357/* Stash Node ID Valid. Indicates that the StashNID field has a valid Stash target value. */
1358inline void snp_request::set_stash_lp_id_valid(bool stash_lp_id_valid) { this->stash_lp_id_valid = stash_lp_id_valid; }
1359inline bool snp_request::is_stash_lp_id_valid() const { return stash_lp_id_valid; }
1360
1361/* Virtual Machine ID Extension use in DVM Operation types*/
1362inline void snp_request::set_vm_id_ext(uint8_t vm_id_ext) { this->vm_id_ext = vm_id_ext; }
1363inline uint8_t snp_request::get_vm_id_ext() const { return vm_id_ext; }
1364
1365/*Forward Node ID is Node ID of the original Requester */
1366inline void snp_request::set_fwd_n_id(uint16_t fwd_n_id) { this->fwd_n_id = fwd_n_id; }
1367inline uint16_t snp_request::get_fwd_n_id() const { return fwd_n_id; }
1368
1369inline void snp_request::set_opcode(snp_optype_e opcode) {
1370 // Check opcode validity
1371 this->opcode = opcode;
1372}
1373inline snp_optype_e snp_request::get_opcode() const { return opcode; }
1374
1375/*Secure and Non-secure transactions are defined to support Secure and
1376Non-secure operating states.*/
1377inline void snp_request::set_non_secure(bool non_secure) // NS bit
1378{
1379 this->ns = non_secure;
1380}
1381inline bool snp_request::is_non_secure() const // NS bit
1382{
1383 return ns;
1384}
1385
1386/* Do Not Go To SD state controls Snoopee use of SD state.It specifies that
1387the Snoopee must not transition to SD state as a result of the Snoop request.*/
1388inline void snp_request::set_do_not_goto_sd(bool do_not_goto_sd) { this->do_not_goto_sd = do_not_goto_sd; }
1389inline bool snp_request::is_do_not_goto_sd() const { return do_not_goto_sd; }
1390
1391/*Do Not Data Pull. Instructs the Snoopee that it is not permitted to use the
1392Data Pull feature associated with Stash requests*/
1393inline void snp_request::set_do_not_data_pull(bool do_not_data_pull) { this->do_not_data_pull = do_not_data_pull; }
1394inline bool snp_request::is_do_not_data_pull() const { return do_not_data_pull; }
1395
1396/*Return to Source. Instructs the receiver of the snoop to return Data with
1397the Snoop response.*/
1398inline void snp_request::set_ret_to_src(bool ret_to_src) { this->ret_to_src = ret_to_src; }
1399inline bool snp_request::is_ret_to_src() const { return ret_to_src; }
1400
1401/*Trace Tag. Provides additional support for the debugging, tracing, and
1402performance measurement of systems*/
1403inline void snp_request::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1404inline bool snp_request::is_trace_tag() const { return trace_tag; }
1405
1406//===== End of [3] snp_request
1407
1408//==== [4] Starting of structure 'data' member functions
1409
1410/* Data Buffer ID. The ID provided to be used as the TxnID in the response to
1411this message*/
1412inline void data::set_db_id(uint16_t db_id) { this->db_id = db_id; }
1413inline uint16_t data::get_db_id() const { return db_id; }
1414
1415/*Response Error status. Indicates the error status associated with a data
1416 transfer*/
1417inline void data::set_resp_err(rsp_resperrtype_e resp_err) { this->resp_err = resp_err; }
1418inline rsp_resperrtype_e data::get_resp_err() const { return resp_err; }
1419
1420/*Response status. Indicates the cache line state associated with a data transfer*/
1421inline void data::set_resp(dat_resptype_e resp) { this->resp = resp; }
1422inline dat_resptype_e data::get_resp() const { return resp; }
1423/*Forward State. Indicates the cache line state associated with a data transfer
1424 to the Requester from the receiver of the snoop*/
1425inline void data::set_fwd_state(uint8_t fwd_state) { this->fwd_state = fwd_state; }
1426inline uint8_t data::get_fwd_state() const { return fwd_state; }
1427
1428/*Data Pull. Indicates the inclusion of an implied Read request in the Data
1429 response*/
1430inline void data::set_data_pull(uint8_t data_pull) { this->data_pull = data_pull; }
1431inline uint8_t data::get_data_pull() const { return data_pull; }
1432/* Data Source. The value indicates the source of the data in a read Data
1433 response*/
1434inline void chi::data::set_data_source(uint8_t data_source) { this->data_source = data_source; }
1435inline uint8_t data::get_data_source() const { return data_source; }
1436
1437/* Critical Chunk Identifier. Replicates the address offset of the original
1438 transaction reques*/
1439inline void data::set_cc_id(uint8_t cc_id) { this->cc_id = cc_id; }
1440inline uint8_t data::get_cc_id() const { return cc_id; }
1441/*Data Identifier. Provides the address offset of the data provided in the packet*/
1442
1443inline void data::set_data_id(uint8_t data_id) { this->data_id = data_id; }
1444inline uint8_t data::get_data_id() const { return data_id; }
1445
1446/*Poison. Indicates that a set of data bytes has previously been corrupted*/
1447inline void data::set_poison(uint8_t poison) { this->poison = poison; }
1448inline uint8_t data::get_poison() const { return poison; }
1449
1450/*A transaction request includes a TgtID that identifies the target node*/
1451inline void data::set_tgt_id(uint16_t tgt_id) { this->tgt_id = tgt_id; }
1452inline uint16_t data::get_tgt_id() const { return tgt_id; }
1453
1454/*Home Node ID. The Node ID of the target of the CompAck response to be
1455 sent from the Requester*/
1456inline void data::set_home_n_id(uint16_t home_n_id) { this->home_n_id = home_n_id; }
1457inline uint16_t data::get_home_n_id() const { return home_n_id; }
1458
1459/*Reserved for customer use. Any value is valid in a Protocol flit. Propagation of this field through the interconnect
1460 is IMPLEMENTATION DEFINED*/
1461inline void data::set_rsvdc(uint32_t rsvdc) { this->rsvdc = rsvdc; }
1462inline uint32_t data::get_rsvdc() const { return rsvdc; }
1463
1464/*Data Check. Detects data errors in the DAT packet*/
1465inline void data::set_data_check(uint64_t data_check) { this->data_check = data_check; }
1466inline uint64_t data::get_data_check() const { return data_check; }
1467
1468inline void data::set_opcode(dat_optype_e opcode) { this->opcode = opcode; }
1469inline dat_optype_e data::get_opcode() const { return opcode; }
1470
1471/*Trace Tag. Provides additional support for the debugging, tracing, and
1472 performance measurement of systems*/
1473inline void data::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1474inline bool data::is_trace_tag() const { return trace_tag; }
1475
1476inline void data::set_tag_op(uint8_t tag_op) { this->tag_op = tag_op; }
1477inline uint8_t data::get_tag_op() const { return tag_op; }
1478inline void data::set_tag(uint64_t tag) { this->tag = tag; }
1479inline uint64_t data::get_tag() const { return tag; }
1480inline void data::set_tu(uint16_t tu) { this->tu = tu; }
1481inline uint16_t data::get_tu() const { return tu; }
1482
1483//===== End of [4] data
1484
1485//==== [5] Starting of structure 'response' member functions
1486
1487/* Data Buffer ID. The ID provided to be used as the TxnID in the response to
1488 this message*/
1489inline void response::set_db_id(uint16_t db_id) { this->db_id = db_id; }
1490inline uint16_t response::get_db_id() const { return db_id; }
1491
1492/*The PCrdType field indicates the credit type associated with the request*/
1493inline void response::set_pcrd_type(uint8_t pcrd_type) { this->pcrd_type = pcrd_type; }
1494inline uint8_t response::get_pcrd_type() const { return pcrd_type; }
1495
1496/*Response Error status. Indicates the error status associated with a data
1497transfer*/
1498inline void response::set_resp_err(rsp_resperrtype_e resp_err) { this->resp_err = resp_err; }
1499inline rsp_resperrtype_e response::get_resp_err() const { return resp_err; }
1500
1501/*Response status. Indicates the cache line state associated with a data transfer*/
1502inline void response::set_resp(rsp_resptype_e resp) { this->resp = resp; }
1503inline rsp_resptype_e response::get_resp() const { return resp; }
1504/*Forward State. Indicates the cache line state associated with a data transfer
1505to the Requester from the receiver of the snoop*/
1506inline void response::set_fwd_state(uint8_t fwd_state) { this->fwd_state = fwd_state; }
1507inline uint8_t response::get_fwd_state() const { return fwd_state; }
1508
1509/*Data Pull. Indicates the inclusion of an implied Read request in the Data
1510response*/
1511inline void response::set_data_pull(bool data_pull) { this->data_pull = data_pull; }
1512inline bool response::get_data_pull() const { return data_pull; }
1513
1514/*A transaction request includes a TgtID that identifies the target node*/
1515inline void response::set_tgt_id(uint16_t tgt_id) { this->tgt_id = tgt_id; }
1516inline uint16_t response::get_tgt_id() const { return tgt_id; }
1517inline void response::set_opcode(rsp_optype_e opcode) { this->opcode = opcode; }
1518inline rsp_optype_e response::get_opcode() const { return opcode; }
1519
1520inline void response::set_tag_op(uint8_t tag_op) { this->tag_op = tag_op; }
1521inline uint8_t response::get_tag_op() const { return tag_op; }
1522inline void response::set_tag_group_id(uint32_t tag_group_id) { this->tag_group_id = tag_group_id; }
1523inline uint32_t response::get_tag_group_id() const { return tag_group_id; }
1524/*Trace Tag. Provides additional support for the debugging, tracing, and
1525performance measurement of systems*/
1526inline void response::set_trace_tag(bool trace_tag) { this->trace_tag = trace_tag; }
1527inline bool response::is_trace_tag() const { return trace_tag; }
1528
1529//===== End of [5] response
1530
1531} // 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:904
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:883
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition chi_tlm.h:879
chi_credit_extension()=default
the default constructor
tlm::tlm_extension_base * clone() const
the copy constructor
Definition chi_tlm.h:874
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:763
tlm::tlm_extension_base * clone() const
the clone function to create deep copies of
Definition chi_tlm.h:758
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition chi_tlm.h:839
tlm::tlm_extension_base * clone() const
the copy constructor
Definition chi_tlm.h:834
chi_data_extension()=default
the default constructor
chi_initiator_socket()
default constructor using a generated instance name
Definition chi_tlm.h:947
const char * kind() const override
get the kind of this sc_object
Definition chi_tlm.h:959
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:943
chi_initiator_socket(const char *name)
constructor with instance name
Definition chi_tlm.h:953
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...
Definition chi_tlm.h:889
void copy_from(tlm::tlm_extension_base const &ext)
deep copy all values from ext
Definition chi_tlm.h:801
chi_snp_extension()=default
the default constructor
tlm::tlm_extension_base * clone() const
the copy constructor
Definition chi_tlm.h:796
chi_target_socket()
default constructor using a generated instance name
Definition chi_tlm.h:981
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:977
const char * kind() const override
get the kind of this sc_object
Definition chi_tlm.h:993
chi_target_socket(const char *name)
constructor with instance name
Definition chi_tlm.h:987
void set_src_id(unsigned int)
Definition chi_tlm.h:1177
unsigned int get_src_id() const
Definition chi_tlm.h:1181
common()=default
the constructori
void set_txn_id(unsigned int)
Definition chi_tlm.h:1166
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:1185
unsigned int get_qos() const
Definition chi_tlm.h:1189
unsigned int get_txn_id() const
Definition chi_tlm.h:1173