----- Original Message ----- From: Daniel Serpell To: Sent: Thursday, June 26, 2003 4:33 PM Subject: Re: [PIC]: 8-byte vertical adder? > On Thu, Jun 26, 2003 at 05:43:23AM +0100, Sergio Masci wrote: > > If I understand correctly you are clocking in all bit 7's followed by all bit > > 6's down to all bit 0's > > > > Try the following: > > > > acc = 0 > > > > for (int j=0; j<8; j++) > > { acc = (acc << 1) + count_one_bits(read_port()) > > } > > > > count_one_bits() could be implemented as a lookup table > > It's more efficient to do directly. Each loop iteration can be > done in 15 cycles, if you unroll it and add the "acc=0" at the > begining, you get 15*8+1 = 121 cycles (and 121 program words). > > Seems that it's the faster version. > > Daniel. Assuming that this is actually giving you what you want and that acc is 16 bits, the first 3 iterations of the loop can be perfomed on 8 bit acc and the remainder on 16 bit acc. Also your lookup table will require 256 entries Regards Sergio Masci -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads