Deleted Added
sdiff udiff text old ( 13293:60c727f33e16 ) new ( 13324:c8b709468e61 )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 19 unchanged lines hidden (view full) ---

28 */
29
30#ifndef __SYSTEMC_EXT_CORE_SC_PORT_HH__
31#define __SYSTEMC_EXT_CORE_SC_PORT_HH__
32
33#include <typeinfo>
34#include <vector>
35
36#include "../utils/sc_report_handler.hh"
37#include "sc_module.hh" // for sc_gen_unique_name
38#include "sc_object.hh"
39
40namespace sc_gem5
41{
42
43class Port;

--- 80 unchanged lines hidden (view full) ---

124
125 virtual void bind(IF &i) { sc_port_base::bind(i); }
126 virtual void bind(sc_port_b<IF> &p) { sc_port_base::bind(p); }
127
128 IF *
129 operator -> ()
130 {
131 if (_interfaces.empty()) {
132 report_error("(E112) get interface failed", "port is not bound");
133 sc_abort();
134 }
135 return _interfaces[0];
136 }
137 const IF *
138 operator -> () const
139 {
140 if (_interfaces.empty()) {
141 report_error("(E112) get interface failed", "port is not bound");
142 sc_abort();
143 }
144 return _interfaces[0];
145 }
146
147 IF *
148 operator [] (int n)
149 {
150 if (n < 0 || n >= size()) {
151 report_error("(E112) get interface failed", "index out of range");
152 return NULL;
153 }
154 return _interfaces[n];
155 }
156 const IF *
157 operator [] (int n) const
158 {
159 if (n < 0 || n >= size()) {
160 report_error("(E112) get interface failed", "index out of range");
161 return NULL;
162 }
163 return _interfaces[n];
164 }
165
166 sc_interface *
167 get_interface()
168 {

--- 45 unchanged lines hidden (view full) ---

214
215 private:
216 std::vector<IF *> _interfaces;
217
218 sc_interface *
219 _gem5Interface(int n) const
220 {
221 if (n < 0 || n >= size()) {
222 report_error("(E112) get interface failed", "index out of range");
223 return NULL;
224 }
225 return _interfaces[n];
226 }
227 void
228 _gem5AddInterface(sc_interface *iface)
229 {
230 IF *interface = dynamic_cast<IF *>(iface);
231 sc_assert(interface);
232 for (int i = 0; i < _interfaces.size(); i++) {
233 if (interface == _interfaces[i]) {
234 report_error("(E107) bind interface to port failed",
235 "interface already bound to port");
236 }
237 }
238 _interfaces.push_back(interface);
239 }
240
241 const char *_ifTypeName() const { return typeid(IF).name(); }
242

--- 67 unchanged lines hidden ---