Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Re: Please review my float package

Reply
Thread Tools

Re: Please review my float package

 
 
Mike Treseler
Guest
Posts: n/a
 
      08-15-2003
Jerker Hammarberg (DST) wrote:

> I put together a generic floating point package that performs addition,
> subtraction, multiplication and comparison. Contrary fphdl
> (www.eda.org/fphdl), it is synthesizable with Xilinx XST - that's why
> I made my own. Anyway, I present it here in the hope that anyone may
> wants to look through it for
> * possible optimizations, particularly for implementation size,
> * language misuse or simplifications,
> * bugs,
> * or actually, any possible improvements.


Consider:

1. A simple testbench with an assertion for each function.
2. numeric_std:

-- use ieee.std_logic_arith.all;
use ieee.numeric_std.all;

m := "01" & shift_left((m(size-3 downto 0))
to_integer(to_unsigned(leftshift,EXPSIZE)));

-- m := "01" & shl(m(size-3 downto 0),
-- conv_unsigned(leftshift, EXPSIZE));

-- rsres := shr(rsarg1, rsarg2);
rsres := shift_right(rsarg1, to_integer(rsarg2));

-- return conv_std_logic_vector(result, TOTALSIZE);
return std_logic_vector(result);


-- return conv_std_logic_vector(result, TOTALSIZE);
return std_logic_vector(result);



-- Mike Treseler

 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      08-15-2003
missed a comma \

m := "01" & shift_left((m(size-3 downto 0)) ,
to_integer(to_unsigned(leftshift,EXPSIZE))) ;

-- Mike Treseler


 
Reply With Quote
 
 
 
 
Tim Hubberstey
Guest
Posts: n/a
 
      08-18-2003
"Jerker Hammarberg (DST)" wrote:
>
> > 2. numeric_std:

>
> This is interesting... what is the difference between numeric_std and
> std_logic_arith? I can see the former is slightly more readable. Is it also
> more efficient?


I don't know for sure about efficiency but I doubt there is any
appreciable difference since efficiency is determined primarily by the
tool, not the package, unless you have optimization turned off.

The most important difference is that numeric_std is an IEEE standard
while std_logic_arith actually has several different (and incompatible)
versions, depending on whose tool you're using. If you want your code to
be portable, use numeric_std.
--
Tim Hubberstey, P.Eng. . . . . . Hardware/Software Consulting Engineer
Marmot Engineering . . . . . . . VHDL, ASICs, FPGAs, embedded systems
Vancouver, BC, Canada . . . . . . . . . . . http://www.marmot-eng.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
operator== (float, float) Jukka Lehtonen C++ 5 08-05-2004 08:28 AM
need code to convert float format to internal java float format which is kept in 4 bytes integer Andy Java 7 05-10-2004 09:26 PM
static_cast<float>(a) versus float(a) Jim West C++ 4 01-16-2004 12:36 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57