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/channel.hh" 31#include "systemc/core/scheduler.hh" 32#include "systemc/ext/channel/messages.hh" 33#include "systemc/ext/core/sc_main.hh" 34#include "systemc/ext/core/sc_prim.hh" 35 36namespace sc_gem5 37{ 38 39uint64_t getChangeStamp() { return scheduler.changeStamp(); } 40 41} // namespace sc_gem5 42 43namespace sc_core 44{ 45 46sc_prim_channel::sc_prim_channel() : _gem5_channel(nullptr) 47{ 48 if (sc_is_running()) { 49 SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "simulation running"); 50 } 51 if (::sc_gem5::scheduler.elaborationDone()) { 52 SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "elaboration done"); 53 } 54 _gem5_channel = new sc_gem5::Channel(this); 55} 56 57sc_prim_channel::sc_prim_channel(const char *_name) : 58 sc_object(_name), _gem5_channel(nullptr) 59{ 60 if (sc_is_running()) { 61 SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "simulation running"); 62 } 63 if (::sc_gem5::scheduler.elaborationDone()) { 64 SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "elaboration done"); 65 } 66 _gem5_channel = new sc_gem5::Channel(this); 67} 68 69sc_prim_channel::~sc_prim_channel() { delete _gem5_channel; } 70 71void 72sc_prim_channel::request_update() 73{ 74 _gem5_channel->requestUpdate(); 75} 76 77void 78sc_prim_channel::async_request_update() 79{ 80 _gem5_channel->asyncRequestUpdate(); 81} 82 83void 84sc_prim_channel::next_trigger() 85{ 86 ::sc_core::next_trigger(); 87} 88 89void 90sc_prim_channel::next_trigger(const sc_event &e) 91{ 92 ::sc_core::next_trigger(e); 93} 94 95void 96sc_prim_channel::next_trigger(const sc_event_or_list &eol) 97{ 98 ::sc_core::next_trigger(eol); 99} 100 101void 102sc_prim_channel::next_trigger(const sc_event_and_list &eal) 103{ 104 ::sc_core::next_trigger(eal); 105} 106 107void 108sc_prim_channel::next_trigger(const sc_time &t) 109{ 110 ::sc_core::next_trigger(t); 111} 112 113void 114sc_prim_channel::next_trigger(double d, sc_time_unit u) 115{ 116 ::sc_core::next_trigger(d, u); 117} 118 119void 120sc_prim_channel::next_trigger(const sc_time &t, const sc_event &e) 121{ 122 ::sc_core::next_trigger(t, e); 123} 124 125void 126sc_prim_channel::next_trigger(double d, sc_time_unit u, const sc_event &e) 127{ 128 ::sc_core::next_trigger(d, u, e); 129} 130 131void 132sc_prim_channel::next_trigger(const sc_time &t, const sc_event_or_list &eol) 133{ 134 ::sc_core::next_trigger(t, eol); 135} 136 137void 138sc_prim_channel::next_trigger( 139 double d, sc_time_unit u, const sc_event_or_list &eol) 140{ 141 ::sc_core::next_trigger(d, u, eol); 142} 143 144void 145sc_prim_channel::next_trigger(const sc_time &t, const sc_event_and_list &eal) 146{ 147 ::sc_core::next_trigger(t, eal); 148} 149 150void 151sc_prim_channel::next_trigger( 152 double d, sc_time_unit u, const sc_event_and_list &eal) 153{ 154 ::sc_core::next_trigger(d, u, eal); 155} 156 157bool 158sc_prim_channel::timed_out() 159{ 160 return ::sc_core::timed_out(); 161} 162 163void 164sc_prim_channel::wait() 165{ 166 ::sc_core::wait(); 167} 168 169void 170sc_prim_channel::wait(int i) 171{ 172 ::sc_core::wait(i); 173} 174 175void 176sc_prim_channel::wait(const sc_event &e) 177{ 178 ::sc_core::wait(e); 179} 180 181void 182sc_prim_channel::wait(const sc_event_or_list &eol) 183{ 184 ::sc_core::wait(eol); 185} 186 187void 188sc_prim_channel::wait(const sc_event_and_list &eal) 189{ 190 ::sc_core::wait(eal); 191} 192 193void 194sc_prim_channel::wait(const sc_time &t) 195{ 196 ::sc_core::wait(t); 197} 198 199void 200sc_prim_channel::wait(double d, sc_time_unit u) 201{ 202 ::sc_core::wait(d, u); 203} 204 205void 206sc_prim_channel::wait(const sc_time &t, const sc_event &e) 207{ 208 ::sc_core::wait(t, e); 209} 210 211void 212sc_prim_channel::wait(double d, sc_time_unit u, const sc_event &e) 213{ 214 ::sc_core::wait(d, u, e); 215} 216 217void 218sc_prim_channel::wait(const sc_time &t, const sc_event_or_list &eol) 219{ 220 ::sc_core::wait(t, eol); 221} 222 223void 224sc_prim_channel::wait(double d, sc_time_unit u, const sc_event_or_list &eol) 225{ 226 ::sc_core::wait(d, u, eol); 227} 228 229void 230sc_prim_channel::wait(const sc_time &t, const sc_event_and_list &eal) 231{ 232 ::sc_core::wait(t, eal); 233} 234 235void 236sc_prim_channel::wait(double d, sc_time_unit u, const sc_event_and_list &eal) 237{ 238 ::sc_core::wait(d, u, eal); 239} 240 241} // namespace sc_core 242