scc  2024.06
SystemC components library
tl_tlm.cpp
1 /*******************************************************************************
2  * Copyright 2019-2024 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 <array>
18 #include <interfaces/tilelink/tl_tlm.h>
19 
20 namespace tilelink {
21 namespace {
22 const std::array<std::string, 3> cmd_str{"R", "W", "I"};
23 }
24 
25 template <> const char* to_char<opcode_e>(opcode_e v) {
26  switch(v) {
27  case opcode_e::Get:
28  return "Get";
29  case opcode_e::AccessAckData:
30  return "AccessAckData";
31  case opcode_e::PutFullData:
32  return "PutFullData";
33  case opcode_e::PutPartialData:
34  return "PutPartialData";
35  case opcode_e::AccessAck:
36  return "AccessAck";
37  case opcode_e::ArithmeticData:
38  return "ArithmeticData";
39  case opcode_e::LogicalData:
40  return "LogicalData";
41  case opcode_e::Intent:
42  return "Intent";
43  case opcode_e::HintAck:
44  return "HintAck";
45  case opcode_e::AcquireBlock:
46  return "AcquireBlock";
47  case opcode_e::AcquirePerm:
48  return "AcquirePerm";
49  case opcode_e::Grant:
50  return "Grant";
51  case opcode_e::GrantData:
52  return "GrantData";
53  case opcode_e::GrantAck:
54  return "GrantAck";
55  case opcode_e::ProbeBlock:
56  return "ProbeBlock";
57  case opcode_e::ProbePerm:
58  return "ProbePerm";
59  case opcode_e::ProbeAck:
60  return "ProbeAck";
61  case opcode_e::ProbeAckData:
62  return "ProbeAckData";
63  case opcode_e::Release:
64  return "Release";
65  case opcode_e::ReleaseData:
66  return "ReleaseData";
67  case opcode_e::ReleaseAck:
68  return "ReleaseAck";
69  default:
70  return "UNKNOWN";
71  }
72 }
73 
74 std::ostream& operator<<(std::ostream& os, const tlm::tlm_generic_payload& t) {
75  os << "CMD:" << cmd_str[t.get_command()] << ", "
76  << "ADDR:0x" << std::hex << t.get_address() << ", TXLEN:0x" << t.get_data_length();
77  if(auto e = t.get_extension<tilelink::tilelink_extension>()) {
78  os << ", "
79  << "PROT:0x" << std::hex << static_cast<unsigned>(e->get_protection()) << "NSE:" << (e->is_nse() ? "True" : "False");
80  }
81  os << " [ptr:" << &t << "]";
82  return os;
83 }
84 
85 } // namespace tilelink
std::ostream & operator<<(std::ostream &stream, const std::vector< T > &vector)
a print function for a vector
Definition: logging.h:305