diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3f0ed21
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+docs/_build/
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..71226ec
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,225 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help
+help:
+ @echo "Please use \`make
+Fixed and Floating point VHDL FAQ
+ ++What follows are frequently asked questions about the fixed and floating +point VHDL packages. VHDL-93 source code can be found on the +VHDL-2008 support library page. + +You will find these packages built into several implimentations of VHDL. +
++Under the hood, all of the fixed and floating point functions call functions +from the "numeric_std" package. Much work was done to make sure that +these algorithms would be as fast as possible. You can expect a fixed +point multiply to be just as fast as an UNSIGNED multiply. Floating +point gives you about 3X overhead. However you get much more accurate +results. My best results have been gotten by mixing the two. +
++You don't need them. Use the "scalb" function. This function works as +follows: +
+variable uf1 : ufixed (5 downto 0); +variable uf2 : ufixed (4 downto -1); +... +uf2 := scalb (uf1, -1); -- shift right by 1 ++The nice thing about this function is that you don't loose any data. +Note that under the hood, for some synthesis tools, this function is +implimented with shift operators. Standard shift operators are built into +VHDL-2008, but some vendors have not implemented them. + +
+The problem here is that the vector returned will be +"ufixed (integer'low to integer'low+Y'high)" or essentially 2**-32,000 +(a VERY small number). +Instead, use the resize function: +
+X <= resize (Y, X'high, X'low); ++The resize function is used to all of the rouding in the fixed point package. + +
+The sizing was done so that you never need to round, thus removing one addition +stage, and making the results run faster. +For the applications where this is just a pain, I've created +fixed_noresize.vhdl. +This package creates the types "fixedu" and "fixeds" (which are similar to +"ufixed" and "sfixed"). However these new types have the same sizing rules +as numeric_std UNSIGNED and SIGNED. +
+Note that there is also an "add_carry" procedure in the +fixed point package for fixed point +accumulators, which can be used like this: +
+variable uf3: ufixed (3 downto -2); +constant one : ufixed (0 downto 0) := "1"; +... +add_carry ( + L => uf3, + R => one, + result => uf3, + c_in => '0', + c_out => open); ++This procedure will return a result which is the "widest" of the inputs. +Overflow will show up in the "c_out" output. + +
+Yes, it will be, a floating point divider is lots of logic. +You will need to pipeline these functions. +Some synthsis tools will do this for you automatically. +Others will make you pipline them manually. +I have already created pipelined versions of many of them. +
++There is a function "to_sfixed(ufixed)" which increases the size of the output +by 1 (the sign bit). +The "to_ufixed(sfixed)" function returns a vector of the same size as the +input. + +
++
+So far: +
+Need some help with this code?
+Drop me an e-mail, maybe I can help.
+My company will also allow me to consult for you.
+
+This web page is brought to you by the +EDA Industry Working Groups and +Accellera. +
+ + + \ No newline at end of file diff --git a/docs/ieee.numeric_std.rst b/docs/ieee.numeric_std.rst new file mode 100644 index 0000000..6c1e323 --- /dev/null +++ b/docs/ieee.numeric_std.rst @@ -0,0 +1,4 @@ +ieee.numeric_std +################ + + diff --git a/docs/ieee.std_logic_1164.rst b/docs/ieee.std_logic_1164.rst new file mode 100644 index 0000000..0aa4f1f --- /dev/null +++ b/docs/ieee.std_logic_1164.rst @@ -0,0 +1,4 @@ +ieee.std_logic_1164 +################### + + diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..06a3acf --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,116 @@ +VHDL-2008 Support Library +######################### + +These packages were designed as a bridge between VHDL-93 and VHDL-2008. I +replicated as many of the new functions as possible. Note that all of these +packages are design to be synthesizable in VHDL-93. So, as long as you stick +to the subsets defined in the "README" files for the various vendors you should +be able to take your code through the entire flow. + +VHDL-2008 is finally getting some traction. What started out as just a fixed +and floating point package got merged into the VHDL LRM. On this page you will +find definitions of the functions available in the VHDL-2008 libraries. You will +also find VHDL-93 compatible code for those that do not yet have access to +VHDL-2008 compilers. + +There is a Fixed Point user's guide and a Floating Point user's guide. Please +check the Fixed and floating point FAQ (NEW!) if you have any quesiton. + +The VHDL-2008 packages will eventually be included in your vendor's environment. +In some cases I have found that they may be encrypted due to IEEE rules. The +packages available on this page are NOT the released packages, but VHDL-93 +versions of those packages, which I published BEFORE the release of the LRM. +They are free of copyright restrictions, and may be used for whatever purpose is +needed. + +VHDL-93 versions of the VHDL-2008 packages +****************************************** + ++----------------------------------+----------------------------------+-------------------------------+ +| Description | File | User Guide | ++==================================+==================================+===============================+ +| Additions to std.standard | standard_additions_c.vhdl | user's guide | ++----------------------------------+----------------------------------+-------------------------------+ +| New package std.env | env_c.vhdl | | ++----------------------------------+----------------------------------+-------------------------------+ +| Additions to std.textio | standard_textio_additions_c.vhdl | (user's guide) | ++----------------------------------+----------------------------------+-------------------------------+ +| Additions to ieee.std_logic_1164 | std_logic_1164_additions.vhdl | (user's guide) | ++----------------------------------+----------------------------------+-------------------------------+ +| Additions to ieee.numeric_std | numeric_std_additions.vhdl | (user's guide) | ++----------------------------------+----------------------------------+-------------------------------+ +| New package numeric_std_unsigned | numeric_std_unsigned_c.vhdl | (user's guide) | ++----------------------------------+----------------------------------+-------------------------------+ +| New package fixed_float_types | fixed_float_types_c.vhdl | | ++----------------------------------+----------------------------------+-------------------------------+ +| New package fixed_pkg | fixed_pkg_c.vhdl | (Fixed Point user's guide) | ++----------------------------------+----------------------------------+-------------------------------+ +| New package float_pkg | float_pkg_c.vhdl | (Floating Point user's guide) | ++----------------------------------+----------------------------------+-------------------------------+ + +.. ZIP file of all the packages (updated 09/2010) + +I use this code in most of my designs. Many times I find that I have to modify +the code slightly in some tools, so I made this list. Included in the "source +code" section for each tool is source code specifically debugged for that +particluar tool. Click on the "documentation" link to see what changes I had to +make, and how to use this code in the specific tool. + +Tool specifc modifications +************************** + ++--------------------------------+----------+-------+ +| Vendor / Tool | ZIP File | Notes | ++================================+==========+=======+ +| :doc:`Altera Quartus+ numeric_std_additions.vhdl -- Additions to the package "ieee.numeric_std" +
+
+ Use model:
+ use ieee.std_logic_1164.all;
+ use ieee.numeric_std.all;
+ use ieee_proposed.numeric_std_additions.all;
+
+ Dependencies: ieee.std_logic_1164, ieee.numeric_std +
++ numeric_std_additions -- Additions to the package "ieee.numeric_std" +
+
+ Use model:
+ use ieee.std_logic_1164.all;
+ use ieee.numeric_std.all;
+ use ieee_proposed.numeric_std_additions.all;
+
+ Dependencies: ieee.std_logic_1164, ieee.numeric_std +
++
+ numeric_std_unsigned.vhdl This package +is a "standardized" verion of "std_logic_unsigned" which appears in many +vendor tools. +
+
+ Use model:
+ use ieee.std_logic_1164.all;
+ use ieee.numeric_std.all;
+ use ieee_proposed.numeric_std_additions.all;
+ use ieee_proposed.numeric_std_unsigned.all;
+
VHDL-2008 use model:
+use ieee.numeric_std_unsigned.all;
+
+ Dependencies: ieee.std_logic_1164, ieee.numeric_std +
++This package treats "std_logic_vector" and "std_ulogic_vector" just like the +"unsigned" type in ieee.numeric_std. It has all of the funcitionality of the +old "std_logic_unsigned" package with the ability to use "std_ulogic_vector". +
+Please send feedback to David W. Bishop +dbishop@vhdl.org.   + + + + \ No newline at end of file diff --git a/docs/standard_additions.rst b/docs/standard_additions.rst new file mode 100644 index 0000000..c87085d --- /dev/null +++ b/docs/standard_additions.rst @@ -0,0 +1,65 @@ + ++ standard_additions -- Additions to the package "std.standard" +
+
+ Use model:
+ use ieee_proposed.standard_additions.all;
+ Dependancies: None.
+
+ Notes: The functions "rising_edge" and "falling_edge" are defined in + this package. If you use "numeric_bit" they are ALSO defined in that + package, causing a conflict. The VHDL-200X-FT version of numeric_bit + has these functions commented out, as well as the "sll", "srl", "ror" + and "rol" functions which are implicit. +
++ std_logic_1164_additions.vhdl -- Additions to the package "ieee.std_logic_1164". This package now includes what used to be in "std_logic_textio", so it must be commented out. Otherwise it will +conflict with the new functions (which are much more forgiving). +
+
+ Usage model:
+ use ieee.std_logic_1164.all;
+ -- use ieee.std_logic_textio.all; -- Comment out, included in "_additions".
+ use ieee_proposed.std_logic_1164_additions.all;
+
+ Dependencies: ieee.std_logic_1164; +
++ Note: The contents of the "std_logic_textio" package have now been + included in the "std_logic_1164" package, and an EMPTY "std_logic_textio" + package is provided in the new release. +
++ standard_textio_additions.vhdl -- Additions to the package "std.textio" +
+
+ Use model:
+ use ieee_proposed.standard_textio_additions.all;
+
+ Dependencies:
+ use std.textio;
use ieee_proposed.standard_additions;
+
+Fixed and Floating point support page
+ + + ++The floating point packages were designed to be 100% +IEEE 754 compatible.   +For synthesis, this just isn't practical.   +I recommend that you that you go into the top of "float_pkg" and change the constants as follows:
+ constant float_exponent_width : NATURAL := 8; + constant float_fraction_width : NATURAL := 15; -- 16 bits of precision + constant float_round_style : round_type := round_zero; -- disable rounding + constant float_denormalize : BOOLEAN := false; -- no denormal numbers + constant float_check_error : BOOLEAN := false; -- NO NAN and overflow checks + constant float_guard_bits : NATURAL := 0; -- no guard bits +In your source code, you should use this type: + begin + signal float1 : float (float_exponent_width downto -float_fraction_width); ++ + + +
+If you are an EDA vendor, and would like to test your tool against these packages, please download the "modeltech.zip" +(which has the fewest changes in it) and try it aginst your syntheis/simulation +tool. If you have any issues please drop me an e-mail. +
++The NEXT step is a Verilog package. Interested? +
++Questions or comments? Please e-mail me. +dbishop"at"vhdl.org +
+ + + diff --git a/docs/xilinx.rst b/docs/xilinx.rst new file mode 100644 index 0000000..642cead --- /dev/null +++ b/docs/xilinx.rst @@ -0,0 +1,33 @@ +Xilinx ISE +########## + +Tested with Xilinx M9.1i sp1 + +Go through "new project" and add the files to the project. +Go to the "Source Libraries" tab under "Sources" +Click on a blank area of that window, Select "New Source" +Select "VHDL Library", enter the name "ieee_proposed" and hit "Finish". +Select "math_utility_pkg.vhdl", "fixed_pkg_c.vhdl", and "float_pkg_c.vhdl" +one at a time and move them into "ieee_proposed" library. + +Click on "Synthesis" and select "Run". + + +Things Xilinx m9.1i didn't like about these packages: +1) Didn't like the "alias" statements on functions and type. Had to comment +these out or replace them with subtypes. +2) 'instance_name - Doesn't like this attribute, replace with package name. +3) "to_stdlogicvector(to_suv(arg))" shows as a type conversion error, replace +with casting "std_logic_vector()" +4) "to_stdulogicvector(arg)" shows as a type conversion error, replace with +casting "std_ulogic_vector()" + +After fixing everything, it gave me the error: +INTERNAL_ERROR:Xst:cmain.c:3111:1.8.6.1 - To resolve this error, please +consult the Answers Database and other online resources at +http://support.xilinx.com + +Which according to Xilinx has to do with the loops in my synthesis testcase, +and not the packages. This is a "use at your own risk" one I guess. I would +recommend Synplicity, which seems to work much better. Xilinx has said that +they plan to fix this problem in version 9.2. diff --git a/docs/xilinx_11.rst b/docs/xilinx_11.rst new file mode 100644 index 0000000..e16d16d --- /dev/null +++ b/docs/xilinx_11.rst @@ -0,0 +1,25 @@ +Xilinx ISE +########## + +Tested with Xilinx M11.2i + +Go through "new project" and add the files to the project. +When the "Adding Source files..." windows comes up, change the library +for "fixed_float_types.vhdl", "fixed_pkg_c.vhdl" and "float_pkg_c.vhdl" to +"ieee_porposed" + +Click on "Synthesis" and select "Run". + +I had to really fight to get these packages to synthesize in this tool. I +could not check everything, so "use at your own risk". For a real Xilinx +project I would use still Synplicity or Leonardo. However, I was able to +get both my fixed and floating point testcases (with some modification) +to place and route. This is a major improvement over M9.1i + +Things Xilinx m11.1i didn't like about these packages: +1) 'instance_name showed as a syntax error, replace with package name +2) "to_stdlogicvector(to_suv(arg))" shows as a type conversion error, replace +with casting "std_logic_vector()" +3) Did not like any of the fixed point division routines, +had to comment them out. +4) Had to comment out the "?=" routines, XST could not deal with that syntax. diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 0000000..e8d6ad6 --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,5 @@ +formats: + - pdf +requirements_file: requirements.txt +python: + version: 3 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ef3f026 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +# Requirements file for Python used by PIP