SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
port_spy_factory.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_AWARENESS_PORT_SPY_FACTORY_H
17#define SIMICS_SYSTEMC_AWARENESS_PORT_SPY_FACTORY_H
18
19#if INTC_EXT
20
22
23#include <sysc/intc/communication/sc_port_spy.h>
24#include <systemc>
25
26#include <map>
27#include <vector>
28
29namespace simics {
30namespace systemc {
31namespace awareness {
32
33template <typename IF, typename HANDLER>
34class PortSpyFactory : public simics::systemc::TraverserInterface {
35 public:
36 typedef typename std::vector<HANDLER *>::iterator iterator;
37 typedef typename std::map<IF*, intc::sc_port_spy<IF> *>::iterator
38 spy_iterator;
39 PortSpyFactory() {}
40 PortSpyFactory(const PortSpyFactory &f) {}
41 PortSpyFactory &operator = (const PortSpyFactory &f) {}
42 virtual ~PortSpyFactory() {
43 for (iterator i = handlers_.begin(); i != handlers_.end(); ++i)
44 delete *i;
45 for (spy_iterator i = spies_.begin(); i != spies_.end(); ++i)
46 delete i->second;
47 }
48 virtual void applyOn(sc_core::sc_object *sc_object) {
49 if (sc_core::sc_port<IF> *if_
50 = dynamic_cast<sc_core::sc_port<IF> *>(sc_object)) {
51 if (if_->size() <= 0)
52 return;
53 intc::sc_port_spy<IF> *spy = new intc::sc_port_spy<IF>(if_);
54 HANDLER *handler = new HANDLER(spy);
55 spy->set_spy_interface(handler);
56 handlers_.push_back(handler);
57 spies_[spy->get_interface()] = spy;
58 }
59 if (sc_core::sc_port<IF, 0> *if_
60 = dynamic_cast<sc_core::sc_port<IF, 0> *>(sc_object)) {
61 if (if_->size() <= 0)
62 return;
63 for (int i = 0; i < if_->size(); ++i) {
64 intc::sc_port_spy<IF> *spy = new intc::sc_port_spy<IF>(if_, i);
65 HANDLER *handler = new HANDLER(spy);
66 handlers_.push_back(handler);
67 spy->set_spy_interface(handler);
68 spies_[spy->get_interface()] = spy;
69 }
70 }
71 }
72 virtual void done() {}
73 void bindSpies(std::map<IF*, intc::sc_export_spy<IF> *> *exports) {
74 for (spy_iterator i = spies_.begin(); i != spies_.end(); ++i) {
75 if (intc::sc_export_spy<IF> *spy = (*exports)[i->first]) {
76 i->second->set_interface(spy->get_current_interface());
77 }
78 }
79 }
80 void bindSpies(std::map<IF*, IF *> *exports) {
81 for (spy_iterator i = spies_.begin(); i != spies_.end(); ++i) {
82 if (IF *spy = (*exports)[i->first]) {
83 i->second->set_interface(spy);
84 }
85 }
86 }
87
88 private:
89 std::vector<HANDLER *> handlers_;
90 std::map<IF*, intc::sc_port_spy<IF> *> spies_;
91};
92
93} // namespace awareness
94} // namespace systemc
95} // namespace simics
96
97#endif // INTC_EXT
98#endif
Definition: traverser_interface.h:26
Definition: pci_bus_interface.h:24