OpenCores
URL https://opencores.org/ocsvn/ratpack/ratpack/trunk

Subversion Repositories ratpack

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /ratpack
    from Rev 4 to Rev 5
    Reverse comparison

Rev 4 → Rev 5

trunk/DUMMY Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/run.sh =================================================================== --- trunk/run.sh (revision 4) +++ trunk/run.sh (nonexistent) @@ -1,14 +0,0 @@ -#!/bin/bash - -make -f $1.mk TEST=$2 clean -make -f $1.mk TEST=$2 init -make -f $1.mk TEST=$2 run - -if [ "$SECONDS" -eq 1 ] -then - units=second -else - units=seconds -fi -echo "This script has been running for $SECONDS $units." -exit 0
trunk/run.sh Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ratpack.vhd =================================================================== --- trunk/ratpack.vhd (revision 4) +++ trunk/ratpack.vhd (nonexistent) @@ -1,260 +0,0 @@ --------------------------------------------------------------------------------- --- Filename: ratpack.vhd --- Purpose : Rational arithmetic package --- Author : Nikolaos Kavvadias --- Date : 17-Nov-2010 --- Version : 0.1 --- Revision: 0.0.0 (2009/07/25) --- Initial version. Added the definition of a rational number, and the --- implementation of the "+", "-", "*", "/" operators on reduced --- rational numbers (i.e. relative primes), the gcd(x,y) and the --- mediant operator. --- 0.0.1 (2009/07/28) --- Added: numerator, denominator, abs, relational operators (>, <, >=, --- <=, =, /=, changed the int2rat to to_rational, new version of --- int2rat (casting an integer to a rational). --- 0.0.2 (2010/11/17) --- Added an iterative version for the gcd computation (gcditer). --- License : Copyright (C) 2009, 2010 by Nikolaos Kavvadias --- This program is free software. You can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public License, --- either version 3 of the License, or (at your option) any later --- version. See COPYING. --- --------------------------------------------------------------------------------- - -package ratpack is - - -- A rational number is defined by the pair (numerator, denominator) where - -- both numbers. -- are in the range [-16384, 16383]. - constant numer : INTEGER := 0; -- numerator - constant denom : INTEGER := 1; -- denominator - type rational is array (natural range numer to denom) of - integer; -- range -16384 to 16383; - constant RAT_ZERO : rational := (0, 1); - constant RAT_ONE : rational := (1, 1); - - function to_rational (a, b : integer) return rational; - function int2rat (a : integer) return rational; - function numerator (a : rational) return integer; - function denominator (a : rational) return integer; - function "+" (a, b : rational) return rational; - function "-" (a, b : rational) return rational; - function "*" (a, b : rational) return rational; - function "/" (a, b : rational) return rational; - function "abs" (a : rational) return rational; - function ">" (a, b : rational) return boolean; - function "<" (a, b : rational) return boolean; - function ">=" (a, b : rational) return boolean; - function "<=" (a, b : rational) return boolean; - function "=" (a, b : rational) return boolean; - function "/=" (a, b : rational) return boolean; - function gcd (a, b : integer) return integer; - function gcditer (a, b : integer) return integer; - function mediant (a, b : rational) return rational; - -end ratpack; - - -package body ratpack is - - function to_rational (a, b : integer) return rational is - variable r : rational; - begin - r(numer) := a; - r(denom) := b; - return r; - end to_rational; - - function int2rat (a : integer) return rational is - variable r : rational; - begin - r(numer) := a; - r(denom) := 1; - return r; - end int2rat; - - function numerator (a : rational) return integer is - variable n : integer; - begin - n := a(numer); - return n; - end numerator; - - function denominator (a : rational) return integer is - variable d : integer; - begin - d := a(denom); - return d; - end denominator; - - function "+" (a, b : rational) return rational is - variable r : rational; - variable tn, td : integer; - begin - tn := a(numer)*b(denom) + a(denom)*b(numer); - td := a(denom) * b(denom); - if ( gcd(abs(tn), abs(td)) > 0 ) then - r(numer) := tn / gcd(abs(tn), abs(td)); - r(denom) := td / gcd(abs(tn), abs(td)); - else - r(numer) := tn; - r(denom) := td; - end if; - return r; - end "+"; - - function "-" (a, b : rational) return rational is - variable r : rational; - variable tn, td : integer; - begin - tn := a(numer)*b(denom) - a(denom)*b(numer); - td := a(denom) * b(denom); - if ( gcd(abs(tn), abs(td)) > 0 ) then - r(numer) := tn / gcd(abs(tn), abs(td)); - r(denom) := td / gcd(abs(tn), abs(td)); - else - r(numer) := tn; - r(denom) := td; - end if; - return r; - end "-"; - - function "*" (a, b : rational) return rational is - variable r : rational; - variable tn, td : integer; - begin - tn := a(numer) * b(numer); - td := a(denom) * b(denom); - if ( gcd(abs(tn), abs(td)) > 0 ) then - r(numer) := tn / gcd(abs(tn), abs(td)); - r(denom) := td / gcd(abs(tn), abs(td)); - else - r(numer) := tn; - r(denom) := td; - end if; - return r; - end "*"; - - function "/" (a, b : rational) return rational is - variable r : rational; - variable tn, td : integer; - begin - tn := a(numer) * b(denom); - td := a(denom) * b(numer); - if ( gcd(abs(tn), abs(td)) > 0 ) then - r(numer) := tn / gcd(abs(tn), abs(td)); - r(denom) := td / gcd(abs(tn), abs(td)); - else - r(numer) := tn; - r(denom) := td; - end if; - return r; - end "/"; - - function "abs" (a : rational) return rational is - variable ta, tb, y : integer; - variable r : rational; - begin - ta := a(numer); - tb := a(denom); - if (ta < 0) then - ta := - a(numer); - end if; - if (tb < 0) then - tb := - a(denom); - end if; - r := to_rational(ta, tb); - return r; - end "abs"; - - function ">" (a, b : rational) return boolean is - variable diff : rational := a - b; - begin - return (((diff(numer) > 0) and (diff(denom) > 0)) or - ((diff(numer) < 0) and (diff(denom) < 0))); - end ">"; - - function "<" (a, b : rational) return boolean is - variable diff : rational := a - b; - begin - return (((diff(numer) > 0) and (diff(denom) < 0)) or - ((diff(numer) < 0) and (diff(denom) > 0))); - end "<"; - - function ">=" (a, b : rational) return boolean is - variable diff : rational := a - b; - begin - return (((diff(numer) >= 0) and (diff(denom) > 0)) or - ((diff(numer) <= 0) and (diff(denom) < 0))); - end ">="; - - function "<=" (a, b : rational) return boolean is - variable diff : rational := a - b; - begin - return (((diff(numer) >= 0) and (diff(denom) < 0)) or - ((diff(numer) <= 0) and (diff(denom) > 0))); - end "<="; - - function "=" (a, b : rational) return boolean is - variable diff : rational := a - b; - begin - return (diff(numer) = 0); - end "="; - - function "/=" (a, b : rational) return boolean is - variable diff : rational := a - b; - begin - return (diff(numer) /= 0); - end "/="; - - function gcd (a, b : integer) return integer is - begin - if a = 0 then - return b; - end if; - if b = 0 then - return a; - end if; - if (a > b) then - return gcd(b, a mod b); - else - return gcd(a, b mod a); - end if; - end gcd; - - function gcditer (a, b : integer) return integer is - variable x, y : integer; - begin - x := a; - y := b; - if ((x = 0) and (y = 0)) then - return 0; - end if; - while (x /= y) loop - if (x >= y) then - x := x - y; - else - y := y - x; - end if; - end loop; - return x; - end gcditer; - - function mediant (a, b : rational) return rational is - variable r : rational; - variable tn, td : integer; - begin - tn := a(numer) + b(numer); - td := a(denom) + b(denom); - if ( gcd(abs(tn), abs(td)) > 0 ) then - r(numer) := tn / gcd(abs(tn), abs(td)); - r(denom) := td / gcd(abs(tn), abs(td)); - else - r(numer) := tn; - r(denom) := td; - end if; - return r; - end mediant; - -end ratpack;
trunk/ratpack.vhd Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/README =================================================================== --- trunk/README (revision 4) +++ trunk/README (nonexistent) @@ -1,104 +0,0 @@ ------------------------------------------------------------------------------- --- Title : ratpack (VHDL rational arithmetic package). -- --- Author : Nikolaos Kavvadias -- --- Contact : nikolaos.kavvadias@gmail.com -- --- : http://electronics.physics.auth.gr/people/nkavv/ -- --- : http://www.nkavvadias.eu -- --- Release Date : 17 November 2010 -- --- Version : 0.1.2 -- ---------------------:--------------------------------------------------------- --- Revision history : -- --- v0.1 : 2010-05-14 -- --- : Initial release. -- --- v0.1.1 : 2010-06-07 -- --- : Minor update in documentation (README). -- --- v0.1.2 : 2010-11-17 -- --- : Added gcditer. -- ------------------------------------------------------------------------------- - - -1. INTRODUCTION ---------------- - -"ratpack" is a rational arithmetic package written in VHDL. - -Currently, the "ratpack" package implements the following: - - - the RATIONAL data type. - - to_rational: construction function of a rational given two integers - (numerator and denominator). - - int2rat: conversion function of an integer to its rational - representation. - - numerator: extracts the numerator of a rational number. - - denominator: extracts the denominator of a rational number. - - "+", "-", "*", "/": implementation of the basic arithmetic - operations for rationals. - - abs: extracts the absolute value of a given rational number. - - ">", "<", ">=", "<=", "=", "/=": overload comparison operators for - rationals. - - gcd: computes the greatest common divisor of two integers (positive, - covers the pathological case of division by zero). - - mediant: computes the mediant rational of two given rationals. - -"ratpack" is distributed along with two VHDL testbenches: a simple one -(ratpack_tb1.vhd) and a testbench generating the Farey series of orders 1 to 12 -(ratpack_tb2.vhd). - - -2. FILE LISTING ---------------- - - The ratpack distributions includes the following files: - - /ratpack- - AUTHORS List of "ratpack" authors. - BUGS Bug list. - ChangeLog A log for code changes. - COPYING The LGPL, version 3. - ratpack.mk Makefile - ratpack_results1.txt Result file after the simple test. - ratpack_results2.txt Result file after the computation of Farey series. - ratpack_tb1.vhd A simple testbench. - ratpack_tb2.vhd Testbench generating the Farey series (orders 1-12). - README This file. - run.sh A bash script for testing the package. - THANKS Acknowledgements. - TODO A list of future enhancements. - - -3. RATPACK USAGE ----------------- - - The ratpack package program can be used as follows: - $./run.sh - After this process, the "ratpack_results.txt" file is generated containing - simulation results. - -Here follow some simple usage examples of this bash script. - -1. Compile the "ratpack" package and do a simple test. -$ ./run.sh ratpack 1 - -2. Compile the "ratpack" package and generate the Farey series. -$ ./run.sh ratpack 2 - - -4. PREREQUISITIES ------------------ - -- Standard UNIX-based tools (tested with gcc-3.3.3, 3.4.3 and 3.4.4 on - cygwin/x86) - make -- GHDL simulator (http://ghdl.free.fr) - Provides the "ghdl" executable. - - -5. CONTACT ----------- - -You may contact me for further questions/suggestions/corrections at: - - Nikolaos Kavvadias - - - http://www.nkavvadias.co.cc
trunk/README Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/VERSION =================================================================== --- trunk/VERSION (revision 4) +++ trunk/VERSION (nonexistent) @@ -1 +0,0 @@ -0.1.2
trunk/VERSION Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/BUGS =================================================================== --- trunk/BUGS (revision 4) +++ trunk/BUGS (nonexistent) @@ -1,11 +0,0 @@ -ratpack BUGS -- known bugs. Last updated: 2010-05-14 - -Known bugs in ratpack-0.1 ----------------------------- - - ** - - - - - - -BUGS ends here.
trunk/BUGS Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ChangeLog =================================================================== --- trunk/ChangeLog (revision 4) +++ trunk/ChangeLog (nonexistent) @@ -1,13 +0,0 @@ -2010-05-14 Nikolaos Kavvadias - - * Release 0.1. - -2010-06-07 Nikolaos Kavvadias - - * Minor release 0.1.1. - -2010-11-17 Nikolaos Kavvadias - - * Minor release 0.1.2. - -ChangeLog ends here
trunk/ChangeLog Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/COPYING =================================================================== --- trunk/COPYING (revision 4) +++ trunk/COPYING (nonexistent) @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library.
trunk/COPYING Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ratpack_tb1.vhd =================================================================== --- trunk/ratpack_tb1.vhd (revision 4) +++ trunk/ratpack_tb1.vhd (nonexistent) @@ -1,125 +0,0 @@ --------------------------------------------------------------------------------- --- Filename: ratpack_tb1.vhd --- Purpose : A simple testbench for "ratpack". --- Author : Nikolaos Kavvadias --- Date : 14-May-2010 --- Version : 0.1 --- Revision: 0.0.0 (2010/05/14) --- Initial version. --- License : Copyright (C) 2010 by Nikolaos Kavvadias --- This program is free software. You can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public License, --- either version 3 of the License, or (at your option) any later --- version. See COPYING. --- --------------------------------------------------------------------------------- - -library STD, IEEE; -use STD.textio.all; -use IEEE.std_logic_1164.all; -use WORK.ratpack.all; - - -entity ratpack_tb is -end ratpack_tb; - - -architecture tb_arch of ratpack_tb is - ------------------------------------------------------- - -- Declare results file - ------------------------------------------------------- - file ResultsFile: text open write_mode is - "ratpack_results.txt"; - ------------------------------------------------------- - -- Constant declarations - ------------------------------------------------------- - constant CLK_PERIOD : time := 10 ns; -begin - - -- Test the basic operators. - TEST_OPS: process - variable a, b, c: rational := RAT_ZERO; - variable BufLine: line; - begin - a := to_rational(5, 12); - b := to_rational(2, 3); - wait for CLK_PERIOD; - -- Test rational addition - c := a + b; - write(Bufline, a(numer)); - write(Bufline, string'("/")); - write(Bufline, a(denom)); - write(Bufline, string'(" + ")); - write(Bufline, b(numer)); - write(Bufline, string'("/")); - write(Bufline, b(denom)); - write(Bufline, string'(" = ")); - write(Bufline, c(numer)); - write(Bufline, string'("/")); - write(Bufline, c(denom)); - writeline(ResultsFile, Bufline); - wait for CLK_PERIOD; - -- Test rational subtraction - c := a - b; - write(Bufline, a(numer)); - write(Bufline, string'("/")); - write(Bufline, a(denom)); - write(Bufline, string'(" - ")); - write(Bufline, b(numer)); - write(Bufline, string'("/")); - write(Bufline, b(denom)); - write(Bufline, string'(" = ")); - write(Bufline, c(numer)); - write(Bufline, string'("/")); - write(Bufline, c(denom)); - writeline(ResultsFile, Bufline); - wait for CLK_PERIOD; - -- Test rational multiplication - c := a * b; - write(Bufline, a(numer)); - write(Bufline, string'("/")); - write(Bufline, a(denom)); - write(Bufline, string'(" * ")); - write(Bufline, b(numer)); - write(Bufline, string'("/")); - write(Bufline, b(denom)); - write(Bufline, string'(" = ")); - write(Bufline, c(numer)); - write(Bufline, string'("/")); - write(Bufline, c(denom)); - writeline(ResultsFile, Bufline); - wait for CLK_PERIOD; - -- Test rational division - c := a / b; - write(Bufline, a(numer)); - write(Bufline, string'("/")); - write(Bufline, a(denom)); - write(Bufline, string'(" : ")); - write(Bufline, b(numer)); - write(Bufline, string'("/")); - write(Bufline, b(denom)); - write(Bufline, string'(" = ")); - write(Bufline, c(numer)); - write(Bufline, string'("/")); - write(Bufline, c(denom)); - writeline(ResultsFile, Bufline); - wait for CLK_PERIOD; - -- Test mediant - c := mediant(a, b); - write(Bufline, string'("mediant(")); - write(Bufline, a(numer)); - write(Bufline, string'("/")); - write(Bufline, a(denom)); - write(Bufline, string'(" , ")); - write(Bufline, b(numer)); - write(Bufline, string'("/")); - write(Bufline, b(denom)); - write(Bufline, string'(") = ")); - write(Bufline, c(numer)); - write(Bufline, string'("/")); - write(Bufline, c(denom)); - writeline(ResultsFile, Bufline); - wait for CLK_PERIOD; - end process TEST_OPS; - -end tb_arch;
trunk/ratpack_tb1.vhd Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ratpack_tb2.vhd =================================================================== --- trunk/ratpack_tb2.vhd (revision 4) +++ trunk/ratpack_tb2.vhd (nonexistent) @@ -1,90 +0,0 @@ --------------------------------------------------------------------------------- --- Filename: ratpack_tb2.vhd --- Purpose : A testbench for "ratpack" generating the Farey series' up to order --- 12. --- Author : Nikolaos Kavvadias --- Date : 14-May-2010 --- Version : 0.1 --- Revision: 0.0.0 (2010/05/14) --- Initial version. --- License : Copyright (C) 2010 by Nikolaos Kavvadias --- This program is free software. You can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public License, --- either version 3 of the License, or (at your option) any later --- version. See COPYING. --- --------------------------------------------------------------------------------- - -library STD; -use STD.textio.all; -use WORK.ratpack.all; - - -entity ratpack_tb is -end ratpack_tb; - - -architecture tb_arch of ratpack_tb is - ------------------------------------------------------- - -- Declare results file - ------------------------------------------------------- - file ResultsFile: text open write_mode is - "ratpack_results.txt"; - ------------------------------------------------------- - -- Constant declarations - ------------------------------------------------------- - constant CLK_PERIOD : time := 10 ns; -begin - - -- Compute the Farey sequences F1 to F12. - -- The Farey sequence Fn for any positive integer n is the set of irreducible - -- rational numbers a/b with 0<=a<=b<=n and (a,b)=1 arranged in increasing - -- order. - FAREY_SERIES: process - variable a, b, c, d, k, n : integer; - variable ta, tb, tc, td : integer; - variable r : rational := RAT_ZERO; - variable BufLine: line; - begin - for n in 1 to 12 loop - write(Bufline, string'(" F")); - write(Bufline, n); - write(Bufline, string'("= ")); - -- Initialize a, b, c, d for computing the ascending Farey sequence - a := 0; - b := 1; - c := 1; - d := n; - -- Print r = a/b - r := to_rational(a, b); - write(Bufline, r(numer)); - write(Bufline, string'("/")); - write(Bufline, r(denom)); - write(Bufline, string'(" ")); - wait for CLK_PERIOD; - -- Compute the subsequent terms of the Farey sequence - while (c < n) loop - k := (n + b) / d; - ta := a; - tb := b; - tc := c; - td := d; - a := tc; - b := td; - c := k * tc - ta; - d := k * td - tb; - c := k * tc - ta; - -- Print r = a/b - r := to_rational(a, b); - write(Bufline, r(numer)); - write(Bufline, string'("/")); - write(Bufline, r(denom)); - write(Bufline, string'(" ")); - wait for CLK_PERIOD; - end loop; - writeline(ResultsFile, Bufline); - end loop; - wait for CLK_PERIOD; - end process FAREY_SERIES; - -end tb_arch;
trunk/ratpack_tb2.vhd Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/THANKS =================================================================== --- trunk/THANKS (revision 4) +++ trunk/THANKS (nonexistent) @@ -1,7 +0,0 @@ -Thanks to: - - X.Y. for whatever. - - -Thessaloniki, Greece, 2010-11-17 -
trunk/THANKS Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/TODO =================================================================== --- trunk/TODO (revision 4) +++ trunk/TODO (nonexistent) @@ -1,8 +0,0 @@ -ratpack --- TODO - -Todo: - - * . - - -end of file TODO
trunk/TODO Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ratpack.mk =================================================================== --- trunk/ratpack.mk (revision 4) +++ trunk/ratpack.mk (nonexistent) @@ -1,26 +0,0 @@ -GHDL=ghdl -GHDLFLAGS=--ieee=synopsys -fexplicit --workdir=work -# Use stop-time = 2340ns for computing Farey series' F1 to F12. -GHDLRUNFLAGS=--stop-time=2340ns - -# Default target : elaborate -all : run - -# Elaborate target. Almost useless -elab : force - $(GHDL) -c $(GHDLFLAGS) -e ratpack_tb - -# Run target -run: force - $(GHDL) --elab-run $(GHDLFLAGS) ratpack_tb $(GHDLRUNFLAGS) - -# Targets to analyze libraries -init: force - mkdir work - $(GHDL) -a $(GHDLFLAGS) ratpack.vhd - $(GHDL) -a $(GHDLFLAGS) ratpack_tb$(TEST).vhd - -force: - -clean : - rm -rf *.o work ratpack_results.txt
trunk/ratpack.mk Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ratpack_results2.txt =================================================================== --- trunk/ratpack_results2.txt (revision 4) +++ trunk/ratpack_results2.txt (nonexistent) @@ -1,12 +0,0 @@ - F1= 0/1 - F2= 0/1 1/2 1/1 - F3= 0/1 1/3 1/2 2/3 1/1 - F4= 0/1 1/4 1/3 1/2 2/3 3/4 1/1 - F5= 0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1 - F6= 0/1 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1/1 - F7= 0/1 1/7 1/6 1/5 1/4 2/7 1/3 2/5 3/7 1/2 4/7 3/5 2/3 5/7 3/4 4/5 5/6 6/7 1/1 - F8= 0/1 1/8 1/7 1/6 1/5 1/4 2/7 1/3 3/8 2/5 3/7 1/2 4/7 3/5 5/8 2/3 5/7 3/4 4/5 5/6 6/7 7/8 1/1 - F9= 0/1 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 1/1 - F10= 0/1 1/10 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 3/10 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 7/10 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 9/10 1/1 - F11= 0/1 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 3/7 4/9 5/11 1/2 6/11 5/9 4/7 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 1/1 - F12= 0/1 1/12 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 5/12 3/7 4/9 5/11 1/2 6/11 5/9 4/7 7/12 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 11/12 1/1
trunk/ratpack_results2.txt Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/ratpack_results1.txt =================================================================== --- trunk/ratpack_results1.txt (revision 4) +++ trunk/ratpack_results1.txt (nonexistent) @@ -1,195 +0,0 @@ -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15 -5/12 + 2/3 = 13/12 -5/12 - 2/3 = -1/4 -5/12 * 2/3 = 5/18 -5/12 : 2/3 = 5/8 -mediant(5/12 , 2/3) = 7/15
trunk/ratpack_results1.txt Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/AUTHORS =================================================================== --- trunk/AUTHORS (revision 4) +++ trunk/AUTHORS (nonexistent) @@ -1,5 +0,0 @@ -Authors of ratpack. - -ratpack Nikolaos Kavvadias - -AUTHORS ends here
trunk/AUTHORS Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/bench/vhdl/ratpack_tb1.vhd =================================================================== --- trunk/bench/vhdl/ratpack_tb1.vhd (nonexistent) +++ trunk/bench/vhdl/ratpack_tb1.vhd (revision 5) @@ -0,0 +1,125 @@ +-------------------------------------------------------------------------------- +-- Filename: ratpack_tb1.vhd +-- Purpose : A simple testbench for "ratpack". +-- Author : Nikolaos Kavvadias +-- Date : 14-May-2010 +-- Version : 0.1 +-- Revision: 0.0.0 (2010/05/14) +-- Initial version. +-- License : Copyright (C) 2010 by Nikolaos Kavvadias +-- This program is free software. You can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public License, +-- either version 3 of the License, or (at your option) any later +-- version. See COPYING. +-- +-------------------------------------------------------------------------------- + +library STD, IEEE; +use STD.textio.all; +use IEEE.std_logic_1164.all; +use WORK.ratpack.all; + + +entity ratpack_tb is +end ratpack_tb; + + +architecture tb_arch of ratpack_tb is + ------------------------------------------------------- + -- Declare results file + ------------------------------------------------------- + file ResultsFile: text open write_mode is + "ratpack_results.txt"; + ------------------------------------------------------- + -- Constant declarations + ------------------------------------------------------- + constant CLK_PERIOD : time := 10 ns; +begin + + -- Test the basic operators. + TEST_OPS: process + variable a, b, c: rational := RAT_ZERO; + variable BufLine: line; + begin + a := to_rational(5, 12); + b := to_rational(2, 3); + wait for CLK_PERIOD; + -- Test rational addition + c := a + b; + write(Bufline, a(numer)); + write(Bufline, string'("/")); + write(Bufline, a(denom)); + write(Bufline, string'(" + ")); + write(Bufline, b(numer)); + write(Bufline, string'("/")); + write(Bufline, b(denom)); + write(Bufline, string'(" = ")); + write(Bufline, c(numer)); + write(Bufline, string'("/")); + write(Bufline, c(denom)); + writeline(ResultsFile, Bufline); + wait for CLK_PERIOD; + -- Test rational subtraction + c := a - b; + write(Bufline, a(numer)); + write(Bufline, string'("/")); + write(Bufline, a(denom)); + write(Bufline, string'(" - ")); + write(Bufline, b(numer)); + write(Bufline, string'("/")); + write(Bufline, b(denom)); + write(Bufline, string'(" = ")); + write(Bufline, c(numer)); + write(Bufline, string'("/")); + write(Bufline, c(denom)); + writeline(ResultsFile, Bufline); + wait for CLK_PERIOD; + -- Test rational multiplication + c := a * b; + write(Bufline, a(numer)); + write(Bufline, string'("/")); + write(Bufline, a(denom)); + write(Bufline, string'(" * ")); + write(Bufline, b(numer)); + write(Bufline, string'("/")); + write(Bufline, b(denom)); + write(Bufline, string'(" = ")); + write(Bufline, c(numer)); + write(Bufline, string'("/")); + write(Bufline, c(denom)); + writeline(ResultsFile, Bufline); + wait for CLK_PERIOD; + -- Test rational division + c := a / b; + write(Bufline, a(numer)); + write(Bufline, string'("/")); + write(Bufline, a(denom)); + write(Bufline, string'(" : ")); + write(Bufline, b(numer)); + write(Bufline, string'("/")); + write(Bufline, b(denom)); + write(Bufline, string'(" = ")); + write(Bufline, c(numer)); + write(Bufline, string'("/")); + write(Bufline, c(denom)); + writeline(ResultsFile, Bufline); + wait for CLK_PERIOD; + -- Test mediant + c := mediant(a, b); + write(Bufline, string'("mediant(")); + write(Bufline, a(numer)); + write(Bufline, string'("/")); + write(Bufline, a(denom)); + write(Bufline, string'(" , ")); + write(Bufline, b(numer)); + write(Bufline, string'("/")); + write(Bufline, b(denom)); + write(Bufline, string'(") = ")); + write(Bufline, c(numer)); + write(Bufline, string'("/")); + write(Bufline, c(denom)); + writeline(ResultsFile, Bufline); + wait for CLK_PERIOD; + end process TEST_OPS; + +end tb_arch;
trunk/bench/vhdl/ratpack_tb1.vhd Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/bench/vhdl/ratpack_tb2.vhd =================================================================== --- trunk/bench/vhdl/ratpack_tb2.vhd (nonexistent) +++ trunk/bench/vhdl/ratpack_tb2.vhd (revision 5) @@ -0,0 +1,90 @@ +-------------------------------------------------------------------------------- +-- Filename: ratpack_tb2.vhd +-- Purpose : A testbench for "ratpack" generating the Farey series' up to order +-- 12. +-- Author : Nikolaos Kavvadias +-- Date : 14-May-2010 +-- Version : 0.1 +-- Revision: 0.0.0 (2010/05/14) +-- Initial version. +-- License : Copyright (C) 2010 by Nikolaos Kavvadias +-- This program is free software. You can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public License, +-- either version 3 of the License, or (at your option) any later +-- version. See COPYING. +-- +-------------------------------------------------------------------------------- + +library STD; +use STD.textio.all; +use WORK.ratpack.all; + + +entity ratpack_tb is +end ratpack_tb; + + +architecture tb_arch of ratpack_tb is + ------------------------------------------------------- + -- Declare results file + ------------------------------------------------------- + file ResultsFile: text open write_mode is + "ratpack_results.txt"; + ------------------------------------------------------- + -- Constant declarations + ------------------------------------------------------- + constant CLK_PERIOD : time := 10 ns; +begin + + -- Compute the Farey sequences F1 to F12. + -- The Farey sequence Fn for any positive integer n is the set of irreducible + -- rational numbers a/b with 0<=a<=b<=n and (a,b)=1 arranged in increasing + -- order. + FAREY_SERIES: process + variable a, b, c, d, k, n : integer; + variable ta, tb, tc, td : integer; + variable r : rational := RAT_ZERO; + variable BufLine: line; + begin + for n in 1 to 12 loop + write(Bufline, string'(" F")); + write(Bufline, n); + write(Bufline, string'("= ")); + -- Initialize a, b, c, d for computing the ascending Farey sequence + a := 0; + b := 1; + c := 1; + d := n; + -- Print r = a/b + r := to_rational(a, b); + write(Bufline, r(numer)); + write(Bufline, string'("/")); + write(Bufline, r(denom)); + write(Bufline, string'(" ")); + wait for CLK_PERIOD; + -- Compute the subsequent terms of the Farey sequence + while (c < n) loop + k := (n + b) / d; + ta := a; + tb := b; + tc := c; + td := d; + a := tc; + b := td; + c := k * tc - ta; + d := k * td - tb; + c := k * tc - ta; + -- Print r = a/b + r := to_rational(a, b); + write(Bufline, r(numer)); + write(Bufline, string'("/")); + write(Bufline, r(denom)); + write(Bufline, string'(" ")); + wait for CLK_PERIOD; + end loop; + writeline(ResultsFile, Bufline); + end loop; + wait for CLK_PERIOD; + end process FAREY_SERIES; + +end tb_arch;
trunk/bench/vhdl/ratpack_tb2.vhd Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/rtl/vhdl/ratpack.vhd =================================================================== --- trunk/rtl/vhdl/ratpack.vhd (nonexistent) +++ trunk/rtl/vhdl/ratpack.vhd (revision 5) @@ -0,0 +1,304 @@ +-------------------------------------------------------------------------------- +-- Filename: ratpack.vhd +-- Purpose : Rational arithmetic package +-- Author : Nikolaos Kavvadias +-- Date : 21-Feb-2014 +-- Version : 0.1.0 +-- Revision: 0.0.0 (2009/07/25) +-- Initial version. Added the definition of a rational number, and the +-- implementation of the "+", "-", "*", "/" operators on reduced +-- rational numbers (i.e. relative primes), the gcd(x,y) and the +-- mediant operator. +-- 0.0.1 (2009/07/28) +-- Added: numerator, denominator, abs, relational operators (>, <, >=, +-- <=, =, /=, changed the int2rat to to_rational, new version of +-- int2rat (casting an integer to a rational). +-- 0.0.2 (2010/11/17) +-- Added an iterative version for the gcd computation (gcditer). +-- 0.0.3 (2012/02/11) +-- Added max, min. +-- 0.1.0 (2014/02/21) +-- Upgraded to version 0.1.0. +-- License : Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 by Nikolaos Kavvadias +-- This program is free software. You can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public License, +-- either version 3 of the License, or (at your option) any later +-- version. See COPYING. +-- +-------------------------------------------------------------------------------- + +package ratpack is + + -- A rational number is defined by the pair (numerator, denominator) where + -- both numbers. -- are in the range [-16384, 16383]. + constant numer : INTEGER := 0; -- numerator + constant denom : INTEGER := 1; -- denominator + type rational is array (natural range numer to denom) of + integer; -- range -16384 to 16383; + constant RAT_ZERO : rational := (0, 1); + constant RAT_ONE : rational := (1, 1); + + function to_rational (a, b : integer) return rational; + function int2rat (a : integer) return rational; + function numerator (a : rational) return integer; + function denominator (a : rational) return integer; + function "+" (a, b : rational) return rational; + function "-" (a, b : rational) return rational; + function "*" (a, b : rational) return rational; + function "/" (a, b : rational) return rational; + function "abs" (a : rational) return rational; + function max (a, b : rational) return rational; + function min (a, b : rational) return rational; + function ">" (a, b : rational) return boolean; + function "<" (a, b : rational) return boolean; + function ">=" (a, b : rational) return boolean; + function "<=" (a, b : rational) return boolean; + function "=" (a, b : rational) return boolean; + function "/=" (a, b : rational) return boolean; + function gcd (a, b : integer) return integer; + function gcditer (a, b : integer) return integer; + function mediant (a, b : rational) return rational; + +end ratpack; + + +package body ratpack is + + function to_rational (a, b : integer) return rational is + variable r : rational; + begin + r(numer) := a; + r(denom) := b; + return r; + end to_rational; + + function int2rat (a : integer) return rational is + variable r : rational; + begin + r(numer) := a; + r(denom) := 1; + return r; + end int2rat; + + function numerator (a : rational) return integer is + variable n : integer; + begin + n := a(numer); + return n; + end numerator; + + function denominator (a : rational) return integer is + variable d : integer; + begin + d := a(denom); + return d; + end denominator; + + function "+" (a, b : rational) return rational is + variable r : rational; + variable tn, td : integer; + begin + tn := a(numer)*b(denom) + a(denom)*b(numer); + td := a(denom) * b(denom); + if ( gcd(abs(tn), abs(td)) > 0 ) then + r(numer) := tn / gcd(abs(tn), abs(td)); + r(denom) := td / gcd(abs(tn), abs(td)); + else + r(numer) := tn; + r(denom) := td; + end if; + return r; + end "+"; + + function "-" (a, b : rational) return rational is + variable r : rational; + variable tn, td : integer; + begin + tn := a(numer)*b(denom) - a(denom)*b(numer); + td := a(denom) * b(denom); + if ( gcd(abs(tn), abs(td)) > 0 ) then + r(numer) := tn / gcd(abs(tn), abs(td)); + r(denom) := td / gcd(abs(tn), abs(td)); + else + r(numer) := tn; + r(denom) := td; + end if; + return r; + end "-"; + + function "*" (a, b : rational) return rational is + variable r : rational; + variable tn, td : integer; + begin + tn := a(numer) * b(numer); + td := a(denom) * b(denom); + if ( gcd(abs(tn), abs(td)) > 0 ) then + r(numer) := tn / gcd(abs(tn), abs(td)); + r(denom) := td / gcd(abs(tn), abs(td)); + else + r(numer) := tn; + r(denom) := td; + end if; + return r; + end "*"; + + function "/" (a, b : rational) return rational is + variable r : rational; + variable tn, td : integer; + begin + tn := a(numer) * b(denom); + td := a(denom) * b(numer); + if ( gcd(abs(tn), abs(td)) > 0 ) then + r(numer) := tn / gcd(abs(tn), abs(td)); + r(denom) := td / gcd(abs(tn), abs(td)); + else + r(numer) := tn; + r(denom) := td; + end if; + return r; + end "/"; + + function "abs" (a : rational) return rational is + variable ta, tb, y : integer; + variable r : rational; + begin + ta := a(numer); + tb := a(denom); + if (ta < 0) then + ta := - a(numer); + end if; + if (tb < 0) then + tb := - a(denom); + end if; + r := to_rational(ta, tb); + return r; + end "abs"; + + function max (a, b : rational) return rational is + variable w, x, y, z : integer; + variable t1, t2 : integer; + variable maxv : rational; + begin + w := numerator(a); + x := denominator(a); + y := numerator(b); + z := denominator(b); + t1 := w*z; + t2 := x*y; + if (t1 > t2) then + maxv := a; + else + maxv := b; + end if; + return maxv; + end max; + + function min (a, b : rational) return rational is + variable w, x, y, z : integer; + variable t1, t2 : integer; + variable minv : rational; + begin + w := numerator(a); + x := denominator(a); + y := numerator(b); + z := denominator(b); + t1 := w*z; + t2 := x*y; + if (t1 < t2) then + minv := a; + else + minv := b; + end if; + return minv; + end min; + + function ">" (a, b : rational) return boolean is + variable diff : rational := a - b; + begin + return (((diff(numer) > 0) and (diff(denom) > 0)) or + ((diff(numer) < 0) and (diff(denom) < 0))); + end ">"; + + function "<" (a, b : rational) return boolean is + variable diff : rational := a - b; + begin + return (((diff(numer) > 0) and (diff(denom) < 0)) or + ((diff(numer) < 0) and (diff(denom) > 0))); + end "<"; + + function ">=" (a, b : rational) return boolean is + variable diff : rational := a - b; + begin + return (((diff(numer) >= 0) and (diff(denom) > 0)) or + ((diff(numer) <= 0) and (diff(denom) < 0))); + end ">="; + + function "<=" (a, b : rational) return boolean is + variable diff : rational := a - b; + begin + return (((diff(numer) >= 0) and (diff(denom) < 0)) or + ((diff(numer) <= 0) and (diff(denom) > 0))); + end "<="; + + function "=" (a, b : rational) return boolean is + variable diff : rational := a - b; + begin + return (diff(numer) = 0); + end "="; + + function "/=" (a, b : rational) return boolean is + variable diff : rational := a - b; + begin + return (diff(numer) /= 0); + end "/="; + + function gcd (a, b : integer) return integer is + begin + if a = 0 then + return b; + end if; + if b = 0 then + return a; + end if; + if (a > b) then + return gcd(b, a mod b); + else + return gcd(a, b mod a); + end if; + end gcd; + + function gcditer (a, b : integer) return integer is + variable x, y : integer; + begin + x := a; + y := b; + if ((x = 0) and (y = 0)) then + return 0; + end if; + while (x /= y) loop + if (x >= y) then + x := x - y; + else + y := y - x; + end if; + end loop; + return x; + end gcditer; + + function mediant (a, b : rational) return rational is + variable r : rational; + variable tn, td : integer; + begin + tn := a(numer) + b(numer); + td := a(denom) + b(denom); + if ( gcditer(abs(tn), abs(td)) > 0 ) then + r(numer) := tn / gcditer(abs(tn), abs(td)); + r(denom) := td / gcditer(abs(tn), abs(td)); + else + r(numer) := tn; + r(denom) := td; + end if; + return r; + end mediant; + +end ratpack;
trunk/rtl/vhdl/ratpack.vhd Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/rtl/vhdl/ratalu.vhd =================================================================== --- trunk/rtl/vhdl/ratalu.vhd (nonexistent) +++ trunk/rtl/vhdl/ratalu.vhd (revision 5) @@ -0,0 +1,83 @@ +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.std_logic_unsigned.all; +use WORK.ratpack.all; + +entity ratalu is + port ( + a : in rational; + b : in rational; + sel : in std_logic_vector(4 downto 0); + y : out rational + ); +end ratalu; + +architecture rtl of ratalu is + signal temp : rational; + constant OP_ADD : std_logic_vector(4 downto 0) := "00000"; + constant OP_SUB : std_logic_vector(4 downto 0) := "00001"; + constant OP_MUL : std_logic_vector(4 downto 0) := "00010"; + constant OP_DIV : std_logic_vector(4 downto 0) := "00011"; + constant OP_ABS : std_logic_vector(4 downto 0) := "00100"; + constant OP_MAX : std_logic_vector(4 downto 0) := "00101"; + constant OP_MIN : std_logic_vector(4 downto 0) := "00110"; + constant OP_CGT : std_logic_vector(4 downto 0) := "00111"; + constant OP_CLT : std_logic_vector(4 downto 0) := "01000"; + constant OP_CGE : std_logic_vector(4 downto 0) := "01001"; + constant OP_CLE : std_logic_vector(4 downto 0) := "01010"; + constant OP_CEQ : std_logic_vector(4 downto 0) := "01011"; + constant OP_CNE : std_logic_vector(4 downto 0) := "01100"; + constant OP_MED : std_logic_vector(4 downto 0) := "01101"; +begin + process (a, b, sel) + begin + case sel is + when OP_ADD => temp <= a + b; + when OP_SUB => temp <= a - b; + when OP_MUL => temp <= a * b; + when OP_DIV => temp <= a / b; + when OP_ABS => temp <= a abs b; + when OP_MAX => temp <= a max b; + when OP_MIN => temp <= a min b; + when OP_CGT => + if (a > b) then + temp <= RAT_ONE; + else + temp <= RAT_ZERO; + end if; + when OP_CLT => + if (a < b) then + temp <= RAT_ONE; + else + temp <= RAT_ZERO; + end if; + when OP_CGE => + if (a >= b) then + temp <= RAT_ONE; + else + temp <= RAT_ZERO; + end if; + when OP_CLE => + if (a <= b) then + temp <= RAT_ONE; + else + temp <= RAT_ZERO; + end if; + when OP_CEQ => + if (a = b) then + temp <= RAT_ONE; + else + temp <= RAT_ZERO; + end if; + when OP_CNE => + if (a /= b) then + temp <= RAT_ONE; + else + temp <= RAT_ZERO; + end if; + when OP_MED => temp <= mediant(a, b); + when others => temp <= RAT_ZERO; + end case; + end process; + y <= temp; +end rtl;
trunk/rtl/vhdl/ratalu.vhd Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/README.html =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/xml Index: trunk/doc/README.html =================================================================== --- trunk/doc/README.html (nonexistent) +++ trunk/doc/README.html (revision 5)
trunk/doc/README.html Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Index: trunk/doc/BUGS =================================================================== --- trunk/doc/BUGS (nonexistent) +++ trunk/doc/BUGS (revision 5) @@ -0,0 +1,11 @@ +ratpack BUGS -- known bugs. Last updated: 2014-02-21 + +Known bugs in ratpack +--------------------- + + ** + - + - + + +BUGS ends here.
trunk/doc/BUGS Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/TODO =================================================================== --- trunk/doc/TODO (nonexistent) +++ trunk/doc/TODO (revision 5) @@ -0,0 +1,8 @@ +ratpack --- TODO + +Todo: + + * . + + +end of file TODO
trunk/doc/TODO Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/README.pdf =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/pdf Index: trunk/doc/README.pdf =================================================================== --- trunk/doc/README.pdf (nonexistent) +++ trunk/doc/README.pdf (revision 5)
trunk/doc/README.pdf Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/pdf \ No newline at end of property Index: trunk/doc/VERSION =================================================================== --- trunk/doc/VERSION (nonexistent) +++ trunk/doc/VERSION (revision 5) @@ -0,0 +1 @@ +0.2.0
trunk/doc/VERSION Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/AUTHORS =================================================================== --- trunk/doc/AUTHORS (nonexistent) +++ trunk/doc/AUTHORS (revision 5) @@ -0,0 +1,5 @@ +Authors of ratpack. + +ratpack Nikolaos Kavvadias + +AUTHORS ends here
trunk/doc/AUTHORS Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog (nonexistent) +++ trunk/doc/ChangeLog (revision 5) @@ -0,0 +1,19 @@ +ChangeLog starts here + +2014-02-21 Nikolaos Kavvadias + + * Release 0.2.0 with documentation updates. + +2010-11-17 Nikolaos Kavvadias + + * Minor releases 0.1.2 and 0.1.3. + +2010-06-07 Nikolaos Kavvadias + + * Minor release 0.1.1. + +2010-05-14 Nikolaos Kavvadias + + * Release 0.1. + +ChangeLog ends here
trunk/doc/ChangeLog Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/THANKS =================================================================== --- trunk/doc/THANKS (nonexistent) +++ trunk/doc/THANKS (revision 5) @@ -0,0 +1,7 @@ +Thanks to: + + This is just a placeholder. + + +Lamia, Greece, 2014-02-21 +
trunk/doc/THANKS Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/COPYING =================================================================== --- trunk/doc/COPYING (nonexistent) +++ trunk/doc/COPYING (revision 5) @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library.
trunk/doc/COPYING Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/rst2docs.sh =================================================================== --- trunk/doc/rst2docs.sh (nonexistent) +++ trunk/doc/rst2docs.sh (revision 5) @@ -0,0 +1,13 @@ +#!/bin/bash + +#DOCUTILS_PATH="/usr/local/bin/docutils/tools" +#DOCUTILS_PATH="/cygdrive/c/docutils-0.11/tools" +#DOCUTILS_PATH="/usr/local/bin/docutils/tools" +DOCUTILS_PATH="/c/docutils-0.11/tools" + +${DOCUTILS_PATH}/rst2html.py <$1 >$1.html +${DOCUTILS_PATH}/rst2latex.py <$1 >$1.tex +pdflatex --shell-escape $1.tex +rm -rf $1.aux $1.log $1.out $1.tex + +exit 0
trunk/doc/rst2docs.sh Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/doc/README =================================================================== --- trunk/doc/README (nonexistent) +++ trunk/doc/README (revision 5) @@ -0,0 +1,187 @@ +===================== + ratpack user manual +===================== + ++-------------------+----------------------------------------------------------+ +| **Title** | ratpack (VHDL rational arithmetic package). | ++-------------------+----------------------------------------------------------+ +| **Author** | Nikolaos Kavvadias 2009, 2010, 2011, 2012, 2013, 2014 | ++-------------------+----------------------------------------------------------+ +| **Contact** | nikos@nkavvadias.com | ++-------------------+----------------------------------------------------------+ +| **Website** | http://www.nkavvadias.com | ++-------------------+----------------------------------------------------------+ +| **Release Date** | 21 February 2014 | ++-------------------+----------------------------------------------------------+ +| **Version** | 0.2.0 | ++-------------------+----------------------------------------------------------+ +| **Rev. history** | | ++-------------------+----------------------------------------------------------+ +| **v0.2.0** | 2014-02-21 | +| | | +| | Changed documentation format to RestructuredText. | +| | Code has been reorganized into new directory structure. | ++-------------------+----------------------------------------------------------+ +| **v0.1.3** | 2010-11-17 | +| | | +| | Added max, min. | ++-------------------+----------------------------------------------------------+ +| **v0.1.2** | 2010-11-17 | +| | | +| | Added gcditer (iterative GCD using rational numbers). | ++-------------------+----------------------------------------------------------+ +| **v0.1.1** | 2010-06-07 | +| | | +| | Minor update in documentation (README). | ++-------------------+----------------------------------------------------------+ +| **v0.1.0** | 2010-05-14 | +| | | +| | First public release. | ++-------------------+----------------------------------------------------------+ + + +1. Introduction +=============== + +``ratpack`` is a rational arithmetic package written in VHDL. + +Currently, the ``ratpack`` package implements the following: + +- the RATIONAL data type. + +- to_rational: + construction function of a rational given two integers + (numerator and denominator). + +- int2rat: + conversion function of an integer to its rational representation. + +- numerator: + extracts the numerator of a rational number. + +- denominator: + extracts the denominator of a rational number. + +- ``"+"``, ``"-"``, ``"*"``, ``"/"``: + implementation of the basic arithmetic operations for rationals. + +- abs: + extracts the absolute value of a given rational number. + +- max: + extracts the maximum of two rationals. + +- min: + extracts the minimum of two rationals. + +- ``">"``, ``"<"``, ``">="``, ``"<="``, ``"="``, ``"/="``: + overload comparison operators for rationals. + +- gcd: + computes the greatest common divisor of two integers (positive, + covers the pathological case of division by zero). + +- mediant: + computes the mediant rational of two given rationals. + +``ratpack`` is distributed along with two VHDL testbenches: a simple one +(``ratpack_tb1.vhd``) and a testbench generating the Farey series of orders +1 to 12 (``ratpack_tb2.vhd``). An exemplary rational arithmetic ALU has also +been included but it is currently left untested (not testbench for it). + +The ``ratpack`` project can be download from the following OpenCores website: +http://opencores.org/project,ratpack + + +2. File listing +=============== + +The ``ratpack`` distribution includes the following files: + ++-----------------------+------------------------------------------------------+ +| /ratpack | Top-level directory | ++-----------------------+------------------------------------------------------+ +| /bench/vhdl | Benchmarks VHDL directory | ++-----------------------+------------------------------------------------------+ +| ratpack_tb1.vhd | A simple testbench. | ++-----------------------+------------------------------------------------------+ +| ratpack_tb2.vhd | Testbench generating the Farey series (orders 1-12). | ++-----------------------+------------------------------------------------------+ +| /doc | Documentation directory | ++-----------------------+------------------------------------------------------+ +| AUTHORS | List of ``ratpack`` authors. | ++-----------------------+------------------------------------------------------+ +| BUGS | Bug list. | ++-----------------------+------------------------------------------------------+ +| ChangeLog | A log for code changes. | ++-----------------------+------------------------------------------------------+ +| COPYING | The LGPL, version 3, governs ``ratpack``. | ++-----------------------+------------------------------------------------------+ +| README | This file. | ++-----------------------+------------------------------------------------------+ +| README.html | HTML version of README. | ++-----------------------+------------------------------------------------------+ +| README.pdf | PDF version of README. | ++-----------------------+------------------------------------------------------+ +| rst2docs.sh | Bash script for generating the HTML and PDF versions.| ++-----------------------+------------------------------------------------------+ +| THANKS | Acknowledgements. | ++-----------------------+------------------------------------------------------+ +| TODO | A list of future enhancements. | ++-----------------------+------------------------------------------------------+ +| VERSION | Current version of the project sources. | ++-----------------------+------------------------------------------------------+ +| /rtl/vhdl | RTL source code directory for the package | ++-----------------------+------------------------------------------------------+ +| ratalu.vhd | Implementation of a rational arithmetic ALU. | ++-----------------------+------------------------------------------------------+ +| ratpack.vhd | The rational arithmetic package. | ++-----------------------+------------------------------------------------------+ +| /sim/rtl_sim | RTL simulation files directory | ++-----------------------+------------------------------------------------------+ +| /sim/rtl_sim/out | RTL simulation output files directory | ++-----------------------+------------------------------------------------------+ +| ratpack_results1.txt | Output generated by the ``ratpack_tb1.vhd`` tests. | ++-----------------------+------------------------------------------------------+ +| ratpack_results2.txt | Output generated by the ``ratpack_tb2.vhd`` tests. | ++-----------------------+------------------------------------------------------+ +| /sim/rtl_sim/run | RTL simulation run scripts directory | ++-----------------------+------------------------------------------------------+ +| ratpack.mk | GNU Makefile for running GHDL simulations. | ++-----------------------+------------------------------------------------------+ +| run.sh | A bash script for running the GNU Makefile for GHDL. | ++-----------------------+------------------------------------------------------+ + + +3. ``ratpack`` usage +==================== + +The ``ratpack`` package test script can be used as follows: + +| ``$./run.sh `` + +After this process, the ``ratpack_results.txt`` file is generated containing +simulation results. + +Here follow some simple usage examples of this bash script. + +1. Compile the ``ratpack`` package and do a simple test. + +| ``$ ./run.sh ratpack 1`` + +2. Compile the ``ratpack`` package and generate the Farey series. + +| ``$ ./run.sh ratpack 2`` + + +4. Prerequisities +================= + +- Standard UNIX-based tools (tested on cygwin/x86) + + * make + * bash + +- GHDL simulator (http://ghdl.free.fr) + + Provides the "ghdl" executable and corresponding simulation environment.
trunk/doc/README Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/sim/rtl_sim/out/ratpack_results1.txt =================================================================== --- trunk/sim/rtl_sim/out/ratpack_results1.txt (nonexistent) +++ trunk/sim/rtl_sim/out/ratpack_results1.txt (revision 5) @@ -0,0 +1,195 @@ +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15 +5/12 + 2/3 = 13/12 +5/12 - 2/3 = -1/4 +5/12 * 2/3 = 5/18 +5/12 : 2/3 = 5/8 +mediant(5/12 , 2/3) = 7/15
trunk/sim/rtl_sim/out/ratpack_results1.txt Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/sim/rtl_sim/out/ratpack_results2.txt =================================================================== --- trunk/sim/rtl_sim/out/ratpack_results2.txt (nonexistent) +++ trunk/sim/rtl_sim/out/ratpack_results2.txt (revision 5) @@ -0,0 +1,12 @@ + F1= 0/1 + F2= 0/1 1/2 1/1 + F3= 0/1 1/3 1/2 2/3 1/1 + F4= 0/1 1/4 1/3 1/2 2/3 3/4 1/1 + F5= 0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1 + F6= 0/1 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1/1 + F7= 0/1 1/7 1/6 1/5 1/4 2/7 1/3 2/5 3/7 1/2 4/7 3/5 2/3 5/7 3/4 4/5 5/6 6/7 1/1 + F8= 0/1 1/8 1/7 1/6 1/5 1/4 2/7 1/3 3/8 2/5 3/7 1/2 4/7 3/5 5/8 2/3 5/7 3/4 4/5 5/6 6/7 7/8 1/1 + F9= 0/1 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 1/1 + F10= 0/1 1/10 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 3/10 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 7/10 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 9/10 1/1 + F11= 0/1 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 3/7 4/9 5/11 1/2 6/11 5/9 4/7 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 1/1 + F12= 0/1 1/12 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 5/12 3/7 4/9 5/11 1/2 6/11 5/9 4/7 7/12 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 11/12 1/1
trunk/sim/rtl_sim/out/ratpack_results2.txt Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.