scc 2025.09
SystemC components library
ahb_tlm.cpp
1/*******************************************************************************
2 * Copyright 2019-2023 MINRES Technologies GmbH
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#include "ahb_tlm.h"
18
19namespace ahb {
20namespace {
21const std::array<std::string, 3> cmd_str{"R", "W", "I"};
22}
23template <> const char* to_char<burst_e>(burst_e v) {
24 switch(v) {
25 case burst_e::SINGLE:
26 return "SINGLE";
27 case burst_e::INCR:
28 return "INCR";
29 case burst_e::INCR4:
30 return "INCR4";
31 case burst_e::INCR8:
32 return "INCR8";
33 case burst_e::INCR16:
34 return "INCR16";
35 case burst_e::WRAP4:
36 return "WRAP4";
37 case burst_e::WRAP8:
38 return "WRAP8";
39 case burst_e::WRAP16:
40 return "WRAP16";
41 default:
42 return "UNKNOWN";
43 }
44}
45
46template <> const char* to_char<resp_e>(resp_e v) {
47 switch(v) {
48 case resp_e::OKAY:
49 return "OKAY";
50 case resp_e::EXOKAY:
51 return "EXOKAY";
52 case resp_e::DECERR:
53 return "DECERR";
54 case resp_e::SLVERR:
55 return "SLVERR";
56 default:
57 return "UNKNOWN";
58 }
59}
60
61std::ostream& operator<<(std::ostream& os, const tlm::tlm_generic_payload& t) {
62 os << "CMD:" << cmd_str[t.get_command()] << ", "
63 << "ADDR:0x" << std::hex << t.get_address() << ", TXLEN:0x" << t.get_data_length();
64 if(auto e = t.get_extension<ahb::ahb_extension>()) {
65 os << ", "
66 << "BURST:" << to_char(e->get_burst()) << ", " << (e->is_seq() ? "SEQ" : "NONSEQ") << ", "
67 << "MSTLOCK:" << e->is_locked() << ", "
68 << "PROT:0x" << std::hex << static_cast<unsigned>(e->get_protection());
69 }
70 os << " [ptr:" << &t << "]";
71 return os;
72}
73
74} // namespace ahb
TLM2.0 components modeling AHB.
Definition ahb_tlm.cpp:19
const char * to_char(E t)