86 "is_valid_base( sc_numrep base ) : "
87 "bases SC_CSD, or ending in _US and _SM are "
91 std::stringstream msg;
92 msg <<
"is_valid_base( sc_numrep base ) : base = " << base <<
108#define CASE_ENUM2STR(Value) case Value: return #Value
178 case '0':
state = 1;
return 0;
218 if (
state == STATE_FINISH)
235 static const char msg[] =
236 "get_base_and_sign( const char* v, small_type&, small_type& ) : "
237 "v = \"\" is not valid";
270 "character string is zero");
275 "character string is empty");
284 src_n = strlen(src_p);
287 src_p = &src_p[delta_n];
290 for (word_i = 0; word_i < dst_n; word_i++)
293 for (word_i = 0; word_i < dst_n; word_i++)
303 for (word_i=0; word_i < dst_n; word_i++) {
311 for (src_i = 0; src_i < src_n; src_i++) {
314 switch (src_p[src_i]) {
316 case 'x': ctrl = ctrl | 1;
data =
data | 1;
break;
319 case 'z': ctrl = ctrl | 1;
break;
323 std::stringstream msg;
324 msg <<
"character string '" << src_p <<
334 ctrl_p[word_i] = ctrl;
335 data_p[word_i] =
data;
345 switch (src_p[src_i++]) {
347 case 'x': ctrl = ctrl | 1;
data =
data | 1;
break;
350 case 'z': ctrl = ctrl | 1;
break;
354 std::stringstream msg;
355 msg <<
"character string '" << src_p <<
365 ctrl_p[word_i] = ctrl;
366 data_p[word_i] =
data;
399 "character string is zero");
404 "character string is empty");
411 src_n = strlen(src_p);
412 delta_n = src_n - (dst_n*8);
414 src_p = &src_p[delta_n];
417 for (word_i = 0; word_i < dst_n; word_i++)
420 for (word_i = 0; word_i < dst_n; word_i++)
430 for (word_i = 0; word_i < dst_n; word_i++) {
438 for (src_i = 0; src_i < src_n; src_i++) {
441 switch (src_p[src_i]) {
443 case 'x': ctrl = ctrl | 15;
data =
data | 15;
break;
467 case 'z': ctrl = ctrl | 15;
break;
470 std::stringstream msg;
471 msg <<
"character string '" << src_p <<
481 ctrl_p[word_i] = ctrl;
482 data_p[word_i] =
data;
489 for (digit_i = 0; digit_i < 8; digit_i++) {
492 switch (src_p[src_i++]) {
494 case 'x': ctrl = ctrl | 15;
data =
data | 15;
break;
518 case 'z': ctrl = ctrl | 15;
break;
521 std::stringstream msg;
522 msg <<
"character string '" << src_p <<
"' is not valid";
531 ctrl_p[word_i] = ctrl;
532 data_p[word_i] =
data;
549 sc_assert((unb > 0) && (und > 0) && (u != NULL));
558 if (base != SC_NOBASE) {
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";
575 for (; (
c = *v); ++v) {
580 val = toupper(
c) -
'A' + 10;
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;
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;
638 carry += (*u++) + (*v++);
644 while (carry && (u < uend)) {
666 sc_assert((ulen > 0) && (ubegin != NULL));
679 carry += (*u) + (*v++);
685 while (carry && (u < uend)) {
694 "vec_add_on( int, sc_digit*, int, const "
696 "result of addition is wrapped around");
712 sc_assert((ulen > 0) && (ubegin != NULL));
724 carry += (*u) + (*v++);
732 "vec_add_on2( int, sc_digit*, int, const "
734 "result of addition is wrapped around");
757 while (carry && (u < uend)) {
782 while (v && (i < ulen)) {
791 "vec_add_small_on( int, sc_digit*, unsigned "
793 "result of addition is wrapped around");
824 while (borrow && (u < uend)) {
846 sc_assert((ulen > 0) && (ubegin != NULL));
865 while (borrow && (u < uend)) {
883 sc_assert((ulen > 0) && (ubegin != NULL));
902 "vec_sub_on2( int, sc_digit*, int, const "
904 "result of subtraction is wrapped around");
926 while (borrow && (u < uend)) {
950 for (
int i = 0; i < ulen; ++i) {
1025 sc_assert((vlen > 0) && (vbegin != NULL));
1031 const sc_digit *vend = (vbegin + vlen);
1058 prod_h = u_h * v_l + u_l * v_h +
1110 for (
int i = 0; i < ulen; ++i) {
1125 "vec_mul_small_on( int, sc_digit*, unsigned "
1127 "result of multiplication is wrapped around");
1171 while ((--xlen >= 0) && (! x[xlen]))
1179 while ((--ylen >= 0) && (! y[ylen]))
1199 for (
int k = (xlen - ylen); k >= 0; --k) {
1207 qk = ((x[k2] << DOUBLE_BITS_PER_BYTE) +
1215 uchar *xk = (x + k);
1220 for (
int i = 0; i < ylen; ++i) {
1244 for (
int i = 0; i < ylen; ++i) {
1245 carry += xk[i] + y[i];
1312 while (ubegin < u) {
1360 while ((--xlen >= 0) && (!x[xlen]))
1368 while ((--ylen >= 0) && (!y[ylen]))
1388 for (
int k = xlen - ylen; k >= 0; --k) {
1396 qk = ((x[k2] << DOUBLE_BITS_PER_BYTE) +
1404 uchar *xk = (x + k);
1409 for (
int i = 0; i < ylen; ++i) {
1430 for (
int i = 0; i < ylen; ++i) {
1431 carry += xk[i] + y[i];
1472 while (ubegin < u) {
1499 while (ubegin < u) {
1533 int d = u[right_digit] >> nsr;
1535 if (left_digit != right_digit) {
1536 if (left_digit < ulen)
1567 for (
int i = ulen - 2; i >= 0; --i) {
1571 while (viter < vend) {
1574 carry = vval >> nsr;
1609 for (
int j = ulen - 1; j >= nd; --j)
1627 while (uiter < uend) {
1629 (*uiter++) = (((uval & mask) << nsl) | carry);
1630 carry = uval >> nsr;
1663 for (
int j = 0; j < (ulen - nd); ++j)
1667 for (
int j = ulen -
sc_min( nd, ulen ); j < ulen; ++j)
1684 sc_digit carry = (fill & mask) << nsl;
1686 while (ubegin < uiter) {
1688 (*uiter) = (uval >> nsr) | carry;
1689 carry = (uval & mask) << nsl;
1700 sc_assert((unb > 0) && (und > 0) && (ud != NULL));
1701 sc_assert((0 <= r) && (r <= l) && (l < unb));
1705 std::stringstream msg;
1706 msg <<
"vec_reverse( int, int, sc_digit*, int l, int r ) : " <<
1707 "l = " << l <<
" < r = " << r <<
" is not valid",
1728 for (
int i = l, j = r; i >= r; --i, ++j) {
1741void test_bound_failed(
int nb)
1743 std::stringstream msg;
1744 msg <<
"test_bound( int nb ) : "
1745 "nb = " << nb <<
" > SC_MAX_NBITS = " << SC_MAX_NBITS <<
const char SC_ID_CONVERSION_FAILED_[]
const char SC_ID_VALUE_NOT_VALID_[]
const char SC_ID_WITHOUT_MESSAGE_[]
const char SC_ID_OUT_OF_BOUNDS_[]
sc_digit vec_rem_small(int ulen, const sc_digit *u, sc_digit v)
void vec_sub_on2(int ulen, sc_digit *ubegin, int vlen, const sc_digit *v)
sc_digit high_half(sc_digit d)
void vec_add_on(int ulen, sc_digit *ubegin, int vlen, const sc_digit *v)
void vec_add_on2(int ulen, sc_digit *ubegin, int, const sc_digit *v)
sc_digit one_and_ones(int n)
sc_digit vec_rem_on_small(int ulen, sc_digit *u, sc_digit v)
void vec_div_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *q)
sc_digit high_half_masked(sc_digit d)
void vec_sub_on(int ulen, sc_digit *ubegin, int vlen, const sc_digit *v)
void vec_shift_right(int ulen, sc_digit *u, int nsr, sc_digit fill)
void vec_reverse(int unb, int und, sc_digit *ud, int l, int r)
const char * get_base_and_sign(const char *v, small_type &b, small_type &s)
void vec_add(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
void vec_sub_small_on(int ulen, sc_digit *u, sc_digit v)
small_type convert_signed_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
void vec_add_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *w)
void vec_div_large(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
void vec_shift_left(int ulen, sc_digit *u, int nsl)
void vec_copy(int n, sc_digit *u, const sc_digit *v)
static void is_valid_base(sc_numrep base)
const T sc_min(const T &a, const T &b)
void vec_mul_small_on(int ulen, sc_digit *u, sc_digit v)
void vec_sub_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *w)
sc_concref_r< sc_bitref_r< T1 >, sc_bitref_r< T2 > > concat(sc_bitref_r< T1 >, sc_bitref_r< T2 >)
sc_digit low_half(sc_digit d)
static const small_type NB_DEFAULT_BASE
const T sc_max(const T &a, const T &b)
int vec_to_char(int ulen, const sc_digit *u, int vlen, uchar *v)
void vec_sub(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
void vec_add_small_on(int ulen, sc_digit *u, sc_digit v)
void vec_mul(int ulen, const sc_digit *u, int vlen, const sc_digit *vbegin, sc_digit *wbegin)
small_type vec_from_str(int unb, int und, sc_digit *u, const char *v, sc_numrep base)
small_type fsm_move(char c, small_type &b, small_type &s, small_type &state)
void vec_zero(int from, int ulen, sc_digit *u)
void vec_mul_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *w)
const std::string to_string(sc_enc enc)
void vec_from_char(int ulen, const uchar *u, int vlen, sc_digit *v)
sc_digit one_and_zeros(int n)
void parse_hex_bits(const char *src_p, int dst_n, sc_digit *data_p, sc_digit *ctrl_p)
void vec_rem_large(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
void parse_binary_bits(const char *src_p, int dst_n, sc_digit *data_p, sc_digit *ctrl_p)
#define LOG2_BITS_PER_BYTE
#define CASE_ENUM2STR(Value)
#define SC_REPORT_WARNING(msg_type, msg)
#define SC_REPORT_ERROR(msg_type, msg)