/
axi_tlm.h
1650 lines (1515 loc) · 50.3 KB
/
axi_tlm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2020 Arteris IP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <array>
#include <cstdint>
#include <tlm>
#include <type_traits>
//! TLM2.0 components modeling AXI/ACE
namespace axi {
enum class flavor_e { AXI, ACEL, ACE };
/**
* helper function to allow SFINAE
*/
template <typename Enum> struct enable_for_enum { static const bool value = false; };
/**
* helper function to convert integer into class enums
* @param t
* @return
*/
template <typename E> inline E into(typename std::underlying_type<E>::type t);
/**
* helper function to convert class enums into integer
* @param t
* @return
*/
template <
typename E, typename ULT = typename std::underlying_type<E>::type,
typename X = typename std::enable_if<std::is_enum<E>::value && !std::is_convertible<E, ULT>::value, bool>::type>
inline constexpr ULT to_int(E t) {
return static_cast<typename std::underlying_type<E>::type>(t);
}
/**
* helper function to convert class enums into char string
* @param t
* @return
*/
template <typename E> const char* to_char(E t);
/**
*
* @param os
* @param e
* @return
*/
template <typename E, typename std::enable_if<enable_for_enum<E>::value, bool>::type>
inline std::ostream& operator<<(std::ostream& os, E e) {
os << to_char(e);
return os;
}
std::ostream& operator<<(std::ostream& os, tlm::tlm_generic_payload const& t);
/**
* the burst type enumeration class
*/
enum class burst_e : uint8_t {
FIXED = 0, /** fixed address burst */
INCR = 1, /** incrementing burst */
WRAP = 2 /** wrapping burst */
};
/**
* the lock type enumeration class
*/
enum class lock_e : uint8_t { NORMAL = 0x0, EXLUSIVE = 0x1, LOCKED = 0x2 };
/**
* the domain type enumeration class
*/
enum class domain_e : uint8_t { NON_SHAREABLE = 0x0, INNER_SHAREABLE = 0x1, OUTER_SHAREABLE = 0x2, SYSTEM = 0x3 };
/**
* the barrier type enumeration class
*/
enum class bar_e : uint8_t {
RESPECT_BARRIER = 0x0, //! Normal access, respecting barriers
MEMORY_BARRIER = 0x1, //! Memory barrier
IGNORE_BARRIER = 0x2, //! Normal access, ignoring barriers
SYNCHRONISATION_BARRIER = 0x3 //!Synchronization barrier
};
/**
* the snoop type enumeration class. Since the interpretation depends of other setting there are double defined entries
*/
enum class snoop_e : uint8_t {
// clang-format off
// non-snooping (domain==0 || domain==3, bar==0)
READ_NO_SNOOP = 0x10,
// Coherent (domain==1 || domain==2, bar==0)
READ_ONCE = 0x0,
READ_SHARED = 0x1,
READ_CLEAN = 0x2,
READ_NOT_SHARED_DIRTY = 0x3,
READ_ONCE_CLEAN_INVALID = 0x4, // ACE5
READ_ONCE_MAKE_INVALID = 0x5, // ACE5
READ_UNIQUE = 0x7,
CLEAN_UNIQUE = 0xb,
MAKE_UNIQUE = 0xc,
// Cache maintenance (domain==0 || domain==1 || domain==2, bar==0)
CLEAN_SHARED = 0x8,
CLEAN_INVALID = 0x9,
CLEAN_SHARED_PERSIST = 0xa, // ACE5
MAKE_INVALID = 0xd,
// DVM (domain==1 || domain==2, bar==0)
DVM_COMPLETE = 0xe,
DVM_MESSAGE = 0xf,
// Barrier (bar==1)
BARRIER = 0x40,
// non-snooping (domain==0 || domain==3, bar==0)
WRITE_NO_SNOOP = 0x30,
// Coherent (domain==1 || domain==2, bar==0)
WRITE_UNIQUE = 0x20,
WRITE_LINE_UNIQUE = 0x21,
// Memory update (domain==0 || domain==1 || domain==2, bar==0)
WRITE_CLEAN = 0x22,
WRITE_BACK = 0x23,
// (domain==1 || domain==2)
EVICT = 0x24,
WRITE_EVICT = 0x25,
CMO_ON_WRITE = 0x26, // ACE5Lite
// Cache Stash Transactions, ACE5Lite
WRITE_UNIQUE_PTL_STASH = 0x28,
WRITE_UNIQUE_FULL_STASH = 0x29,
STASH_ONCE_SHARED = 0x2c,
STASH_ONCE_UNIQUE = 0x2d,
STASH_TRANSLATION = 0x2e
// clang-format on
};
enum class atop_low_e { ADD = 0x0, CLR = 0x1, EOR = 0x2, SET = 0x3, SMAX = 0x4, SMIN = 0x5, UMAX = 0x6, UMIN = 0x7 };
enum class atop_enc_e {
NonAtomic = 0x00,
AtomicStore = 0x10,
AtomicLoad = 0x20,
AtomicSwap = 0x30,
AtomicCompare = 0x31,
};
/**
* the response type enumeration class
*/
enum class resp_e : uint8_t { OKAY = 0x0, EXOKAY = 0x1, SLVERR = 0x2, DECERR = 0x3 };
/**
* the variable part of all requests containing AxID and AxUSER
*/
struct common {
//! the constructor
common() = default;
//! reset all data member to their default
void reset();
/**
* @brief copy assignment operator
* @param o
* @return reference to self
*/
common& operator=(const common& o) {
id = o.id;
user = o.user;
return *this;
}
/**
* Since AXI has up to three channels per transaction the id and user fields are denoted by this enum
*/
enum class id_type { CTRL, DATA, RESP };
//! set the id value of a particular channel
//! @param value of the AxID of the ADDR, DATA, and RESP channel
void set_id(unsigned int value);
//! get the id value of a particular channel
//! @return the AxID
unsigned int get_id() const;
//! set the user value of a particular channel
//! @param chnl AxUSER value of the ADDR, DATA, and RESP channel
//! @param value of the user field
void set_user(id_type chnl, unsigned int value);
//! get the user value of a particular channel
//! @return AxUSER value
unsigned int get_user(id_type chnl) const;
protected:
unsigned id{0};
std::array<unsigned, 3> user{{0, 0, 0}};
};
/**
* The request part of AXI3, AXI4 and ACE transactions. All member data are stored in this
* class to allow easy reuse of free'd memory and prevent memory fragmentation.
* The request class holds the data in a similar representation than in the HW implementation. Derived
* classes are not expected to add data member, they only add interpretation of bits and fields as
* member functions
*/
struct request {
//! the default constructor
request() = default;
//! reset all data member to their default
void reset();
/**
* @brief set the AxLEN value of the transaction, the value denotes the burst length - 1
* @param the len value
*/
void set_length(uint8_t);
/**
* @brief get the AxLEN value of the transaction, the value denotes the burst length - 1
* @return the AxLEN value
*/
uint8_t get_length() const;
/**
* @brief get the AxSIZE value of the transaction, the length is 2^size. It needs to be less than 10 (512 bit width)
* @param size value of AxSIZE
*/
void set_size(uint8_t);
/**
* @brief set the AxSIZE value of the transaction
* @return AxSIZE value
*/
uint8_t get_size() const;
/**
* @brief set the AxBURST value, @see burst_e
* @param the burst
*/
void set_burst(burst_e);
/**
* @brief get the AxBURST value, @see burst_e
* @return
*/
burst_e get_burst() const;
/**
* @brief set the AxPROT value as POD, only values from 0...7 are allowed
* @param the prot value
*/
void set_prot(uint8_t);
/**
* @brief set the AxPROT value as POD, only values from 0...7 are allowed
* @return the prot value
*/
uint8_t get_prot() const;
/**
* @brief set the privileged bit of the AxPROT (AxPROT[0])
* @param the privileged value
*/
void set_privileged(bool = true);
/**
* @brief get the privileged bit of the AxPROT (AxPROT[0])
* @return the privileged value
*/
bool is_privileged() const;
/**
* @brief set the non-secure bit of the AxPROT (AxPROT[1])
* @param the non-secure bit
*/
void set_non_secure(bool = true);
/**
* @brief set the non-secure bit of the AxPROT (AxPROT[1])
* @return the non-secure bit
*/
bool is_non_secure() const;
/**
* @brief set the instruction bit of the AxPROT (AxPROT[2])
* @param the instruction bit
*/
void set_instruction(bool = true);
/**
* @brief set the instruction bit of the AxPROT (AxPROT[2])
* @return the instruction bit
*/
bool is_instruction() const;
/**
* @brief set the AxCACHE value as POD, only value from 0..15 are allowed
* @param the cache value
*/
void set_cache(uint8_t);
/**
* @brief get the AxCACHE value as POD
* @return the cache value
*/
uint8_t get_cache() const;
/**
* @brief set the AxQOS (quality of service) value
* @param the qos value
*/
void set_qos(uint8_t);
/**
* @brief get the AxQOS (quality of service) value
* @return the qos value
*/
uint8_t get_qos() const;
/**
* @brief set the AxREGION value
* @param the region value
*/
void set_region(uint8_t);
/**
* @brief get the AxREGION value
* @return the region value
*/
uint8_t get_region() const;
/**
* @brief set the raw AWATOP value
* @param the atop value
*/
void set_atop(uint8_t);
/**
* @brief get the raw AWATOP value
* return the unique value
*/
uint8_t get_atop() const;
/**
* @brief set the raw AWSTASHNID value
* @param the atop value
*/
void set_stash_nid(uint8_t);
/**
* @brief get the raw AWSTASHNID value
* return the unique value
*/
uint8_t get_stash_nid() const;
/**
* @brief check if AWSTASHNID is valid
* return the valid value
*/
bool is_stash_nid_en() const;
/**
* @brief set the raw AWSTASHLPID value
* @param the atop value
*/
void set_stash_lpid(uint8_t);
/**
* @brief get the raw AWSTASHLPID value
* return the unique value
*/
uint8_t get_stash_lpid() const;
/**
* @brief check if AWSTASHLPID is valid
* return the valid value
*/
bool is_stash_lpid_en() const;
protected:
/**
* equal operator
* @param o
* @return reference to self
*/
request& operator=(const request& o) {
length = o.length;
size = o.size;
burst = o.burst;
prot = o.prot;
qos = o.qos;
region = o.region;
domain = o.domain;
snoop = o.snoop;
barrier = o.barrier;
lock = o.lock;
cache = o.cache;
unique = o.unique;
atop = o.atop;
return *this;
}
enum { // bit masks
BUFFERABLE = 1,
CACHEABLE = 2,
RA = 4,
WA = 8,
EXCL = 1,
LOCKED = 2,
PRIVILEGED = 1,
SECURE = 2,
INSTRUCTION = 4
};
bool unique{false};
// sums up to sizeof(bool) +11 bytes + sizeof(response)= 16bytes
uint8_t length{0};
uint8_t size{0};
burst_e burst{burst_e::FIXED};
uint8_t prot{0};
uint8_t qos{0};
uint8_t region{0};
domain_e domain{domain_e::NON_SHAREABLE};
snoop_e snoop{snoop_e::READ_NO_SNOOP};
bar_e barrier{bar_e::RESPECT_BARRIER};
lock_e lock{lock_e::NORMAL};
uint8_t cache{0};
uint8_t atop{0};
uint16_t stash_nid{std::numeric_limits<uint16_t>::max()};
uint8_t stash_lpid{std::numeric_limits<uint8_t>::max()};
};
/**
* The AXI3 specific interpretation of request data members
*/
struct axi3 : public request {
/**
* equal operator
* @param o
* @return reference to self
*/
axi3& operator=(const axi3& o) {
request::operator=(o);
return *this;
}
/**
* @brief get the exclusive bit of AxLOCK (AxLOCK[0])
* @param the exclusive bit
*/
void set_exclusive(bool = true);
/**
* @brief get the exclusive bit of AxLOCK (AxLOCK[0])
* return the exclusive bit
*/
bool is_exclusive() const;
/**
* @brief get the locked bit of AxLOCK (AxLOCK[1])
* @param the locked bit
*/
void set_locked(bool = true);
/**
* @brief get the locked bit of AxLOCK (AxLOCK[1])
* return the locked bit
*/
bool is_locked() const;
/**
* @brief set the bufferable bit of AxCACHE (AxCACHE[0])
* @param the bufferable bit
*/
void set_bufferable(bool = true);
/**
* @brief get the bufferable bit of AxCACHE (AxCACHE[0])
* return the bufferable bit
*/
bool is_bufferable() const;
/**
* @brief set the cacheable bit of AxCACHE (AxCACHE[1])
* @param the cacheable bit
*/
void set_cacheable(bool = true);
/**
* @brief get the cacheable bit of AxCACHE (AxCACHE[1])
* return the cacheable bit
*/
bool is_cacheable() const;
/**
* @brief set the write_allocate bit of AxCACHE (AxCACHE[2])
* @param the write_allocate bit
*/
void set_write_allocate(bool = true);
/**
* @brief get the write_allocate bit of AxCACHE (AxCACHE[2])
* return the write_allocate bit
*/
bool is_write_allocate() const;
/**
* @brief set the read_allocate bit of AxCACHE (AxCACHE[3])
* @param the read_allocate bit
*/
void set_read_allocate(bool = true);
/**
* @brief get the read_allocate bit of AxCACHE (AxCACHE[3])
* return the read_allocate bit
*/
bool is_read_allocate() const;
};
/**
* The AXI4 specific interpretation of request data members
*/
struct axi4 : public request {
/**
* equal operator
* @param o
* @return reference to self
*/
axi4& operator=(const axi4& o) {
request::operator=(o);
return *this;
}
/**
* @brief get the exclusive bit of AxLOCK (AxLOCK[0])
* @param the exclusive bit
*/
void set_exclusive(bool = true);
/**
* @brief get the exclusive bit of AxLOCK (AxLOCK[0])
* return the exclusive bit
*/
bool is_exclusive() const;
/**
* @brief set the bufferable bit of AxCACHE (AxCACHE[0])
* @param the bufferable bit
*/
void set_bufferable(bool = true);
/**
* @brief get the bufferable bit of AxCACHE (AxCACHE[0])
* return the bufferable bit
*/
bool is_bufferable() const;
/**
* @brief set the modifiable bit of AxCACHE (AxCACHE[1])
* @param the modifiable bit
*/
void set_modifiable(bool = true);
/**
* @brief get the modifiable bit of AxCACHE (AxCACHE[1])
* return the modifiable bit
*/
bool is_modifiable() const;
/**
* @brief set the read allocate/write other allocate bit of AxCACHE (AxCACHE[2])
* @param the read_other_allocate bit
*/
void set_read_other_allocate(bool = true);
/**
* @brief get the read allocate/write other allocate bit of AxCACHE (AxCACHE[2])
* return the read_other_allocate bit
*/
bool is_read_other_allocate() const;
/**
* @brief set the write allocate/read other allocate bit of AxCACHE (AxCACHE[3])
* @param the write_other_allocate bit
*/
void set_write_other_allocate(bool = true);
/**
* @brief get the write allocate/read other allocate bit of AxCACHE (AxCACHE[3])
* return the write_other_allocate bit
*/
bool is_write_other_allocate() const;
};
/**
* The ACE specific interpretation of request data members extending the AXI4 one
*/
struct ace : public axi4 {
/**
* equal operator
* @param o
* @return reference to self
*/
ace& operator=(const ace& o) {
request::operator=(o);
return *this;
}
/**
* @brief set the AxDOMAIN value
* @param the domain value
*/
void set_domain(domain_e);
/**
* @brief get the AxDOMAIN value
* return the domain value
*/
domain_e get_domain() const;
/**
* @brief set the AxSNOOP value
* @param the snoop value
*/
void set_snoop(snoop_e);
/**
* @brief get the AxSNOOP value
* return the snoop value
*/
snoop_e get_snoop() const;
/**
* @brief set the AxBAR value
* @param the barrier value
*/
void set_barrier(bar_e);
/**
* @brief get the AxBAR value
* return the barrier value
*/
bar_e get_barrier() const;
/**
* @brief set the AxUNIQUE value
* @param the unique value
*/
void set_unique(bool);
/**
* @brief get the AxUNIQUE value
* return the unique value
*/
bool get_unique() const;
};
/**
* the response status of an AXI transaction
*/
struct response {
response() = default;
/**
* @brief assignment operator
* @param o
* @return reference to self
*/
response& operator=(const response& o) {
resp = o.resp;
return *this;
}
/**
* @brief reset all data member to their default
*/
void reset();
/**
* @brief converts the response status of a generic payload to a @see resp_e type
* @param the tlm gp response status
* @return the axi response status
*/
static resp_e from_tlm_response_status(tlm::tlm_response_status);
/**
* @brief converts a @see resp_e type to a response status of a generic payload
* @param the axi response status
* @return the tlm gp response status
*/
static tlm::tlm_response_status to_tlm_response_status(resp_e);
/**
* @brief set the response status as POD
* @param the status
*/
void set_resp(resp_e);
/**
* @brief get the response status as POD
* @return the status
*/
resp_e get_resp() const;
/**
* @brief check if the response status is OKAY
* @return true if the status was ok
*/
bool is_okay() const;
/**
* @brief set the response status to OKAY
*/
void set_okay();
/**
* @brief check if the response status is EXOKAY
* @return true if the status was exok
*/
bool is_exokay() const;
/**
* @brief set the response status to EXOKAY
*/
void set_exokay();
/**
* @brief check if the response status is SLVERR
* @return true if the status was slverr
*/
bool is_slverr() const;
/**
* @brief set the response status to SLVERR
*/
void set_slverr();
/**
* @brief check if the response status is DECERR
* @return true if the status was decerr
*/
bool is_decerr() const;
/**
* @brief set the response status to DECERR
*/
void set_decerr();
protected:
enum { // bit masks for CRESP
DATATRANSFER = 1,
SNOOPEERROR = 2,
PASSDIRTY = 4,
ISSHARED = 8,
WASUNIQUE = 16
};
uint8_t resp{static_cast<uint8_t>(resp_e::OKAY)};
};
/**
* the response status of an ACE and SNOOP transaction extending the AXI one
*/
struct ace_response : public response {
/**
* @brief set the coherent response status
* @param the status
*/
void set_cresp(uint8_t);
/**
* @brief get the coherent response status
* @return the status
*/
uint8_t get_cresp() const;
/**
* @brief check the response status bit PassDirty (CRESP[2])
* @return true if the status was pass dirty
*/
bool is_pass_dirty() const;
/**
* @brief set the response status bit PassDirty
* @param the pass dirty status
*/
void set_pass_dirty(bool = true);
/**
* @brief check the response status bit IsShared (CRESP[3])
* @return true if the status was shared
*/
bool is_shared() const;
/**
* @brief set the response status bit IsShared
* @param the shared status
*/
void set_shared(bool = true);
/**
* @brief check the response status bit DataTransfer
* @return true if there is data to be transfered
*/
// CRRESP[0]
bool is_snoop_data_transfer() const;
/**
* @brief set the response status bit DataTransfer
* @param true if there is data to be transfered false otherwise
*/
void set_snoop_data_transfer(bool = true);
/**
* @brief check the response status bit Error
* @return true if the was an error
*/
// CRRESP[1]
bool is_snoop_error() const;
/**
* @brief set the response status bit Error
* @param true if there is an error false otherwise
*/
void set_snoop_error(bool = true);
/**
* @brief check the response status bit WasUnique
* @return true if the access was unique
*/
// CRRESP[4]
bool is_snoop_was_unique() const;
/**
* @brief set the response status bit WasUnique
* @param the unique flag
*/
void set_snoop_was_unique(bool = true);
};
/**
* the template class forming an AXI extension as a combination of common, a request class and a response class
*/
template <typename REQ, typename RESP = response>
struct axi_extension : public common, // 2x 4byte
public REQ, // 11byte + 4byte
public RESP // 1byte
{
/**
* @brief the default constructor
*/
axi_extension() = default;
/**
* @brief the copy constructor
* @param the extension to copy from
*/
axi_extension(const axi_extension<REQ, RESP>*);
/**
* the virtual destructor
*/
virtual ~axi_extension() {}
/**
* @brief reset all data member to their default
*/
void reset();
/**
* @brief reset the common and response part, reset response using the given reset value
* @param the response reset value
*/
void reset(const REQ*);
/**
* @brief add a read response to the response array
* @param the response
*/
void add_to_response_array(response&);
/**
* @brief return the read response array for constant instances
* @return the const-qualified response array
*/
const std::vector<response>& get_response_array() const;
/**
* @brief return the read response array
* @return the response array
*/
std::vector<response>& get_response_array();
/**
* @brief set the flag indicating the all read responses are collected
* @param the flag value
*/
void set_response_array_complete(bool = true);
/**
* get the flag indicating the all read responses are collected
* @return the flag value
*/
bool is_response_array_complete();
private:
std::vector<response> response_arr{};
bool response_array_complete{false};
};
/**
* the AXI3 tlm extension class
*/
struct axi3_extension : public tlm::tlm_extension<axi3_extension>, public axi_extension<axi3> {
/**
* @brief the default constructor
*/
axi3_extension() = default;
/**
* @brief the copy constructor
* @param the extension to copy from
*/
axi3_extension(const axi3_extension* o)
: axi_extension<axi3>(o) {}
/**
* @brief the clone function to create deep copies of
* @return pointer to heap-allocated extension
*/
tlm::tlm_extension_base* clone() const override;
/**
* @brief deep copy all values from ext
* @param ext
*/
void copy_from(tlm::tlm_extension_base const& ext) override;
};
/**
* the AXI4 tlm extension class
*/
struct axi4_extension : public tlm::tlm_extension<axi4_extension>, public axi_extension<axi4> {
/**
* @brief the default constructor
*/
axi4_extension() = default;
/**
* @brief the copy constructor
* @param the extension to copy from
*/
axi4_extension(const axi4_extension* o)
: axi_extension<axi4>(o) {}
/**
* @brief the clone function to create deep copies of
* @return pointer to heap-allocated extension
*/
tlm::tlm_extension_base* clone() const override;
/**
* @brief deep copy all values from ext
* @param ext
*/
void copy_from(tlm::tlm_extension_base const& ext) override;
};
/**
* the ACE tlm extension class
*/
struct ace_extension : public tlm::tlm_extension<ace_extension>, public axi_extension<ace, ace_response> {
/**
* @brief the default constructor
*/
ace_extension() = default;
/**
* @brief the copy constructor
* @param the extension to copy from
*/
ace_extension(const ace_extension* o)
: axi_extension<ace, ace_response>(o) {}
/**
* @brief the clone function to create deep copies of
* @return pointer to heap-allocated extension
*/
tlm::tlm_extension_base* clone() const override;
/**
* @brief deep copy all values from ext
* @param ext
*/
void copy_from(tlm::tlm_extension_base const& ext) override;
};
//! aliases for payload and phase types
using axi_payload = tlm::tlm_generic_payload;
using axi_phase = tlm::tlm_phase;
/**
* @brief The AXI protocol traits class.
* Since the protocoll defines additional non-ignorable phases a dedicated protocol traits class has to be defined.
*/
struct axi_protocol_types {
typedef axi_payload tlm_payload_type;
typedef axi_phase tlm_phase_type;
};
/**
* definition of the additional protocol phases
*/
DECLARE_EXTENDED_PHASE(BEGIN_PARTIAL_REQ);
DECLARE_EXTENDED_PHASE(END_PARTIAL_REQ);
DECLARE_EXTENDED_PHASE(BEGIN_PARTIAL_RESP);
DECLARE_EXTENDED_PHASE(END_PARTIAL_RESP);
DECLARE_EXTENDED_PHASE(ACK);
/**
* interface definition for the blocking backward interface. This is need to allow snoop accesses in blocking mode
*/
template <typename TRANS = tlm::tlm_generic_payload>
class bw_blocking_transport_if : public virtual sc_core::sc_interface {
public:
/**
* @brief snoop access to a snooped master
* @param trans the payload
* @param t annotated delay
*/
virtual void b_snoop(TRANS& trans, sc_core::sc_time& t) = 0;
};
//! alias declaration for the forward interface
template <typename TYPES = axi_protocol_types> using axi_fw_transport_if = tlm::tlm_fw_transport_if<TYPES>;
//! alias declaration for the backward interface:
template <typename TYPES = axi_protocol_types> using axi_bw_transport_if = tlm::tlm_bw_transport_if<TYPES>;
//! alias declaration for the ACE forward interface
template <typename TYPES = axi_protocol_types> using ace_fw_transport_if = tlm::tlm_fw_transport_if<TYPES>;
/**
* The ACE backward interface which combines the TLM2.0 backward interface and the @see bw_blocking_transport_if
*/
template <typename TYPES = axi_protocol_types>
class ace_bw_transport_if : public tlm::tlm_bw_transport_if<TYPES>,
public virtual bw_blocking_transport_if<typename TYPES::tlm_payload_type> {};
/**
* AXI initiator socket class using payloads carrying AXI3 or AXi4 extensions
*/
template <unsigned int BUSWIDTH = 32, typename TYPES = axi_protocol_types, int N = 1,
sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
struct axi_initiator_socket
: public tlm::tlm_base_initiator_socket<BUSWIDTH, axi_fw_transport_if<TYPES>, axi_bw_transport_if<TYPES>, N, POL> {
//! base type alias
using base_type =
tlm::tlm_base_initiator_socket<BUSWIDTH, axi_fw_transport_if<TYPES>, axi_bw_transport_if<TYPES>, N, POL>;
/**
* @brief default constructor using a generated instance name
*/
axi_initiator_socket()
: base_type() {}
/**
* @brief constructor with instance name
* @param name
*/
explicit axi_initiator_socket(const char* name)
: base_type(name) {}
/**
* @brief get the kind of this sc_object
* @return the kind string
*/
const char* kind() const override { return "axi_initiator_socket"; }
// not the right version but we assume TLM is always bundled with SystemC
#if SYSTEMC_VERSION >= 20181013 // ((TLM_VERSION_MAJOR > 2) || (TLM_VERSION==2 && TLM_VERSION_MINOR>0) ||(TLM_VERSION==2
// && TLM_VERSION_MINOR>0 && TLM_VERSION_PATCH>4))
sc_core::sc_type_index get_protocol_types() const override { return typeid(TYPES); }
#endif
};
/**
* AXI target socket class using payloads carrying AXI3 or AXi4 extensions
*/
template <unsigned int BUSWIDTH = 32, typename TYPES = axi_protocol_types, int N = 1,
sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
struct axi_target_socket
: public tlm::tlm_base_target_socket<BUSWIDTH, axi_fw_transport_if<TYPES>, axi_bw_transport_if<TYPES>, N, POL> {
//! base type alias
using base_type =
tlm::tlm_base_target_socket<BUSWIDTH, axi_fw_transport_if<TYPES>, axi_bw_transport_if<TYPES>, N, POL>;
/**
* @brief default constructor using a generated instance name
*/
axi_target_socket()
: base_type() {}
/**
* @brief constructor with instance name
* @param name
*/
explicit axi_target_socket(const char* name)
: base_type(name) {}
/**
* @brief get the kind of this sc_object
* @return the kind string
*/
const char* kind() const override { return "axi_target_socket"; }
// not the right version but we assume TLM is always bundled with SystemC
#if SYSTEMC_VERSION >= 20181013 // ((TLM_VERSION_MAJOR > 2) || (TLM_VERSION==2 && TLM_VERSION_MINOR>0) ||(TLM_VERSION==2
// && TLM_VERSION_MINOR>0 && TLM_VERSION_PATCH>4))
sc_core::sc_type_index get_protocol_types() const override { return typeid(TYPES); }
#endif
};
/**
* ACE initiator socket class using payloads carrying AXI3 or AXi4 extensions
*/
template <unsigned int BUSWIDTH = 32, typename TYPES = axi_protocol_types, int N = 1,
sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
struct ace_initiator_socket
: public tlm::tlm_base_initiator_socket<BUSWIDTH, ace_fw_transport_if<TYPES>, ace_bw_transport_if<TYPES>, N, POL> {
//! base type alias
using base_type =
tlm::tlm_base_initiator_socket<BUSWIDTH, ace_fw_transport_if<TYPES>, ace_bw_transport_if<TYPES>, N, POL>;