sc_time.cc (13263:bcd6d8140486) | sc_time.cc (13265:6cde60ee99fb) |
---|---|
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 --- 139 unchanged lines hidden (view full) --- 148 set(this, d, tu); 149} 150 151sc_time::sc_time(const sc_time &t) 152{ 153 val = t.val; 154} 155 | 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 --- 139 unchanged lines hidden (view full) --- 148 set(this, d, tu); 149} 150 151sc_time::sc_time(const sc_time &t) 152{ 153 val = t.val; 154} 155 |
156sc_time::sc_time(double d, const char *unit) 157{ 158 sc_time_unit tu; 159 for (tu = SC_FS; tu <= SC_SEC; tu = (sc_time_unit)(tu + 1)) { 160 if (strcmp(unit, sc_gem5::TimeUnitNames[tu]) == 0 || 161 strcmp(unit, sc_gem5::TimeUnitConstantNames[tu]) == 0) { 162 break; 163 } 164 } 165 166 if (tu > SC_SEC) { 167 SC_REPORT_ERROR("(E567) sc_time conversion failed", 168 "invalid unit given"); 169 val = 0; 170 return; 171 } 172 set(this, d, tu); 173} 174 |
|
156sc_time::sc_time(double d, bool scale) 157{ 158 double scaler = scale ? defaultUnit : SimClock::Float::Hz; 159 set(this, d * scaler, SC_SEC); 160} 161 162sc_time::sc_time(sc_dt::uint64 v, bool scale) 163{ --- 119 unchanged lines hidden (view full) --- 283 sc_time t; 284 set(&t, d, SC_SEC); 285 return t; 286} 287 288sc_time 289sc_time::from_string(const char *str) 290{ | 175sc_time::sc_time(double d, bool scale) 176{ 177 double scaler = scale ? defaultUnit : SimClock::Float::Hz; 178 set(this, d * scaler, SC_SEC); 179} 180 181sc_time::sc_time(sc_dt::uint64 v, bool scale) 182{ --- 119 unchanged lines hidden (view full) --- 302 sc_time t; 303 set(&t, d, SC_SEC); 304 return t; 305} 306 307sc_time 308sc_time::from_string(const char *str) 309{ |
291 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 292 return sc_time(); | 310 char *end = nullptr; 311 312 double d = str ? std::strtod(str, &end) : 0.0; 313 if (str == end || d < 0.0) { 314 SC_REPORT_ERROR("(E567) sc_time conversion failed", 315 "invalid value given"); 316 return SC_ZERO_TIME; 317 } 318 319 while (*end && std::isspace(*end)) 320 end++; 321 322 return sc_time(d, end); |
293} 294 295const sc_time 296operator + (const sc_time &a, const sc_time &b) 297{ 298 return sc_time::from_value(a.value() + b.value()); 299} 300 --- 214 unchanged lines hidden --- | 323} 324 325const sc_time 326operator + (const sc_time &a, const sc_time &b) 327{ 328 return sc_time::from_value(a.value() + b.value()); 329} 330 --- 214 unchanged lines hidden --- |