1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at --- 47 unchanged lines hidden (view full) --- 56// source. 57// 58 59#include <cctype> 60#include <cstdio> 61#include <cstring> 62#include <sstream> 63 |
64#include "systemc/ext/dt/bit/messages.hh" 65#include "systemc/ext/dt/int/messages.hh" |
66#include "systemc/ext/dt/int/sc_nbutils.hh" 67#include "systemc/ext/utils/functions.hh" 68 69namespace sc_dt 70{ 71 72// only used within vec_from_str (non-standard, deprecated) 73static inline void --- 12 unchanged lines hidden (view full) --- 86 "is_valid_base( sc_numrep base ) : " 87 "bases SC_CSD, or ending in _US and _SM are " 88 "not supported"); 89 break; 90 default: 91 std::stringstream msg; 92 msg << "is_valid_base( sc_numrep base ) : base = " << base << 93 " is not valid"; |
94 SC_REPORT_ERROR(sc_core::SC_ID_VALUE_NOT_VALID_, msg.str().c_str()); |
95 } 96} 97 98// ---------------------------------------------------------------------------- 99// ENUM : sc_numrep 100// 101// Enumeration of number representations for character string conversion. 102// ---------------------------------------------------------------------------- --- 127 unchanged lines hidden (view full) --- 230 v += nskip; 231 232 // Handles empty strings or strings without any digits after the 233 // base or base and sign specifier. 234 if (*v == '\0') { 235 static const char msg[] = 236 "get_base_and_sign( const char* v, small_type&, small_type& ) : " 237 "v = \"\" is not valid"; |
238 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, msg); |
239 } 240 return v; 241} 242 243//----------------------------------------------------------------------------- 244//"parse_binary_bits" 245// 246// This function parses the supplied string into the supplied vector as a --- 14 unchanged lines hidden (view full) --- 261 sc_digit data; // Data word now assembling. 262 int delta_n; // src_n - dst_n*BITS_PER_DIGIT. 263 int src_i; // Index in src_p now accessing (left to right). 264 int src_n; // Length of source that is left in bits. 265 int word_i; // Bit within word now accessing (left to right). 266 267 // MAKE SURE WE HAVE A STRING TO PARSE: 268 if (src_p == 0) { |
269 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
270 "character string is zero"); 271 return; 272 } 273 if (*src_p == 0) { |
274 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
275 "character string is empty"); 276 return; 277 } 278 279 280 // INDEX INTO THE SOURCE TO A DEPTH THAT WILL ACCOMODATE OUR SIZE: 281 // 282 // If the source is smaller than our value initialize our value to zero. --- 35 unchanged lines hidden (view full) --- 318 case 'Z': 319 case 'z': ctrl = ctrl | 1; break; 320 case '0': break; 321 default: 322 { 323 std::stringstream msg; 324 msg << "character string '" << src_p << 325 "' is not valid"; |
326 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
327 msg.str().c_str()); 328 return; 329 } 330 break; 331 } 332 } 333 if (ctrl_p) 334 ctrl_p[word_i] = ctrl; --- 14 unchanged lines hidden (view full) --- 349 case 'Z': 350 case 'z': ctrl = ctrl | 1; break; 351 case '0': break; 352 default: 353 { 354 std::stringstream msg; 355 msg << "character string '" << src_p << 356 "' is not valid"; |
357 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
358 msg.str().c_str()); 359 return; 360 } 361 break; 362 } 363 } 364 if (ctrl_p) 365 ctrl_p[word_i] = ctrl; --- 24 unchanged lines hidden (view full) --- 390 int delta_n; // src_n - dst_n*BITS_PER_DIGIT. 391 int digit_i; // Number of digit now processing. 392 int src_i; // Index in src_p now accessing (left to right). 393 int src_n; // Length of source that is left in bits. 394 int word_i; // Bit within word now accessing (left to right). 395 396 // MAKE SURE WE HAVE A STRING TO PARSE: 397 if (src_p == 0) { |
398 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
399 "character string is zero"); 400 return; 401 } 402 if (*src_p == 0) { |
403 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
404 "character string is empty"); 405 return; 406 } 407 408 // INDEX INTO THE SOURCE TO A DEPTH THAT WILL ACCOMODATE OUR SIZE: 409 // 410 // If the source is smaller than our value initialize our value to zero. 411 src_n = strlen(src_p); --- 53 unchanged lines hidden (view full) --- 465 case '0': break; 466 case 'Z': 467 case 'z': ctrl = ctrl | 15; break; 468 default: 469 { 470 std::stringstream msg; 471 msg << "character string '" << src_p << 472 "' is not valid"; |
473 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
474 msg.str().c_str()); 475 return; 476 } 477 break; 478 } 479 } 480 if (ctrl_p) 481 ctrl_p[word_i] = ctrl; --- 33 unchanged lines hidden (view full) --- 515 case '1': data = data | 1; break; 516 case '0': break; 517 case 'Z': 518 case 'z': ctrl = ctrl | 15; break; 519 default: 520 { 521 std::stringstream msg; 522 msg << "character string '" << src_p << "' is not valid"; |
523 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
524 msg.str().c_str() ); 525 return; 526 } 527 break; 528 } 529 } 530 if (ctrl_p) 531 ctrl_p[word_i] = ctrl; --- 26 unchanged lines hidden (view full) --- 558 if (base != SC_NOBASE) { 559 if (b == NB_DEFAULT_BASE) { 560 b = base; 561 } else { 562 std::stringstream msg; 563 msg << "vec_from_str( int, int, sc_digit*, const char*, " << 564 "sc_numrep base ) : base = " << base << 565 " does not match the default base"; |
566 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
567 msg.str().c_str()); 568 return 0; 569 } 570 } 571 572 vec_zero(und, u); 573 574 char c; --- 6 unchanged lines hidden (view full) --- 581 else 582 val = c - '0'; 583 584 if (val >= b) { 585 std::stringstream msg; 586 msg << "vec_from_str( int, int, sc_digit*, const char*, " << 587 "sc_numrep base ) : '" << *v << "' is not a valid " << 588 "digit in base " << b; |
589 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
590 msg.str().c_str()); 591 return 0; 592 } 593 594 // digit = digit * b + val; 595 vec_mul_small_on(und, u, b); 596 597 if (val) 598 vec_add_small_on(und, u, val); 599 } else { 600 std::stringstream msg; 601 msg << "vec_from_str( int, int, sc_digit*, const char*, " << 602 "sc_numrep base ) : '" << *v << "' is not a valid " << 603 "digit in base " << b; |
604 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, |
605 msg.str().c_str()); 606 return 0; 607 } 608 } 609 610 return convert_signed_SM_to_2C_to_SM(s, unb, und, u); 611} 612 --- 1087 unchanged lines hidden (view full) --- 1700 sc_assert((unb > 0) && (und > 0) && (ud != NULL)); 1701 sc_assert((0 <= r) && (r <= l) && (l < unb)); 1702#endif 1703 1704 if (l < r) { 1705 std::stringstream msg; 1706 msg << "vec_reverse( int, int, sc_digit*, int l, int r ) : " << 1707 "l = " << l << " < r = " << r << " is not valid", |
1708 SC_REPORT_ERROR(sc_core::SC_ID_CONVERSION_FAILED_, msg.str().c_str()); |
1709 return; 1710 } 1711 1712 // Make sure that l and r are within bounds. 1713 r = sc_max(r, 0); 1714 l = sc_min(l, unb - 1); 1715 1716 // Allocate memory for processing. --- 35 unchanged lines hidden --- |