sc_fix.h revision 12027:1eb7dc7aa10b
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 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_fix.h - 23 24 Original Author: Martin Janssen, Synopsys, Inc. 25 26 *****************************************************************************/ 27 28/***************************************************************************** 29 30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 31 changes you are making here. 32 33 Name, Affiliation, Date: 34 Description of Modification: 35 36 *****************************************************************************/ 37 38// $Log: sc_fix.h,v $ 39// Revision 1.2 2011/01/19 18:57:40 acg 40// Andy Goodrich: changes for IEEE_1666_2011. 41// 42// Revision 1.1.1.1 2006/12/15 20:20:04 acg 43// SystemC 2.3 44// 45// Revision 1.3 2006/01/13 18:53:57 acg 46// Andy Goodrich: added $Log command so that CVS comments are reproduced in 47// the source. 48// 49 50#ifndef SC_FIX_H 51#define SC_FIX_H 52 53 54#include "sysc/datatypes/fx/sc_fxnum.h" 55 56 57namespace sc_dt 58{ 59 60// classes defined in this module 61class sc_fix; 62class sc_fix_fast; 63 64 65// ---------------------------------------------------------------------------- 66// CLASS : sc_fix 67// 68// "Unconstrained" signed fixed-point class; arbitrary precision. 69// ---------------------------------------------------------------------------- 70 71class sc_fix : public sc_fxnum 72{ 73 74public: 75 76 // constructors 77 78 explicit sc_fix( sc_fxnum_observer* = 0 ); 79 sc_fix( int, int, 80 sc_fxnum_observer* = 0 ); 81 sc_fix( sc_q_mode, sc_o_mode, 82 sc_fxnum_observer* = 0 ); 83 sc_fix( sc_q_mode, sc_o_mode, int, 84 sc_fxnum_observer* = 0 ); 85 sc_fix( int, int, sc_q_mode, sc_o_mode, 86 sc_fxnum_observer* = 0 ); 87 sc_fix( int, int, sc_q_mode, sc_o_mode, int, 88 sc_fxnum_observer* = 0 ); 89 explicit sc_fix( const sc_fxcast_switch&, 90 sc_fxnum_observer* = 0 ); 91 sc_fix( int, int, 92 const sc_fxcast_switch&, 93 sc_fxnum_observer* = 0 ); 94 sc_fix( sc_q_mode, sc_o_mode, 95 const sc_fxcast_switch&, 96 sc_fxnum_observer* = 0 ); 97 sc_fix( sc_q_mode, sc_o_mode, int, 98 const sc_fxcast_switch&, 99 sc_fxnum_observer* = 0 ); 100 sc_fix( int, int, sc_q_mode, sc_o_mode, 101 const sc_fxcast_switch&, 102 sc_fxnum_observer* = 0 ); 103 sc_fix( int, int, sc_q_mode, sc_o_mode, int, 104 const sc_fxcast_switch&, 105 sc_fxnum_observer* = 0 ); 106 explicit sc_fix( const sc_fxtype_params&, 107 sc_fxnum_observer* = 0 ); 108 sc_fix( const sc_fxtype_params&, 109 const sc_fxcast_switch&, 110 sc_fxnum_observer* = 0 ); 111 112#define DECL_CTORS_T(tp) \ 113 sc_fix( tp, \ 114 int, int, \ 115 sc_fxnum_observer* = 0 ); \ 116 sc_fix( tp, \ 117 sc_q_mode, sc_o_mode, \ 118 sc_fxnum_observer* = 0 ); \ 119 sc_fix( tp, \ 120 sc_q_mode, sc_o_mode, int, \ 121 sc_fxnum_observer* = 0 ); \ 122 sc_fix( tp, \ 123 int, int, sc_q_mode, sc_o_mode, \ 124 sc_fxnum_observer* = 0 ); \ 125 sc_fix( tp, \ 126 int, int, sc_q_mode, sc_o_mode, int, \ 127 sc_fxnum_observer* = 0 ); \ 128 sc_fix( tp, \ 129 const sc_fxcast_switch&, \ 130 sc_fxnum_observer* = 0 ); \ 131 sc_fix( tp, \ 132 int, int, \ 133 const sc_fxcast_switch&, \ 134 sc_fxnum_observer* = 0 ); \ 135 sc_fix( tp, \ 136 sc_q_mode, sc_o_mode, \ 137 const sc_fxcast_switch&, \ 138 sc_fxnum_observer* = 0 ); \ 139 sc_fix( tp, \ 140 sc_q_mode, sc_o_mode, int, \ 141 const sc_fxcast_switch&, \ 142 sc_fxnum_observer* = 0 ); \ 143 sc_fix( tp, \ 144 int, int, sc_q_mode, sc_o_mode, \ 145 const sc_fxcast_switch&, \ 146 sc_fxnum_observer* = 0 ); \ 147 sc_fix( tp, \ 148 int, int, sc_q_mode, sc_o_mode, int, \ 149 const sc_fxcast_switch&, \ 150 sc_fxnum_observer* = 0 ); \ 151 sc_fix( tp, \ 152 const sc_fxtype_params&, \ 153 sc_fxnum_observer* = 0 ); \ 154 sc_fix( tp, \ 155 const sc_fxtype_params&, \ 156 const sc_fxcast_switch&, \ 157 sc_fxnum_observer* = 0 ); 158 159#define DECL_CTORS_T_A(tp) \ 160 sc_fix( tp, \ 161 sc_fxnum_observer* = 0 ); \ 162 DECL_CTORS_T(tp) 163 164#define DECL_CTORS_T_B(tp) \ 165 explicit sc_fix( tp, \ 166 sc_fxnum_observer* = 0 ); \ 167 DECL_CTORS_T(tp) 168 169 DECL_CTORS_T_A(int) 170 DECL_CTORS_T_A(unsigned int) 171 DECL_CTORS_T_A(long) 172 DECL_CTORS_T_A(unsigned long) 173 DECL_CTORS_T_A(float) 174 DECL_CTORS_T_A(double) 175 DECL_CTORS_T_A(const char*) 176 DECL_CTORS_T_A(const sc_fxval&) 177 DECL_CTORS_T_A(const sc_fxval_fast&) 178 DECL_CTORS_T_A(const sc_fxnum&) 179 DECL_CTORS_T_A(const sc_fxnum_fast&) 180#ifndef SC_FX_EXCLUDE_OTHER 181 DECL_CTORS_T_B(int64) 182 DECL_CTORS_T_B(uint64) 183 DECL_CTORS_T_B(const sc_int_base&) 184 DECL_CTORS_T_B(const sc_uint_base&) 185 DECL_CTORS_T_B(const sc_signed&) 186 DECL_CTORS_T_B(const sc_unsigned&) 187#endif 188 189#undef DECL_CTORS_T 190#undef DECL_CTORS_T_A 191#undef DECL_CTORS_T_B 192 193 // copy constructor 194 195 sc_fix( const sc_fix& ); 196 197 198 // unary bitwise operators 199 200 const sc_fix operator ~ () const; 201 202 203 // unary bitwise functions 204 205 friend void b_not( sc_fix&, const sc_fix& ); 206 207 208 // binary bitwise operators 209 210 friend const sc_fix operator & ( const sc_fix&, const sc_fix& ); 211 friend const sc_fix operator & ( const sc_fix&, const sc_fix_fast& ); 212 friend const sc_fix operator & ( const sc_fix_fast&, const sc_fix& ); 213 friend const sc_fix operator | ( const sc_fix&, const sc_fix& ); 214 friend const sc_fix operator | ( const sc_fix&, const sc_fix_fast& ); 215 friend const sc_fix operator | ( const sc_fix_fast&, const sc_fix& ); 216 friend const sc_fix operator ^ ( const sc_fix&, const sc_fix& ); 217 friend const sc_fix operator ^ ( const sc_fix&, const sc_fix_fast& ); 218 friend const sc_fix operator ^ ( const sc_fix_fast&, const sc_fix& ); 219 220 221 // binary bitwise functions 222 223 friend void b_and( sc_fix&, const sc_fix&, const sc_fix& ); 224 friend void b_and( sc_fix&, const sc_fix&, const sc_fix_fast& ); 225 friend void b_and( sc_fix&, const sc_fix_fast&, const sc_fix& ); 226 friend void b_or ( sc_fix&, const sc_fix&, const sc_fix& ); 227 friend void b_or ( sc_fix&, const sc_fix&, const sc_fix_fast& ); 228 friend void b_or ( sc_fix&, const sc_fix_fast&, const sc_fix& ); 229 friend void b_xor( sc_fix&, const sc_fix&, const sc_fix& ); 230 friend void b_xor( sc_fix&, const sc_fix&, const sc_fix_fast& ); 231 friend void b_xor( sc_fix&, const sc_fix_fast&, const sc_fix& ); 232 233 234 // assignment operators 235 236 sc_fix& operator = ( const sc_fix& ); 237 238#define DECL_ASN_OP_T(op,tp) \ 239 sc_fix& operator op ( tp ); 240 241#ifndef SC_FX_EXCLUDE_OTHER 242#define DECL_ASN_OP_OTHER(op) \ 243 DECL_ASN_OP_T(op,int64) \ 244 DECL_ASN_OP_T(op,uint64) \ 245 DECL_ASN_OP_T(op,const sc_int_base&) \ 246 DECL_ASN_OP_T(op,const sc_uint_base&) \ 247 DECL_ASN_OP_T(op,const sc_signed&) \ 248 DECL_ASN_OP_T(op,const sc_unsigned&) 249#else 250#define DECL_ASN_OP_OTHER(op) 251#endif 252 253#define DECL_ASN_OP(op) \ 254 DECL_ASN_OP_T(op,int) \ 255 DECL_ASN_OP_T(op,unsigned int) \ 256 DECL_ASN_OP_T(op,long) \ 257 DECL_ASN_OP_T(op,unsigned long) \ 258 DECL_ASN_OP_T(op,float) \ 259 DECL_ASN_OP_T(op,double) \ 260 DECL_ASN_OP_T(op,const char*) \ 261 DECL_ASN_OP_T(op,const sc_fxval&) \ 262 DECL_ASN_OP_T(op,const sc_fxval_fast&) \ 263 DECL_ASN_OP_T(op,const sc_fxnum&) \ 264 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \ 265 DECL_ASN_OP_OTHER(op) 266 267 DECL_ASN_OP(=) 268 269 DECL_ASN_OP(*=) 270 DECL_ASN_OP(/=) 271 DECL_ASN_OP(+=) 272 DECL_ASN_OP(-=) 273 274 DECL_ASN_OP_T(<<=,int) 275 DECL_ASN_OP_T(>>=,int) 276 277 DECL_ASN_OP_T(&=,const sc_fix&) 278 DECL_ASN_OP_T(&=,const sc_fix_fast&) 279 DECL_ASN_OP_T(|=,const sc_fix&) 280 DECL_ASN_OP_T(|=,const sc_fix_fast&) 281 DECL_ASN_OP_T(^=,const sc_fix&) 282 DECL_ASN_OP_T(^=,const sc_fix_fast&) 283 284#undef DECL_ASN_OP_T 285#undef DECL_ASN_OP_OTHER 286#undef DECL_ASN_OP 287 288 289 // auto-increment and auto-decrement 290 291 const sc_fxval operator ++ ( int ); 292 const sc_fxval operator -- ( int ); 293 294 sc_fix& operator ++ (); 295 sc_fix& operator -- (); 296 297}; 298 299 300// ---------------------------------------------------------------------------- 301// CLASS : sc_fix_fast 302// 303// "Unconstrained" signed fixed-point class; limited precision. 304// ---------------------------------------------------------------------------- 305 306class sc_fix_fast : public sc_fxnum_fast 307{ 308 309public: 310 311 // constructors 312 313 explicit sc_fix_fast( sc_fxnum_fast_observer* = 0 ); 314 sc_fix_fast( int, int, 315 sc_fxnum_fast_observer* = 0 ); 316 sc_fix_fast( sc_q_mode, sc_o_mode, 317 sc_fxnum_fast_observer* = 0 ); 318 sc_fix_fast( sc_q_mode, sc_o_mode, int, 319 sc_fxnum_fast_observer* = 0 ); 320 sc_fix_fast( int, int, sc_q_mode, sc_o_mode, 321 sc_fxnum_fast_observer* = 0 ); 322 sc_fix_fast( int, int, sc_q_mode, sc_o_mode, int, 323 sc_fxnum_fast_observer* = 0 ); 324 explicit sc_fix_fast( const sc_fxcast_switch&, 325 sc_fxnum_fast_observer* = 0 ); 326 sc_fix_fast( int, int, 327 const sc_fxcast_switch&, 328 sc_fxnum_fast_observer* = 0 ); 329 sc_fix_fast( sc_q_mode, sc_o_mode, 330 const sc_fxcast_switch&, 331 sc_fxnum_fast_observer* = 0 ); 332 sc_fix_fast( sc_q_mode, sc_o_mode, int, 333 const sc_fxcast_switch&, 334 sc_fxnum_fast_observer* = 0 ); 335 sc_fix_fast( int, int, sc_q_mode, sc_o_mode, 336 const sc_fxcast_switch&, 337 sc_fxnum_fast_observer* = 0 ); 338 sc_fix_fast( int, int, sc_q_mode, sc_o_mode, int, 339 const sc_fxcast_switch&, 340 sc_fxnum_fast_observer* = 0 ); 341 explicit sc_fix_fast( const sc_fxtype_params&, 342 sc_fxnum_fast_observer* = 0 ); 343 sc_fix_fast( const sc_fxtype_params&, 344 const sc_fxcast_switch&, 345 sc_fxnum_fast_observer* = 0 ); 346 347#define DECL_CTORS_T(tp) \ 348 sc_fix_fast( tp, \ 349 int, int, \ 350 sc_fxnum_fast_observer* = 0 ); \ 351 sc_fix_fast( tp, \ 352 sc_q_mode, sc_o_mode, \ 353 sc_fxnum_fast_observer* = 0 ); \ 354 sc_fix_fast( tp, \ 355 sc_q_mode, sc_o_mode, int, \ 356 sc_fxnum_fast_observer* = 0 ); \ 357 sc_fix_fast( tp, \ 358 int, int, sc_q_mode, sc_o_mode, \ 359 sc_fxnum_fast_observer* = 0 ); \ 360 sc_fix_fast( tp, \ 361 int, int, sc_q_mode, sc_o_mode, int, \ 362 sc_fxnum_fast_observer* = 0 ); \ 363 sc_fix_fast( tp, \ 364 const sc_fxcast_switch&, \ 365 sc_fxnum_fast_observer* = 0 ); \ 366 sc_fix_fast( tp, \ 367 int, int, \ 368 const sc_fxcast_switch&, \ 369 sc_fxnum_fast_observer* = 0 ); \ 370 sc_fix_fast( tp, \ 371 sc_q_mode, sc_o_mode, \ 372 const sc_fxcast_switch&, \ 373 sc_fxnum_fast_observer* = 0 ); \ 374 sc_fix_fast( tp, \ 375 sc_q_mode, sc_o_mode, int, \ 376 const sc_fxcast_switch&, \ 377 sc_fxnum_fast_observer* = 0 ); \ 378 sc_fix_fast( tp, \ 379 int, int, sc_q_mode, sc_o_mode, \ 380 const sc_fxcast_switch&, \ 381 sc_fxnum_fast_observer* = 0 ); \ 382 sc_fix_fast( tp, \ 383 int, int, sc_q_mode, sc_o_mode, int, \ 384 const sc_fxcast_switch&, \ 385 sc_fxnum_fast_observer* = 0 ); \ 386 sc_fix_fast( tp, \ 387 const sc_fxtype_params&, \ 388 sc_fxnum_fast_observer* = 0 ); \ 389 sc_fix_fast( tp, \ 390 const sc_fxtype_params&, \ 391 const sc_fxcast_switch&, \ 392 sc_fxnum_fast_observer* = 0 ); 393 394#define DECL_CTORS_T_A(tp) \ 395 sc_fix_fast( tp, \ 396 sc_fxnum_fast_observer* = 0 ); \ 397 DECL_CTORS_T(tp) 398 399#define DECL_CTORS_T_B(tp) \ 400 explicit sc_fix_fast( tp, \ 401 sc_fxnum_fast_observer* = 0 ); \ 402 DECL_CTORS_T(tp) 403 404 DECL_CTORS_T_A(int) 405 DECL_CTORS_T_A(unsigned int) 406 DECL_CTORS_T_A(long) 407 DECL_CTORS_T_A(unsigned long) 408 DECL_CTORS_T_A(float) 409 DECL_CTORS_T_A(double) 410 DECL_CTORS_T_A(const char*) 411 DECL_CTORS_T_A(const sc_fxval&) 412 DECL_CTORS_T_A(const sc_fxval_fast&) 413 DECL_CTORS_T_A(const sc_fxnum&) 414 DECL_CTORS_T_A(const sc_fxnum_fast&) 415#ifndef SC_FX_EXCLUDE_OTHER 416 DECL_CTORS_T_B(int64) 417 DECL_CTORS_T_B(uint64) 418 DECL_CTORS_T_B(const sc_int_base&) 419 DECL_CTORS_T_B(const sc_uint_base&) 420 DECL_CTORS_T_B(const sc_signed&) 421 DECL_CTORS_T_B(const sc_unsigned&) 422#endif 423 424#undef DECL_CTORS_T 425#undef DECL_CTORS_T_A 426#undef DECL_CTORS_T_B 427 428 // copy constructor 429 430 sc_fix_fast( const sc_fix_fast& ); 431 432 433 // unary bitwise operators 434 435 const sc_fix_fast operator ~ () const; 436 437 438 // unary bitwise functions 439 440 friend void b_not( sc_fix_fast&, const sc_fix_fast& ); 441 442 443 // binary bitwise operators 444 445 friend const sc_fix_fast operator & ( const sc_fix_fast&, 446 const sc_fix_fast& ); 447 friend const sc_fix_fast operator ^ ( const sc_fix_fast&, 448 const sc_fix_fast& ); 449 friend const sc_fix_fast operator | ( const sc_fix_fast&, 450 const sc_fix_fast& ); 451 452 453 // binary bitwise functions 454 455 friend void b_and( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& ); 456 friend void b_or ( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& ); 457 friend void b_xor( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& ); 458 459 460 // assignment operators 461 462 sc_fix_fast& operator = ( const sc_fix_fast& ); 463 464#define DECL_ASN_OP_T(op,tp) \ 465 sc_fix_fast& operator op ( tp ); 466 467#ifndef SC_FX_EXCLUDE_OTHER 468#define DECL_ASN_OP_OTHER(op) \ 469 DECL_ASN_OP_T(op,int64) \ 470 DECL_ASN_OP_T(op,uint64) \ 471 DECL_ASN_OP_T(op,const sc_int_base&) \ 472 DECL_ASN_OP_T(op,const sc_uint_base&) \ 473 DECL_ASN_OP_T(op,const sc_signed&) \ 474 DECL_ASN_OP_T(op,const sc_unsigned&) 475#else 476#define DECL_ASN_OP_OTHER(op) 477#endif 478 479#define DECL_ASN_OP(op) \ 480 DECL_ASN_OP_T(op,int) \ 481 DECL_ASN_OP_T(op,unsigned int) \ 482 DECL_ASN_OP_T(op,long) \ 483 DECL_ASN_OP_T(op,unsigned long) \ 484 DECL_ASN_OP_T(op,float) \ 485 DECL_ASN_OP_T(op,double) \ 486 DECL_ASN_OP_T(op,const char*) \ 487 DECL_ASN_OP_T(op,const sc_fxval&) \ 488 DECL_ASN_OP_T(op,const sc_fxval_fast&) \ 489 DECL_ASN_OP_T(op,const sc_fxnum&) \ 490 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \ 491 DECL_ASN_OP_OTHER(op) 492 493 DECL_ASN_OP(=) 494 495 DECL_ASN_OP(*=) 496 DECL_ASN_OP(/=) 497 DECL_ASN_OP(+=) 498 DECL_ASN_OP(-=) 499 500 DECL_ASN_OP_T(<<=,int) 501 DECL_ASN_OP_T(>>=,int) 502 503 DECL_ASN_OP_T(&=,const sc_fix&) 504 DECL_ASN_OP_T(&=,const sc_fix_fast&) 505 DECL_ASN_OP_T(|=,const sc_fix&) 506 DECL_ASN_OP_T(|=,const sc_fix_fast&) 507 DECL_ASN_OP_T(^=,const sc_fix&) 508 DECL_ASN_OP_T(^=,const sc_fix_fast&) 509 510#undef DECL_ASN_OP_T 511#undef DECL_ASN_OP_OTHER 512#undef DECL_ASN_OP 513 514 515 // auto-increment and auto-decrement 516 517 const sc_fxval_fast operator ++ ( int ); 518 const sc_fxval_fast operator -- ( int ); 519 520 sc_fix_fast& operator ++ (); 521 sc_fix_fast& operator -- (); 522 523}; 524 525 526// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 527 528// ---------------------------------------------------------------------------- 529// CLASS : sc_fix 530// 531// "Unconstrained" signed fixed-point class; arbitrary precision. 532// ---------------------------------------------------------------------------- 533 534// constructors 535 536inline 537sc_fix::sc_fix( sc_fxnum_observer* observer_ ) 538: sc_fxnum( sc_fxtype_params(), 539 SC_TC_, 540 sc_fxcast_switch(), 541 observer_ ) 542{} 543 544inline 545sc_fix::sc_fix( int wl_, int iwl_, 546 sc_fxnum_observer* observer_ ) 547: sc_fxnum( sc_fxtype_params( wl_, iwl_ ), 548 SC_TC_, 549 sc_fxcast_switch(), 550 observer_ ) 551{} 552 553inline 554sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, 555 sc_fxnum_observer* observer_ ) 556: sc_fxnum( sc_fxtype_params( qm, om ), 557 SC_TC_, 558 sc_fxcast_switch(), 559 observer_ ) 560{} 561 562inline 563sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, int nb, 564 sc_fxnum_observer* observer_ ) 565: sc_fxnum( sc_fxtype_params( qm, om, nb ), 566 SC_TC_, 567 sc_fxcast_switch(), 568 observer_ ) 569{} 570 571inline 572sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, 573 sc_fxnum_observer* observer_ ) 574: sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ), 575 SC_TC_, 576 sc_fxcast_switch(), 577 observer_ ) 578{} 579 580inline 581sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, 582 sc_fxnum_observer* observer_ ) 583: sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ), 584 SC_TC_, 585 sc_fxcast_switch(), 586 observer_ ) 587{} 588 589inline 590sc_fix::sc_fix( const sc_fxcast_switch& cast_sw, 591 sc_fxnum_observer* observer_ ) 592: sc_fxnum( sc_fxtype_params(), 593 SC_TC_, 594 cast_sw, 595 observer_ ) 596{} 597 598inline 599sc_fix::sc_fix( int wl_, int iwl_, 600 const sc_fxcast_switch& cast_sw, 601 sc_fxnum_observer* observer_ ) 602: sc_fxnum( sc_fxtype_params( wl_, iwl_ ), 603 SC_TC_, 604 cast_sw, 605 observer_ ) 606{} 607 608inline 609sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, 610 const sc_fxcast_switch& cast_sw, 611 sc_fxnum_observer* observer_ ) 612: sc_fxnum( sc_fxtype_params( qm, om ), 613 SC_TC_, 614 cast_sw, 615 observer_ ) 616{} 617 618inline 619sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, int nb, 620 const sc_fxcast_switch& cast_sw, 621 sc_fxnum_observer* observer_ ) 622: sc_fxnum( sc_fxtype_params( qm, om, nb ), 623 SC_TC_, 624 cast_sw, 625 observer_ ) 626{} 627 628inline 629sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, 630 const sc_fxcast_switch& cast_sw, 631 sc_fxnum_observer* observer_ ) 632: sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ), 633 SC_TC_, 634 cast_sw, 635 observer_ ) 636{} 637 638inline 639sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, 640 const sc_fxcast_switch& cast_sw, 641 sc_fxnum_observer* observer_ ) 642: sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ), 643 SC_TC_, 644 cast_sw, 645 observer_ ) 646{} 647 648inline 649sc_fix::sc_fix( const sc_fxtype_params& type_params, 650 sc_fxnum_observer* observer_ ) 651: sc_fxnum( type_params, 652 SC_TC_, 653 sc_fxcast_switch(), 654 observer_ ) 655{} 656 657inline 658sc_fix::sc_fix( const sc_fxtype_params& type_params, 659 const sc_fxcast_switch& cast_sw, 660 sc_fxnum_observer* observer_ ) 661: sc_fxnum( type_params, 662 SC_TC_, 663 cast_sw, 664 observer_ ) 665{} 666 667#define DEFN_CTORS_T_A(tp) \ 668inline \ 669sc_fix::sc_fix( tp a, \ 670 sc_fxnum_observer* observer_ ) \ 671: sc_fxnum( a, \ 672 sc_fxtype_params(), \ 673 SC_TC_, \ 674 sc_fxcast_switch(), \ 675 observer_ ) \ 676{} \ 677 \ 678inline \ 679sc_fix::sc_fix( tp a, \ 680 int wl_, int iwl_, \ 681 sc_fxnum_observer* observer_ ) \ 682: sc_fxnum( a, \ 683 sc_fxtype_params( wl_, iwl_ ), \ 684 SC_TC_, \ 685 sc_fxcast_switch(), \ 686 observer_ ) \ 687{} \ 688 \ 689inline \ 690sc_fix::sc_fix( tp a, \ 691 sc_q_mode qm, sc_o_mode om, \ 692 sc_fxnum_observer* observer_ ) \ 693: sc_fxnum( a, \ 694 sc_fxtype_params( qm, om ), \ 695 SC_TC_, \ 696 sc_fxcast_switch(), \ 697 observer_ ) \ 698{} \ 699 \ 700inline \ 701sc_fix::sc_fix( tp a, \ 702 sc_q_mode qm, sc_o_mode om, int nb, \ 703 sc_fxnum_observer* observer_ ) \ 704: sc_fxnum( a, \ 705 sc_fxtype_params( qm, om, nb ), \ 706 SC_TC_, \ 707 sc_fxcast_switch(), \ 708 observer_ ) \ 709{} \ 710 \ 711inline \ 712sc_fix::sc_fix( tp a, \ 713 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 714 sc_fxnum_observer* observer_ ) \ 715: sc_fxnum( a, \ 716 sc_fxtype_params( wl_, iwl_, qm, om ), \ 717 SC_TC_, \ 718 sc_fxcast_switch(), \ 719 observer_ ) \ 720{} \ 721 \ 722inline \ 723sc_fix::sc_fix( tp a, \ 724 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \ 725 sc_fxnum_observer* observer_ ) \ 726: sc_fxnum( a, \ 727 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 728 SC_TC_, \ 729 sc_fxcast_switch(), \ 730 observer_ ) \ 731{} \ 732 \ 733inline \ 734sc_fix::sc_fix( tp a, \ 735 const sc_fxcast_switch& cast_sw, \ 736 sc_fxnum_observer* observer_ ) \ 737: sc_fxnum( a, \ 738 sc_fxtype_params(), \ 739 SC_TC_, \ 740 cast_sw, \ 741 observer_ ) \ 742{} \ 743 \ 744inline \ 745sc_fix::sc_fix( tp a, \ 746 int wl_, int iwl_, \ 747 const sc_fxcast_switch& cast_sw, \ 748 sc_fxnum_observer* observer_ ) \ 749: sc_fxnum( a, \ 750 sc_fxtype_params( wl_, iwl_ ), \ 751 SC_TC_, \ 752 cast_sw, \ 753 observer_ ) \ 754{} \ 755 \ 756inline \ 757sc_fix::sc_fix( tp a, \ 758 sc_q_mode qm, sc_o_mode om, \ 759 const sc_fxcast_switch& cast_sw, \ 760 sc_fxnum_observer* observer_ ) \ 761: sc_fxnum( a, \ 762 sc_fxtype_params( qm, om ), \ 763 SC_TC_, \ 764 cast_sw, \ 765 observer_ ) \ 766{} \ 767 \ 768inline \ 769sc_fix::sc_fix( tp a, \ 770 sc_q_mode qm, sc_o_mode om, int nb, \ 771 const sc_fxcast_switch& cast_sw, \ 772 sc_fxnum_observer* observer_ ) \ 773: sc_fxnum( a, \ 774 sc_fxtype_params( qm, om, nb ), \ 775 SC_TC_, \ 776 cast_sw, \ 777 observer_ ) \ 778{} \ 779 \ 780inline \ 781sc_fix::sc_fix( tp a, \ 782 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 783 const sc_fxcast_switch& cast_sw, \ 784 sc_fxnum_observer* observer_ ) \ 785: sc_fxnum( a, \ 786 sc_fxtype_params( wl_, iwl_, qm, om ), \ 787 SC_TC_, \ 788 cast_sw, \ 789 observer_ ) \ 790{} \ 791 \ 792inline \ 793sc_fix::sc_fix( tp a, \ 794 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \ 795 const sc_fxcast_switch& cast_sw, \ 796 sc_fxnum_observer* observer_ ) \ 797: sc_fxnum( a, \ 798 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 799 SC_TC_, \ 800 cast_sw, \ 801 observer_ ) \ 802{} \ 803 \ 804inline \ 805sc_fix::sc_fix( tp a, \ 806 const sc_fxtype_params& type_params, \ 807 sc_fxnum_observer* observer_ ) \ 808: sc_fxnum( a, \ 809 type_params, \ 810 SC_TC_, \ 811 sc_fxcast_switch(), \ 812 observer_ ) \ 813{} \ 814 \ 815inline \ 816sc_fix::sc_fix( tp a, \ 817 const sc_fxtype_params& type_params, \ 818 const sc_fxcast_switch& cast_sw, \ 819 sc_fxnum_observer* observer_ ) \ 820: sc_fxnum( a, \ 821 type_params, \ 822 SC_TC_, \ 823 cast_sw, \ 824 observer_ ) \ 825{} 826 827#define DEFN_CTORS_T_B(tp) \ 828inline \ 829sc_fix::sc_fix( tp a, \ 830 sc_fxnum_observer* observer_ ) \ 831: sc_fxnum( a, \ 832 a.type_params(), \ 833 SC_TC_, \ 834 sc_fxcast_switch(), \ 835 observer_ ) \ 836{} \ 837 \ 838inline \ 839sc_fix::sc_fix( tp a, \ 840 int wl_, int iwl_, \ 841 sc_fxnum_observer* observer_ ) \ 842: sc_fxnum( a, \ 843 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \ 844 SC_TC_, \ 845 sc_fxcast_switch(), \ 846 observer_ ) \ 847{} \ 848 \ 849inline \ 850sc_fix::sc_fix( tp a, \ 851 sc_q_mode qm, sc_o_mode om, \ 852 sc_fxnum_observer* observer_ ) \ 853: sc_fxnum( a, \ 854 sc_fxtype_params( a.type_params(), qm, om ), \ 855 SC_TC_, \ 856 sc_fxcast_switch(), \ 857 observer_ ) \ 858{} \ 859 \ 860inline \ 861sc_fix::sc_fix( tp a, \ 862 sc_q_mode qm, sc_o_mode om, int nb, \ 863 sc_fxnum_observer* observer_ ) \ 864: sc_fxnum( a, \ 865 sc_fxtype_params( a.type_params(), qm, om, nb ), \ 866 SC_TC_, \ 867 sc_fxcast_switch(), \ 868 observer_ ) \ 869{} \ 870 \ 871inline \ 872sc_fix::sc_fix( tp a, \ 873 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 874 sc_fxnum_observer* observer_ ) \ 875: sc_fxnum( a, \ 876 sc_fxtype_params( wl_, iwl_, qm, om ), \ 877 SC_TC_, \ 878 sc_fxcast_switch(), \ 879 observer_ ) \ 880{} \ 881 \ 882inline \ 883sc_fix::sc_fix( tp a, \ 884 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \ 885 sc_fxnum_observer* observer_ ) \ 886: sc_fxnum( a, \ 887 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 888 SC_TC_, \ 889 sc_fxcast_switch(), \ 890 observer_ ) \ 891{} \ 892 \ 893inline \ 894sc_fix::sc_fix( tp a, \ 895 const sc_fxcast_switch& cast_sw, \ 896 sc_fxnum_observer* observer_ ) \ 897: sc_fxnum( a, \ 898 a.type_params(), \ 899 SC_TC_, \ 900 cast_sw, \ 901 observer_ ) \ 902{} \ 903 \ 904inline \ 905sc_fix::sc_fix( tp a, \ 906 int wl_, int iwl_, \ 907 const sc_fxcast_switch& cast_sw, \ 908 sc_fxnum_observer* observer_ ) \ 909: sc_fxnum( a, \ 910 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \ 911 SC_TC_, \ 912 cast_sw, \ 913 observer_ ) \ 914{} \ 915 \ 916inline \ 917sc_fix::sc_fix( tp a, \ 918 sc_q_mode qm, sc_o_mode om, \ 919 const sc_fxcast_switch& cast_sw, \ 920 sc_fxnum_observer* observer_ ) \ 921: sc_fxnum( a, \ 922 sc_fxtype_params( a.type_params(), qm, om ), \ 923 SC_TC_, \ 924 cast_sw, \ 925 observer_ ) \ 926{} \ 927 \ 928inline \ 929sc_fix::sc_fix( tp a, \ 930 sc_q_mode qm, sc_o_mode om, int nb, \ 931 const sc_fxcast_switch& cast_sw, \ 932 sc_fxnum_observer* observer_ ) \ 933: sc_fxnum( a, \ 934 sc_fxtype_params( a.type_params(), qm, om, nb ), \ 935 SC_TC_, \ 936 cast_sw, \ 937 observer_ ) \ 938{} \ 939 \ 940inline \ 941sc_fix::sc_fix( tp a, \ 942 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 943 const sc_fxcast_switch& cast_sw, \ 944 sc_fxnum_observer* observer_ ) \ 945: sc_fxnum( a, \ 946 sc_fxtype_params( wl_, iwl_, qm, om ), \ 947 SC_TC_, \ 948 cast_sw, \ 949 observer_ ) \ 950{} \ 951 \ 952inline \ 953sc_fix::sc_fix( tp a, \ 954 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \ 955 const sc_fxcast_switch& cast_sw, \ 956 sc_fxnum_observer* observer_ ) \ 957: sc_fxnum( a, \ 958 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 959 SC_TC_, \ 960 cast_sw, \ 961 observer_ ) \ 962{} \ 963 \ 964inline \ 965sc_fix::sc_fix( tp a, \ 966 const sc_fxtype_params& type_params, \ 967 sc_fxnum_observer* observer_ ) \ 968: sc_fxnum( a, \ 969 type_params, \ 970 SC_TC_, \ 971 sc_fxcast_switch(), \ 972 observer_ ) \ 973{} \ 974 \ 975inline \ 976sc_fix::sc_fix( tp a, \ 977 const sc_fxtype_params& type_params, \ 978 const sc_fxcast_switch& cast_sw, \ 979 sc_fxnum_observer* observer_ ) \ 980: sc_fxnum( a, \ 981 type_params, \ 982 SC_TC_, \ 983 cast_sw, \ 984 observer_ ) \ 985{} 986 987DEFN_CTORS_T_A(int) 988DEFN_CTORS_T_A(unsigned int) 989DEFN_CTORS_T_A(long) 990DEFN_CTORS_T_A(unsigned long) 991DEFN_CTORS_T_A(float) 992DEFN_CTORS_T_A(double) 993DEFN_CTORS_T_A(const char*) 994DEFN_CTORS_T_A(const sc_fxval&) 995DEFN_CTORS_T_A(const sc_fxval_fast&) 996DEFN_CTORS_T_B(const sc_fxnum&) 997DEFN_CTORS_T_B(const sc_fxnum_fast&) 998#ifndef SC_FX_EXCLUDE_OTHER 999DEFN_CTORS_T_A(int64) 1000DEFN_CTORS_T_A(uint64) 1001DEFN_CTORS_T_A(const sc_int_base&) 1002DEFN_CTORS_T_A(const sc_uint_base&) 1003DEFN_CTORS_T_A(const sc_signed&) 1004DEFN_CTORS_T_A(const sc_unsigned&) 1005#endif 1006 1007#undef DEFN_CTORS_T_A 1008#undef DEFN_CTORS_T_B 1009 1010// copy constructor 1011 1012inline 1013sc_fix::sc_fix( const sc_fix& a ) 1014: sc_fxnum( a, 1015 a.type_params(), 1016 SC_TC_, 1017 sc_fxcast_switch(), 1018 0 ) 1019{} 1020 1021 1022// unary bitwise operators 1023 1024inline 1025const sc_fix 1026sc_fix::operator ~ () const 1027{ 1028 SC_FXNUM_OBSERVER_READ_( *this ) 1029 int iwl_c = iwl(); 1030 int wl_c = wl(); 1031 sc_fix c( wl_c, iwl_c ); 1032 for( int i = iwl_c - wl_c; i < iwl_c; ++ i ) 1033 c.set_bit( i, ! get_bit( i ) ); 1034 return sc_fix( c, wl_c, iwl_c ); 1035} 1036 1037 1038// unary bitwise functions 1039 1040inline 1041void 1042b_not( sc_fix& c, const sc_fix& a ) 1043{ 1044 SC_FXNUM_OBSERVER_READ_( a ) 1045 int iwl_c = c.iwl(); 1046 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) 1047 c.set_bit( i, ! a.get_bit( i ) ); 1048 c.cast(); 1049 SC_FXNUM_OBSERVER_WRITE_( c ) 1050} 1051 1052 1053// binary bitwise operators 1054 1055#define DEFN_BIN_OP_T(op,op2,tp1,tp2) \ 1056inline \ 1057const sc_fix \ 1058operator op ( const tp1& a, const tp2& b ) \ 1059{ \ 1060 a.observer_read(); \ 1061 b.observer_read(); \ 1062 int iwl_a = a.iwl(); \ 1063 int iwl_b = b.iwl(); \ 1064 int iwl_c = sc_max( iwl_a, iwl_b ); \ 1065 int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b ); \ 1066 sc_fix c( iwl_c + fwl_c, iwl_c ); \ 1067 for( int i = -fwl_c; i < iwl_c; ++ i ) \ 1068 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \ 1069 return sc_fix( c, iwl_c + fwl_c, iwl_c ); \ 1070} 1071 1072DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix) 1073DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix_fast) 1074DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix) 1075 1076DEFN_BIN_OP_T(|,||,sc_fix,sc_fix) 1077DEFN_BIN_OP_T(|,||,sc_fix,sc_fix_fast) 1078DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix) 1079 1080DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix) 1081DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix_fast) 1082DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix) 1083 1084#undef DEFN_BIN_OP_T 1085 1086 1087// binary bitwise functions 1088 1089#define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2) \ 1090inline \ 1091void \ 1092fnc ( sc_fix& c, const tp1& a, const tp2& b ) \ 1093{ \ 1094 a.observer_read(); \ 1095 b.observer_read(); \ 1096 int iwl_c = c.iwl(); \ 1097 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) \ 1098 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \ 1099 c.cast(); \ 1100 SC_FXNUM_OBSERVER_WRITE_( c ) \ 1101} 1102 1103DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix) 1104DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix_fast) 1105DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix) 1106 1107DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix) 1108DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix_fast) 1109DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix) 1110 1111DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix) 1112DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix_fast) 1113DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix) 1114 1115#undef DEFN_BIN_FNC_T 1116 1117 1118// assignment operators 1119 1120inline 1121sc_fix& 1122sc_fix::operator = ( const sc_fix& a ) 1123{ 1124 sc_fxnum::operator = ( a ); 1125 return *this; 1126} 1127 1128#define DEFN_ASN_OP_T(op,tp) \ 1129inline \ 1130sc_fix& \ 1131sc_fix::operator op ( tp a ) \ 1132{ \ 1133 sc_fxnum::operator op( a ); \ 1134 return *this; \ 1135} 1136 1137#ifndef SC_FX_EXCLUDE_OTHER 1138#define DEFN_ASN_OP_OTHER(op) \ 1139DEFN_ASN_OP_T(op,int64) \ 1140DEFN_ASN_OP_T(op,uint64) \ 1141DEFN_ASN_OP_T(op,const sc_int_base&) \ 1142DEFN_ASN_OP_T(op,const sc_uint_base&) \ 1143DEFN_ASN_OP_T(op,const sc_signed&) \ 1144DEFN_ASN_OP_T(op,const sc_unsigned&) 1145#else 1146#define DEFN_ASN_OP_OTHER(op) 1147#endif 1148 1149#define DEFN_ASN_OP(op) \ 1150DEFN_ASN_OP_T(op,int) \ 1151DEFN_ASN_OP_T(op,unsigned int) \ 1152DEFN_ASN_OP_T(op,long) \ 1153DEFN_ASN_OP_T(op,unsigned long) \ 1154DEFN_ASN_OP_T(op,float) \ 1155DEFN_ASN_OP_T(op,double) \ 1156DEFN_ASN_OP_T(op,const char*) \ 1157DEFN_ASN_OP_T(op,const sc_fxval&) \ 1158DEFN_ASN_OP_T(op,const sc_fxval_fast&) \ 1159DEFN_ASN_OP_T(op,const sc_fxnum&) \ 1160DEFN_ASN_OP_T(op,const sc_fxnum_fast&) \ 1161DEFN_ASN_OP_OTHER(op) 1162 1163DEFN_ASN_OP(=) 1164 1165DEFN_ASN_OP(*=) 1166DEFN_ASN_OP(/=) 1167DEFN_ASN_OP(+=) 1168DEFN_ASN_OP(-=) 1169 1170DEFN_ASN_OP_T(<<=,int) 1171DEFN_ASN_OP_T(>>=,int) 1172 1173#undef DEFN_ASN_OP_T 1174#undef DEFN_ASN_OP_OTHER 1175#undef DEFN_ASN_OP 1176 1177 1178#define DEFN_ASN_OP_T(op,op2,tp) \ 1179inline \ 1180sc_fix& \ 1181sc_fix::operator op ( const tp& b ) \ 1182{ \ 1183 SC_FXNUM_OBSERVER_READ_( *this ) \ 1184 b.observer_read(); \ 1185 int iwl_c = iwl(); \ 1186 for( int i = iwl_c - wl(); i < iwl_c; ++ i ) \ 1187 set_bit( i, get_bit( i ) op2 b.get_bit( i ) ); \ 1188 cast(); \ 1189 SC_FXNUM_OBSERVER_WRITE_( *this ) \ 1190 return *this; \ 1191} 1192 1193DEFN_ASN_OP_T(&=,&&,sc_fix) 1194DEFN_ASN_OP_T(&=,&&,sc_fix_fast) 1195DEFN_ASN_OP_T(|=,||,sc_fix) 1196DEFN_ASN_OP_T(|=,||,sc_fix_fast) 1197DEFN_ASN_OP_T(^=,!=,sc_fix) 1198DEFN_ASN_OP_T(^=,!=,sc_fix_fast) 1199 1200#undef DEFN_ASN_OP_T 1201 1202 1203// auto-increment and auto-decrement 1204 1205inline 1206const sc_fxval 1207sc_fix::operator ++ ( int ) 1208{ 1209 return sc_fxval( sc_fxnum::operator ++ ( 0 ) ); 1210} 1211 1212inline 1213const sc_fxval 1214sc_fix::operator -- ( int ) 1215{ 1216 return sc_fxval( sc_fxnum::operator -- ( 0 ) ); 1217} 1218 1219inline 1220sc_fix& 1221sc_fix::operator ++ () 1222{ 1223 sc_fxnum::operator ++ (); 1224 return *this; 1225} 1226 1227inline 1228sc_fix& 1229sc_fix::operator -- () 1230{ 1231 sc_fxnum::operator -- (); 1232 return *this; 1233} 1234 1235 1236// ---------------------------------------------------------------------------- 1237// CLASS : sc_fix_fast 1238// 1239// "Unconstrained" signed fixed-point class; limited precision. 1240// ---------------------------------------------------------------------------- 1241 1242// constructors 1243 1244inline 1245sc_fix_fast::sc_fix_fast( sc_fxnum_fast_observer* observer_ ) 1246: sc_fxnum_fast( sc_fxtype_params(), 1247 SC_TC_, 1248 sc_fxcast_switch(), 1249 observer_ ) 1250{} 1251 1252inline 1253sc_fix_fast::sc_fix_fast( int wl_, int iwl_, 1254 sc_fxnum_fast_observer* observer_ ) 1255: sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ), 1256 SC_TC_, 1257 sc_fxcast_switch(), 1258 observer_ ) 1259{} 1260 1261inline 1262sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, 1263 sc_fxnum_fast_observer* observer_ ) 1264: sc_fxnum_fast( sc_fxtype_params( qm, om ), 1265 SC_TC_, 1266 sc_fxcast_switch(), 1267 observer_ ) 1268{} 1269 1270inline 1271sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, int nb, 1272 sc_fxnum_fast_observer* observer_ ) 1273: sc_fxnum_fast( sc_fxtype_params( qm, om, nb ), 1274 SC_TC_, 1275 sc_fxcast_switch(), 1276 observer_ ) 1277{} 1278 1279inline 1280sc_fix_fast::sc_fix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, 1281 sc_fxnum_fast_observer* observer_ ) 1282: sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ), 1283 SC_TC_, 1284 sc_fxcast_switch(), 1285 observer_ ) 1286{} 1287 1288inline 1289sc_fix_fast::sc_fix_fast( int wl_, int iwl_, 1290 sc_q_mode qm, sc_o_mode om, int nb, 1291 sc_fxnum_fast_observer* observer_ ) 1292: sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ), 1293 SC_TC_, 1294 sc_fxcast_switch(), 1295 observer_ ) 1296{} 1297 1298inline 1299sc_fix_fast::sc_fix_fast( const sc_fxcast_switch& cast_sw, 1300 sc_fxnum_fast_observer* observer_ ) 1301: sc_fxnum_fast( sc_fxtype_params(), 1302 SC_TC_, 1303 cast_sw, 1304 observer_ ) 1305{} 1306 1307inline 1308sc_fix_fast::sc_fix_fast( int wl_, int iwl_, 1309 const sc_fxcast_switch& cast_sw, 1310 sc_fxnum_fast_observer* observer_ ) 1311: sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ), 1312 SC_TC_, 1313 cast_sw, 1314 observer_ ) 1315{} 1316 1317inline 1318sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, 1319 const sc_fxcast_switch& cast_sw, 1320 sc_fxnum_fast_observer* observer_ ) 1321: sc_fxnum_fast( sc_fxtype_params( qm, om ), 1322 SC_TC_, 1323 cast_sw, 1324 observer_ ) 1325{} 1326 1327inline 1328sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, int nb, 1329 const sc_fxcast_switch& cast_sw, 1330 sc_fxnum_fast_observer* observer_ ) 1331: sc_fxnum_fast( sc_fxtype_params( qm, om, nb ), 1332 SC_TC_, 1333 cast_sw, 1334 observer_ ) 1335{} 1336 1337inline 1338sc_fix_fast::sc_fix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, 1339 const sc_fxcast_switch& cast_sw, 1340 sc_fxnum_fast_observer* observer_ ) 1341: sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ), 1342 SC_TC_, 1343 cast_sw, 1344 observer_ ) 1345{} 1346 1347inline 1348sc_fix_fast::sc_fix_fast( int wl_, int iwl_, 1349 sc_q_mode qm, sc_o_mode om, int nb, 1350 const sc_fxcast_switch& cast_sw, 1351 sc_fxnum_fast_observer* observer_ ) 1352: sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ), 1353 SC_TC_, 1354 cast_sw, 1355 observer_ ) 1356{} 1357 1358inline 1359sc_fix_fast::sc_fix_fast( const sc_fxtype_params& type_params, 1360 sc_fxnum_fast_observer* observer_ ) 1361: sc_fxnum_fast( type_params, 1362 SC_TC_, 1363 sc_fxcast_switch(), 1364 observer_ ) 1365{} 1366 1367inline 1368sc_fix_fast::sc_fix_fast( const sc_fxtype_params& type_params, 1369 const sc_fxcast_switch& cast_sw, 1370 sc_fxnum_fast_observer* observer_ ) 1371: sc_fxnum_fast( type_params, 1372 SC_TC_, 1373 cast_sw, 1374 observer_ ) 1375{} 1376 1377#define DEFN_CTORS_T_A(tp) \ 1378inline \ 1379sc_fix_fast::sc_fix_fast( tp a, \ 1380 sc_fxnum_fast_observer* observer_ ) \ 1381: sc_fxnum_fast( a, \ 1382 sc_fxtype_params(), \ 1383 SC_TC_, \ 1384 sc_fxcast_switch(), \ 1385 observer_ ) \ 1386{} \ 1387 \ 1388inline \ 1389sc_fix_fast::sc_fix_fast( tp a, \ 1390 int wl_, int iwl_, \ 1391 sc_fxnum_fast_observer* observer_ ) \ 1392: sc_fxnum_fast( a, \ 1393 sc_fxtype_params( wl_, iwl_ ), \ 1394 SC_TC_, \ 1395 sc_fxcast_switch(), \ 1396 observer_ ) \ 1397{} \ 1398 \ 1399inline \ 1400sc_fix_fast::sc_fix_fast( tp a, \ 1401 sc_q_mode qm, sc_o_mode om, \ 1402 sc_fxnum_fast_observer* observer_ ) \ 1403: sc_fxnum_fast( a, \ 1404 sc_fxtype_params( qm, om ), \ 1405 SC_TC_, \ 1406 sc_fxcast_switch(), \ 1407 observer_ ) \ 1408{} \ 1409 \ 1410inline \ 1411sc_fix_fast::sc_fix_fast( tp a, \ 1412 sc_q_mode qm, sc_o_mode om, int nb, \ 1413 sc_fxnum_fast_observer* observer_ ) \ 1414: sc_fxnum_fast( a, \ 1415 sc_fxtype_params( qm, om, nb ), \ 1416 SC_TC_, \ 1417 sc_fxcast_switch(), \ 1418 observer_ ) \ 1419{} \ 1420 \ 1421inline \ 1422sc_fix_fast::sc_fix_fast( tp a, \ 1423 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 1424 sc_fxnum_fast_observer* observer_ ) \ 1425: sc_fxnum_fast( a, \ 1426 sc_fxtype_params( wl_, iwl_, qm, om ), \ 1427 SC_TC_, \ 1428 sc_fxcast_switch(), \ 1429 observer_ ) \ 1430{} \ 1431 \ 1432inline \ 1433sc_fix_fast::sc_fix_fast( tp a, \ 1434 int wl_, int iwl_, \ 1435 sc_q_mode qm, sc_o_mode om, int nb, \ 1436 sc_fxnum_fast_observer* observer_ ) \ 1437: sc_fxnum_fast( a, \ 1438 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 1439 SC_TC_, \ 1440 sc_fxcast_switch(), \ 1441 observer_ ) \ 1442{} \ 1443 \ 1444inline \ 1445sc_fix_fast::sc_fix_fast( tp a, \ 1446 const sc_fxcast_switch& cast_sw, \ 1447 sc_fxnum_fast_observer* observer_ ) \ 1448: sc_fxnum_fast( a, \ 1449 sc_fxtype_params(), \ 1450 SC_TC_, \ 1451 cast_sw, \ 1452 observer_ ) \ 1453{} \ 1454 \ 1455inline \ 1456sc_fix_fast::sc_fix_fast( tp a, \ 1457 int wl_, int iwl_, \ 1458 const sc_fxcast_switch& cast_sw, \ 1459 sc_fxnum_fast_observer* observer_ ) \ 1460: sc_fxnum_fast( a, \ 1461 sc_fxtype_params( wl_, iwl_ ), \ 1462 SC_TC_, \ 1463 cast_sw, \ 1464 observer_ ) \ 1465{} \ 1466 \ 1467inline \ 1468sc_fix_fast::sc_fix_fast( tp a, \ 1469 sc_q_mode qm, sc_o_mode om, \ 1470 const sc_fxcast_switch& cast_sw, \ 1471 sc_fxnum_fast_observer* observer_ ) \ 1472: sc_fxnum_fast( a, \ 1473 sc_fxtype_params( qm, om ), \ 1474 SC_TC_, \ 1475 cast_sw, \ 1476 observer_ ) \ 1477{} \ 1478 \ 1479inline \ 1480sc_fix_fast::sc_fix_fast( tp a, \ 1481 sc_q_mode qm, sc_o_mode om, int nb, \ 1482 const sc_fxcast_switch& cast_sw, \ 1483 sc_fxnum_fast_observer* observer_ ) \ 1484: sc_fxnum_fast( a, \ 1485 sc_fxtype_params( qm, om, nb ), \ 1486 SC_TC_, \ 1487 cast_sw, \ 1488 observer_ ) \ 1489{} \ 1490 \ 1491inline \ 1492sc_fix_fast::sc_fix_fast( tp a, \ 1493 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 1494 const sc_fxcast_switch& cast_sw, \ 1495 sc_fxnum_fast_observer* observer_ ) \ 1496: sc_fxnum_fast( a, \ 1497 sc_fxtype_params( wl_, iwl_, qm, om ), \ 1498 SC_TC_, \ 1499 cast_sw, \ 1500 observer_ ) \ 1501{} \ 1502 \ 1503inline \ 1504sc_fix_fast::sc_fix_fast( tp a, \ 1505 int wl_, int iwl_, \ 1506 sc_q_mode qm, sc_o_mode om, int nb, \ 1507 const sc_fxcast_switch& cast_sw, \ 1508 sc_fxnum_fast_observer* observer_ ) \ 1509: sc_fxnum_fast( a, \ 1510 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 1511 SC_TC_, \ 1512 cast_sw, \ 1513 observer_ ) \ 1514{} \ 1515 \ 1516inline \ 1517sc_fix_fast::sc_fix_fast( tp a, \ 1518 const sc_fxtype_params& type_params, \ 1519 sc_fxnum_fast_observer* observer_ ) \ 1520: sc_fxnum_fast( a, \ 1521 type_params, \ 1522 SC_TC_, \ 1523 sc_fxcast_switch(), \ 1524 observer_ ) \ 1525{} \ 1526 \ 1527inline \ 1528sc_fix_fast::sc_fix_fast( tp a, \ 1529 const sc_fxtype_params& type_params, \ 1530 const sc_fxcast_switch& cast_sw, \ 1531 sc_fxnum_fast_observer* observer_ ) \ 1532: sc_fxnum_fast( a, \ 1533 type_params, \ 1534 SC_TC_, \ 1535 cast_sw, \ 1536 observer_ ) \ 1537{} 1538 1539#define DEFN_CTORS_T_B(tp) \ 1540inline \ 1541sc_fix_fast::sc_fix_fast( tp a, \ 1542 sc_fxnum_fast_observer* observer_ ) \ 1543: sc_fxnum_fast( a, \ 1544 a.type_params(), \ 1545 SC_TC_, \ 1546 sc_fxcast_switch(), \ 1547 observer_ ) \ 1548{} \ 1549 \ 1550inline \ 1551sc_fix_fast::sc_fix_fast( tp a, \ 1552 int wl_, int iwl_, \ 1553 sc_fxnum_fast_observer* observer_ ) \ 1554: sc_fxnum_fast( a, \ 1555 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \ 1556 SC_TC_, \ 1557 sc_fxcast_switch(), \ 1558 observer_ ) \ 1559{} \ 1560 \ 1561inline \ 1562sc_fix_fast::sc_fix_fast( tp a, \ 1563 sc_q_mode qm, sc_o_mode om, \ 1564 sc_fxnum_fast_observer* observer_ ) \ 1565: sc_fxnum_fast( a, \ 1566 sc_fxtype_params( a.type_params(), qm, om ), \ 1567 SC_TC_, \ 1568 sc_fxcast_switch(), \ 1569 observer_ ) \ 1570{} \ 1571 \ 1572inline \ 1573sc_fix_fast::sc_fix_fast( tp a, \ 1574 sc_q_mode qm, sc_o_mode om, int nb, \ 1575 sc_fxnum_fast_observer* observer_ ) \ 1576: sc_fxnum_fast( a, \ 1577 sc_fxtype_params( a.type_params(), qm, om, nb ), \ 1578 SC_TC_, \ 1579 sc_fxcast_switch(), \ 1580 observer_ ) \ 1581{} \ 1582 \ 1583inline \ 1584sc_fix_fast::sc_fix_fast( tp a, \ 1585 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 1586 sc_fxnum_fast_observer* observer_ ) \ 1587: sc_fxnum_fast( a, \ 1588 sc_fxtype_params( wl_, iwl_, qm, om ), \ 1589 SC_TC_, \ 1590 sc_fxcast_switch(), \ 1591 observer_ ) \ 1592{} \ 1593 \ 1594inline \ 1595sc_fix_fast::sc_fix_fast( tp a, \ 1596 int wl_, int iwl_, \ 1597 sc_q_mode qm, sc_o_mode om, int nb, \ 1598 sc_fxnum_fast_observer* observer_ ) \ 1599: sc_fxnum_fast( a, \ 1600 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 1601 SC_TC_, \ 1602 sc_fxcast_switch(), \ 1603 observer_ ) \ 1604{} \ 1605 \ 1606inline \ 1607sc_fix_fast::sc_fix_fast( tp a, \ 1608 const sc_fxcast_switch& cast_sw, \ 1609 sc_fxnum_fast_observer* observer_ ) \ 1610: sc_fxnum_fast( a, \ 1611 a.type_params(), \ 1612 SC_TC_, \ 1613 cast_sw, \ 1614 observer_ ) \ 1615{} \ 1616 \ 1617inline \ 1618sc_fix_fast::sc_fix_fast( tp a, \ 1619 int wl_, int iwl_, \ 1620 const sc_fxcast_switch& cast_sw, \ 1621 sc_fxnum_fast_observer* observer_ ) \ 1622: sc_fxnum_fast( a, \ 1623 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \ 1624 SC_TC_, \ 1625 cast_sw, \ 1626 observer_ ) \ 1627{} \ 1628 \ 1629inline \ 1630sc_fix_fast::sc_fix_fast( tp a, \ 1631 sc_q_mode qm, sc_o_mode om, \ 1632 const sc_fxcast_switch& cast_sw, \ 1633 sc_fxnum_fast_observer* observer_ ) \ 1634: sc_fxnum_fast( a, \ 1635 sc_fxtype_params( a.type_params(), qm, om ), \ 1636 SC_TC_, \ 1637 cast_sw, \ 1638 observer_ ) \ 1639{} \ 1640 \ 1641inline \ 1642sc_fix_fast::sc_fix_fast( tp a, \ 1643 sc_q_mode qm, sc_o_mode om, int nb, \ 1644 const sc_fxcast_switch& cast_sw, \ 1645 sc_fxnum_fast_observer* observer_ ) \ 1646: sc_fxnum_fast( a, \ 1647 sc_fxtype_params( a.type_params(), qm, om, nb ), \ 1648 SC_TC_, \ 1649 cast_sw, \ 1650 observer_ ) \ 1651{} \ 1652 \ 1653inline \ 1654sc_fix_fast::sc_fix_fast( tp a, \ 1655 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ 1656 const sc_fxcast_switch& cast_sw, \ 1657 sc_fxnum_fast_observer* observer_ ) \ 1658: sc_fxnum_fast( a, \ 1659 sc_fxtype_params( wl_, iwl_, qm, om ), \ 1660 SC_TC_, \ 1661 cast_sw, \ 1662 observer_ ) \ 1663{} \ 1664 \ 1665inline \ 1666sc_fix_fast::sc_fix_fast( tp a, \ 1667 int wl_, int iwl_, \ 1668 sc_q_mode qm, sc_o_mode om, int nb, \ 1669 const sc_fxcast_switch& cast_sw, \ 1670 sc_fxnum_fast_observer* observer_ ) \ 1671: sc_fxnum_fast( a, \ 1672 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ 1673 SC_TC_, \ 1674 cast_sw, \ 1675 observer_ ) \ 1676{} \ 1677 \ 1678inline \ 1679sc_fix_fast::sc_fix_fast( tp a, \ 1680 const sc_fxtype_params& type_params, \ 1681 sc_fxnum_fast_observer* observer_ ) \ 1682: sc_fxnum_fast( a, \ 1683 type_params, \ 1684 SC_TC_, \ 1685 sc_fxcast_switch(), \ 1686 observer_ ) \ 1687{} \ 1688 \ 1689inline \ 1690sc_fix_fast::sc_fix_fast( tp a, \ 1691 const sc_fxtype_params& type_params, \ 1692 const sc_fxcast_switch& cast_sw, \ 1693 sc_fxnum_fast_observer* observer_ ) \ 1694: sc_fxnum_fast( a, \ 1695 type_params, \ 1696 SC_TC_, \ 1697 cast_sw, \ 1698 observer_ ) \ 1699{} 1700 1701DEFN_CTORS_T_A(int) 1702DEFN_CTORS_T_A(unsigned int) 1703DEFN_CTORS_T_A(long) 1704DEFN_CTORS_T_A(unsigned long) 1705DEFN_CTORS_T_A(float) 1706DEFN_CTORS_T_A(double) 1707DEFN_CTORS_T_A(const char*) 1708DEFN_CTORS_T_A(const sc_fxval&) 1709DEFN_CTORS_T_A(const sc_fxval_fast&) 1710DEFN_CTORS_T_B(const sc_fxnum&) 1711DEFN_CTORS_T_B(const sc_fxnum_fast&) 1712#ifndef SC_FX_EXCLUDE_OTHER 1713DEFN_CTORS_T_A(int64) 1714DEFN_CTORS_T_A(uint64) 1715DEFN_CTORS_T_A(const sc_int_base&) 1716DEFN_CTORS_T_A(const sc_uint_base&) 1717DEFN_CTORS_T_A(const sc_signed&) 1718DEFN_CTORS_T_A(const sc_unsigned&) 1719#endif 1720 1721#undef DEFN_CTORS_T_A 1722#undef DEFN_CTORS_T_B 1723 1724// copy constructor 1725 1726inline 1727sc_fix_fast::sc_fix_fast( const sc_fix_fast& a ) 1728: sc_fxnum_fast( a, 1729 a.type_params(), 1730 SC_TC_, 1731 sc_fxcast_switch(), 1732 0 ) 1733{} 1734 1735 1736// unary bitwise operators 1737 1738inline 1739const sc_fix_fast 1740sc_fix_fast::operator ~ () const 1741{ 1742 SC_FXNUM_FAST_OBSERVER_READ_( *this ) 1743 int iwl_c = iwl(); 1744 int wl_c = wl(); 1745 sc_fix_fast c( wl_c, iwl_c ); 1746 for( int i = iwl_c - wl_c; i < iwl_c; ++ i ) 1747 c.set_bit( i, ! get_bit( i ) ); 1748 return sc_fix_fast( c, wl_c, iwl_c ); 1749} 1750 1751 1752// unary bitwise functions 1753 1754inline 1755void 1756b_not( sc_fix_fast& c, const sc_fix_fast& a ) 1757{ 1758 SC_FXNUM_FAST_OBSERVER_READ_( a ) 1759 int iwl_c = c.iwl(); 1760 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) 1761 c.set_bit( i, ! a.get_bit( i ) ); 1762 c.cast(); 1763 SC_FXNUM_FAST_OBSERVER_WRITE_( c ) 1764} 1765 1766 1767// binary bitwise operators 1768 1769#define DEFN_BIN_OP_T(op,op2,tp1,tp2) \ 1770inline \ 1771const sc_fix_fast \ 1772operator op ( const tp1& a, const tp2& b ) \ 1773{ \ 1774 a.observer_read(); \ 1775 b.observer_read(); \ 1776 int iwl_a = a.iwl(); \ 1777 int iwl_b = b.iwl(); \ 1778 int iwl_c = sc_max( iwl_a, iwl_b ); \ 1779 int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b ); \ 1780 sc_fix_fast c( iwl_c + fwl_c, iwl_c ); \ 1781 for( int i = -fwl_c; i < iwl_c; ++ i ) \ 1782 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \ 1783 return sc_fix_fast( c, iwl_c + fwl_c, iwl_c ); \ 1784} 1785 1786DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix_fast) 1787DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix_fast) 1788DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix_fast) 1789 1790#undef DEFN_BIN_OP_T 1791 1792 1793// binary bitwise functions 1794 1795#define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2) \ 1796inline \ 1797void \ 1798fnc ( sc_fix_fast& c, const tp1& a, const tp2& b ) \ 1799{ \ 1800 a.observer_read(); \ 1801 b.observer_read(); \ 1802 int iwl_c = c.iwl(); \ 1803 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) \ 1804 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \ 1805 c.cast(); \ 1806 SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \ 1807} 1808 1809DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix_fast) 1810DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix_fast) 1811DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix_fast) 1812 1813#undef DEFN_BIN_FNC_T 1814 1815 1816// assignment operators 1817 1818inline 1819sc_fix_fast& 1820sc_fix_fast::operator = ( const sc_fix_fast& a ) 1821{ 1822 sc_fxnum_fast::operator = ( a ); 1823 return *this; 1824} 1825 1826#define DEFN_ASN_OP_T(op,tp) \ 1827inline \ 1828sc_fix_fast& \ 1829sc_fix_fast::operator op ( tp a ) \ 1830{ \ 1831 sc_fxnum_fast::operator op( a ); \ 1832 return *this; \ 1833} 1834 1835#ifndef SC_FX_EXCLUDE_OTHER 1836#define DEFN_ASN_OP_OTHER(op) \ 1837DEFN_ASN_OP_T(op,int64) \ 1838DEFN_ASN_OP_T(op,uint64) \ 1839DEFN_ASN_OP_T(op,const sc_int_base&) \ 1840DEFN_ASN_OP_T(op,const sc_uint_base&) \ 1841DEFN_ASN_OP_T(op,const sc_signed&) \ 1842DEFN_ASN_OP_T(op,const sc_unsigned&) 1843#else 1844#define DEFN_ASN_OP_OTHER(op) 1845#endif 1846 1847#define DEFN_ASN_OP(op) \ 1848DEFN_ASN_OP_T(op,int) \ 1849DEFN_ASN_OP_T(op,unsigned int) \ 1850DEFN_ASN_OP_T(op,long) \ 1851DEFN_ASN_OP_T(op,unsigned long) \ 1852DEFN_ASN_OP_T(op,float) \ 1853DEFN_ASN_OP_T(op,double) \ 1854DEFN_ASN_OP_T(op,const char*) \ 1855DEFN_ASN_OP_T(op,const sc_fxval&) \ 1856DEFN_ASN_OP_T(op,const sc_fxval_fast&) \ 1857DEFN_ASN_OP_T(op,const sc_fxnum&) \ 1858DEFN_ASN_OP_T(op,const sc_fxnum_fast&) \ 1859DEFN_ASN_OP_OTHER(op) 1860 1861DEFN_ASN_OP(=) 1862 1863DEFN_ASN_OP(*=) 1864DEFN_ASN_OP(/=) 1865DEFN_ASN_OP(+=) 1866DEFN_ASN_OP(-=) 1867 1868DEFN_ASN_OP_T(<<=,int) 1869DEFN_ASN_OP_T(>>=,int) 1870 1871#undef DEFN_ASN_OP_T 1872#undef DEFN_ASN_OP_OTHER 1873#undef DEFN_ASN_OP 1874 1875 1876#define DEFN_ASN_OP_T(op,op2,tp) \ 1877inline \ 1878sc_fix_fast& \ 1879sc_fix_fast::operator op ( const tp& b ) \ 1880{ \ 1881 SC_FXNUM_FAST_OBSERVER_READ_( *this ) \ 1882 b.observer_read(); \ 1883 int iwl_c = iwl(); \ 1884 for( int i = iwl_c - wl(); i < iwl_c; ++ i ) \ 1885 set_bit( i, get_bit( i ) op2 b.get_bit( i ) ); \ 1886 cast(); \ 1887 SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \ 1888 return *this; \ 1889} 1890 1891DEFN_ASN_OP_T(&=,&&,sc_fix) 1892DEFN_ASN_OP_T(&=,&&,sc_fix_fast) 1893DEFN_ASN_OP_T(|=,||,sc_fix) 1894DEFN_ASN_OP_T(|=,||,sc_fix_fast) 1895DEFN_ASN_OP_T(^=,!=,sc_fix) 1896DEFN_ASN_OP_T(^=,!=,sc_fix_fast) 1897 1898#undef DEFN_ASN_OP_T 1899 1900 1901// auto-increment and auto-decrement 1902 1903inline 1904const sc_fxval_fast 1905sc_fix_fast::operator ++ ( int ) 1906{ 1907 return sc_fxval_fast( sc_fxnum_fast::operator ++ ( 0 ) ); 1908} 1909 1910inline 1911const sc_fxval_fast 1912sc_fix_fast::operator -- ( int ) 1913{ 1914 return sc_fxval_fast( sc_fxnum_fast::operator -- ( 0 ) ); 1915} 1916 1917inline 1918sc_fix_fast& 1919sc_fix_fast::operator ++ () 1920{ 1921 sc_fxnum_fast::operator ++ (); 1922 return *this; 1923} 1924 1925inline 1926sc_fix_fast& 1927sc_fix_fast::operator -- () 1928{ 1929 sc_fxnum_fast::operator -- (); 1930 return *this; 1931} 1932 1933} // namespace sc_dt 1934 1935 1936#endif 1937 1938// Taf! 1939