port.cc revision 13207:034ca389a810
13806SN/A/* 23806SN/A * Copyright 2018 Google, Inc. 33806SN/A * 43806SN/A * Redistribution and use in source and binary forms, with or without 53806SN/A * modification, are permitted provided that the following conditions are 63806SN/A * met: redistributions of source code must retain the above copyright 73806SN/A * notice, this list of conditions and the following disclaimer; 83806SN/A * redistributions in binary form must reproduce the above copyright 93806SN/A * notice, this list of conditions and the following disclaimer in the 103806SN/A * documentation and/or other materials provided with the distribution; 113806SN/A * neither the name of the copyright holders nor the names of its 123806SN/A * contributors may be used to endorse or promote products derived from 133806SN/A * this software without specific prior written permission. 143806SN/A * 153806SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 163806SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 173806SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 183806SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 193806SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 203806SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 213806SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 223806SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 233806SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 243806SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 253806SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 263806SN/A * 273806SN/A * Authors: Gabe Black 283806SN/A */ 293806SN/A 303806SN/A#include "systemc/core/port.hh" 318105Sgblack@eecs.umich.edu 328105Sgblack@eecs.umich.edu#include "systemc/core/sensitivity.hh" 333806SN/A 343806SN/Anamespace sc_gem5 353806SN/A{ 363806SN/A 373806SN/Avoid 383806SN/APort::finalizePort(StaticSensitivityPort *port) 393806SN/A{ 403817SN/A for (int i = 0; i < size(); i++) 413806SN/A port->addEvent(&getInterface(i)->default_event()); 423806SN/A} 433806SN/A 443806SN/Avoid 453806SN/APort::finalizeFinder(StaticSensitivityFinder *finder) 463806SN/A{ 473806SN/A for (int i = 0; i < size(); i++) 487741SN/A finder->addEvent(&finder->find(getInterface(i))); 493806SN/A} 503806SN/A 513806SN/Avoid 523817SN/APort::sensitive(StaticSensitivityPort *port) 533806SN/A{ 543817SN/A if (finalized) 553817SN/A finalizePort(port); 563817SN/A else 573806SN/A sensitivities.push_back(new Sensitivity(port)); 583806SN/A} 593806SN/A 603806SN/Avoid 613806SN/APort::sensitive(StaticSensitivityFinder *finder) 623817SN/A{ 633806SN/A if (finalized) 643817SN/A finalizeFinder(finder); 653817SN/A else 663817SN/A sensitivities.push_back(new Sensitivity(finder)); 673806SN/A} 683806SN/A 693806SN/Avoid 703806SN/APort::finalize() 713806SN/A{ 723806SN/A 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