RE: [vhdl-200x] [RFC] Rounding functions proposal

From: <ryan.w.hinton@L-3com.com>
Date: Mon May 20 2013 - 07:05:13 PDT
Nikolaos:

I believe the resize function in fixed_pkg already provides the
beginning of the rounding capabilities you describe.  I would rather
expand the fixed_round_style options and then add some or all of the
functions you describe to call resize with the appropriate
fixed_round_style.

The current enumeration handles two of the eight possibilities.  Matlab
doesn't (directly) offer two of the eight.

Floor-like functions
CEIL         -- 
FLOOR        -- fixed_round_style => fixed_truncate
FIX          -- 
toward inf   -- 

Rounding functions
NEAREST      -- 
CONVERGENT   -- fixed_round_style => fixed_round
ROUND        --  
toward zero  -- 

We might as well offer them all.  On the other hand, I implemented
something similar for numeric_std at one point, but I never used
anything besides (convergent) round and truncate.

- Ryan

-----Original Message-----
From: owner-vhdl-200x@eda.org [mailto:owner-vhdl-200x@eda.org] On Behalf
Of nkavvadias
Sent: Monday, May 20, 2013 2:15 AM
To: vhdl-200x@eda.org
Subject: [vhdl-200x] [RFC] Rounding functions proposal

Dear all,

I have a sketch of a proposal regarding additional rounding functions 
for the fixed_pkg revision. It is pasted below.

In case you find this interesting/reasonable, I could setup the 
corresponding TWIKI page in CollectedRequirements (not sure if i have 
write access; i was just exploring the TWIKI platform yesterday).

BTW I have an experimental, reference implementation of the proposed 
functionalities. I have posted the relevant files as an OpenCores 
project here:
http://www.opencores.org/project,fixed_extensions

Feel free to comment on the proposal!


Best regards,
Nikolaos Kavvadias
CEO
Ajax Compilers
Athens, Greece

============================
  RoundingFunctions proposal
============================

.. _NikolaosKavvadias: 
http://www.eda-twiki.org/cgi-bin/view.cgi/Main/NikolaosKavvadias
.. _FixedExtensions: http://www.opencores.org/project,fixed_extensions
.. _DavidBishop: http://www.eda-twiki.org/fphdl/
.. _DASIP2012paper: 
http://www.nkavvadias.com/publications/kavvadias_dasip12.pdf

1. Proposal details
===================

+-------------------+---------------------------------------------------
-------+
| **Title**         | 
RoundingFunctions                                        |
+-------------------+---------------------------------------------------
-------+
| **Description**   | Proposal for fixed-point rounding 
functions              |
+-------------------+---------------------------------------------------
-------+
| **Author**        | Nikolaos Kavvadias 
2013                                  |
+-------------------+---------------------------------------------------
-------+
| **Contact**       | 
nkavvadias@ajaxcompilers.com                             |
+-------------------+---------------------------------------------------
-------+
| **Website**       | 
http://www.ajaxcompilers.com                             |
+-------------------+---------------------------------------------------
-------+
| **Release Date**  | 20 May 
2013                                              |
+-------------------+---------------------------------------------------
-------+
| **Priority** |
|
+-------------------+---------------------------------------------------
-------+
| **Complexity** 
|                                                          |
+-------------------+---------------------------------------------------
-------+
| **Focus** |                                                          |
+-------------------+---------------------------------------------------
-------+
| **Version**       | 
0.0.1                                                    |
+-------------------+---------------------------------------------------
-------+
| **Rev. history** 
|                                                          |
+-------------------+---------------------------------------------------
-------+
|        **v0.0.1** | 
20-05-2013                                               |
| |                                                          |
|                   | First sketch of a proposal; amenable to 
comments.        |
+-------------------+---------------------------------------------------
-------+

1.1 Summary
-----------

Provide explicit implementations of fixed-point rounding functions in 
the same
sense to the ``fix``, ``round``, ``nearest`` and ``convergent`` schemes 
supported
by the MATLAB programming language. Similar schemes are supported by 
essentially
all numerical analysis environments.

1.1 Current Situation
---------------------

The VHDL-2008 introduced a fixed-point arithmetic package named 
``fixed_pkg``.
While this package supports a comprehensive list of operators and 
functions for
utilizing fixed-point arithmetic in VHDL design projects, it does not 
provide
functions for explicitly performing rounding.

In the context of the VHDL-201x revision of the standard, DavidBishop_
has
proposed ``ceil`` and ``round`` functions for the corresponding basic 
forms of
rounding. This proposal argues for the inclusion of further rounding 
schemes,
since the choice of a rounding scheme is often an application-specific 
decision.
Such schemes would be compatible to ``fix``, ``round``, ``nearest`` and
``convergent`` rounding as e.g. implemented by the well-known MATLAB 
numerical
analysis programming language. Other numerical analysis packages offer 
similar
functionalities.

1.2 Requirement
---------------

The proposed functions depend on the existing `fixed_pkg` package. No
other
dependencies are expected. Some of the implementations

Rounding functions are proposed for both the ``ufixed`` and ``sfixed``
data types. Some of these might depend on the ``resize()`` function as
defined in ``fixed_pkg``.

The implementation should be written in portable VHDL adhering the
expected
coding standards imposed by the committee.

1.3 Implementation details
--------------------------

A reference implementation of the additional fixed-point rounding
schemes
can be found here: FixedExtensions_

This distribution includes documentation and a test case generator for
exercising the proposed functions on both unsigned and signed
fixed-point
arithmetic.

1.4 Code Examples
-----------------

The declaration of the ``round`` function would be as follows:

::

   function round (arg : UNRESOLVED_sfixed) return UNRESOLVED_sfixed;
   function round (arg : UNRESOLVED_ufixed) return UNRESOLVED_ufixed;

In end-user code, ``round`` would be invoked as follows:

::

   a_next <= to_ufixed(0.062500, 3, -4);
   y_round_next      <= round(a_next);
   assert false report "y_round_next = "
          & to_bstring(y_round_next) severity note;

2. Related Issues
=================

3. Use Cases
============

Algorithm developers using very high-level programming languages such as

MATLAB in order to
generate low-level design facets such as ANSI C implementation code and 
synthesizable HDL code.

4. Arguments FOR
================

* Provide a link to HDL code generation from numerical analysis 
environments.
* The proposed rounding functions are of general interest and
usefulness.

5. Arguments AGAINST
====================

* We should not overpopulate standard packages.

6. General Comments
===================

A detailed presentation of the proposed fixed-point rounding functions 
can be found
here: DASIP2012paper_

7. Supporters
=============

* -- NikolaosKavvadias_ 2013-05-20


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon May 20 07:05:30 2013

This archive was generated by hypermail 2.1.8 : Mon May 20 2013 - 07:06:05 PDT