quic/qbox
Loading...
Searching...
No Matches
router_if.h
1/*
2 * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 * Author: GreenSocs 2022
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _GREENSOCS_BASE_COMPONENTS_ROUTER_IF_H
9#define _GREENSOCS_BASE_COMPONENTS_ROUTER_IF_H
10
11#include <systemc>
12#include <tlm>
13#include <scp/report.h>
14#include <scp/helpers.h>
15#include <tlm_utils/multi_passthrough_initiator_socket.h>
16#include <tlm_utils/multi_passthrough_target_socket.h>
17#include <tlm_sockets_buswidth.h>
18#include <string>
19
20namespace gs {
21template <unsigned int BUSWIDTH = DEFAULT_TLM_BUSWIDTH>
23{
24protected:
25 template <typename MOD>
27 : public tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>
28 {
29 using typename tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>::base_target_socket_type;
30
31 const std::function<void(std::string)> register_cb;
32
33 public:
34 multi_passthrough_initiator_socket_spying(const char* name, const std::function<void(std::string)>& f)
35 : tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>::multi_passthrough_initiator_socket(name)
36 , register_cb(f)
37 {
38 }
39
40 void bind(base_target_socket_type& socket)
41 {
42 tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>::bind(socket);
43 register_cb(socket.get_base_export().name());
44 }
45 };
46
47public:
48 struct target_info {
49 size_t index;
50 std::string name;
51 sc_dt::uint64 address;
52 sc_dt::uint64 size;
53 uint32_t priority;
54 bool use_offset;
55 bool is_callback;
56 bool chained;
57 std::string shortname;
58 };
59
60 void rename_last(std::string s)
61 {
62 target_info& ti = bound_targets.back();
63 ti.name = s;
64 }
65
66 std::vector<target_info> get_bound_targets() { return bound_targets; }
67
68 virtual ~router_if() = default;
69
70protected:
71 std::string parent(std::string name) { return name.substr(0, name.find_last_of('.')); }
72
73 /* NB use the EXPORT name, so as not to be hassled by the _port_0*/
74 std::string nameFromSocket(std::string s) { return s; }
75
76 virtual void register_boundto(std::string s) = 0;
77
78 virtual target_info* decode_address(tlm::tlm_generic_payload& trans) = 0;
79
80 virtual void lazy_initialize() = 0;
81
82 std::vector<target_info> bound_targets;
83};
84} // namespace gs
85
86#endif
Definition target.h:160
Definition router_if.h:23
Tool which reads a Lua configuration file and sets parameters.
Definition biflow.cc:10
Definition router_if.h:48