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#include <memory>
20
21namespace gs {
22template <unsigned int BUSWIDTH = DEFAULT_TLM_BUSWIDTH>
24{
25protected:
26 template <typename MOD>
28 : public tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>
29 {
30 using typename tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>::base_target_socket_type;
31
32 const std::function<void(std::string)> register_cb;
33
34 public:
35 multi_passthrough_initiator_socket_spying(const char* name, const std::function<void(std::string)>& f)
36 : tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>::multi_passthrough_initiator_socket(name)
37 , register_cb(f)
38 {
39 }
40
41 void bind(base_target_socket_type& socket)
42 {
43 tlm_utils::multi_passthrough_initiator_socket<MOD, BUSWIDTH>::bind(socket);
44 register_cb(socket.get_base_export().name());
45 }
46 };
47
48public:
49 struct target_info {
50 size_t index;
51 std::string name;
52 sc_dt::uint64 address;
53 sc_dt::uint64 size;
54 uint32_t priority;
55 bool use_offset;
56 bool is_callback;
57 bool chained;
58 std::string shortname;
59 };
60
61 void rename_last(std::string s)
62 {
63 auto ti = bound_targets.back();
64 ti->name = s;
65 }
66
67 std::vector<std::shared_ptr<target_info>> get_bound_targets() { return bound_targets; } // Returns shared_ptrs
68
69 virtual ~router_if() = default;
70
71protected:
72 std::string parent(std::string name) { return name.substr(0, name.find_last_of('.')); }
73
74 /* NB use the EXPORT name, so as not to be hassled by the _port_0*/
75 std::string nameFromSocket(std::string s) { return s; }
76
77 virtual void register_boundto(std::string s) = 0;
78
79 virtual std::shared_ptr<target_info> decode_address(tlm::tlm_generic_payload& trans) = 0; // Returns shared_ptr
80
81 virtual void lazy_initialize() = 0;
82
83 std::vector<std::shared_ptr<target_info>> bound_targets; // Changed to shared_ptr
84};
85} // namespace gs
86
87#endif
Definition target.h:160
Definition router_if.h:24
Tool which reads a Lua configuration file and sets parameters.
Definition biflow.cc:10
Definition router_if.h:49