![]() |
|
|
|
#1 |
|
Hello!
David Bishop wrote in this newsgroup a function which implemented a recursive xor function. Please check out http://groups.google.com/groups?hl=p...r.nyroc.rr.com This worked beautifully in Synplify Pro 7.7. I tried extending the idea to do a "Ones counter" using a generic binary adder structure. The synthesis tool implements the function as if it was done in a FOR loop and not recursively. I'm just curious as if somebody can successfully use this function (get a binary adder tree) in another synthesis tool or if there is a better way of doing this. Thanks a lot. BTW, here is the code I adapted from Bishop's code. function ones_count (arg : std_logic_vector ) return integer is variable Upper, Lower : integer range 0 to VEC_SIZE; variable Half : integer range 0 to VEC_SIZE; variable BUS_int : std_logic_vector ( arg'length - 1 downto 0 ); variable Result : integer range 0 to VEC_SIZE; begin if (arg'LENGTH < 1) then -- In the case of a NULL range Result := 0; else BUS_int := to_ux01 (arg); if ( BUS_int'length = 1 ) then Result := conv_integer(BUS_int ( BUS_int'left )); elsif ( BUS_int'length = 2 ) then Result := conv_integer(BUS_int ( BUS_int'right )) + conv_integer(BUS_int ( BUS_int'left)); else Half := ( BUS_int'length + 1 ) / 2 + BUS_int'right; Upper := ones_count ( BUS_int ( BUS_int'left downto Half )); Lower := ones_count ( BUS_int ( Half - 1 downto BUS_int'right)); Result := Upper + Lower; end if; end if; return Result; end; Any ideas to make this work better? Thanks! - Paulo Valentim Paulo Valentim |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VHDL 12 bit BCD counter | dv09 | Hardware | 0 | 10-07-2009 05:57 PM |
| The Counter Strikes... | aihockey44 | Gaming | 0 | 04-29-2009 08:35 PM |
| divide by n counter (with n as variable) | rnpatil | Hardware | 0 | 04-27-2009 12:42 PM |
| VHDL problem - Signal counter cannot be synthesized, bad synchronous description. | shipacpoloy | Software | 0 | 08-14-2007 07:26 AM |
| Resetting The Counter. | Patrick D. Rockwell | DVD Video | 3 | 07-09-2004 10:32 PM |