sc_sensitive.cc revision 13211:62e227fef520
13963Sgblack@eecs.umich.edu/* 211274Sshingarov@labware.com * Copyright 2018 Google, Inc. 310595Sgabeblack@google.com * 45254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 55254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 63963Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 75254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 85254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 95254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 105254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 115254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 125254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 135254Sksewell@umich.edu * this software without specific prior written permission. 145254Sksewell@umich.edu * 155254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 173963Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265254Sksewell@umich.edu * 275254Sksewell@umich.edu * Authors: Gabe Black 285254Sksewell@umich.edu */ 293963Sgblack@eecs.umich.edu 305254Sksewell@umich.edu#include "base/logging.hh" 3111274Sshingarov@labware.com#include "systemc/core/process.hh" 323963Sgblack@eecs.umich.edu#include "systemc/ext/channel/sc_in.hh" 333963Sgblack@eecs.umich.edu#include "systemc/ext/channel/sc_inout.hh" 343963Sgblack@eecs.umich.edu#include "systemc/ext/channel/sc_signal_in_if.hh" 353963Sgblack@eecs.umich.edu#include "systemc/ext/core/sc_interface.hh" 363963Sgblack@eecs.umich.edu#include "systemc/ext/core/sc_main.hh" 378544Sguodeyuan@tsinghua.org.cn#include "systemc/ext/core/sc_sensitive.hh" 388544Sguodeyuan@tsinghua.org.cn#include "systemc/ext/utils/sc_report_handler.hh" 393963Sgblack@eecs.umich.edu 403963Sgblack@eecs.umich.edunamespace sc_core 418544Sguodeyuan@tsinghua.org.cn{ 428544Sguodeyuan@tsinghua.org.cn 438544Sguodeyuan@tsinghua.org.cnnamespace 443963Sgblack@eecs.umich.edu{ 453963Sgblack@eecs.umich.edu 468544Sguodeyuan@tsinghua.org.cnvoid 4711274Sshingarov@labware.comcheckIfRunning() 4811274Sshingarov@labware.com{ 4911274Sshingarov@labware.com if (sc_is_running()) 5011274Sshingarov@labware.com SC_REPORT_ERROR("(E526) make sensitive failed", "simulation running"); 518544Sguodeyuan@tsinghua.org.cn} 5211274Sshingarov@labware.com 5311274Sshingarov@labware.com} // anonymous namespace 5411274Sshingarov@labware.com 5511274Sshingarov@labware.comsc_sensitive::sc_sensitive() : currentProcess(nullptr) {} 5611274Sshingarov@labware.com 5711274Sshingarov@labware.comsc_sensitive & 5811274Sshingarov@labware.comsc_sensitive::operator << (const sc_event &e) 5911274Sshingarov@labware.com{ 6011274Sshingarov@labware.com checkIfRunning(); 6111274Sshingarov@labware.com sc_gem5::newStaticSensitivityEvent(currentProcess, &e); 6211274Sshingarov@labware.com return *this; 6311274Sshingarov@labware.com} 6411274Sshingarov@labware.com 6511274Sshingarov@labware.comsc_sensitive & 6611274Sshingarov@labware.comsc_sensitive::operator << (const sc_interface &i) 6711274Sshingarov@labware.com{ 6811274Sshingarov@labware.com checkIfRunning(); 6911274Sshingarov@labware.com sc_gem5::newStaticSensitivityInterface(currentProcess, &i); 7011274Sshingarov@labware.com return *this; 7111274Sshingarov@labware.com} 7211274Sshingarov@labware.com 7312031Sgabeblack@google.comsc_sensitive & 7412031Sgabeblack@google.comsc_sensitive::operator << (const sc_port_base &b) 7512031Sgabeblack@google.com{ 7612031Sgabeblack@google.com checkIfRunning(); 7712031Sgabeblack@google.com sc_gem5::newStaticSensitivityPort(currentProcess, &b); 7811274Sshingarov@labware.com return *this; 798544Sguodeyuan@tsinghua.org.cn} 8012031Sgabeblack@google.com 813963Sgblack@eecs.umich.edusc_sensitive & 8211274Sshingarov@labware.comsc_sensitive::operator << (sc_event_finder &f) 8312449Sgabeblack@google.com{ 8411274Sshingarov@labware.com checkIfRunning(); 8511274Sshingarov@labware.com sc_gem5::newStaticSensitivityFinder(currentProcess, &f); 863963Sgblack@eecs.umich.edu return *this; 8711274Sshingarov@labware.com} 883963Sgblack@eecs.umich.edu 898544Sguodeyuan@tsinghua.org.cnsc_sensitive & 90sc_sensitive::operator << (::sc_gem5::Process *p) 91{ 92 currentProcess = p; 93 return *this; 94} 95 96 97void 98sc_sensitive::operator () (::sc_gem5::Process *p, 99 const sc_signal_in_if<bool> &i) 100{ 101 checkIfRunning(); 102 sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event()); 103} 104 105void 106sc_sensitive::operator () (::sc_gem5::Process *p, 107 const sc_signal_in_if<sc_dt::sc_logic> &i) 108{ 109 checkIfRunning(); 110 sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event()); 111} 112 113void 114sc_sensitive::operator () (::sc_gem5::Process *p, const sc_in<bool> &port) 115{ 116 checkIfRunning(); 117 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 118} 119 120void 121sc_sensitive::operator () (::sc_gem5::Process *p, 122 const sc_in<sc_dt::sc_logic> &port) 123{ 124 checkIfRunning(); 125 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 126} 127 128void 129sc_sensitive::operator () (::sc_gem5::Process *p, const sc_inout<bool> &port) 130{ 131 checkIfRunning(); 132 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 133} 134 135void 136sc_sensitive::operator () (::sc_gem5::Process *p, 137 const sc_inout<sc_dt::sc_logic> &port) 138{ 139 checkIfRunning(); 140 sc_gem5::newStaticSensitivityFinder(p, &port.pos()); 141} 142 143void 144sc_sensitive::operator () (::sc_gem5::Process *p, sc_event_finder &f) 145{ 146 checkIfRunning(); 147 sc_gem5::newStaticSensitivityFinder(p, &f); 148} 149 150} // namespace sc_core 151