sc_sensitive.cc revision 13317
112047Schristian.menard@tu-dresden.de/* 212047Schristian.menard@tu-dresden.de * Copyright 2018 Google, Inc. 312047Schristian.menard@tu-dresden.de * 412047Schristian.menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without 512047Schristian.menard@tu-dresden.de * modification, are permitted provided that the following conditions are 612047Schristian.menard@tu-dresden.de * met: redistributions of source code must retain the above copyright 712047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer; 812047Schristian.menard@tu-dresden.de * redistributions in binary form must reproduce the above copyright 912047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the 1012047Schristian.menard@tu-dresden.de * documentation and/or other materials provided with the distribution; 1112047Schristian.menard@tu-dresden.de * neither the name of the copyright holders nor the names of its 1212047Schristian.menard@tu-dresden.de * contributors may be used to endorse or promote products derived from 1312047Schristian.menard@tu-dresden.de * this software without specific prior written permission. 1412047Schristian.menard@tu-dresden.de * 1512047Schristian.menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612047Schristian.menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712047Schristian.menard@tu-dresden.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812047Schristian.menard@tu-dresden.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912047Schristian.menard@tu-dresden.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012047Schristian.menard@tu-dresden.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112047Schristian.menard@tu-dresden.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212047Schristian.menard@tu-dresden.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312047Schristian.menard@tu-dresden.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412047Schristian.menard@tu-dresden.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512047Schristian.menard@tu-dresden.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612047Schristian.menard@tu-dresden.de * 2712047Schristian.menard@tu-dresden.de * Authors: Gabe Black 2812047Schristian.menard@tu-dresden.de */ 2912047Schristian.menard@tu-dresden.de 3012047Schristian.menard@tu-dresden.de#include "base/logging.hh" 3112047Schristian.menard@tu-dresden.de#include "systemc/core/process.hh" 3212047Schristian.menard@tu-dresden.de#include "systemc/ext/channel/sc_in.hh" 3312047Schristian.menard@tu-dresden.de#include "systemc/ext/channel/sc_inout.hh" 3412047Schristian.menard@tu-dresden.de#include "systemc/ext/channel/sc_signal_in_if.hh" 3512047Schristian.menard@tu-dresden.de#include "systemc/ext/core/messages.hh" 3612047Schristian.menard@tu-dresden.de#include "systemc/ext/core/sc_interface.hh" 3712047Schristian.menard@tu-dresden.de#include "systemc/ext/core/sc_main.hh" 3812047Schristian.menard@tu-dresden.de#include "systemc/ext/core/sc_sensitive.hh" 3912047Schristian.menard@tu-dresden.de#include "systemc/ext/utils/sc_report_handler.hh" 4012047Schristian.menard@tu-dresden.de 4112047Schristian.menard@tu-dresden.denamespace sc_core 4212047Schristian.menard@tu-dresden.de{ 4312047Schristian.menard@tu-dresden.de 4412047Schristian.menard@tu-dresden.denamespace 4512047Schristian.menard@tu-dresden.de{ 4612047Schristian.menard@tu-dresden.de 4712047Schristian.menard@tu-dresden.devoid 4812047Schristian.menard@tu-dresden.decheckIfRunning() 4912047Schristian.menard@tu-dresden.de{ 5012047Schristian.menard@tu-dresden.de if (sc_is_running()) 5112047Schristian.menard@tu-dresden.de SC_REPORT_ERROR(SC_ID_MAKE_SENSITIVE_, "simulation running"); 5212047Schristian.menard@tu-dresden.de} 5312047Schristian.menard@tu-dresden.de 5412047Schristian.menard@tu-dresden.de} // anonymous namespace 5512047Schristian.menard@tu-dresden.de 5612047Schristian.menard@tu-dresden.desc_sensitive::sc_sensitive() : currentProcess(nullptr) {} 5712047Schristian.menard@tu-dresden.de 5812047Schristian.menard@tu-dresden.desc_sensitive & 5912047Schristian.menard@tu-dresden.desc_sensitive::operator << (const sc_event &e) 6012047Schristian.menard@tu-dresden.de{ 6112047Schristian.menard@tu-dresden.de checkIfRunning(); 6212047Schristian.menard@tu-dresden.de sc_gem5::newStaticSensitivityEvent(currentProcess, &e); 63 return *this; 64} 65 66sc_sensitive & 67sc_sensitive::operator << (const sc_interface &i) 68{ 69 checkIfRunning(); 70 sc_gem5::newStaticSensitivityInterface(currentProcess, &i); 71 return *this; 72} 73 74sc_sensitive & 75sc_sensitive::operator << (const sc_port_base &b) 76{ 77 checkIfRunning(); 78 sc_gem5::newStaticSensitivityPort(currentProcess, &b); 79 return *this; 80} 81 82sc_sensitive & 83sc_sensitive::operator << (sc_event_finder &f) 84{ 85 checkIfRunning(); 86 sc_gem5::newStaticSensitivityFinder(currentProcess, &f); 87 return *this; 88} 89 90sc_sensitive & 91sc_sensitive::operator << (::sc_gem5::Process *p) 92{ 93 currentProcess = p; 94 return *this; 95} 96 97 98void 99sc_sensitive::operator () (::sc_gem5::Process *p, 100 const sc_signal_in_if<bool> &i) 101{ 102 checkIfRunning(); 103 sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event()); 104} 105 106void 107sc_sensitive::operator () (::sc_gem5::Process *p, 108 const sc_signal_in_if<sc_dt::sc_logic> &i) 109{ 110 checkIfRunning(); 111 sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event()); 112} 113 114void 115sc_sensitive::operator () (::sc_gem5::Process *p, const sc_in<bool> &port) 116{ 117 checkIfRunning(); 118 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 119} 120 121void 122sc_sensitive::operator () (::sc_gem5::Process *p, 123 const sc_in<sc_dt::sc_logic> &port) 124{ 125 checkIfRunning(); 126 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 127} 128 129void 130sc_sensitive::operator () (::sc_gem5::Process *p, const sc_inout<bool> &port) 131{ 132 checkIfRunning(); 133 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 134} 135 136void 137sc_sensitive::operator () (::sc_gem5::Process *p, 138 const sc_inout<sc_dt::sc_logic> &port) 139{ 140 checkIfRunning(); 141 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 142} 143 144void 145sc_sensitive::operator () (::sc_gem5::Process *p, sc_event_finder &f) 146{ 147 checkIfRunning(); 148 sc_gem5::newStaticSensitivityFinder(p, &f); 149} 150 151} // namespace sc_core 152