sc_port.hh (13293:60c727f33e16) | sc_port.hh (13324:c8b709468e61) |
---|---|
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 | 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 "../channel/messages.hh" |
|
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()) { | 37#include "../utils/sc_report_handler.hh" 38#include "sc_module.hh" // for sc_gen_unique_name 39#include "sc_object.hh" 40 41namespace sc_gem5 42{ 43 44class Port; --- 80 unchanged lines hidden (view full) --- 125 126 virtual void bind(IF &i) { sc_port_base::bind(i); } 127 virtual void bind(sc_port_b<IF> &p) { sc_port_base::bind(p); } 128 129 IF * 130 operator -> () 131 { 132 if (_interfaces.empty()) { |
132 report_error("(E112) get interface failed", "port is not bound"); | 133 report_error(SC_ID_GET_IF_, "port is not bound"); |
133 sc_abort(); 134 } 135 return _interfaces[0]; 136 } 137 const IF * 138 operator -> () const 139 { 140 if (_interfaces.empty()) { | 134 sc_abort(); 135 } 136 return _interfaces[0]; 137 } 138 const IF * 139 operator -> () const 140 { 141 if (_interfaces.empty()) { |
141 report_error("(E112) get interface failed", "port is not bound"); | 142 report_error(SC_ID_GET_IF_, "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()) { | 143 sc_abort(); 144 } 145 return _interfaces[0]; 146 } 147 148 IF * 149 operator [] (int n) 150 { 151 if (n < 0 || n >= size()) { |
151 report_error("(E112) get interface failed", "index out of range"); | 152 report_error(SC_ID_GET_IF_, "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()) { | 153 return NULL; 154 } 155 return _interfaces[n]; 156 } 157 const IF * 158 operator [] (int n) const 159 { 160 if (n < 0 || n >= size()) { |
160 report_error("(E112) get interface failed", "index out of range"); | 161 report_error(SC_ID_GET_IF_, "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()) { | 162 return NULL; 163 } 164 return _interfaces[n]; 165 } 166 167 sc_interface * 168 get_interface() 169 { --- 45 unchanged lines hidden (view full) --- 215 216 private: 217 std::vector<IF *> _interfaces; 218 219 sc_interface * 220 _gem5Interface(int n) const 221 { 222 if (n < 0 || n >= size()) { |
222 report_error("(E112) get interface failed", "index out of range"); | 223 report_error(SC_ID_GET_IF_, "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]) { | 224 return NULL; 225 } 226 return _interfaces[n]; 227 } 228 void 229 _gem5AddInterface(sc_interface *iface) 230 { 231 IF *interface = dynamic_cast<IF *>(iface); 232 sc_assert(interface); 233 for (int i = 0; i < _interfaces.size(); i++) { 234 if (interface == _interfaces[i]) { |
234 report_error("(E107) bind interface to port failed", | 235 report_error(SC_ID_BIND_IF_TO_PORT_, |
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 --- | 236 "interface already bound to port"); 237 } 238 } 239 _interfaces.push_back(interface); 240 } 241 242 const char *_ifTypeName() const { return typeid(IF).name(); } 243 --- 67 unchanged lines hidden --- |