111821SChristian.Menard@tu-dresden.de/* 211821SChristian.Menard@tu-dresden.de * Copyright (c) 2016, Dresden University of Technology (TU Dresden) 311821SChristian.Menard@tu-dresden.de * All rights reserved. 411821SChristian.Menard@tu-dresden.de * 511821SChristian.Menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without 611821SChristian.Menard@tu-dresden.de * modification, are permitted provided that the following conditions are 711821SChristian.Menard@tu-dresden.de * met: 811821SChristian.Menard@tu-dresden.de * 911821SChristian.Menard@tu-dresden.de * 1. Redistributions of source code must retain the above copyright notice, 1011821SChristian.Menard@tu-dresden.de * this list of conditions and the following disclaimer. 1111821SChristian.Menard@tu-dresden.de * 1211821SChristian.Menard@tu-dresden.de * 2. Redistributions in binary form must reproduce the above copyright 1311821SChristian.Menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the 1411821SChristian.Menard@tu-dresden.de * documentation and/or other materials provided with the distribution. 1511821SChristian.Menard@tu-dresden.de * 1611821SChristian.Menard@tu-dresden.de * 3. Neither the name of the copyright holder nor the names of its 1711821SChristian.Menard@tu-dresden.de * contributors may be used to endorse or promote products derived from 1811821SChristian.Menard@tu-dresden.de * this software without specific prior written permission. 1911821SChristian.Menard@tu-dresden.de * 2011821SChristian.Menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2111821SChristian.Menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2211821SChristian.Menard@tu-dresden.de * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2311821SChristian.Menard@tu-dresden.de * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 2411821SChristian.Menard@tu-dresden.de * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2511821SChristian.Menard@tu-dresden.de * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2611821SChristian.Menard@tu-dresden.de * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2711821SChristian.Menard@tu-dresden.de * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 2811821SChristian.Menard@tu-dresden.de * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 2911821SChristian.Menard@tu-dresden.de * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3011821SChristian.Menard@tu-dresden.de * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3111821SChristian.Menard@tu-dresden.de * 3211821SChristian.Menard@tu-dresden.de * Authors: Christian Menard 3311821SChristian.Menard@tu-dresden.de */ 3411821SChristian.Menard@tu-dresden.de 3511821SChristian.Menard@tu-dresden.de#include <iostream> 3611821SChristian.Menard@tu-dresden.de#include <systemc> 3711821SChristian.Menard@tu-dresden.de 3811821SChristian.Menard@tu-dresden.de#include <sim/core.hh> 3911821SChristian.Menard@tu-dresden.de#include <sim/simulate.hh> 4011821SChristian.Menard@tu-dresden.de 4111821SChristian.Menard@tu-dresden.de#include "report_handler.hh" 4211821SChristian.Menard@tu-dresden.de 4311821SChristian.Menard@tu-dresden.deusing namespace sc_core; 4411821SChristian.Menard@tu-dresden.de 4511821SChristian.Menard@tu-dresden.devoid 4611821SChristian.Menard@tu-dresden.dereportHandler(const sc_report &report, const sc_actions &actions) 4711821SChristian.Menard@tu-dresden.de{ 4811821SChristian.Menard@tu-dresden.de uint64_t systemc_time = report.get_time().value(); 4911821SChristian.Menard@tu-dresden.de uint64_t gem5_time = curTick(); 5011821SChristian.Menard@tu-dresden.de 5111821SChristian.Menard@tu-dresden.de if (actions & SC_DO_NOTHING) 5211821SChristian.Menard@tu-dresden.de return; 5311821SChristian.Menard@tu-dresden.de 5411821SChristian.Menard@tu-dresden.de if (actions & SC_DISPLAY || actions & SC_LOG) 5511821SChristian.Menard@tu-dresden.de { 5611821SChristian.Menard@tu-dresden.de std::ostream& stream = actions & SC_DISPLAY ? std::cout : std::cerr; 5711821SChristian.Menard@tu-dresden.de 5811821SChristian.Menard@tu-dresden.de stream << report.get_time(); 5911821SChristian.Menard@tu-dresden.de 6011821SChristian.Menard@tu-dresden.de if (gem5_time < systemc_time) { 6111821SChristian.Menard@tu-dresden.de stream << " (<) "; 6211821SChristian.Menard@tu-dresden.de } else if (gem5_time > systemc_time) { 6311821SChristian.Menard@tu-dresden.de stream << " (!) "; 6411821SChristian.Menard@tu-dresden.de } else { 6511821SChristian.Menard@tu-dresden.de stream << " (=) "; 6611821SChristian.Menard@tu-dresden.de } 6711821SChristian.Menard@tu-dresden.de 6811821SChristian.Menard@tu-dresden.de stream << ": " << report.get_msg_type() 6911821SChristian.Menard@tu-dresden.de << ' ' << report.get_msg() << '\n'; 7011821SChristian.Menard@tu-dresden.de } 7111821SChristian.Menard@tu-dresden.de 7211821SChristian.Menard@tu-dresden.de if (actions & SC_THROW) { 7311821SChristian.Menard@tu-dresden.de std::cerr << "warning: the report handler ignored a SC_THROW action\n"; 7411821SChristian.Menard@tu-dresden.de } else if (actions & SC_INTERRUPT) { 7511821SChristian.Menard@tu-dresden.de std::cerr << "warning: the report handler ignored a SC_INTERRUPT" 7611821SChristian.Menard@tu-dresden.de << "action\n"; 7711821SChristian.Menard@tu-dresden.de } else if (actions & SC_CACHE_REPORT) { 7811821SChristian.Menard@tu-dresden.de std::cerr << "warning: the report handler ignored a SC_CACHE_REPORT" 7911821SChristian.Menard@tu-dresden.de << "action\n"; 8011821SChristian.Menard@tu-dresden.de } 8111821SChristian.Menard@tu-dresden.de 8211821SChristian.Menard@tu-dresden.de if (actions & SC_STOP) 8311821SChristian.Menard@tu-dresden.de sc_stop(); 8411821SChristian.Menard@tu-dresden.de 8511821SChristian.Menard@tu-dresden.de if (actions & SC_ABORT) 8611821SChristian.Menard@tu-dresden.de abort(); 8711821SChristian.Menard@tu-dresden.de} 88