00001
00013 #ifndef C4E_MPVEC_H
00014 #define C4E_MPVEC_H
00015
00016
00017
00018
00019 #include "c4e_sys.h"
00020
00021
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00050 #define C4E_MPVEC_DIGIT_MAC(a, b, y, carry) \
00051 do \
00052 { \
00053 C4eArchDigit2 tmp_ = C4E_ARCH_DIGIT2_ADD(C4E_ARCH_DIGIT2_MUL((a), (b)), \
00054 (y), C4E_SYS_DIGIT_ZERO); \
00055 (carry) = C4E_ARCH_DIGIT2_MSD(tmp_); \
00056 (y) = C4E_ARCH_DIGIT2_LSD(tmp_); \
00057 } while(C4E_FALSE)
00058
00059
00060
00061
00062 #ifdef C4E_CONFIG_ENABLE_COMBA
00063
00064
00076 #define C4E_MPVEC_MAC_DECL(mac) C4eArchMac mac
00077
00078
00079
00080
00097 #define C4E_MPVEC_MAC_INIT(mac) C4E_MPVEC_MAC_DECL(mac) = \
00098 { \
00099 .acc = (C4eArchDigit2)C4E_SYS_DIGIT_ZERO, \
00100 .cy = C4E_SYS_DIGIT_ZERO \
00101 }
00102
00103
00104
00105
00122 #define C4E_MPVEC_MAC_DIGIT(mac) C4E_ARCH_DIGIT2_LSD((mac).acc)
00123
00124
00125
00126
00139 #define C4E_MPVEC_MAC_ADD(mac, val) \
00140 do \
00141 { \
00142 C4eArchDigit2 _tmp = (mac).acc; \
00143 (mac).acc += val; \
00144 \
00145 if ((mac).acc < _tmp) \
00146 { \
00147 ++(mac).cy; \
00148 } \
00149 } \
00150 while (C4E_FALSE)
00151
00152
00153
00154
00169 #define C4E_MPVEC_MAC_OP(mac, a, b) \
00170 C4E_MPVEC_MAC_ADD((mac), C4E_ARCH_DIGIT2_MUL((a), (b)))
00171
00172
00173
00174 #endif
00175
00176
00177
00178
00179
00180
00181
00202 C4eArchDigit c4e_mpvec_add(C4E_CONST C4eArchDigit* pa,
00203 C4E_CONST C4eArchDigit* pb,
00204 C4eArchIdx len, C4eArchDigit* py);
00205
00206
00207
00229 C4eArchDigit c4e_mpvec_cyadd(C4eArchDigit carry,
00230 C4E_CONST C4eArchDigit* px,
00231 C4eArchIdx len, C4eArchDigit* py);
00232
00233
00234
00249 C4eArchDigit c4e_mpvec_cyacc(C4eArchDigit carry, C4eArchIdx len,
00250 C4eArchDigit* pxy);
00251
00252
00253
00275 C4eArchDigit c4e_mpvec_sub(C4E_CONST C4eArchDigit* pa,
00276 C4E_CONST C4eArchDigit* pb,
00277 C4eArchIdx len, C4eArchDigit* py);
00278
00279
00280
00301 C4eArchDigit c4e_mpvec_cysub(C4eArchDigit borrow,
00302 C4E_CONST C4eArchDigit* px,
00303 C4eArchIdx len, C4eArchDigit* py);
00304
00305
00306
00325 C4eArchDigit c4e_mpvec_cpl(C4eArchDigit borrow,
00326 C4E_CONST C4eArchDigit* px,
00327 C4eArchIdx len, C4eArchDigit* py);
00328
00329
00330
00331
00346 C4eArchDigit c4e_mpvec_muladd(C4eArchDigit digit,
00347 C4E_CONST C4eArchDigit* px,
00348 C4eArchIdx len, C4eArchDigit* py);
00349
00350
00351
00371 C4eArchDigit c4e_mpvec_dblmuladd(C4eArchDigit digit,
00372 C4E_CONST C4eArchDigit* px,
00373 C4eArchIdx len, C4eArchDigit* py);
00374
00375
00376
00392 C4eArchDigit c4e_mpvec_mulsub(C4eArchDigit digit,
00393 C4E_CONST C4eArchDigit* px,
00394 C4eArchIdx len, C4eArchDigit* py);
00395
00396
00414 C4eArchDigit c4e_mpvec_sqr(C4E_CONST C4eArchDigit* px,
00415 C4eArchIdx len, C4eArchDigit* py);
00416
00417
00418 #ifdef C4E_CONFIG_ENABLE_COMBA
00419
00420
00440 C4eArchDigit c4e_mpvec_imac(C4E_MPVEC_MAC_DECL(*mac),
00441 C4E_CONST C4eArchDigit* pUp,
00442 C4E_CONST C4eArchDigit* pDown,
00443 C4eArchIdx len);
00444
00445
00446
00466 C4eArchDigit c4e_mpvec_dblimac(C4E_MPVEC_MAC_DECL(*mac),
00467 C4E_CONST C4eArchDigit* pUp,
00468 C4E_CONST C4eArchDigit* pDown,
00469 C4eArchIdx len);
00470
00471 #endif
00472
00473
00474
00475 #ifdef __cplusplus
00476 }
00477 #endif
00478
00479
00480 #endif
00481
00482
00483
00484
00485
00486