sc_trace_file.cc revision 13245:c666c5d4996b
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 <vector> 31 32#include "base/logging.hh" 33#include "systemc/core/scheduler.hh" 34#include "systemc/ext/channel/sc_signal_in_if.hh" 35#include "systemc/ext/core/sc_event.hh" 36#include "systemc/ext/core/sc_time.hh" 37#include "systemc/ext/dt/bit/sc_bv_base.hh" 38#include "systemc/ext/dt/bit/sc_logic.hh" 39#include "systemc/ext/dt/bit/sc_lv_base.hh" 40#include "systemc/ext/dt/fx/sc_fxnum.hh" 41#include "systemc/ext/dt/fx/sc_fxval.hh" 42#include "systemc/ext/dt/int/sc_int_base.hh" 43#include "systemc/ext/dt/int/sc_signed.hh" 44#include "systemc/ext/dt/int/sc_uint_base.hh" 45#include "systemc/ext/dt/int/sc_unsigned.hh" 46#include "systemc/ext/utils/sc_trace_file.hh" 47#include "systemc/utils/vcd.hh" 48 49namespace sc_core 50{ 51 52sc_trace_file::sc_trace_file() {} 53sc_trace_file::~sc_trace_file() {} 54 55sc_trace_file * 56sc_create_vcd_trace_file(const char *name) 57{ 58 auto tf = new ::sc_gem5::VcdTraceFile(name); 59 ::sc_gem5::scheduler.registerTraceFile(tf); 60 return tf; 61} 62 63void 64sc_close_vcd_trace_file(sc_trace_file *tf) 65{ 66 ::sc_gem5::scheduler.unregisterTraceFile( 67 static_cast<::sc_gem5::TraceFile *>(tf)); 68 delete tf; 69} 70 71void 72sc_write_comment(sc_trace_file *tf, const std::string &comment) 73{ 74 static_cast<::sc_gem5::TraceFile *>(tf)->writeComment(comment); 75} 76 77void 78sc_trace(sc_trace_file *tf, const bool &v, const std::string &name) 79{ 80 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 81} 82 83void 84sc_trace(sc_trace_file *tf, const bool *v, const std::string &name) 85{ 86 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 87} 88 89void 90sc_trace(sc_trace_file *tf, const float &v, const std::string &name) 91{ 92 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 93} 94 95void 96sc_trace(sc_trace_file *tf, const float *v, const std::string &name) 97{ 98 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 99} 100 101void 102sc_trace(sc_trace_file *tf, const double &v, const std::string &name) 103{ 104 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 105} 106 107void 108sc_trace(sc_trace_file *tf, const double *v, const std::string &name) 109{ 110 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 111} 112 113void 114sc_trace(sc_trace_file *tf, const sc_dt::sc_logic &v, const std::string &name) 115{ 116 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 117} 118 119void 120sc_trace(sc_trace_file *tf, const sc_dt::sc_logic *v, const std::string &name) 121{ 122 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 123} 124 125void 126sc_trace(sc_trace_file *tf, const sc_dt::sc_int_base &v, 127 const std::string &name) 128{ 129 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 130} 131 132void 133sc_trace(sc_trace_file *tf, const sc_dt::sc_int_base *v, 134 const std::string &name) 135{ 136 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 137} 138 139void 140sc_trace(sc_trace_file *tf, const sc_dt::sc_uint_base &v, 141 const std::string &name) 142{ 143 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 144} 145 146void 147sc_trace(sc_trace_file *tf, const sc_dt::sc_uint_base *v, 148 const std::string &name) 149{ 150 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 151} 152 153void 154sc_trace(sc_trace_file *tf, const sc_dt::sc_signed &v, 155 const std::string &name) 156{ 157 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 158} 159 160void 161sc_trace(sc_trace_file *tf, const sc_dt::sc_signed *v, 162 const std::string &name) 163{ 164 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 165} 166 167void 168sc_trace(sc_trace_file *tf, const sc_dt::sc_unsigned &v, 169 const std::string &name) 170{ 171 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 172} 173 174void 175sc_trace(sc_trace_file *tf, const sc_dt::sc_unsigned *v, 176 const std::string &name) 177{ 178 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 179} 180 181void 182sc_trace(sc_trace_file *tf, const sc_dt::sc_bv_base &v, 183 const std::string &name) 184{ 185 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 186} 187 188void 189sc_trace(sc_trace_file *tf, const sc_dt::sc_bv_base *v, 190 const std::string &name) 191{ 192 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 193} 194 195void 196sc_trace(sc_trace_file *tf, const sc_dt::sc_lv_base &v, 197 const std::string &name) 198{ 199 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 200} 201 202void 203sc_trace(sc_trace_file *tf, const sc_dt::sc_lv_base *v, 204 const std::string &name) 205{ 206 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 207} 208 209void 210sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval &v, const std::string &name) 211{ 212 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 213} 214 215void 216sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval *v, const std::string &name) 217{ 218 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 219} 220 221void 222sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval_fast &v, 223 const std::string &name) 224{ 225 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 226} 227 228void 229sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval_fast *v, 230 const std::string &name) 231{ 232 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 233} 234 235void 236sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum &v, const std::string &name) 237{ 238 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 239} 240 241void 242sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum *v, const std::string &name) 243{ 244 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 245} 246 247void 248sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum_fast &v, 249 const std::string &name) 250{ 251 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 252} 253 254void 255sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum_fast *v, 256 const std::string &name) 257{ 258 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 259} 260 261void 262sc_trace(sc_trace_file *tf, const sc_event &v, const std::string &name) 263{ 264 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 265} 266 267void 268sc_trace(sc_trace_file *tf, const sc_event *v, const std::string &name) 269{ 270 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 271} 272 273void 274sc_trace(sc_trace_file *tf, const sc_time &v, const std::string &name) 275{ 276 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name); 277} 278 279void 280sc_trace(sc_trace_file *tf, const sc_time *v, const std::string &name) 281{ 282 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name); 283} 284 285void 286sc_trace(sc_trace_file *tf, const unsigned char &v, 287 const std::string &name, int width) 288{ 289 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 290} 291 292void 293sc_trace(sc_trace_file *tf, const unsigned char *v, 294 const std::string &name, int width) 295{ 296 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 297} 298 299void 300sc_trace(sc_trace_file *tf, const unsigned short &v, 301 const std::string &name, int width) 302{ 303 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 304} 305 306void 307sc_trace(sc_trace_file *tf, const unsigned short *v, 308 const std::string &name, int width) 309{ 310 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 311} 312 313void 314sc_trace(sc_trace_file *tf, const unsigned int &v, 315 const std::string &name, int width) 316{ 317 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 318} 319 320void 321sc_trace(sc_trace_file *tf, const unsigned int *v, 322 const std::string &name, int width) 323{ 324 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 325} 326 327void 328sc_trace(sc_trace_file *tf, const unsigned long &v, 329 const std::string &name, int width) 330{ 331 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 332} 333 334void 335sc_trace(sc_trace_file *tf, const unsigned long *v, 336 const std::string &name, int width) 337{ 338 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 339} 340 341void 342sc_trace(sc_trace_file *tf, const char &v, const std::string &name, int width) 343{ 344 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 345} 346 347void 348sc_trace(sc_trace_file *tf, const char *v, const std::string &name, int width) 349{ 350 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 351} 352 353void 354sc_trace(sc_trace_file *tf, const short &v, 355 const std::string &name, int width) 356{ 357 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 358} 359 360void 361sc_trace(sc_trace_file *tf, const short *v, 362 const std::string &name, int width) 363{ 364 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 365} 366 367void 368sc_trace(sc_trace_file *tf, const int &v, const std::string &name, int width) 369{ 370 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 371} 372 373void 374sc_trace(sc_trace_file *tf, const int *v, const std::string &name, int width) 375{ 376 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 377} 378 379void 380sc_trace(sc_trace_file *tf, const long &v, const std::string &name, int width) 381{ 382 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 383} 384 385void 386sc_trace(sc_trace_file *tf, const long *v, const std::string &name, int width) 387{ 388 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 389} 390 391void 392sc_trace(sc_trace_file *tf, const sc_dt::int64 &v, 393 const std::string &name, int width) 394{ 395 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 396} 397 398void 399sc_trace(sc_trace_file *tf, const sc_dt::int64 *v, 400 const std::string &name, int width) 401{ 402 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 403} 404 405void 406sc_trace(sc_trace_file *tf, const sc_dt::uint64 &v, 407 const std::string &name, int width) 408{ 409 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width); 410} 411 412void 413sc_trace(sc_trace_file *tf, const sc_dt::uint64 *v, 414 const std::string &name, int width) 415{ 416 static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width); 417} 418 419void 420sc_trace(sc_trace_file *tf, const sc_signal_in_if<char> &v, 421 const std::string &name, int width) 422{ 423 static_cast<::sc_gem5::TraceFile *>(tf)-> 424 addTraceVal(&v.read(), name, width); 425} 426 427void 428sc_trace(sc_trace_file *tf, const sc_signal_in_if<short> &v, 429 const std::string &name, int width) 430{ 431 static_cast<::sc_gem5::TraceFile *>(tf)-> 432 addTraceVal(&v.read(), name, width); 433} 434 435void 436sc_trace(sc_trace_file *tf, const sc_signal_in_if<int> &v, 437 const std::string &name, int width) 438{ 439 static_cast<::sc_gem5::TraceFile *>(tf)-> 440 addTraceVal(&v.read(), name, width); 441} 442 443void 444sc_trace(sc_trace_file *tf, const sc_signal_in_if<long> &v, 445 const std::string &name, int width) 446{ 447 static_cast<::sc_gem5::TraceFile *>(tf)-> 448 addTraceVal(&v.read(), name, width); 449} 450 451void 452sc_trace(sc_trace_file *tf, const unsigned int &v, 453 const std::string &name, const char **enum_literals) 454{ 455 static_cast<::sc_gem5::TraceFile *>(tf)-> 456 addTraceVal(&v, name, enum_literals); 457} 458 459void 460sc_trace_delta_cycles(sc_trace_file *tf, bool on) 461{ 462 static_cast<::sc_gem5::TraceFile *>(tf)->traceDeltas(on); 463} 464 465} // namespace sc_core 466