Deleted Added
sdiff udiff text old ( 13160:1e959d3afc64 ) new ( 13325:86323e6cc8ec )
full compact
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/int/sc_nbutils.hh"
65#include "systemc/ext/utils/functions.hh"
66
67namespace sc_dt
68{
69
70// only used within vec_from_str (non-standard, deprecated)
71static inline void

--- 12 unchanged lines hidden (view full) ---

84 "is_valid_base( sc_numrep base ) : "
85 "bases SC_CSD, or ending in _US and _SM are "
86 "not supported");
87 break;
88 default:
89 std::stringstream msg;
90 msg << "is_valid_base( sc_numrep base ) : base = " << base <<
91 " is not valid";
92 SC_REPORT_ERROR("(E204) value is not valid", msg.str().c_str() );
93 }
94}
95
96// ----------------------------------------------------------------------------
97// ENUM : sc_numrep
98//
99// Enumeration of number representations for character string conversion.
100// ----------------------------------------------------------------------------

--- 127 unchanged lines hidden (view full) ---

228 v += nskip;
229
230 // Handles empty strings or strings without any digits after the
231 // base or base and sign specifier.
232 if (*v == '\0') {
233 static const char msg[] =
234 "get_base_and_sign( const char* v, small_type&, small_type& ) : "
235 "v = \"\" is not valid";
236 SC_REPORT_ERROR("conversion failed", msg);
237 }
238 return v;
239}
240
241//-----------------------------------------------------------------------------
242//"parse_binary_bits"
243//
244// This function parses the supplied string into the supplied vector as a

--- 14 unchanged lines hidden (view full) ---

259 sc_digit data; // Data word now assembling.
260 int delta_n; // src_n - dst_n*BITS_PER_DIGIT.
261 int src_i; // Index in src_p now accessing (left to right).
262 int src_n; // Length of source that is left in bits.
263 int word_i; // Bit within word now accessing (left to right).
264
265 // MAKE SURE WE HAVE A STRING TO PARSE:
266 if (src_p == 0) {
267 SC_REPORT_ERROR("conversion failed",
268 "character string is zero");
269 return;
270 }
271 if (*src_p == 0) {
272 SC_REPORT_ERROR("conversion failed",
273 "character string is empty");
274 return;
275 }
276
277
278 // INDEX INTO THE SOURCE TO A DEPTH THAT WILL ACCOMODATE OUR SIZE:
279 //
280 // If the source is smaller than our value initialize our value to zero.

--- 35 unchanged lines hidden (view full) ---

316 case 'Z':
317 case 'z': ctrl = ctrl | 1; break;
318 case '0': break;
319 default:
320 {
321 std::stringstream msg;
322 msg << "character string '" << src_p <<
323 "' is not valid";
324 SC_REPORT_ERROR("conversion failed",
325 msg.str().c_str());
326 return;
327 }
328 break;
329 }
330 }
331 if (ctrl_p)
332 ctrl_p[word_i] = ctrl;

--- 14 unchanged lines hidden (view full) ---

347 case 'Z':
348 case 'z': ctrl = ctrl | 1; break;
349 case '0': break;
350 default:
351 {
352 std::stringstream msg;
353 msg << "character string '" << src_p <<
354 "' is not valid";
355 SC_REPORT_ERROR("conversion failed",
356 msg.str().c_str());
357 return;
358 }
359 break;
360 }
361 }
362 if (ctrl_p)
363 ctrl_p[word_i] = ctrl;

--- 24 unchanged lines hidden (view full) ---

388 int delta_n; // src_n - dst_n*BITS_PER_DIGIT.
389 int digit_i; // Number of digit now processing.
390 int src_i; // Index in src_p now accessing (left to right).
391 int src_n; // Length of source that is left in bits.
392 int word_i; // Bit within word now accessing (left to right).
393
394 // MAKE SURE WE HAVE A STRING TO PARSE:
395 if (src_p == 0) {
396 SC_REPORT_ERROR("conversion failed",
397 "character string is zero");
398 return;
399 }
400 if (*src_p == 0) {
401 SC_REPORT_ERROR("conversion failed",
402 "character string is empty");
403 return;
404 }
405
406 // INDEX INTO THE SOURCE TO A DEPTH THAT WILL ACCOMODATE OUR SIZE:
407 //
408 // If the source is smaller than our value initialize our value to zero.
409 src_n = strlen(src_p);

--- 53 unchanged lines hidden (view full) ---

463 case '0': break;
464 case 'Z':
465 case 'z': ctrl = ctrl | 15; break;
466 default:
467 {
468 std::stringstream msg;
469 msg << "character string '" << src_p <<
470 "' is not valid";
471 SC_REPORT_ERROR("conversion failed",
472 msg.str().c_str());
473 return;
474 }
475 break;
476 }
477 }
478 if (ctrl_p)
479 ctrl_p[word_i] = ctrl;

--- 33 unchanged lines hidden (view full) ---

513 case '1': data = data | 1; break;
514 case '0': break;
515 case 'Z':
516 case 'z': ctrl = ctrl | 15; break;
517 default:
518 {
519 std::stringstream msg;
520 msg << "character string '" << src_p << "' is not valid";
521 SC_REPORT_ERROR("conversion failed",
522 msg.str().c_str() );
523 return;
524 }
525 break;
526 }
527 }
528 if (ctrl_p)
529 ctrl_p[word_i] = ctrl;

--- 26 unchanged lines hidden (view full) ---

556 if (base != SC_NOBASE) {
557 if (b == NB_DEFAULT_BASE) {
558 b = base;
559 } else {
560 std::stringstream msg;
561 msg << "vec_from_str( int, int, sc_digit*, const char*, " <<
562 "sc_numrep base ) : base = " << base <<
563 " does not match the default base";
564 SC_REPORT_ERROR("conversion failed",
565 msg.str().c_str());
566 return 0;
567 }
568 }
569
570 vec_zero(und, u);
571
572 char c;

--- 6 unchanged lines hidden (view full) ---

579 else
580 val = c - '0';
581
582 if (val >= b) {
583 std::stringstream msg;
584 msg << "vec_from_str( int, int, sc_digit*, const char*, " <<
585 "sc_numrep base ) : '" << *v << "' is not a valid " <<
586 "digit in base " << b;
587 SC_REPORT_ERROR("conversion failed",
588 msg.str().c_str());
589 return 0;
590 }
591
592 // digit = digit * b + val;
593 vec_mul_small_on(und, u, b);
594
595 if (val)
596 vec_add_small_on(und, u, val);
597 } else {
598 std::stringstream msg;
599 msg << "vec_from_str( int, int, sc_digit*, const char*, " <<
600 "sc_numrep base ) : '" << *v << "' is not a valid " <<
601 "digit in base " << b;
602 SC_REPORT_ERROR("conversion failed",
603 msg.str().c_str());
604 return 0;
605 }
606 }
607
608 return convert_signed_SM_to_2C_to_SM(s, unb, und, u);
609}
610

--- 1087 unchanged lines hidden (view full) ---

1698 sc_assert((unb > 0) && (und > 0) && (ud != NULL));
1699 sc_assert((0 <= r) && (r <= l) && (l < unb));
1700#endif
1701
1702 if (l < r) {
1703 std::stringstream msg;
1704 msg << "vec_reverse( int, int, sc_digit*, int l, int r ) : " <<
1705 "l = " << l << " < r = " << r << " is not valid",
1706 SC_REPORT_ERROR("conversion failed", msg.str().c_str());
1707 return;
1708 }
1709
1710 // Make sure that l and r are within bounds.
1711 r = sc_max(r, 0);
1712 l = sc_min(l, unb - 1);
1713
1714 // Allocate memory for processing.

--- 35 unchanged lines hidden ---