112837Sgabeblack@google.com/* 212837Sgabeblack@google.com * Copyright 2018 Google, Inc. 312837Sgabeblack@google.com * 412837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512837Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012837Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312837Sgabeblack@google.com * this software without specific prior written permission. 1412837Sgabeblack@google.com * 1512837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612837Sgabeblack@google.com * 2712837Sgabeblack@google.com * Authors: Gabe Black 2812837Sgabeblack@google.com */ 2912837Sgabeblack@google.com 3012957Sgabeblack@google.com#include "systemc/core/process.hh" 3113210Sgabeblack@google.com#include "systemc/ext/channel/sc_in.hh" 3213210Sgabeblack@google.com#include "systemc/ext/channel/sc_inout.hh" 3313210Sgabeblack@google.com#include "systemc/ext/channel/sc_signal_in_if.hh" 3413317Sgabeblack@google.com#include "systemc/ext/core/messages.hh" 3512957Sgabeblack@google.com#include "systemc/ext/core/sc_interface.hh" 3613211Sgabeblack@google.com#include "systemc/ext/core/sc_main.hh" 3712837Sgabeblack@google.com#include "systemc/ext/core/sc_sensitive.hh" 3813211Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh" 3912837Sgabeblack@google.com 4012837Sgabeblack@google.comnamespace sc_core 4112837Sgabeblack@google.com{ 4212837Sgabeblack@google.com 4313211Sgabeblack@google.comnamespace 4413211Sgabeblack@google.com{ 4513211Sgabeblack@google.com 4613211Sgabeblack@google.comvoid 4713211Sgabeblack@google.comcheckIfRunning() 4813211Sgabeblack@google.com{ 4913211Sgabeblack@google.com if (sc_is_running()) 5013317Sgabeblack@google.com SC_REPORT_ERROR(SC_ID_MAKE_SENSITIVE_, "simulation running"); 5113211Sgabeblack@google.com} 5213211Sgabeblack@google.com 5313211Sgabeblack@google.com} // anonymous namespace 5413211Sgabeblack@google.com 5512952Sgabeblack@google.comsc_sensitive::sc_sensitive() : currentProcess(nullptr) {} 5612952Sgabeblack@google.com 5712837Sgabeblack@google.comsc_sensitive & 5812957Sgabeblack@google.comsc_sensitive::operator << (const sc_event &e) 5912837Sgabeblack@google.com{ 6013211Sgabeblack@google.com checkIfRunning(); 6113207Sgabeblack@google.com sc_gem5::newStaticSensitivityEvent(currentProcess, &e); 6212837Sgabeblack@google.com return *this; 6312837Sgabeblack@google.com} 6412837Sgabeblack@google.com 6512837Sgabeblack@google.comsc_sensitive & 6612957Sgabeblack@google.comsc_sensitive::operator << (const sc_interface &i) 6712837Sgabeblack@google.com{ 6813211Sgabeblack@google.com checkIfRunning(); 6913207Sgabeblack@google.com sc_gem5::newStaticSensitivityInterface(currentProcess, &i); 7012837Sgabeblack@google.com return *this; 7112837Sgabeblack@google.com} 7212837Sgabeblack@google.com 7312837Sgabeblack@google.comsc_sensitive & 7412957Sgabeblack@google.comsc_sensitive::operator << (const sc_port_base &b) 7512837Sgabeblack@google.com{ 7613211Sgabeblack@google.com checkIfRunning(); 7713207Sgabeblack@google.com sc_gem5::newStaticSensitivityPort(currentProcess, &b); 7812837Sgabeblack@google.com return *this; 7912837Sgabeblack@google.com} 8012837Sgabeblack@google.com 8112837Sgabeblack@google.comsc_sensitive & 8212957Sgabeblack@google.comsc_sensitive::operator << (sc_event_finder &f) 8312837Sgabeblack@google.com{ 8413211Sgabeblack@google.com checkIfRunning(); 8513207Sgabeblack@google.com sc_gem5::newStaticSensitivityFinder(currentProcess, &f); 8612837Sgabeblack@google.com return *this; 8712837Sgabeblack@google.com} 8812837Sgabeblack@google.com 8912952Sgabeblack@google.comsc_sensitive & 9012952Sgabeblack@google.comsc_sensitive::operator << (::sc_gem5::Process *p) 9112952Sgabeblack@google.com{ 9212952Sgabeblack@google.com currentProcess = p; 9312952Sgabeblack@google.com return *this; 9412952Sgabeblack@google.com} 9512952Sgabeblack@google.com 9613210Sgabeblack@google.com 9713210Sgabeblack@google.comvoid 9813210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, 9913210Sgabeblack@google.com const sc_signal_in_if<bool> &i) 10013210Sgabeblack@google.com{ 10113211Sgabeblack@google.com checkIfRunning(); 10213210Sgabeblack@google.com sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event()); 10313210Sgabeblack@google.com} 10413210Sgabeblack@google.com 10513210Sgabeblack@google.comvoid 10613210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, 10713210Sgabeblack@google.com const sc_signal_in_if<sc_dt::sc_logic> &i) 10813210Sgabeblack@google.com{ 10913211Sgabeblack@google.com checkIfRunning(); 11013210Sgabeblack@google.com sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event()); 11113210Sgabeblack@google.com} 11213210Sgabeblack@google.com 11313210Sgabeblack@google.comvoid 11413210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, const sc_in<bool> &port) 11513210Sgabeblack@google.com{ 11613211Sgabeblack@google.com checkIfRunning(); 11713210Sgabeblack@google.com sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 11813210Sgabeblack@google.com} 11913210Sgabeblack@google.com 12013210Sgabeblack@google.comvoid 12113210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, 12213210Sgabeblack@google.com const sc_in<sc_dt::sc_logic> &port) 12313210Sgabeblack@google.com{ 12413211Sgabeblack@google.com checkIfRunning(); 12513210Sgabeblack@google.com sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 12613210Sgabeblack@google.com} 12713210Sgabeblack@google.com 12813210Sgabeblack@google.comvoid 12913210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, const sc_inout<bool> &port) 13013210Sgabeblack@google.com{ 13113211Sgabeblack@google.com checkIfRunning(); 13213210Sgabeblack@google.com sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 13313210Sgabeblack@google.com} 13413210Sgabeblack@google.com 13513210Sgabeblack@google.comvoid 13613210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, 13713210Sgabeblack@google.com const sc_inout<sc_dt::sc_logic> &port) 13813210Sgabeblack@google.com{ 13913211Sgabeblack@google.com checkIfRunning(); 14013210Sgabeblack@google.com sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 14113210Sgabeblack@google.com} 14213210Sgabeblack@google.com 14313210Sgabeblack@google.comvoid 14413210Sgabeblack@google.comsc_sensitive::operator () (::sc_gem5::Process *p, sc_event_finder &f) 14513210Sgabeblack@google.com{ 14613211Sgabeblack@google.com checkIfRunning(); 14713210Sgabeblack@google.com sc_gem5::newStaticSensitivityFinder(p, &f); 14813210Sgabeblack@google.com} 14913210Sgabeblack@google.com 15012837Sgabeblack@google.com} // namespace sc_core 151