port.cc revision 13207
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 9 * notice, this list of conditions and the following disclaimer in the 10 * documentation and/or other materials provided with the distribution; 11 * neither the name of the copyright holders nor the names of its 12 * contributors may be used to endorse or promote products derived from 13 * this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#include "systemc/core/port.hh" 31 32#include "systemc/core/sensitivity.hh" 33 34namespace sc_gem5 35{ 36 37void 38Port::finalizePort(StaticSensitivityPort *port) 39{ 40 for (int i = 0; i < size(); i++) 41 port->addEvent(&getInterface(i)->default_event()); 42} 43 44void 45Port::finalizeFinder(StaticSensitivityFinder *finder) 46{ 47 for (int i = 0; i < size(); i++) 48 finder->addEvent(&finder->find(getInterface(i))); 49} 50 51void 52Port::sensitive(StaticSensitivityPort *port) 53{ 54 if (finalized) 55 finalizePort(port); 56 else 57 sensitivities.push_back(new Sensitivity(port)); 58} 59 60void 61Port::sensitive(StaticSensitivityFinder *finder) 62{ 63 if (finalized) 64 finalizeFinder(finder); 65 else 66 sensitivities.push_back(new Sensitivity(finder)); 67} 68 69void 70Port::finalize() 71{ 72 if (finalized) 73 return; 74 finalized = true; 75 76 for (auto &b: bindings) { 77 if (b->interface) { 78 addInterface(b->interface); 79 } else { 80 b->port->_gem5Port->finalize(); 81 addInterfaces(b->port); 82 } 83 delete b; 84 } 85 86 bindings.clear(); 87 88 for (auto &s: sensitivities) { 89 if (s->port) 90 finalizePort(s->port); 91 else 92 finalizeFinder(s->finder); 93 delete s; 94 } 95 96 sensitivities.clear(); 97} 98 99std::list<Port *> allPorts; 100 101} // namespace sc_gem5 102