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 --- 357 unchanged lines hidden (view full) --- 366 return os; 367} 368 369const sc_time SC_ZERO_TIME; 370 371void 372sc_set_time_resolution(double d, sc_time_unit tu) 373{ |
374 if (d <= 0.0) { |
375 SC_REPORT_ERROR("(E514) set time resolution failed", 376 "value not positive"); 377 } 378 double dummy; 379 if (modf(log10(d), &dummy) != 0.0) { 380 SC_REPORT_ERROR("(E514) set time resolution failed", 381 "value not a power of ten"); 382 } --- 38 unchanged lines hidden (view full) --- 421{ 422 static const sc_time MaxScTime = sc_time::from_value(MaxTick); 423 return MaxScTime; 424} 425 426void 427sc_set_default_time_unit(double d, sc_time_unit tu) 428{ |
429 if (d < 0.0) { 430 SC_REPORT_ERROR("(E515) set default time unit failed", 431 "value not positive"); 432 } 433 double dummy; 434 if (modf(log10(d), &dummy) != 0.0) { 435 SC_REPORT_ERROR("(E515) set default time unit failed", 436 "value not a power of ten"); 437 } 438 if (sc_is_running()) { 439 SC_REPORT_ERROR("(E515) set default time unit failed", 440 "simulation running"); 441 } 442 static bool specified = false; 443 if (specified) { 444 SC_REPORT_ERROR("(E515) set default time unit failed", 445 "already specified"); 446 } 447 // This won't detect the timescale being fixed outside of systemc, but 448 // it's at least some protection. 449 if (timeFixed) { 450 SC_REPORT_ERROR("(E515) set default time unit failed", 451 "sc_time object(s) constructed"); 452 } 453 454 // Normalize d to seconds. |
455 defaultUnit = d * TimeUnitScale[tu]; |
456 specified = true; |
457} 458 459sc_time 460sc_get_default_time_unit() 461{ 462 return sc_time(defaultUnit, SC_SEC); 463} 464 --- 41 unchanged lines hidden --- |