SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_port_simics_adapter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2015 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_SYSTEMC_IFACE_SC_PORT_SIMICS_ADAPTER_H
17#define SIMICS_SYSTEMC_IFACE_SC_PORT_SIMICS_ADAPTER_H
18
21
22#include <systemc-interfaces.h>
23
24#include <string>
25#include <vector>
26
27namespace simics {
28namespace systemc {
29namespace iface {
30
32template<typename TBase, typename TInterface = ScPortInterface>
33class ScPortSimicsAdapter : public SimicsAdapter<sc_port_interface_t> {
34 public:
35 ScPortSimicsAdapter() : SimicsAdapter<sc_port_interface_t>(
36 SC_PORT_INTERFACE, init_iface()) {
37 }
38
39 protected:
40 static attr_value_t port_to_proxies(conf_object_t *obj) {
41 return stl2simics(
42 adapter<TBase, TInterface>(obj)->port_to_proxies());
43 }
44 static const char *if_typename(conf_object_t *obj) {
45 return adapter<TBase, TInterface>(obj)->if_typename();
46 }
47 static int max_number_of_proxies(conf_object_t *obj) {
48 return adapter<TBase, TInterface>(obj)->max_number_of_proxies();
49 }
50
51 private:
52 static attr_value_t stl2simics(std::vector<conf_object_t *> proxies) {
53 attr_value_t list = SIM_alloc_attr_list(proxies.size());
54 for (unsigned i = 0; i < proxies.size(); ++i)
55 SIM_attr_list_set_item(&list, i,
56 SIM_make_attr_object(proxies[i]));
57
58 return list;
59 }
60 std::vector<std::string> description(conf_object_t *obj,
61 DescriptionType type) {
62 return descriptionBase<TBase, TInterface>(obj, type);
63 }
64 sc_port_interface_t init_iface() {
65 sc_port_interface_t iface = {};
66 iface.port_to_proxies = port_to_proxies;
67 iface.if_typename = if_typename;
68 iface.max_number_of_proxies = max_number_of_proxies;
69 return iface;
70 }
71};
72
73} // namespace iface
74} // namespace systemc
75} // namespace simics
76
77#endif
Definition: sc_port_simics_adapter.h:33
static attr_value_t port_to_proxies(conf_object_t *obj)
Definition: sc_port_simics_adapter.h:40
static const char * if_typename(conf_object_t *obj)
Definition: sc_port_simics_adapter.h:44
static int max_number_of_proxies(conf_object_t *obj)
Definition: sc_port_simics_adapter.h:47
ScPortSimicsAdapter()
Definition: sc_port_simics_adapter.h:35
Base class for mapping Simics interface to a C++ interface.
Definition: simics_adapter.h:47
DescriptionType
Definition: description_interface.h:25
Definition: pci_bus_interface.h:24