Changeset 2213 for trunk/lib


Ignore:
Timestamp:
Jun 5, 2012, 5:30:47 PM (7 years ago)
Author:
cameron
Message:

Use direct CarryArray? implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/carryQ.hpp

    r2207 r2213  
    4040}
    4141
    42 // Abstract Base Class
    43 class ICarryQueue {
    44 
    45         IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_ci_co(BitBlock strm, BitBlock carryin, uint16_t carryno);
    46         IDISA_ALWAYS_INLINE BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, BitBlock carryin, const uint16_t carryno);
    47         IDISA_ALWAYS_INLINE BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, BitBlock carryin, uint16_t carryno);
    48 
    49         IDISA_ALWAYS_INLINE BitBlock BitBlock_scantofirst(BitBlock charclass, BitBlock carryin, uint16_t carryno);
    50         IDISA_ALWAYS_INLINE BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, BitBlock carryin, uint16_t carryno);
    51         IDISA_ALWAYS_INLINE BitBlock BitBlock_advance32_ci_co(BitBlock strm, uint32_t pending_in, uint32_t & pending_out);
    52         template <int n> IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_n_(BitBlock strm, BitBlock pending_in, uint16_t pendingno);
    53 
    54         IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_then_scanthru(BitBlock markers0, BitBlock charclass, BitBlock carryin, uint16_t carryno);
    55         IDISA_ALWAYS_INLINE BitBlock BitBlock_span_upto(BitBlock starts, BitBlock follows, BitBlock carryin, uint16_t carryno);
    56         IDISA_ALWAYS_INLINE BitBlock BitBlock_inclusive_span(BitBlock starts, BitBlock ends, BitBlock carryin, uint16_t carryno);
    57         IDISA_ALWAYS_INLINE BitBlock BitBlock_exclusive_span(BitBlock starts, BitBlock ends, BitBlock carryin, uint16_t carryno);
    58 
    59         IDISA_ALWAYS_INLINE bool CarryTest(uint16_t carryno, uint16_t carry_count);
    60         IDISA_ALWAYS_INLINE void CarryDequeueEnqueue(uint16_t carryno, uint16_t carry_count);
    61         IDISA_ALWAYS_INLINE void CarryQ_Adjust(uint16_t carry_count);
    62         IDISA_ALWAYS_INLINE void CarryCombine(ICarryQueue carryqueue, uint16_t carryno, uint16_t carry_count);
    63 
    64         IDISA_ALWAYS_INLINE BitBlock get_carry_in(uint16_t carryno) const ;
    65 protected:
    66         ICarryQueue(){};
    67         ~ICarryQueue(){};
    68         // helpers
    69         IDISA_ALWAYS_INLINE BitBlock carry_flip(BitBlock carry) const ;
    70         IDISA_ALWAYS_INLINE bool test_carry(BitBlock carry) const ;
    71         IDISA_ALWAYS_INLINE BitBlock carry_or(BitBlock carry1, BitBlock carry2) const ;
    72 };
    7342
    7443#include <string.h>
     
    7645// Array of BitBlock implementation.
    7746template <uint16_t CarryCount, uint16_t AdvanceNCount>
    78 class CarryArray: public ICarryQueue{
     47class CarryArray {
    7948
    8049public:
     
    196165        }
    197166
    198         IDISA_ALWAYS_INLINE void CarryCombine(ICarryQueue * carryqueue, uint16_t carryno, uint16_t carry_count)
    199         {
    200                   BitBlock * local_cq = ((CarryArray *)carryqueue)->cq;
     167        IDISA_ALWAYS_INLINE void CarryCombine(BitBlock local_cq[], uint16_t carryno, uint16_t carry_count)
     168        {
    201169                  for (int i = 0; i < carry_count; i++) {
    202170                    cq[carryno+i] = carry_or(cq[carryno+i], local_cq[i]);
     
    231199};
    232200
    233 // Single bit per carry implementation.
    234 template <class BitBlock, uint16_t CarryCount>
    235 class CarryRegister: public ICarryQueue {
    236 
    237 public:
    238         CarryRegister() {}
    239         ~CarryRegister() {}
    240 
    241 private:
    242         BitBlock cq;
    243 };
    244 
    245201#endif // CARRYQ_HPP_
Note: See TracChangeset for help on using the changeset viewer.