Initial import
git-svn-id: http://moon:8086/svn/vhdl/trunk@5 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
---- $Id: CHANGES,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
|
||||
Changes from version 1.16 to version 2002.07
|
||||
============================================
|
||||
|
||||
PCK_FIO is now distributed under the GNU Lesser General Public Licencse
|
||||
instead of the ordinary GPL, to better reflect intended usage.
|
||||
|
||||
Cosmetic changes in source code to correct some typos in the testbench output.
|
||||
A new testbench is also supplied.
|
||||
|
||||
The package now uses IEEE.numeric_std as default.
|
||||
|
||||
URL http://www.easics.com has been made part of address.
|
||||
|
||||
Changed syntax in the PCK_FIO package and its testbench to support VHDL-1993.
|
||||
Because of backwards-incompatibility, it has been necessary to supply
|
||||
different sets of files for 1987 and 1993.
|
||||
|
||||
Split the packages into a separate file for the header and a
|
||||
separate file for the body (in compliance with Easics' guidelines).
|
||||
|
||||
These changes resulted in the files:
|
||||
|
||||
Files for VHDL-1993:
|
||||
--------------------
|
||||
PCK_FIO_1993.vhd : the source code of the header file for the package
|
||||
PCK_FIO_1993_BODY.vhd: the source code of the body of the package
|
||||
TB_PCK_FIO_1993.vhd: the testbench for the package
|
||||
|
||||
Files for VHDL-1987:
|
||||
--------------------
|
||||
PCK_FIO_1987.vhd: the source code of the header file for the package
|
||||
PCK_FIO_1987_BODY.vhd: the source code of the body of the package
|
||||
TB_PCK_FIO_1987.vhd: the testbench for the package
|
||||
|
||||
Updated README and PCK_FIO.html to support these changes.
|
||||
|
||||
Adapted package files to support NUL termination of strings.
|
||||
fo(Arg: string) now prints the string until the first NUL.
|
||||
Several examples of its use are demonstrated in the supplied testbenches.
|
||||
|
||||
Made cosmetic changes to code to improve readability.
|
||||
|
||||
Acknowledgment
|
||||
--------------
|
||||
These changes have been implemented by Peter Geens.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.4.13 i686) [Netscape]">
|
||||
<title>VHDL package for formatted file output</title>
|
||||
<!-- $Id: PCK_FIO.html,v 1.1 2008-08-23 08:20:28 Jens Exp $ -->
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_name_0"></a>Name</h1>
|
||||
<b>PCK_FIO</b> - VHDL package for formatted file output
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
Contents</h1>
|
||||
<a href="#PCK_FIO_usage_0">Usage</a>
|
||||
<br><a href="#PCK_FIO_file_0">The file output function 'fo'</a>
|
||||
<br><a href="#PCK_FIO_format_0">Format specifiers</a>
|
||||
<br><a href="#PCK_FIO_special_0">Special characters</a>
|
||||
<br><a href="#PCK_FIO_things_0">Things to watch out for</a>
|
||||
<br><a href="#PCK_FIO_methodology_0">Methodology notes</a>
|
||||
<br><a href="#PCK_FIO_parametrization_0">Parametrization</a>
|
||||
<br><a href="#PCK_FIO_test_0">Test bench</a>
|
||||
<br><a href="#PCK_FIO_limitations_0">Known limitations and problems</a>
|
||||
<br><a href="#PCK_FIO_author_0">Author</a>
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_usage_0"></a>Usage</h1>
|
||||
PCK_FIO is a VHDL package that defines <tt>fprint, </tt>a function
|
||||
for formatted file output.
|
||||
<p>After installing the package you can call <tt>fprint</tt> as follows:
|
||||
<pre> fprint(F, L, Format, fo(Expr_1), fo(Expr_2), ... fo(Expr_n));</pre>
|
||||
where F is the filehandle and L is the line variable.
|
||||
<p>The argument Format is the format string, which consists of ``normal''
|
||||
substrings which are copied verbatim, and format specifiers, starting with
|
||||
<tt>'%'</tt>.
|
||||
A typical format string looks as follows:
|
||||
<pre> "Arg1 = %6r, Arg2 = %10d, Arg3 = %-5r\n"</pre>
|
||||
The remaining arguments are the expressions whose results you want to write
|
||||
to the file, embedded in <tt>fo</tt> function calls. There can be 0 to
|
||||
32 of such arguments. The expressions can be of any type for which an <tt>fo</tt>
|
||||
function exists. String expressions can also be called directly.
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_file_0"></a>The file output function <tt>'fo'</tt></h1>
|
||||
The <tt>fo</tt> (<u>f</u>ile <u>o</u>utput) functions do the trick. They
|
||||
return a tagged string representation that is meaningful to format specifiers.
|
||||
Here are some examples:
|
||||
<pre> fo (signed'("1100")) returns "S:1100"
|
||||
fo (unsigned'("1100")) returns "U:1100"
|
||||
fo (TRUE) returns "L:T"
|
||||
fo (127) returns "I:127"</pre>
|
||||
The internal behavior of <tt>fo</tt> is irrelevant to the typical user.
|
||||
<br>
|
||||
<pre>The <tt>fo</tt> function is currently overloaded as follows:</pre>
|
||||
|
||||
<pre> function fo (Arg: unsigned) return string;
|
||||
function fo (Arg: signed) return string;
|
||||
function fo (Arg: std_logic_vector) return string;
|
||||
function fo (Arg: std_ulogic_vector) return string;
|
||||
function fo (Arg: bit_vector) return string;
|
||||
function fo (Arg: integer) return string;
|
||||
function fo (Arg: std_ulogic) return string;
|
||||
function fo (Arg: bit) return string;
|
||||
function fo (Arg: boolean) return string;
|
||||
function fo (Arg: character) return string;
|
||||
function fo (Arg: string) return string;
|
||||
function fo (Arg: time) return string;</pre>
|
||||
|
||||
<p><br>To support null-terminated strings, the function <tt>fo</tt>(Arg:
|
||||
string) processes <tt>Arg</tt> up to the first <tt>NUL</tt> character,
|
||||
if any. If you want the whole string to be outputted you can just enter
|
||||
the string as a direct argument in <tt>fprint</tt>. See also the
|
||||
examples in the testbench.
|
||||
<pre>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%"></pre>
|
||||
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_format_0"></a>Format specifiers</h1>
|
||||
The general format of a format specifier is:
|
||||
<pre> %[-][n]c</pre>
|
||||
The optional <b>-</b> sign specifies left justified output; default is
|
||||
right justified.
|
||||
<p>The optional number <b>n</b> specifies a field-width. If it is not specified,
|
||||
<tt>fprint</tt>
|
||||
does something reasonable.
|
||||
<p><b>c</b> is the conversion specifier. Currently the following conversion
|
||||
specifiers are supported:
|
||||
<dl COMPACT>
|
||||
<dt>
|
||||
<a NAME="PCK_FIO_r_0"></a><b>r</b></dt>
|
||||
|
||||
<dd>
|
||||
reasonable output format (inspired by Synopsys VSS)</dd>
|
||||
|
||||
<dl COMPACT>Prints the ``most reasonable'' representation e.g. hex for
|
||||
unsigned, signed and other bit-like vectors (not preferred for integers)</dl>
|
||||
|
||||
<dt>
|
||||
<a NAME="PCK_FIO_b_0"></a><b>b</b></dt>
|
||||
|
||||
<dd>
|
||||
bit-oriented output</dd>
|
||||
|
||||
<dt>
|
||||
<a NAME="PCK_FIO_d_0"></a><b>d</b></dt>
|
||||
|
||||
<dd>
|
||||
decimal output</dd>
|
||||
|
||||
<dt>
|
||||
<a NAME="PCK_FIO_s_0"></a><b>s</b></dt>
|
||||
|
||||
<dd>
|
||||
string output (e.g. in combination with 'IMAGE for enum types)</dd>
|
||||
|
||||
<dt>
|
||||
<a NAME="PCK_FIO_q_0"></a><b>q</b></dt>
|
||||
|
||||
<dd>
|
||||
``qualified'' string output (shows internal representation from <tt>fo</tt>)</dd>
|
||||
|
||||
<dt>
|
||||
<a NAME="PCK_FIO__0"></a><b>{}</b></dt>
|
||||
|
||||
<dd>
|
||||
Iteration operator, used as follows:</dd>
|
||||
|
||||
<dd>
|
||||
<tt>%n{<format-string>}</tt></dd>
|
||||
|
||||
<br>In this case, <b>n</b> is the iteration count and is mandatory. Iteration
|
||||
can be nested.</dl>
|
||||
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_special_0"></a>Special characters</h1>
|
||||
To print a double quote, use <tt>'""'</tt> in the format string (VHDL
|
||||
convention). To print the special characters, <tt>'\'</tt>, and <tt>'%'</tt>,
|
||||
escape them with <tt>'\'</tt>. To prevent <tt>'{'</tt> and <tt>'}'</tt>
|
||||
from being interpreted as opening and closing brackets in iteration strings,
|
||||
escape them with <tt>'\'</tt>.
|
||||
<p>A newline is specified in the format string by <tt>'\n'</tt>.
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_things_0"></a>Things to notice</h1>
|
||||
The fprint function expands into VHDL <tt>write</tt> and <tt>writeline</tt>
|
||||
commands. As in plain VHDL, nothing will be written to the output file
|
||||
until a <tt>writeline</tt> is given. Therefore, don't forget to include
|
||||
<tt>'\n'</tt>
|
||||
commands in the format string, or it ``will not work''.
|
||||
<p>The preferred format specifier for integers is, naturally, <b>%d</b>.
|
||||
This calls the VHDL <tt>write</tt> for integers. If you specify a field
|
||||
width that is too small, the field will automatically be expanded. If you
|
||||
use <b>%r</b> for integers, the field is not expanded automatically, which
|
||||
means that some digits are simply thrown away. This may sometimes be useful
|
||||
but it is also dangerous. Look at the test bench output for differences
|
||||
between <b>%d</b> and <b>%r</b> output.
|
||||
<p>When using the <b>%d</b> format specifier, the VHDL constraints for
|
||||
the allowed integer range apply.
|
||||
<p>In VHDL, signed/unsigned types have been standardized only relatively
|
||||
recently, in the package <tt>IEEE.numeric_std</tt>. The lack of a standard
|
||||
has caused (and is causing) portability issues. The most popular non-standard
|
||||
package that defines signed/unsigned is <tt>IEEE.std_logic_arith</tt> from
|
||||
Synopsys. PCK_FIO works with both packages, but refers to the standard
|
||||
package <tt>IEEE.numeric_std</tt> by default. To use <tt>IEEE.std_logic_arith</tt>
|
||||
instead, replace the reference to <tt>IEEE.numeric_std</tt> in the source
|
||||
code. This needs to be done consistently in a design database (e.g.
|
||||
in the PCK_FIO test bench as well).
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_methodology_0"></a>Methodology notes</h1>
|
||||
The obvious application for <tt>fprint</tt> is in test benches, to produce
|
||||
output files that trace the simulation behavior.
|
||||
<p>Another interesting application for <tt>fprint</tt> is to produce info,
|
||||
warning and error messages in your models. As it can take arguments, <tt>fprint</tt>
|
||||
is much better suited for this task than VHDL's <tt>assert</tt> or <tt>report</tt>
|
||||
statements. Actually <tt>fprint</tt> produces its own (few) warning messages.
|
||||
<p>An advanced usage is the generation of test vectors in a specific format.
|
||||
Instead of using the <tt>fo </tt>functions, you can write your own set
|
||||
of functions that return the symbols of a specific test format in a way
|
||||
that is understandable to the <tt>fprint</tt> format specifiers. As an
|
||||
example, when a high output value should be represented using the symbol
|
||||
'H' it suffices to write a conversion function that returns "B:H" and call
|
||||
it in combination with the <b>%b</b> format specifier.
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_parametrization_0"></a>Parametrization</h1>
|
||||
Prefix and postfix strings for bit-oriented and hex-oriented output are
|
||||
parameterizable in the packages to accommodate different output styles.
|
||||
The settings in the distribution are such that hex output is indicated
|
||||
by the prefix '0x', while bit output prefix and postfix are empty
|
||||
strings.
|
||||
<p>You can adapt the output style by modifying the following constants
|
||||
in the package header:
|
||||
<p> <tt> -- prefix string for hex output</tt>
|
||||
<br><tt> -- VHDL style: "X"""</tt>
|
||||
<br><tt> -- Verilog style: "h'"</tt>
|
||||
<br><tt> -- C style: "0x"</tt>
|
||||
<br><tt> constant FIO_h_PRE: string := "0x";</tt>
|
||||
<p><tt> -- postfix string for hex output</tt>
|
||||
<br><tt> -- VHDL style: """"</tt>
|
||||
<br><tt> constant FIO_h_POST: string := "";</tt>
|
||||
<p><tt> -- prefix string for bit vector output</tt>
|
||||
<br><tt> -- VHDL style: "B"""</tt>
|
||||
<br><tt> -- Verilog style: "b'"</tt>
|
||||
<br><tt> constant FIO_bv_PRE: string := "";</tt>
|
||||
<p><tt> -- postfix string for bit vector output</tt>
|
||||
<br><tt> -- VHDL style: """"</tt>
|
||||
<br><tt> constant FIO_bv_POST: string := "";</tt>
|
||||
<p><tt> -- prefix string for bit output</tt>
|
||||
<br><tt> -- VHDL style: "'"</tt>
|
||||
<br><tt> -- Verilog style: "b'"</tt>
|
||||
<br><tt> constant FIO_b_PRE: string := "";</tt>
|
||||
<p><tt> -- postfix string for bit output</tt>
|
||||
<br><tt> -- VHDL style: "'"</tt>
|
||||
<br><tt> constant FIO_b_POST: string := "";</tt>
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_test_0"></a>Test bench</h1>
|
||||
Included in the distribution are the files <tt>TB_PCK_FIO_1987.vhd and
|
||||
TB_PCK_FIO_1993</tt> with a test bench,depending on the standard you're
|
||||
running, for the PCK_FIO package. The file <tt>PCK_FIO.out.gold </tt>contains
|
||||
the expected output. If you run the test bench it should produce the file
|
||||
<tt>PCK_FIO.out</tt>
|
||||
that should be identical to <tt>PCK_FIO.out.gold</tt>. The source files
|
||||
should be analyzed in a VHDL library <tt>EASICS_PACKAGES</tt>.
|
||||
<p>A good way to understand <tt>fprint</tt> is to inspect the test bench
|
||||
and what it produces.
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_limitations_0"></a>Known limitations and problems</h1>
|
||||
This VHDL package is an implementation of a flexible concept. It is likely
|
||||
to be extended and modified in the future. Backward compatibility is not
|
||||
guaranteed. Therefore, it is not recommended to give this package the status
|
||||
of a company wide standard package (or even worse, a VHDL standard package).
|
||||
Rather, it should be linked with a particular project (and it can be regarded
|
||||
as a standard package within that project).
|
||||
<p>PCK_FIO is available in either standard VHDL Std1076-1987 or standard
|
||||
VHDL Std1076-1993. Nevertheless, some simulators/versions have problems
|
||||
with the package. The following is an overview of currently known issues:
|
||||
<br>
|
||||
<center><table BORDER COLS=2 WIDTH="80%" NOSAVE >
|
||||
<caption>PCK_FIO_1987 and various simulators/versions</caption>
|
||||
|
||||
<tr>
|
||||
<th>Simulator</th>
|
||||
|
||||
<th>PCK_FIO_1987</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Synopsys VSS 3.5 and earlier</td>
|
||||
|
||||
<td>Incorrect (all zero) output in compiled mode</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Synopsys VSS 97.01</td>
|
||||
|
||||
<td>OK</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Synopsys VSS/Scirocco 2000.02</td>
|
||||
|
||||
<td>Incorrect output in compiled mode, interpreted mode works</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Mentor quickhdl</td>
|
||||
|
||||
<td>OK</td>
|
||||
</tr>
|
||||
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE>Modeltech modelsim</td>
|
||||
|
||||
<td>OK</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Cadence Leapfrog</td>
|
||||
|
||||
<td>Should work with 4.4.1
|
||||
<br>Mysterious problems have been reported - please run the test bench
|
||||
and report problems</td>
|
||||
</tr>
|
||||
</table></center>
|
||||
|
||||
<br>
|
||||
<center><table BORDER COLS=2 WIDTH="80%" NOSAVE >
|
||||
<caption>PCK_FIO_1993 and various simulators/versions</caption>
|
||||
|
||||
<tr NOSAVE>
|
||||
<th NOSAVE>Simulator</th>
|
||||
|
||||
<th NOSAVE>PCK_FIO_1993</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Synopsys VSS/Scirocco 2000.02</td>
|
||||
|
||||
<td>Compile errors due to improper handling of files by Synopsys</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Synopsys VSS/Scirocco 2000.06</td>
|
||||
|
||||
<td>works fine</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Modeltech modelsim 5.4c and higher</td>
|
||||
|
||||
<td>OK</td>
|
||||
</tr>
|
||||
</table></center>
|
||||
|
||||
<p>Although the package name suggests file IO, it only does file output.
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="PCK_FIO_author_0"></a>Author</h1>
|
||||
<a href="mailto:jand@easics.be">Jan Decaluwe</a>
|
||||
<p>
|
||||
<hr SIZE=1 NOSHADE WIDTH="100%">
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
---- $Id: PCK_FIO_1987.vhd,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
use STD.TEXTIO.all;
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
-- signed/unsigned definition: use either std_logic_arith or numeric_std
|
||||
-- use IEEE.std_logic_arith.all; -- the Synopsys one
|
||||
use IEEE.numeric_std.all;
|
||||
|
||||
package PCK_FIO is
|
||||
|
||||
-- prefix string for hex output
|
||||
-- VHDL style: "X"""
|
||||
-- Verilog style: "h'"
|
||||
-- C style: "0x"
|
||||
constant FIO_h_PRE: string := "0x";
|
||||
|
||||
-- postfix string for hex output
|
||||
-- VHDL style: """"
|
||||
constant FIO_h_POST: string := "";
|
||||
|
||||
-- prefix string for bit vector output
|
||||
-- VHDL style: "B"""
|
||||
-- Verilog style: "b'"
|
||||
constant FIO_bv_PRE: string := "";
|
||||
|
||||
-- postfix string for bit vector output
|
||||
-- VHDL style: """"
|
||||
constant FIO_bv_POST: string := "";
|
||||
|
||||
-- prefix string for bit output
|
||||
-- VHDL style: "'"
|
||||
-- Verilog style: "b'"
|
||||
constant FIO_b_PRE: string := "";
|
||||
|
||||
-- postfix string for bit output
|
||||
-- VHDL style: "'"
|
||||
constant FIO_b_POST: string := "";
|
||||
|
||||
-- digit width for the string representation of integers
|
||||
constant FIO_d_WIDTH: integer := 10;
|
||||
|
||||
-- bit width for the string representation of integers
|
||||
constant FIO_b_WIDTH: integer := 32;
|
||||
|
||||
-- definition of the NIL string (default value for fprint arguments)
|
||||
-- fprint stops consuming arguments at the first NIL argument
|
||||
constant FIO_NIL: string := "\";
|
||||
|
||||
|
||||
procedure fprint
|
||||
(F: out text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 : in string := FIO_NIL;
|
||||
A9 , A10, A11, A12, A13, A14, A15, A16: in string := FIO_NIL;
|
||||
A17, A18, A19, A20, A21, A22, A23, A24: in string := FIO_NIL;
|
||||
A25, A26, A27, A28, A29, A30, A31, A32: in string := FIO_NIL
|
||||
);
|
||||
|
||||
function fo (Arg: unsigned) return string;
|
||||
function fo (Arg: signed) return string;
|
||||
function fo (Arg: std_logic_vector) return string;
|
||||
function fo (Arg: std_ulogic_vector) return string;
|
||||
function fo (Arg: bit_vector) return string;
|
||||
function fo (Arg: integer) return string;
|
||||
function fo (Arg: std_ulogic) return string;
|
||||
function fo (Arg: bit) return string;
|
||||
function fo (Arg: boolean) return string;
|
||||
function fo (Arg: character) return string;
|
||||
function fo (Arg: string) return string;
|
||||
function fo (Arg: time) return string;
|
||||
|
||||
procedure FIO_FormatExpand (FMT: inout line;
|
||||
Format: in string;
|
||||
StartPointer: in positive);
|
||||
|
||||
end PCK_FIO;
|
||||
|
||||
@@ -0,0 +1,821 @@
|
||||
---- $Id: PCK_FIO_1987_BODY.vhd,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
|
||||
package body PCK_FIO is
|
||||
|
||||
--------------------------
|
||||
-- FIO Warnings support --
|
||||
--------------------------
|
||||
|
||||
procedure FIO_Warning_Fsbla (F: out text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: in positive) is
|
||||
begin
|
||||
fprint (F, L, "\n** Warning: FIO_PrintLastValue: " &
|
||||
"Format specifier beyond last argument\n");
|
||||
fprint (F, L, "** in format string: ""%s""\n", Format);
|
||||
fprint (F, L, "** ");
|
||||
for i in 1 to Pointer-1 loop
|
||||
fprint (F, L, "-");
|
||||
end loop;
|
||||
fprint (F, L, "^\n");
|
||||
end FIO_Warning_Fsbla;
|
||||
|
||||
procedure FIO_Warning_Ufs (F: out text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: in positive;
|
||||
Char: in character) is
|
||||
begin
|
||||
fprint (F, L, "\n** Warning: FIO_PrintArg: " &
|
||||
"Unexpected format specifier '%r'\n",
|
||||
fo(Char));
|
||||
fprint (F, L, "** in format string: ""%s""\n", Format) ;
|
||||
fprint (F, L, "** ");
|
||||
for i in 1 to Pointer-1 loop
|
||||
fprint (F, L, "-");
|
||||
end loop;
|
||||
fprint (F, L, "^\n** Assuming 'q' to proceed: ");
|
||||
end FIO_Warning_Ufs;
|
||||
|
||||
|
||||
----------------------------------
|
||||
-- bit conversion support --
|
||||
----------------------------------
|
||||
|
||||
type T_bit_map is array(bit) of character;
|
||||
|
||||
constant C_BIT_MAP: T_bit_map
|
||||
:= ('0', '1');
|
||||
|
||||
----------------------------------
|
||||
-- std_logic conversion support --
|
||||
----------------------------------
|
||||
|
||||
type T_std_logic_map is array(std_ulogic) of character;
|
||||
|
||||
constant C_STD_LOGIC_MAP: T_std_logic_map
|
||||
:= ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-');
|
||||
|
||||
------------------------------
|
||||
-- Digit conversion support --
|
||||
------------------------------
|
||||
|
||||
-- types & constants
|
||||
|
||||
subtype S_digit_chars is character range '0' to '9';
|
||||
subtype S_digits is integer range 0 to 9 ;
|
||||
|
||||
type T_digit_chars_map is array(S_digit_chars) of S_digits;
|
||||
|
||||
constant C_DIGIT_CHARS_MAP: T_digit_chars_map
|
||||
:= (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
|
||||
type T_digits_map is array(S_digits) of S_digit_chars;
|
||||
|
||||
constant C_DIGITS_MAP: T_digits_map
|
||||
:= ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
|
||||
|
||||
|
||||
--------------------------------
|
||||
-- Decimal conversion support --
|
||||
--------------------------------
|
||||
|
||||
-- unsigned to decimal
|
||||
|
||||
function U_To_d (Arg: string) return integer is
|
||||
constant Argument: string(Arg'length downto 1) := Arg;
|
||||
variable Result: integer := 0;
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
case Argument(i) is when '1' => Result := 2**(i-1) + Result;
|
||||
when '0' => null;
|
||||
when others => return(-1);
|
||||
end case;
|
||||
end loop;
|
||||
return (Result);
|
||||
end U_To_d;
|
||||
|
||||
-- signed to decimal
|
||||
|
||||
function S_To_d (Arg: string) return integer is
|
||||
constant Argument: string(Arg'length downto 1) := Arg;
|
||||
variable Result: integer := 0;
|
||||
begin
|
||||
case Argument(Argument'left) is
|
||||
when '1' => Result := - 2**(Argument'left-1);
|
||||
when '0' => Result := 0;
|
||||
when others => return (integer'low);
|
||||
end case;
|
||||
for i in Argument'left-1 downto 1 loop
|
||||
case Argument(i) is when '1' => Result := 2**(i-1) + Result;
|
||||
when '0' => null;
|
||||
when others => return(integer'low);
|
||||
end case;
|
||||
end loop;
|
||||
return (Result);
|
||||
end S_To_d;
|
||||
|
||||
-- string to decimal
|
||||
|
||||
function I_To_d (Arg: string(1 to FIO_d_WIDTH+1)) return integer is
|
||||
constant Sign: character := Arg(1);
|
||||
constant Value: string(Arg'length-1 downto 1) := Arg(2 to Arg'length);
|
||||
variable Char: character;
|
||||
variable Result: integer := 0;
|
||||
begin
|
||||
Result := 0;
|
||||
for i in Value'range loop
|
||||
Result := Result * 10;
|
||||
Char := Value(i);
|
||||
if (Char /= ' ') then
|
||||
Result := Result + C_DIGIT_CHARS_MAP(Char);
|
||||
end if;
|
||||
end loop;
|
||||
case Sign is when '-' => return(-Result);
|
||||
when others => return(Result);
|
||||
end case;
|
||||
end I_To_d;
|
||||
|
||||
-- boolean (0,1) to decimal
|
||||
|
||||
function B_To_d (Arg: string(1 to 1)) return integer is
|
||||
begin
|
||||
case Arg is when "1" => return(1);
|
||||
when "0" => return(0);
|
||||
when others => return(-1);
|
||||
end case;
|
||||
end B_To_d;
|
||||
|
||||
-- boolean (T,F) to decimal
|
||||
|
||||
function L_To_d (Arg: string(1 to 1)) return integer is
|
||||
begin
|
||||
case Arg is when "T" => return(1);
|
||||
when others => return(0);
|
||||
end case;
|
||||
end L_To_d;
|
||||
|
||||
|
||||
|
||||
----------------------------
|
||||
-- Hex conversion support --
|
||||
----------------------------
|
||||
|
||||
-- Constants & types
|
||||
|
||||
constant C_HEX_CHARS: string(1 to 17) := "0123456789ABCDEF?";
|
||||
|
||||
-- Function to return Hex index of a nibble
|
||||
|
||||
function U_To_h_Index(Arg: string(4 downto 1)) return integer is
|
||||
variable Index: integer := 0;
|
||||
begin
|
||||
for i in Arg'range loop
|
||||
case Arg(i) is when '1' => Index := 2**(i-1) + Index;
|
||||
when '0' => null;
|
||||
when others => return (17);
|
||||
end case;
|
||||
end loop;
|
||||
return (Index+1);
|
||||
end U_To_h_Index;
|
||||
|
||||
-- Hex conversion
|
||||
|
||||
function U_To_h (Arg: string) return string is
|
||||
variable Result: string((Arg'length-1)/4 +1 downto 1);
|
||||
variable ExtArg: string(Result'length*4 downto 1) := (others => '0');
|
||||
begin
|
||||
ExtArg(Arg'length downto 1) := Arg;
|
||||
for i in Result'range loop
|
||||
Result(i) := C_HEX_CHARS(U_To_h_Index( ExtArg(i*4 downto i*4 -3) ));
|
||||
end loop;
|
||||
return (FIO_h_PRE & Result & FIO_h_POST);
|
||||
end U_To_h;
|
||||
|
||||
|
||||
|
||||
----------------------------
|
||||
-- Bit conversion support --
|
||||
----------------------------
|
||||
|
||||
function L_To_b (Arg: string(1 to 1)) return string is
|
||||
variable Result: string(1 to 1);
|
||||
begin
|
||||
case Arg is when "T" => Result := "1";
|
||||
when others => Result := "0";
|
||||
end case;
|
||||
return(FIO_b_PRE & Result & FIO_b_POST);
|
||||
end L_To_b;
|
||||
|
||||
|
||||
function I_To_b (Arg: string(1 to FIO_d_WIDTH+1);
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
|
||||
variable IntValue: integer := I_To_d(Arg);
|
||||
variable BitValue: string(1 to FIO_b_WIDTH) := (others => ' ');
|
||||
variable Sign: character := ' ';
|
||||
constant Blanks: string(1 to FIO_b_WIDTH) := (others => ' ');
|
||||
variable BitWidth: integer range 0 to FIO_b_WIDTH;
|
||||
variable MsPos: integer range 1 to BitValue'length;
|
||||
variable BitValueExtended: string(1 to 2*FIO_b_WIDTH);
|
||||
|
||||
begin
|
||||
|
||||
if (IntValue < 0) then
|
||||
Sign := '-';
|
||||
IntValue := -IntValue;
|
||||
end if;
|
||||
|
||||
for i in BitValue'reverse_range loop
|
||||
BitValue(i) := C_DIGITS_MAP(IntValue mod 2);
|
||||
IntValue := IntValue / 2;
|
||||
exit when (IntValue = 0);
|
||||
end loop;
|
||||
|
||||
BitValueExtended := BitValue & Blanks;
|
||||
|
||||
if (Width = 0) or (Width > FIO_b_WIDTH+1) then
|
||||
BitWidth := FIO_b_WIDTH;
|
||||
else
|
||||
BitWidth := Width-1;
|
||||
end if;
|
||||
|
||||
if (Justified = RIGHT) then
|
||||
return (FIO_bv_PRE &
|
||||
Sign & BitValue(BitValue'length-BitWidth+1 to BitValue'length) &
|
||||
FIO_bv_POST);
|
||||
else
|
||||
for i in BitValue'range loop
|
||||
if BitValue(i) /= ' ' then
|
||||
MSPos := i;
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
return (FIO_bv_PRE &
|
||||
Sign & BitValueExtended(MSPos to MSPos+BitWidth-1) &
|
||||
FIO_bv_POST);
|
||||
end if;
|
||||
|
||||
end I_To_b;
|
||||
|
||||
|
||||
-----------------------------------
|
||||
-- Reasonable conversion support --
|
||||
-----------------------------------
|
||||
|
||||
function I_To_r (Arg: string(1 to FIO_d_WIDTH+1);
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
constant Value: string(1 to FIO_d_WIDTH) := Arg(2 to FIO_d_WIDTH+1);
|
||||
constant Sign: character := Arg(1);
|
||||
constant Blanks: string(1 to FIO_d_WIDTH) := (others => ' ');
|
||||
variable IntWidth: integer range 0 to FIO_d_WIDTH;
|
||||
variable MsPos: integer range 1 to Value'length;
|
||||
variable ValueExtended: string(1 to 2*FIO_d_WIDTH) := Value & Blanks;
|
||||
begin
|
||||
if (Width = 0) or (Width > FIO_d_WIDTH+1) then
|
||||
IntWidth := FIO_d_WIDTH;
|
||||
else
|
||||
IntWidth := Width-1;
|
||||
end if;
|
||||
if (Justified = RIGHT) then
|
||||
return (Sign & Value(Value'length-IntWidth+1 to Value'length));
|
||||
else
|
||||
for i in Value'range loop
|
||||
if Value(i) /= ' ' then
|
||||
MSPos := i;
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
return (Sign & ValueExtended(MSPos to MSPos+IntWidth-1));
|
||||
end if;
|
||||
end I_To_r;
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
-- Reasonable output conversion function --
|
||||
-------------------------------------------
|
||||
|
||||
function ReasonableOutput (Arg: string;
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
constant Argument: string(1 to Arg'length) := Arg;
|
||||
constant TypeSpec: string (1 to 2) := Argument(1 to 2);
|
||||
constant Value: string(1 to Arg'length-2) := Argument(3 to Arg'length);
|
||||
begin
|
||||
case TypeSpec is
|
||||
when "U:" | "S:" | "V:" =>
|
||||
return U_To_h(Value);
|
||||
when "I:" =>
|
||||
return I_To_r(Value, Justified, Width);
|
||||
when "B:" | "L:" | "C:" =>
|
||||
return Value;
|
||||
when others =>
|
||||
return Argument;
|
||||
end case;
|
||||
|
||||
end ReasonableOutput;
|
||||
|
||||
|
||||
------------------------------------
|
||||
-- Bit output conversion function --
|
||||
------------------------------------
|
||||
|
||||
function BitOutput (Arg: string;
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
constant Argument: string(1 to Arg'length) := Arg;
|
||||
constant TypeSpec: string (1 to 2) := Argument(1 to 2);
|
||||
constant Value: string(1 to Arg'length-2) := Argument(3 to Arg'length);
|
||||
begin
|
||||
case TypeSpec is
|
||||
when "U:" | "S:" | "V:" =>
|
||||
return (FIO_bv_PRE & Value & FIO_bv_POST);
|
||||
when "B:" =>
|
||||
-- Value(1 to 1) instead of Value for LeapFrog
|
||||
return (FIO_b_PRE & Value(1 to 1) & FIO_b_POST);
|
||||
when "I:" =>
|
||||
return I_To_b(Value, Justified, Width);
|
||||
when "L:" =>
|
||||
-- Value(1 to 1) instead of Value for LeapFrog
|
||||
return L_To_b(Value(1 to 1));
|
||||
when others =>
|
||||
return Argument;
|
||||
end case;
|
||||
|
||||
end BitOutput;
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
-- Decimal output conversion function --
|
||||
-------------------------------------------
|
||||
|
||||
function DecimalOutput (Arg: string) return integer is
|
||||
constant Argument: string(1 to Arg'length) := Arg;
|
||||
constant TypeSpec: string (1 to 2) := Argument(1 to 2);
|
||||
constant Value: string(1 to Arg'length-2) := Argument(3 to Arg'length);
|
||||
begin
|
||||
case TypeSpec is
|
||||
when "U:"| "V:" =>
|
||||
return U_To_d(Value);
|
||||
when "S:" =>
|
||||
return S_To_d(Value);
|
||||
when "I:" =>
|
||||
return I_To_d(Value);
|
||||
when "B:" =>
|
||||
return B_To_d(Value);
|
||||
when "L:" =>
|
||||
return L_To_d(Value);
|
||||
when others =>
|
||||
return integer'low;
|
||||
end case;
|
||||
|
||||
end DecimalOutput;
|
||||
|
||||
|
||||
----------------------------
|
||||
-- Atomic print functions --
|
||||
----------------------------
|
||||
|
||||
-- test for end of format string
|
||||
|
||||
function FIO_EOS (Format: in string;
|
||||
Pointer: in integer)
|
||||
return boolean is
|
||||
begin
|
||||
return (Pointer > Format'length);
|
||||
end FIO_EOS;
|
||||
|
||||
|
||||
-- Atomic value print function
|
||||
|
||||
procedure FIO_PrintValue (F: out text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: inout integer;
|
||||
Last: in boolean := FALSE) is
|
||||
variable Char: character;
|
||||
begin
|
||||
while (not FIO_EOS(Format, Pointer)) loop
|
||||
Char := Format(Pointer);
|
||||
case Char is
|
||||
when '\' =>
|
||||
Pointer := Pointer + 1;
|
||||
exit when (FIO_EOS(Format, Pointer));
|
||||
Char := Format(Pointer);
|
||||
case Char is when 'n' => writeline(F, L);
|
||||
when others => write(L, Char);
|
||||
end case;
|
||||
when '%' =>
|
||||
if Last then
|
||||
FIO_Warning_Fsbla(F, L, Format, Pointer);
|
||||
end if;
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when others =>
|
||||
write(L, char);
|
||||
end case;
|
||||
Pointer := Pointer + 1;
|
||||
end loop;
|
||||
end FIO_PrintValue;
|
||||
|
||||
|
||||
---- Atomic argument print function
|
||||
|
||||
procedure FIO_PrintArg (F: out text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: inout integer;
|
||||
Arg: in string) is
|
||||
variable Char: character;
|
||||
variable Justified: side;
|
||||
variable Width: integer;
|
||||
begin
|
||||
|
||||
FIO_PrintValue(F, L, Format, Pointer);
|
||||
|
||||
Justified := RIGHT;
|
||||
Width := 0;
|
||||
while (not FIO_EOS(Format, Pointer)) loop
|
||||
Char := Format(Pointer);
|
||||
case Char is
|
||||
when '-' =>
|
||||
Justified := LEFT;
|
||||
Pointer := Pointer + 1;
|
||||
when '0' to '9' =>
|
||||
Width := Width*10 + C_DIGIT_CHARS_MAP(Char);
|
||||
Pointer := Pointer + 1;
|
||||
when 'r' =>
|
||||
write(L, ReasonableOutput(Arg, Justified, Width), Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when 'b' =>
|
||||
write(L, BitOutput(Arg, Justified, Width), Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when 'd' =>
|
||||
write(L, DecimalOutput(Arg), Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when 'q' | 's' =>
|
||||
write(L, Arg, Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when others =>
|
||||
FIO_Warning_Ufs(F, L, Format, Pointer, Char);
|
||||
write(L, Arg, Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
end case;
|
||||
end loop;
|
||||
end FIO_PrintArg;
|
||||
|
||||
|
||||
-----------------------------------------------------
|
||||
-- The format string iteration expansion procedure --
|
||||
-----------------------------------------------------
|
||||
|
||||
procedure FIO_FormatExpand (FMT: inout line;
|
||||
Format: in string;
|
||||
StartPointer: in positive) is
|
||||
|
||||
variable Pointer: positive := StartPointer;
|
||||
variable TokenStart: positive;
|
||||
variable IterStringStart: positive;
|
||||
variable IterStringEnd: positive;
|
||||
variable IterCount: natural;
|
||||
variable OpenBrackets: natural;
|
||||
variable L: line;
|
||||
|
||||
begin
|
||||
|
||||
FORMAT_SEARCH: while not FIO_EOS(Format, Pointer) loop
|
||||
|
||||
case Format(Pointer) is
|
||||
|
||||
-- look for format specifier
|
||||
when '%' =>
|
||||
|
||||
-- initialize iteration token search
|
||||
TokenStart := Pointer;
|
||||
IterCount := 0;
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
-- start iteration token search
|
||||
TOKEN_READ: while not FIO_EOS(Format, Pointer) loop
|
||||
|
||||
case Format(Pointer) is
|
||||
|
||||
-- read iteration counter
|
||||
when '0' to '9' =>
|
||||
IterCount := IterCount*10 + C_DIGIT_CHARS_MAP(Format(Pointer));
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
-- expect open bracket
|
||||
when '{' =>
|
||||
|
||||
-- initialize iteration string read
|
||||
OpenBrackets := 1;
|
||||
IterStringStart := Pointer + 1;
|
||||
Pointer := Pointer + 1;
|
||||
-- quit prematurely when iteration count is 0
|
||||
next FORMAT_SEARCH when (IterCount = 0);
|
||||
|
||||
-- start iteration string read
|
||||
ITER_STRING_READ: while not FIO_EOS(Format, Pointer) loop
|
||||
|
||||
case Format(Pointer) is
|
||||
-- keep track of open brackets
|
||||
when '{' =>
|
||||
OpenBrackets := OpenBrackets + 1;
|
||||
Pointer := Pointer + 1;
|
||||
-- when closing bracket is found, process iteration string
|
||||
when '}' =>
|
||||
OpenBrackets := OpenBrackets - 1;
|
||||
if (OpenBrackets = 0) then
|
||||
IterStringEnd := Pointer-1;
|
||||
if (TokenStart /= 1) then
|
||||
write(L, Format(1 to TokenStart-1));
|
||||
end if;
|
||||
for i in 1 to IterCount loop
|
||||
write(L, Format(IterStringStart to IterStringEnd));
|
||||
end loop;
|
||||
if (IterStringEnd /= Format'length) then
|
||||
write(L, Format(IterStringEnd+2 to Format'length));
|
||||
end if;
|
||||
-- call expansion procedure recursively on expanded format
|
||||
FIO_FormatExpand(FMT, L.all, TokenStart);
|
||||
deallocate(L);
|
||||
return;
|
||||
end if;
|
||||
Pointer := Pointer + 1;
|
||||
-- skip escaped characters
|
||||
when '\' =>
|
||||
Pointer := Pointer + 2;
|
||||
-- read iteration string
|
||||
when others =>
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
end case;
|
||||
|
||||
end loop ITER_STRING_READ;
|
||||
|
||||
-- stop iteration token search when no opening bracket found
|
||||
when others =>
|
||||
Pointer := Pointer + 1;
|
||||
next FORMAT_SEARCH;
|
||||
|
||||
end case;
|
||||
|
||||
end loop TOKEN_READ;
|
||||
|
||||
-- skip escaped characters
|
||||
when '\' =>
|
||||
Pointer := Pointer + 2;
|
||||
|
||||
-- read other characters
|
||||
when others =>
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
end case;
|
||||
|
||||
end loop FORMAT_SEARCH;
|
||||
|
||||
write(FMT, Format);
|
||||
deallocate(L);
|
||||
|
||||
end FIO_FormatExpand;
|
||||
|
||||
|
||||
|
||||
--------------------------
|
||||
-- The fprint procedure --
|
||||
--------------------------
|
||||
|
||||
procedure fprint
|
||||
(F: out text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 : in string := FIO_NIL;
|
||||
A9 , A10, A11, A12, A13, A14, A15, A16: in string := FIO_NIL;
|
||||
A17, A18, A19, A20, A21, A22, A23, A24: in string := FIO_NIL;
|
||||
A25, A26, A27, A28, A29, A30, A31, A32: in string := FIO_NIL
|
||||
) is
|
||||
|
||||
variable Pointer: integer;
|
||||
variable FMT: line;
|
||||
|
||||
begin
|
||||
|
||||
Pointer := 1;
|
||||
|
||||
FIO_FormatExpand (FMT, Format, Format'low);
|
||||
|
||||
if (A1 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A1 );
|
||||
if (A2 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A2 );
|
||||
if (A3 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A3 );
|
||||
if (A4 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A4 );
|
||||
if (A5 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A5 );
|
||||
if (A6 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A6 );
|
||||
if (A7 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A7 );
|
||||
if (A8 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A8 );
|
||||
if (A9 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A9 );
|
||||
if (A10 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A10);
|
||||
if (A11 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A11);
|
||||
if (A12 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A12);
|
||||
if (A13 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A13);
|
||||
if (A14 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A14);
|
||||
if (A15 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A15);
|
||||
if (A16 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A16);
|
||||
if (A17 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A17);
|
||||
if (A18 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A18);
|
||||
if (A19 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A19);
|
||||
if (A20 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A20);
|
||||
if (A21 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A21);
|
||||
if (A22 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A22);
|
||||
if (A23 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A23);
|
||||
if (A24 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A24);
|
||||
if (A25 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A25);
|
||||
if (A26 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A26);
|
||||
if (A27 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A27);
|
||||
if (A28 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A28);
|
||||
if (A29 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A29);
|
||||
if (A30 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A30);
|
||||
if (A31 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A31);
|
||||
if (A32 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A32);
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
|
||||
FIO_PrintValue(F, L, FMT.all, Pointer, Last => TRUE);
|
||||
|
||||
deallocate(FMT);
|
||||
|
||||
end fprint;
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
-- Formatted output conversion functions --
|
||||
-------------------------------------------
|
||||
|
||||
function fo (Arg: unsigned) return string is
|
||||
constant Argument: unsigned(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("U:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: signed) return string is
|
||||
constant Argument: signed(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("S:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: std_logic_vector) return string is
|
||||
constant Argument: std_logic_vector(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("V:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: std_ulogic_vector) return string is
|
||||
constant Argument: std_ulogic_vector(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("V:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: bit_vector) return string is
|
||||
constant Argument: bit_vector(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_BIT_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("V:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: integer) return string is
|
||||
variable Argument: integer := Arg;
|
||||
variable Result: string(1 to FIO_d_WIDTH) := (others => ' ');
|
||||
variable Sign: character := ' ';
|
||||
begin
|
||||
if (Argument < 0) and (Argument /= integer'low) then
|
||||
Sign := '-';
|
||||
Argument := -Argument;
|
||||
end if;
|
||||
for i in Result'reverse_range loop
|
||||
Result(i) := C_DIGITS_MAP(Argument mod 10);
|
||||
Argument := Argument / 10;
|
||||
exit when (Argument = 0);
|
||||
end loop;
|
||||
return ("I:" & Sign & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: std_ulogic) return string is
|
||||
begin
|
||||
return ("B:" & C_STD_LOGIC_MAP(Arg));
|
||||
end fo;
|
||||
|
||||
function fo (Arg: bit) return string is
|
||||
begin
|
||||
return ("B:" & C_BIT_MAP(Arg));
|
||||
end fo;
|
||||
|
||||
function fo (Arg: boolean) return string is
|
||||
begin
|
||||
if (ARG = TRUE) then
|
||||
return ("L:T");
|
||||
else
|
||||
return ("L:F");
|
||||
end if;
|
||||
end fo;
|
||||
|
||||
function fo (Arg: character) return string is
|
||||
begin
|
||||
return ("C:" & Arg);
|
||||
end fo;
|
||||
|
||||
-- auxilary function fgets(Arg: string)
|
||||
-- gives index until first NUL
|
||||
-- reads string from 1 to Arg'length
|
||||
function fgets (Arg: string) return integer is
|
||||
variable index: integer := Arg'length;
|
||||
begin
|
||||
for i in 1 to Arg'length loop
|
||||
if Arg(i) = NUL then
|
||||
index := i - 1;
|
||||
exit;
|
||||
else
|
||||
null;
|
||||
end if;
|
||||
end loop;
|
||||
return index;
|
||||
end fgets;
|
||||
|
||||
function fo (Arg: string) return string is
|
||||
begin
|
||||
return Arg(1 to fgets(Arg));
|
||||
end fo;
|
||||
|
||||
function fo (Arg: time) return string is
|
||||
begin
|
||||
return fo (integer (Arg / 1 ns));
|
||||
end fo;
|
||||
|
||||
end PCK_FIO;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
---- $Id: PCK_FIO_1993.vhd,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
|
||||
use STD.TEXTIO.all;
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
-- signed/unsigned definition: use either std_logic_arith or numeric_std
|
||||
-- use IEEE.std_logic_arith.all; -- the Synopsys one
|
||||
use IEEE.numeric_std.all;
|
||||
|
||||
package PCK_FIO is
|
||||
|
||||
|
||||
-- prefix string for hex output
|
||||
-- VHDL style: "X"""
|
||||
-- Verilog style: "h'"
|
||||
-- C style: "0x"
|
||||
constant FIO_h_PRE: string := "0x";
|
||||
|
||||
-- postfix string for hex output
|
||||
-- VHDL style: """"
|
||||
constant FIO_h_POST: string := "";
|
||||
|
||||
-- prefix string for bit vector output
|
||||
-- VHDL style: "B"""
|
||||
-- Verilog style: "b'"
|
||||
constant FIO_bv_PRE: string := "";
|
||||
|
||||
-- postfix string for bit vector output
|
||||
-- VHDL style: """"
|
||||
constant FIO_bv_POST: string := "";
|
||||
|
||||
-- prefix string for bit output
|
||||
-- VHDL style: "'"
|
||||
-- Verilog style: "b'"
|
||||
constant FIO_b_PRE: string := "";
|
||||
|
||||
-- postfix string for bit output
|
||||
-- VHDL style: "'"
|
||||
constant FIO_b_POST: string := "";
|
||||
|
||||
-- digit width for the string representation of integers
|
||||
constant FIO_d_WIDTH: integer := 10;
|
||||
|
||||
-- bit width for the string representation of integers
|
||||
constant FIO_b_WIDTH: integer := 32;
|
||||
|
||||
-- definition of the NIL string (default value for fprint arguments)
|
||||
-- fprint stops consuming arguments at the first NIL argument
|
||||
constant FIO_NIL: string := "\";
|
||||
|
||||
procedure fprint
|
||||
(file F: text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 : in string := FIO_NIL;
|
||||
A9 , A10, A11, A12, A13, A14, A15, A16: in string := FIO_NIL;
|
||||
A17, A18, A19, A20, A21, A22, A23, A24: in string := FIO_NIL;
|
||||
A25, A26, A27, A28, A29, A30, A31, A32: in string := FIO_NIL
|
||||
);
|
||||
|
||||
function fo (Arg: unsigned) return string;
|
||||
function fo (Arg: signed) return string;
|
||||
function fo (Arg: std_logic_vector) return string;
|
||||
function fo (Arg: std_ulogic_vector) return string;
|
||||
function fo (Arg: bit_vector) return string;
|
||||
function fo (Arg: integer) return string;
|
||||
function fo (Arg: std_ulogic) return string;
|
||||
function fo (Arg: bit) return string;
|
||||
function fo (Arg: boolean) return string;
|
||||
function fo (Arg: character) return string;
|
||||
function fo (Arg: string) return string;
|
||||
function fo (Arg: time) return string;
|
||||
|
||||
procedure FIO_FormatExpand (FMT: inout line;
|
||||
Format: in string;
|
||||
StartPointer: in positive);
|
||||
|
||||
end PCK_FIO;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,814 @@
|
||||
---- $Id: PCK_FIO_1993_BODY.vhd,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
|
||||
package body PCK_FIO is
|
||||
|
||||
--------------------------
|
||||
-- FIO Warnings support --
|
||||
--------------------------
|
||||
|
||||
procedure FIO_Warning_Fsbla (file F: text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: in positive) is
|
||||
begin
|
||||
fprint (F, L, "\n** Warning: FIO_PrintLastValue: " &
|
||||
"Format specifier beyond last argument\n");
|
||||
fprint (F, L, "** in format string: ""%s""\n", Format);
|
||||
fprint (F, L, "** ");
|
||||
for i in 1 to Pointer-1 loop
|
||||
fprint (F, L, "-");
|
||||
end loop;
|
||||
fprint (F, L, "^\n");
|
||||
end FIO_Warning_Fsbla;
|
||||
|
||||
procedure FIO_Warning_Ufs (file F: text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: in positive;
|
||||
Char: in character) is
|
||||
begin
|
||||
fprint (F, L, "\n** Warning: FIO_PrintArg: " &
|
||||
"Unexpected format specifier '%r'\n",
|
||||
fo(Char));
|
||||
fprint (F, L, "** in format string: ""%s""\n", Format) ;
|
||||
fprint (F, L, "** ");
|
||||
for i in 1 to Pointer-1 loop
|
||||
fprint (F, L, "-");
|
||||
end loop;
|
||||
fprint (F, L, "^\n** Assuming 'q' to proceed: ");
|
||||
end FIO_Warning_Ufs;
|
||||
|
||||
|
||||
----------------------------------
|
||||
-- bit conversion support --
|
||||
----------------------------------
|
||||
|
||||
type T_bit_map is array(bit) of character;
|
||||
|
||||
constant C_BIT_MAP: T_bit_map
|
||||
:= ('0', '1');
|
||||
|
||||
----------------------------------
|
||||
-- std_logic conversion support --
|
||||
----------------------------------
|
||||
|
||||
type T_std_logic_map is array(std_ulogic) of character;
|
||||
|
||||
constant C_STD_LOGIC_MAP: T_std_logic_map
|
||||
:= ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-');
|
||||
|
||||
------------------------------
|
||||
-- Digit conversion support --
|
||||
------------------------------
|
||||
|
||||
-- types & constants
|
||||
|
||||
subtype S_digit_chars is character range '0' to '9';
|
||||
subtype S_digits is integer range 0 to 9 ;
|
||||
|
||||
type T_digit_chars_map is array(S_digit_chars) of S_digits;
|
||||
|
||||
constant C_DIGIT_CHARS_MAP: T_digit_chars_map
|
||||
:= (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
|
||||
type T_digits_map is array(S_digits) of S_digit_chars;
|
||||
|
||||
constant C_DIGITS_MAP: T_digits_map
|
||||
:= ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
|
||||
|
||||
|
||||
--------------------------------
|
||||
-- Decimal conversion support --
|
||||
--------------------------------
|
||||
|
||||
-- unsigned to decimal
|
||||
|
||||
function U_To_d (Arg: string) return integer is
|
||||
constant Argument: string(Arg'length downto 1) := Arg;
|
||||
variable Result: integer := 0;
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
case Argument(i) is when '1' => Result := 2**(i-1) + Result;
|
||||
when '0' => null;
|
||||
when others => return(-1);
|
||||
end case;
|
||||
end loop;
|
||||
return (Result);
|
||||
end U_To_d;
|
||||
|
||||
-- signed to decimal
|
||||
|
||||
function S_To_d (Arg: string) return integer is
|
||||
constant Argument: string(Arg'length downto 1) := Arg;
|
||||
variable Result: integer := 0;
|
||||
begin
|
||||
case Argument(Argument'left) is
|
||||
when '1' => Result := - 2**(Argument'left-1);
|
||||
when '0' => Result := 0;
|
||||
when others => return (integer'low);
|
||||
end case;
|
||||
for i in Argument'left-1 downto 1 loop
|
||||
case Argument(i) is when '1' => Result := 2**(i-1) + Result;
|
||||
when '0' => null;
|
||||
when others => return(integer'low);
|
||||
end case;
|
||||
end loop;
|
||||
return (Result);
|
||||
end S_To_d;
|
||||
|
||||
-- string to decimal
|
||||
|
||||
function I_To_d (Arg: string(1 to FIO_d_WIDTH+1)) return integer is
|
||||
constant Sign: character := Arg(1);
|
||||
constant Value: string(Arg'length-1 downto 1) := Arg(2 to Arg'length);
|
||||
variable Char: character;
|
||||
variable Result: integer := 0;
|
||||
begin
|
||||
Result := 0;
|
||||
for i in Value'range loop
|
||||
Result := Result * 10;
|
||||
Char := Value(i);
|
||||
if (Char /= ' ') then
|
||||
Result := Result + C_DIGIT_CHARS_MAP(Char);
|
||||
end if;
|
||||
end loop;
|
||||
case Sign is when '-' => return(-Result);
|
||||
when others => return(Result);
|
||||
end case;
|
||||
end I_To_d;
|
||||
|
||||
-- boolean (0,1) to decimal
|
||||
|
||||
function B_To_d (Arg: string(1 to 1)) return integer is
|
||||
begin
|
||||
case Arg is when "1" => return(1);
|
||||
when "0" => return(0);
|
||||
when others => return(-1);
|
||||
end case;
|
||||
end B_To_d;
|
||||
|
||||
-- boolean (T,F) to decimal
|
||||
|
||||
function L_To_d (Arg: string(1 to 1)) return integer is
|
||||
begin
|
||||
case Arg is when "T" => return(1);
|
||||
when others => return(0);
|
||||
end case;
|
||||
end L_To_d;
|
||||
|
||||
|
||||
|
||||
----------------------------
|
||||
-- Hex conversion support --
|
||||
----------------------------
|
||||
|
||||
-- Constants & types
|
||||
|
||||
constant C_HEX_CHARS: string(1 to 17) := "0123456789ABCDEF?";
|
||||
|
||||
-- Function to return Hex index of a nibble
|
||||
|
||||
function U_To_h_Index(Arg: string(4 downto 1)) return integer is
|
||||
variable Index: integer := 0;
|
||||
begin
|
||||
for i in Arg'range loop
|
||||
case Arg(i) is when '1' => Index := 2**(i-1) + Index;
|
||||
when '0' => null;
|
||||
when others => return (17);
|
||||
end case;
|
||||
end loop;
|
||||
return (Index+1);
|
||||
end U_To_h_Index;
|
||||
|
||||
-- Hex conversion
|
||||
|
||||
function U_To_h (Arg: string) return string is
|
||||
variable Result: string((Arg'length-1)/4 +1 downto 1);
|
||||
variable ExtArg: string(Result'length*4 downto 1) := (others => '0');
|
||||
begin
|
||||
ExtArg(Arg'length downto 1) := Arg;
|
||||
for i in Result'range loop
|
||||
Result(i) := C_HEX_CHARS(U_To_h_Index( ExtArg(i*4 downto i*4 -3) ));
|
||||
end loop;
|
||||
return (FIO_h_PRE & Result & FIO_h_POST);
|
||||
end U_To_h;
|
||||
|
||||
|
||||
|
||||
----------------------------
|
||||
-- Bit conversion support --
|
||||
----------------------------
|
||||
|
||||
function L_To_b (Arg: string(1 to 1)) return string is
|
||||
variable Result: string(1 to 1);
|
||||
begin
|
||||
case Arg is when "T" => Result := "1";
|
||||
when others => Result := "0";
|
||||
end case;
|
||||
return(FIO_b_PRE & Result & FIO_b_POST);
|
||||
end L_To_b;
|
||||
|
||||
|
||||
function I_To_b (Arg: string(1 to FIO_d_WIDTH+1);
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
|
||||
variable IntValue: integer := I_To_d(Arg);
|
||||
variable BitValue: string(1 to FIO_b_WIDTH) := (others => ' ');
|
||||
variable Sign: character := ' ';
|
||||
constant Blanks: string(1 to FIO_b_WIDTH) := (others => ' ');
|
||||
variable BitWidth: integer range 0 to FIO_b_WIDTH;
|
||||
variable MsPos: integer range 1 to BitValue'length;
|
||||
variable BitValueExtended: string(1 to 2*FIO_b_WIDTH);
|
||||
|
||||
begin
|
||||
|
||||
if (IntValue < 0) then
|
||||
Sign := '-';
|
||||
IntValue := -IntValue;
|
||||
end if;
|
||||
|
||||
for i in BitValue'reverse_range loop
|
||||
BitValue(i) := C_DIGITS_MAP(IntValue mod 2);
|
||||
IntValue := IntValue / 2;
|
||||
exit when (IntValue = 0);
|
||||
end loop;
|
||||
|
||||
BitValueExtended := BitValue & Blanks;
|
||||
|
||||
if (Width = 0) or (Width > FIO_b_WIDTH+1) then
|
||||
BitWidth := FIO_b_WIDTH;
|
||||
else
|
||||
BitWidth := Width-1;
|
||||
end if;
|
||||
|
||||
if (Justified = RIGHT) then
|
||||
return (FIO_bv_PRE &
|
||||
Sign & BitValue(BitValue'length-BitWidth+1 to BitValue'length) &
|
||||
FIO_bv_POST);
|
||||
else
|
||||
for i in BitValue'range loop
|
||||
if BitValue(i) /= ' ' then
|
||||
MSPos := i;
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
return (FIO_bv_PRE &
|
||||
Sign & BitValueExtended(MSPos to MSPos+BitWidth-1) &
|
||||
FIO_bv_POST);
|
||||
end if;
|
||||
|
||||
end I_To_b;
|
||||
|
||||
|
||||
-----------------------------------
|
||||
-- Reasonable conversion support --
|
||||
-----------------------------------
|
||||
|
||||
function I_To_r (Arg: string(1 to FIO_d_WIDTH+1);
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
constant Value: string(1 to FIO_d_WIDTH) := Arg(2 to FIO_d_WIDTH+1);
|
||||
constant Sign: character := Arg(1);
|
||||
constant Blanks: string(1 to FIO_d_WIDTH) := (others => ' ');
|
||||
variable IntWidth: integer range 0 to FIO_d_WIDTH;
|
||||
variable MsPos: integer range 1 to Value'length;
|
||||
variable ValueExtended: string(1 to 2*FIO_d_WIDTH) := Value & Blanks;
|
||||
begin
|
||||
if (Width = 0) or (Width > FIO_d_WIDTH+1) then
|
||||
IntWidth := FIO_d_WIDTH;
|
||||
else
|
||||
IntWidth := Width-1;
|
||||
end if;
|
||||
if (Justified = RIGHT) then
|
||||
return (Sign & Value(Value'length-IntWidth+1 to Value'length));
|
||||
else
|
||||
for i in Value'range loop
|
||||
if Value(i) /= ' ' then
|
||||
MSPos := i;
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
return (Sign & ValueExtended(MSPos to MSPos+IntWidth-1));
|
||||
end if;
|
||||
end I_To_r;
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
-- Reasonable output conversion function --
|
||||
-------------------------------------------
|
||||
|
||||
function ReasonableOutput (Arg: string;
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
constant Argument: string(1 to Arg'length) := Arg;
|
||||
constant TypeSpec: string (1 to 2) := Argument(1 to 2);
|
||||
constant Value: string(1 to Arg'length-2) := Argument(3 to Arg'length);
|
||||
begin
|
||||
case TypeSpec is
|
||||
when "U:" | "S:" | "V:" =>
|
||||
return U_To_h(Value);
|
||||
when "I:" =>
|
||||
return I_To_r(Value, Justified, Width);
|
||||
when "B:" | "L:" | "C:" =>
|
||||
return Value;
|
||||
when others =>
|
||||
return Argument;
|
||||
end case;
|
||||
|
||||
end ReasonableOutput;
|
||||
|
||||
|
||||
------------------------------------
|
||||
-- Bit output conversion function --
|
||||
------------------------------------
|
||||
|
||||
function BitOutput (Arg: string;
|
||||
Justified: side;
|
||||
Width: integer) return string is
|
||||
constant Argument: string(1 to Arg'length) := Arg;
|
||||
constant TypeSpec: string (1 to 2) := Argument(1 to 2);
|
||||
constant Value: string(1 to Arg'length-2) := Argument(3 to Arg'length);
|
||||
begin
|
||||
case TypeSpec is
|
||||
when "U:" | "S:" | "V:" =>
|
||||
return (FIO_bv_PRE & Value & FIO_bv_POST);
|
||||
when "B:" =>
|
||||
-- Value(1 to 1) instead of Value for LeapFrog
|
||||
return (FIO_b_PRE & Value(1 to 1) & FIO_b_POST);
|
||||
when "I:" =>
|
||||
return I_To_b(Value, Justified, Width);
|
||||
when "L:" =>
|
||||
-- Value(1 to 1) instead of Value for LeapFrog
|
||||
return L_To_b(Value(1 to 1));
|
||||
when others =>
|
||||
return Argument;
|
||||
end case;
|
||||
|
||||
end BitOutput;
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
-- Decimal output conversion function --
|
||||
-------------------------------------------
|
||||
|
||||
function DecimalOutput (Arg: string) return integer is
|
||||
constant Argument: string(1 to Arg'length) := Arg;
|
||||
constant TypeSpec: string (1 to 2) := Argument(1 to 2);
|
||||
constant Value: string(1 to Arg'length-2) := Argument(3 to Arg'length);
|
||||
begin
|
||||
case TypeSpec is
|
||||
when "U:"| "V:" =>
|
||||
return U_To_d(Value);
|
||||
when "S:" =>
|
||||
return S_To_d(Value);
|
||||
when "I:" =>
|
||||
return I_To_d(Value);
|
||||
when "B:" =>
|
||||
return B_To_d(Value);
|
||||
when "L:" =>
|
||||
return L_To_d(Value);
|
||||
when others =>
|
||||
return integer'low;
|
||||
end case;
|
||||
|
||||
end DecimalOutput;
|
||||
|
||||
|
||||
----------------------------
|
||||
-- Atomic print functions --
|
||||
----------------------------
|
||||
|
||||
-- test for end of format string
|
||||
|
||||
function FIO_EOS (Format: in string;
|
||||
Pointer: in integer)
|
||||
return boolean is
|
||||
begin
|
||||
return (Pointer > Format'length);
|
||||
end FIO_EOS;
|
||||
|
||||
|
||||
-- Atomic value print function
|
||||
|
||||
procedure FIO_PrintValue (file F: text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: inout integer;
|
||||
Last: in boolean := FALSE) is
|
||||
variable Char: character;
|
||||
begin
|
||||
while (not FIO_EOS(Format, Pointer)) loop
|
||||
Char := Format(Pointer);
|
||||
case Char is
|
||||
when '\' =>
|
||||
Pointer := Pointer + 1;
|
||||
exit when (FIO_EOS(Format, Pointer));
|
||||
Char := Format(Pointer);
|
||||
case Char is when 'n' => writeline(F, L);
|
||||
when others => write(L, Char);
|
||||
end case;
|
||||
when '%' =>
|
||||
if Last then
|
||||
FIO_Warning_Fsbla(F, L, Format, Pointer);
|
||||
end if;
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when others =>
|
||||
write(L, char);
|
||||
end case;
|
||||
Pointer := Pointer + 1;
|
||||
end loop;
|
||||
end FIO_PrintValue;
|
||||
|
||||
|
||||
---- Atomic argument print function
|
||||
|
||||
procedure FIO_PrintArg (file F: text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
Pointer: inout integer;
|
||||
Arg: in string) is
|
||||
variable Char: character;
|
||||
variable Justified: side;
|
||||
variable Width: integer;
|
||||
|
||||
begin
|
||||
|
||||
FIO_PrintValue(F, L, Format, Pointer);
|
||||
|
||||
Justified := RIGHT;
|
||||
Width := 0;
|
||||
while (not FIO_EOS(Format, Pointer)) loop
|
||||
Char := Format(Pointer);
|
||||
case Char is
|
||||
when '-' =>
|
||||
Justified := LEFT;
|
||||
Pointer := Pointer + 1;
|
||||
when '0' to '9' =>
|
||||
Width := Width*10 + C_DIGIT_CHARS_MAP(Char);
|
||||
Pointer := Pointer + 1;
|
||||
when 'r' =>
|
||||
write(L, ReasonableOutput(Arg, Justified, Width), Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when 'b' =>
|
||||
write(L, BitOutput(Arg, Justified, Width), Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when 'd' =>
|
||||
write(L, DecimalOutput(Arg), Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when 'q' | 's' =>
|
||||
write(L, Arg, Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
when others =>
|
||||
FIO_Warning_Ufs(F, L, Format, Pointer, Char);
|
||||
write(L, Arg, Justified, Width);
|
||||
Pointer := Pointer + 1;
|
||||
exit;
|
||||
end case;
|
||||
end loop;
|
||||
end FIO_PrintArg;
|
||||
|
||||
|
||||
-----------------------------------------------------
|
||||
-- The format string iteration expansion procedure --
|
||||
-----------------------------------------------------
|
||||
|
||||
procedure FIO_FormatExpand (FMT: inout line;
|
||||
Format: in string;
|
||||
StartPointer: in positive) is
|
||||
|
||||
variable Pointer: positive := StartPointer;
|
||||
variable TokenStart: positive;
|
||||
variable IterStringStart: positive;
|
||||
variable IterStringEnd: positive;
|
||||
variable IterCount: natural;
|
||||
variable OpenBrackets: natural;
|
||||
variable L: line;
|
||||
|
||||
begin
|
||||
|
||||
FORMAT_SEARCH: while not FIO_EOS(Format, Pointer) loop
|
||||
|
||||
case Format(Pointer) is
|
||||
|
||||
-- look for format specifier
|
||||
when '%' =>
|
||||
|
||||
-- initialize iteration token search
|
||||
TokenStart := Pointer;
|
||||
IterCount := 0;
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
-- start iteration token search
|
||||
TOKEN_READ: while not FIO_EOS(Format, Pointer) loop
|
||||
|
||||
case Format(Pointer) is
|
||||
|
||||
-- read iteration counter
|
||||
when '0' to '9' =>
|
||||
IterCount := IterCount*10 + C_DIGIT_CHARS_MAP(Format(Pointer));
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
-- expect open bracket
|
||||
when '{' =>
|
||||
|
||||
-- initialize iteration string read
|
||||
OpenBrackets := 1;
|
||||
IterStringStart := Pointer + 1;
|
||||
Pointer := Pointer + 1;
|
||||
-- quit prematurely when iteration count is 0
|
||||
next FORMAT_SEARCH when (IterCount = 0);
|
||||
|
||||
-- start iteration string read
|
||||
ITER_STRING_READ: while not FIO_EOS(Format, Pointer) loop
|
||||
|
||||
case Format(Pointer) is
|
||||
-- keep track of open brackets
|
||||
when '{' =>
|
||||
OpenBrackets := OpenBrackets + 1;
|
||||
Pointer := Pointer + 1;
|
||||
-- when closing bracket is found, process iteration string
|
||||
when '}' =>
|
||||
OpenBrackets := OpenBrackets - 1;
|
||||
if (OpenBrackets = 0) then
|
||||
IterStringEnd := Pointer-1;
|
||||
if (TokenStart /= 1) then
|
||||
write(L, Format(1 to TokenStart-1));
|
||||
end if;
|
||||
for i in 1 to IterCount loop
|
||||
write(L, Format(IterStringStart to IterStringEnd));
|
||||
end loop;
|
||||
if (IterStringEnd /= Format'length) then
|
||||
write(L, Format(IterStringEnd+2 to Format'length));
|
||||
end if;
|
||||
-- call expansion procedure recursively on expanded format
|
||||
FIO_FormatExpand(FMT, L.all, TokenStart);
|
||||
deallocate(L);
|
||||
return;
|
||||
end if;
|
||||
Pointer := Pointer + 1;
|
||||
-- skip escaped characters
|
||||
when '\' =>
|
||||
Pointer := Pointer + 2;
|
||||
-- read iteration string
|
||||
when others =>
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
end case;
|
||||
|
||||
end loop ITER_STRING_READ;
|
||||
|
||||
-- stop iteration token search when no opening bracket found
|
||||
when others =>
|
||||
Pointer := Pointer + 1;
|
||||
next FORMAT_SEARCH;
|
||||
|
||||
end case;
|
||||
|
||||
end loop TOKEN_READ;
|
||||
|
||||
-- skip escaped characters
|
||||
when '\' =>
|
||||
Pointer := Pointer + 2;
|
||||
|
||||
-- read other characters
|
||||
when others =>
|
||||
Pointer := Pointer + 1;
|
||||
|
||||
end case;
|
||||
|
||||
end loop FORMAT_SEARCH;
|
||||
|
||||
write(FMT, Format);
|
||||
deallocate(L);
|
||||
|
||||
end FIO_FormatExpand;
|
||||
|
||||
|
||||
|
||||
--------------------------
|
||||
-- The fprint procedure --
|
||||
--------------------------
|
||||
|
||||
procedure fprint
|
||||
(file F: text;
|
||||
L: inout line;
|
||||
Format: in string;
|
||||
A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 : in string := FIO_NIL;
|
||||
A9 , A10, A11, A12, A13, A14, A15, A16: in string := FIO_NIL;
|
||||
A17, A18, A19, A20, A21, A22, A23, A24: in string := FIO_NIL;
|
||||
A25, A26, A27, A28, A29, A30, A31, A32: in string := FIO_NIL
|
||||
) is
|
||||
|
||||
variable Pointer: integer;
|
||||
variable FMT: line;
|
||||
|
||||
begin
|
||||
|
||||
Pointer := 1;
|
||||
|
||||
FIO_FormatExpand (FMT, Format, Format'low);
|
||||
|
||||
if (A1 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A1 );
|
||||
if (A2 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A2 );
|
||||
if (A3 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A3 );
|
||||
if (A4 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A4 );
|
||||
if (A5 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A5 );
|
||||
if (A6 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A6 );
|
||||
if (A7 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A7 );
|
||||
if (A8 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A8 );
|
||||
if (A9 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A9 );
|
||||
if (A10 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A10);
|
||||
if (A11 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A11);
|
||||
if (A12 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A12);
|
||||
if (A13 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A13);
|
||||
if (A14 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A14);
|
||||
if (A15 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A15);
|
||||
if (A16 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A16);
|
||||
if (A17 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A17);
|
||||
if (A18 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A18);
|
||||
if (A19 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A19);
|
||||
if (A20 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A20);
|
||||
if (A21 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A21);
|
||||
if (A22 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A22);
|
||||
if (A23 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A23);
|
||||
if (A24 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A24);
|
||||
if (A25 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A25);
|
||||
if (A26 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A26);
|
||||
if (A27 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A27);
|
||||
if (A28 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A28);
|
||||
if (A29 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A29);
|
||||
if (A30 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A30);
|
||||
if (A31 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A31);
|
||||
if (A32 /= FIO_NIL) then FIO_PrintArg(F, L, FMT.all, Pointer, A32);
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
end if; end if; end if; end if; end if; end if; end if; end if;
|
||||
|
||||
FIO_PrintValue(F, L, FMT.all, Pointer, Last => TRUE);
|
||||
|
||||
deallocate(FMT);
|
||||
|
||||
end fprint;
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
-- Formatted output conversion functions --
|
||||
-------------------------------------------
|
||||
|
||||
function fo (Arg: unsigned) return string is
|
||||
constant Argument: unsigned(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("U:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: signed) return string is
|
||||
constant Argument: signed(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("S:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: std_logic_vector) return string is
|
||||
constant Argument: std_logic_vector(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("V:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: std_ulogic_vector) return string is
|
||||
constant Argument: std_ulogic_vector(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_STD_LOGIC_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("V:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: bit_vector) return string is
|
||||
constant Argument: bit_vector(1 to Arg'length) := Arg;
|
||||
variable Result: string(1 to Arg'length);
|
||||
begin
|
||||
for i in Argument'range loop
|
||||
Result(i) := C_BIT_MAP(Argument(i));
|
||||
end loop;
|
||||
return ("V:" & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: integer) return string is
|
||||
variable Argument: integer := Arg;
|
||||
variable Result: string(1 to FIO_d_WIDTH) := (others => ' ');
|
||||
variable Sign: character := ' ';
|
||||
begin
|
||||
if (Argument < 0) and (Argument /= integer'low) then
|
||||
Sign := '-';
|
||||
Argument := -Argument;
|
||||
end if;
|
||||
for i in Result'reverse_range loop
|
||||
Result(i) := C_DIGITS_MAP(Argument mod 10);
|
||||
Argument := Argument / 10;
|
||||
exit when (Argument = 0);
|
||||
end loop;
|
||||
return ("I:" & Sign & Result);
|
||||
end fo;
|
||||
|
||||
function fo (Arg: std_ulogic) return string is
|
||||
begin
|
||||
return ("B:" & C_STD_LOGIC_MAP(Arg));
|
||||
end fo;
|
||||
|
||||
function fo (Arg: bit) return string is
|
||||
begin
|
||||
return ("B:" & C_BIT_MAP(Arg));
|
||||
end fo;
|
||||
|
||||
function fo (Arg: boolean) return string is
|
||||
begin
|
||||
if (ARG = TRUE) then
|
||||
return ("L:T");
|
||||
else
|
||||
return ("L:F");
|
||||
end if;
|
||||
end fo;
|
||||
|
||||
function fo (Arg: character) return string is
|
||||
begin
|
||||
return ("C:" & Arg);
|
||||
end fo;
|
||||
|
||||
-- auxilary function fgets(Arg :string)
|
||||
-- returns index of first NUL in Arg or if no NUL is present just Arg'length
|
||||
-- goes through Arg from 1 to Arg'length
|
||||
function fgets (Arg: string) return integer is
|
||||
variable index: integer := Arg'length;
|
||||
begin
|
||||
for i in 1 to Arg'length loop
|
||||
if Arg(i) = NUL then
|
||||
index := i - 1;
|
||||
exit;
|
||||
else
|
||||
null;
|
||||
end if;
|
||||
end loop;
|
||||
return index;
|
||||
end fgets;
|
||||
|
||||
-- returns the Arg string until the first NUL was encountered
|
||||
-- if fo is used on a string with NUL in it it will stop reading the rest
|
||||
-- of the string, even if a larger field width has been supplied. fo will
|
||||
-- then just pad the remaining characters with blanco's
|
||||
function fo (Arg: string) return string is
|
||||
begin
|
||||
return Arg(1 to fgets(Arg));
|
||||
end fo;
|
||||
|
||||
function fo (Arg: time) return string is
|
||||
begin
|
||||
return fo (integer (Arg / 1 ns));
|
||||
end fo;
|
||||
|
||||
end PCK_FIO;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
---- $Id: README,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
Version 2002.07
|
||||
===============
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
This distribution contains the following files:
|
||||
|
||||
PCK_FIO_1987.vhd: VHDL-87 source of the header of the PCK_FIO package
|
||||
PCK_FIO_1987_BODY.vhd: VHDL-87 source of the body of the PCK_FIO package
|
||||
PCK_FIO_1993.vhd: VHDL-93 source of the header of the PCK_FIO package
|
||||
PCK_FIO_1993_BODY.vhd: VHDL-93 source of the body of the PCK_FIO package
|
||||
TB_PCK_FIO_1987.vhd: VHDL-87 source of the testbench for package PCK_FIO
|
||||
TB_PCK_FIO_1993.vhd: VHDL-93 source of the testbench for package PCK_FIO
|
||||
PCK_FIO.out.gold: Certified test bench output
|
||||
PCK_FIO.html: Manual for PCK_FIO in html format
|
||||
README: This file
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
VHDL-1987
|
||||
---------
|
||||
To install PCK_FIO, define a VHDL library called EASICS_PACKAGES, and
|
||||
analyze the VHDL file PCK_FIO_1987.vhd and PCK_FIO_1987_BODY.vhd into this library.
|
||||
|
||||
To install the test bench, analyze TB_PCK_FIO_1987.vhd into the same library.
|
||||
|
||||
VHDL-1993
|
||||
---------
|
||||
To install PCK_FIO, define a VHDL library called EASICS_PACKAGES, and
|
||||
analyze the VHDL file PCK_FIO_1993.vhd and PCK_FIO_1993_BODY.vhd into this library.
|
||||
|
||||
To install the test bench, analyze TB_PCK_FIO_1993.vhd into the same library.
|
||||
|
||||
Numeric packages
|
||||
----------------
|
||||
If you want to use IEEE.std_logic_arith instead of IEEE.numeric_std, you need
|
||||
to edit the source code of the package, both header and body, and the test bench
|
||||
and replace the package use clause. PCK_FIO works with either of these packages.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
To install the documentation, put the file point PCK_FIO.html in a path of
|
||||
your choosing, point your web browser to it, and bookmark it.
|
||||
|
||||
|
||||
Installation check
|
||||
==================
|
||||
|
||||
After installing the test bench, you should run it. The corresponding VHDL
|
||||
design unit is EASICS_PACKAGES.TBE_PCK_FIO(TB).
|
||||
|
||||
Simulating the test bench should create a file called PCK_FIO.out. This file
|
||||
should be identical to PCK_FIO.out.gold. Any difference indicates a portability
|
||||
issue or a simulator non-compliance or bug.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,531 @@
|
||||
---- $Id: TB_PCK_FIO_1987.vhd,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
-- signed/unsigned definition: use either std_logic_arith or numeric_std
|
||||
-- use IEEE.std_logic_arith.all; -- the Synopsys one
|
||||
use IEEE.numeric_std.all;
|
||||
|
||||
use STD.TEXTIO.all;
|
||||
|
||||
library EASICS_PACKAGES;
|
||||
use EASICS_PACKAGES.PCK_FIO.all;
|
||||
|
||||
entity TBE_PCK_FIO is
|
||||
|
||||
end TBE_PCK_FIO;
|
||||
|
||||
architecture TB of TBE_PCK_FIO is
|
||||
|
||||
begin
|
||||
|
||||
USAGE: process
|
||||
|
||||
file RESULT: text is out "PCK_FIO.out";
|
||||
variable L: line;
|
||||
variable Pointer: integer;
|
||||
variable BoolTrue: boolean := TRUE;
|
||||
variable BoolFalse: boolean := FALSE;
|
||||
variable IntPos: integer := 5678;
|
||||
variable BigIntPos: integer := 12345678;
|
||||
variable IntNeg: integer := -8765;
|
||||
variable BigIntNeg: integer := -87654321;
|
||||
variable Uns: unsigned(6 downto 0) := unsigned'("1010010");
|
||||
variable Unk: unsigned(6 downto 0) := unsigned'("1X10Z10");
|
||||
variable Std: std_logic_vector(6 downto 0) := std_logic_vector'("0010010");
|
||||
variable SigPos: signed(6 downto 0) := signed'("0010010");
|
||||
variable SigNeg: signed(6 downto 0) := signed'("1010010");
|
||||
variable BitX: std_logic := 'X';
|
||||
variable Bit1: std_logic := '1';
|
||||
variable Bit0: std_logic := '0';
|
||||
|
||||
variable parameter_1: integer := 1234;
|
||||
variable parameter_2: integer := 2345;
|
||||
variable parameter_3: integer := 4567;
|
||||
|
||||
constant TempString: string :="ABC" & NUL & "DEF";
|
||||
begin
|
||||
|
||||
fprint(RESULT, L,
|
||||
"PCK_FIO.out: TESTBENCH OUTPUT FOR PCK_FIO\n" &
|
||||
"-----------------------------------------\n\n" &
|
||||
"This is the result of running the PCK_FIO testbench.\n" &
|
||||
"This file should be compared with PCK_FIO.out.gold, which is\n" &
|
||||
"the reference output. Any difference indicates a portability\n" &
|
||||
"issue or a simulator non-compliance or bug.\n\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n--------------------\n" &
|
||||
"-- Basic features --\n" &
|
||||
"--------------------\n\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"-- First some auxiliary declarations\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"> file RESULT: text is out ""PCK_FIO.out"";\n" &
|
||||
"> variable L: line;\n" &
|
||||
"> variable BoolTrue: boolean := TRUE;\n" &
|
||||
"> variable BoolFalse: boolean := FALSE;\n" &
|
||||
"> variable IntPos: integer := 5678;\n" &
|
||||
"> variable BigIntPos: integer := 12345678;\n" &
|
||||
"> variable IntNeg: integer := -8765;\n" &
|
||||
"> variable BigIntNeg: integer := -87654321;\n" &
|
||||
"> variable Uns: unsigned(6 downto 0) := unsigned'(""1010010"");\n" &
|
||||
"> variable Unk: unsigned(6 downto 0) := unsigned'(""1X10Z10"");\n" &
|
||||
"> variable Std: std_logic_vector(6 downto 0) := std_logic_vector'(""0010010"");\n" &
|
||||
"> variable SigPos: signed(6 downto 0) := signed'(""0010010"");\n" &
|
||||
"> variable SigNeg: signed(6 downto 0) := signed'(""1010010"");\n" &
|
||||
"> variable BitX: std_logic := 'X';\n" &
|
||||
"> variable Bit1: std_logic := '1';\n" &
|
||||
"> variable Bit0: std_logic := '0';\n" &
|
||||
"> constant TempString: string := ""ABC"" & NUL & ""DEF"";\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n-- fprint call with no arguments\n" &
|
||||
"> fprint(RESULT, L, ""No arguments.\\n"");\n"
|
||||
);
|
||||
fprint(RESULT, L, "No arguments.\n");
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-- Special characters need to be escaped\n" &
|
||||
"> fprint(RESULT, L, ""Special characters: \\\% \\\\ "" \\n"");\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Special characters: \% \\ "" \n");
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-- Various format specifiers interprete the same object differently\n" &
|
||||
"> fprint(RESULT, L, ""Format specifiers: \%r \%d \%b \%q\\n"",\n" &
|
||||
"> fo(Uns), fo(Uns), fo(Uns), fo(Uns)\n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Format specifiers: %r %d %b %q\n",
|
||||
fo(Uns), fo(Uns), fo(Uns), fo(Uns)
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-- Format string can be shortened by using the iteration specifier\n" &
|
||||
"> fprint(RESULT, L, ""Iteration specifier: \%4{\%r }\\n"",\n" &
|
||||
"> fo(Uns), fo(SigPos), fo(SigNeg), fo(Std)\n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Iteration specifier: %4{%r }\n",
|
||||
fo(Uns), fo(SigPos), fo(SigNeg), fo(Std)
|
||||
);
|
||||
fprint(RESULT, L,
|
||||
"\n-------------------------------\n"&
|
||||
"--Testing string manipulation--\n"&
|
||||
"-------------------------------\n");
|
||||
fprint(RESULT, L, "--testing done using the string TempString : " & """ABC"""
|
||||
& " & NUL & ""DEF""\n");
|
||||
-- temp_string: string:="ABC"&NUL&"DEF"
|
||||
-- test for detecting NUL in string
|
||||
fprint(RESULT, L, "\n--test for NUL ending in strings\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, fo(TempString));\n");
|
||||
fprint(RESULT, L, fo(TempString));
|
||||
|
||||
-- direct inclusion of string in fprint should give whole string
|
||||
fprint(RESULT, L, "\n--same without fo,so without NUL testing\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, TempString);\n");
|
||||
fprint(RESULT, L, TempString & "\n");
|
||||
|
||||
-- influence of given width
|
||||
|
||||
fprint(RESULT, L, "\n--if there are less characters in the given string then"
|
||||
& " in the width fo will\n"&
|
||||
"-- pad the remaining with blanco's according to the given justification\n");
|
||||
fprint(RESULT, L, "\n--with specified width, justified right,using fo\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%5s"", fo(TempString));\n");
|
||||
fprint(RESULT, L, "%5s", fo(TempString));
|
||||
fprint(RESULT, L, "\n--with specified width, justified left, using fo\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%-5s"", fo(TempString));\n");
|
||||
fprint(RESULT, L, "%-5s",fo(TempString));
|
||||
fprint(RESULT, L, "\n--with specified width without fo\n");
|
||||
fprint(RESUlT, L, "> fprint(RESULT, L, ""\%9s"", TempString);\n");
|
||||
fprint(RESULT, L, "%9s", TempString);
|
||||
fprint(RESULT, L, "\n\n-- if the width is smaller then the number" &
|
||||
" of characters in the string fprint\n" &
|
||||
"-- will output the string with the minimum of characters needed\n");
|
||||
fprint(RESULT, L, "\n--with specified width,using fo\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%2s"", fo(TempString));\n");
|
||||
fprint(RESULT, L, "%2s",fo(TempString));
|
||||
fprint(RESULT, L, "\n--with specified width without fo\n");
|
||||
fprint(RESUlT, L, "> fprint(RESULT, L, ""\%4s"", TempString);\n");
|
||||
fprint(RESULT, L, "%4s", TempString);
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n------------------------------------\n" &
|
||||
"-- Support for bit-oriented types --\n" &
|
||||
"------------------------------------\n"
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "\n-- Reasonable format\n" &
|
||||
"> fprint(RESULT, L, ""Reasonable format: \%9{\%r }\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),\n" &
|
||||
"> fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse) \n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Reasonable format: %9{%r }\n",
|
||||
fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),
|
||||
fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse)
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "\n-- Decimal format\n" &
|
||||
"> fprint(RESULT, L, ""Decimal format: \%7{\%d }\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),\n" &
|
||||
"> fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse) \n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Decimal format: %9{%d }\n",
|
||||
fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),
|
||||
fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse)
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "\n-- Bit format\n" &
|
||||
"> fprint(RESULT, L, ""Bit format: \%7{\%b }\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),\n" &
|
||||
"> fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse) \n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Bit format: %9{%b }\n",
|
||||
fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),
|
||||
fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse)
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n" &
|
||||
"-- Alignment\n-- Template of the call: (<fs> stands for the format specifier)\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "\n" &
|
||||
"> fprint(RESULT, L, ""Bitvectors with <fs>: \%4{<fs>|}\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg)\n" &
|
||||
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n" &
|
||||
"-- Results of the call with various format specifiers\n\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Bitvectors with \%1r: %4{%1r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%2r: %4{%2r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%3r: %4{%3r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%4r: %4{%4r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%5r: %4{%5r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%6r: %4{%6r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%7r: %4{%7r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%8r: %4{%8r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%9r: %4{%9r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Bitvectors with \%-1r: %4{%-1r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-2r: %4{%-2r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-3r: %4{%-3r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-4r: %4{%-4r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-5r: %4{%-5r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-6r: %4{%-6r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-7r: %4{%-7r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-8r: %4{%-8r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-9r: %4{%-9r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Bitvectors with \%1d: %4{%1d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%2d: %4{%2d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%3d: %4{%3d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%4d: %4{%4d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%5d: %4{%5d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%6d: %4{%6d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%7d: %4{%7d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%8d: %4{%8d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%9d: %4{%9d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Bitvectors with \%-1d: %4{%-1d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-2d: %4{%-2d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-3d: %4{%-3d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-4d: %4{%-4d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-5d: %4{%-5d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-6d: %4{%-6d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-7d: %4{%-7d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-8d: %4{%-8d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-9d: %4{%-9d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-------------------------------\n" &
|
||||
"-- Support for integer types --\n" &
|
||||
"-------------------------------\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n" &
|
||||
"-- Template of the call: (<fs> stands for the format specifier)\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "\n" &
|
||||
"> fprint(RESULT, L, ""Integers with <fs>: \%4{<fs>|}\\n"",\n" &
|
||||
"> fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)\n" &
|
||||
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n" &
|
||||
"-- Results of the call with various format specifiers\n\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Integers with \%5d: %4{%5d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%6d: %4{%6d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%7d: %4{%7d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%8d: %4{%8d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%9d: %4{%9d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%10d: %4{%10d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Integers with \%-5d: %4{%-5d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-6d: %4{%-6d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-7d: %4{%-7d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-8d: %4{%-8d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-9d: %4{%-9d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-10d: %4{%-10d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Integers with \%5r: %4{%5r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%6r: %4{%6r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%7r: %4{%7r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%8r: %4{%8r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%9r: %4{%9r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%10r: %4{%10r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Integers with \%-5r: %4{%-5r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-6r: %4{%-6r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-7r: %4{%-7r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-8r: %4{%-8r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-9r: %4{%-9r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-10r: %4{%-10r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n----------------------\n" &
|
||||
"-- Support for time --\n" &
|
||||
"----------------------\n"
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "-- For portability reasons, time is converted \n" &
|
||||
"-- into an integer value (of nanoseconds)\n"
|
||||
);
|
||||
fprint (RESULT, L, "> wait for 648 ns\n");
|
||||
fprint (RESULT, L, "> fprint (RESULT, L, ""The time is now \%d ns\\n"", fo(now));\n");
|
||||
|
||||
wait for 648 ns;
|
||||
|
||||
fprint (RESULT, L, "The time is now %d ns\n", fo(now));
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n----------------------------------------\n" &
|
||||
"-- Erroneous calls and error messages --\n" &
|
||||
"----------------------------------------\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "\n-- Less arguments than formats specifiers\n" &
|
||||
"> fprint(RESULT, L, ""\%d \%d \%d \%d \\n"", fo(Uns), fo(Std));\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "%d %d %d %d \n", fo(Uns), fo(Std));
|
||||
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
fprint(RESULT, L, "-- Unsupported format specifier\n" &
|
||||
"> fprint(RESULT, L, ""\%r \%v \%r \%r\\n"", " &
|
||||
"fo(Uns), fo(Std), fo(Uns), fo(Std));\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "%r %v %r %r\n", fo(Uns), fo(Std), fo(Uns), fo(Std));
|
||||
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n----------------------------------------\n" &
|
||||
"-- Things you wouldn't expect to work --\n" &
|
||||
"----------------------------------------\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "\n-- Nested iteration\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%3{<<\%3{_END_}>>}\\n"");\n");
|
||||
fprint(RESULT, L, "%3{<<%3{_END_}>>}\n");
|
||||
|
||||
wait;
|
||||
|
||||
end process USAGE;
|
||||
|
||||
end TB;
|
||||
|
||||
|
||||
@@ -0,0 +1,536 @@
|
||||
---- $Id: TB_PCK_FIO_1993.vhd,v 1.1 2008-08-23 08:20:28 Jens Exp $
|
||||
----
|
||||
---- PCK_FIO: a VHDL package for C-style formatted file output
|
||||
---- Copyright (C) 1995, 2001 Easics NV
|
||||
----
|
||||
---- This library is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU Lesser General Public
|
||||
---- License as published by the Free Software Foundation; either
|
||||
---- version 2.1 of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This library is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
---- Lesser General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU Lesser General Public
|
||||
---- License along with this library; if not, write to the Free Software
|
||||
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
----
|
||||
---- For suggestions, bug reports, enhancement requests, and info about
|
||||
---- our design services, you can contact us at the following address:
|
||||
---- http://www.easics.com
|
||||
---- Easics NV, Interleuvenlaan 86, B-3001 Leuven, Belgium
|
||||
---- tel.: +32 16 395 600 fax : +32 16 395 619
|
||||
---- e-mail: jand@easics.be (Jan Decaluwe)
|
||||
----
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
-- signed/unsigned definition: use either std_logic_arith or numeric_std
|
||||
-- use IEEE.std_logic_arith.all; -- the Synopsys one
|
||||
use IEEE.numeric_std.all;
|
||||
|
||||
use STD.TEXTIO.all;
|
||||
|
||||
library EASICS_PACKAGES;
|
||||
use EASICS_PACKAGES.PCK_FIO.all;
|
||||
|
||||
entity TBE_PCK_FIO is
|
||||
|
||||
end TBE_PCK_FIO;
|
||||
|
||||
architecture TB of TBE_PCK_FIO is
|
||||
|
||||
begin
|
||||
|
||||
USAGE: process
|
||||
|
||||
file RESULT: text open write_mode is "PCK_FIO.out";
|
||||
variable L: line;
|
||||
variable Pointer: integer;
|
||||
variable BoolTrue: boolean := TRUE;
|
||||
variable BoolFalse: boolean := FALSE;
|
||||
variable IntPos: integer := 5678;
|
||||
variable BigIntPos: integer := 12345678;
|
||||
variable IntNeg: integer := -8765;
|
||||
variable BigIntNeg: integer := -87654321;
|
||||
variable Uns: unsigned(6 downto 0) := unsigned'("1010010");
|
||||
variable Unk: unsigned(6 downto 0) := unsigned'("1X10Z10");
|
||||
variable Std: std_logic_vector(6 downto 0) := std_logic_vector'("0010010");
|
||||
variable SigPos: signed(6 downto 0) := signed'("0010010");
|
||||
variable SigNeg: signed(6 downto 0) := signed'("1010010");
|
||||
variable BitX: std_logic := 'X';
|
||||
variable Bit1: std_logic := '1';
|
||||
variable Bit0: std_logic := '0';
|
||||
|
||||
variable parameter_1: integer := 1234;
|
||||
variable parameter_2: integer := 2345;
|
||||
variable parameter_3: integer := 4567;
|
||||
|
||||
constant TempString: string :="ABC" & NUL & "DEF";
|
||||
begin
|
||||
|
||||
fprint(RESULT, L,
|
||||
"PCK_FIO.out: TESTBENCH OUTPUT FOR PCK_FIO\n" &
|
||||
"-----------------------------------------\n\n" &
|
||||
"This is the result of running the PCK_FIO testbench.\n" &
|
||||
"This file should be compared with PCK_FIO.out.gold, which is\n" &
|
||||
"the reference output. Any difference indicates a portability\n" &
|
||||
"issue or a simulator non-compliance or bug.\n\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n--------------------\n" &
|
||||
"-- Basic features --\n" &
|
||||
"--------------------\n\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"-- First some auxiliary declarations\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"> file RESULT: text is out ""PCK_FIO.out"";\n" &
|
||||
"> variable L: line;\n" &
|
||||
"> variable BoolTrue: boolean := TRUE;\n" &
|
||||
"> variable BoolFalse: boolean := FALSE;\n" &
|
||||
"> variable IntPos: integer := 5678;\n" &
|
||||
"> variable BigIntPos: integer := 12345678;\n" &
|
||||
"> variable IntNeg: integer := -8765;\n" &
|
||||
"> variable BigIntNeg: integer := -87654321;\n" &
|
||||
"> variable Uns: unsigned(6 downto 0) := unsigned'(""1010010"");\n" &
|
||||
"> variable Unk: unsigned(6 downto 0) := unsigned'(""1X10Z10"");\n" &
|
||||
"> variable Std: std_logic_vector(6 downto 0) := std_logic_vector'(""0010010"");\n" &
|
||||
"> variable SigPos: signed(6 downto 0) := signed'(""0010010"");\n" &
|
||||
"> variable SigNeg: signed(6 downto 0) := signed'(""1010010"");\n" &
|
||||
"> variable BitX: std_logic := 'X';\n" &
|
||||
"> variable Bit1: std_logic := '1';\n" &
|
||||
"> variable Bit0: std_logic := '0';\n" &
|
||||
"> constant TempString: string := ""ABC"" & NUL & ""DEF"";\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n-- fprint call with no arguments\n" &
|
||||
"> fprint(RESULT, L, ""No arguments.\\n"");\n"
|
||||
);
|
||||
fprint(RESULT, L, "No arguments.\n");
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-- Special characters need to be escaped\n" &
|
||||
"> fprint(RESULT, L, ""Special characters: \\\% \\\\ "" \\n"");\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Special characters: \% \\ "" \n");
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-- Various format specifiers interprete the same object differently\n" &
|
||||
"> fprint(RESULT, L, ""Format specifiers: \%r \%d \%b \%q\\n"",\n" &
|
||||
"> fo(Uns), fo(Uns), fo(Uns), fo(Uns)\n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Format specifiers: %r %d %b %q\n",
|
||||
fo(Uns), fo(Uns), fo(Uns), fo(Uns)
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-- Format string can be shortened by using the iteration specifier\n" &
|
||||
"> fprint(RESULT, L, ""Iteration specifier: \%4{\%r }\\n"",\n" &
|
||||
"> fo(Uns), fo(SigPos), fo(SigNeg), fo(Std)\n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Iteration specifier: %4{%r }\n",
|
||||
fo(Uns), fo(SigPos), fo(SigNeg), fo(Std)
|
||||
);
|
||||
fprint(RESULT, L,
|
||||
"\n-------------------------------\n"&
|
||||
"--Testing string manipulation--\n"&
|
||||
"-------------------------------\n");
|
||||
fprint(RESULT, L, "--testing done using the string TempString : " & """ABC"""
|
||||
& " & NUL & ""DEF""\n");
|
||||
-- TempString: string:="ABC" & NUL & "DEF"
|
||||
-- test for detecting NUL in string
|
||||
fprint(RESULT, L ,"\n--test for NUL ending in strings\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, fo(TempString));\n");
|
||||
fprint(RESULT, L, fo(TempString));
|
||||
|
||||
-- direct inclusion of string in fprint should give whole string
|
||||
fprint(RESULT, L, "\n--same without fo,so without NUL testing\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, TempString);\n");
|
||||
fprint(RESULT, L, TempString & "\n");
|
||||
|
||||
-- influence of given width
|
||||
|
||||
fprint(RESULT, L, "\n--if there are less characters in the given string then in the width fo will\n"&
|
||||
"-- pad the remaining with blanco's according to the given justification\n");
|
||||
fprint(RESULT, L, "\n--with specified width, justified right,using fo\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%5s"", fo(TempString));\n");
|
||||
fprint(RESULT, L, "%5s", fo(TempString));
|
||||
fprint(RESULT, L, "\n--with specified width, justified left, using fo\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%-5s"", fo(TempString));\n");
|
||||
fprint(RESULT, L, "%-5s", fo(TempString));
|
||||
fprint(RESULT, L, "\n--with specified width without fo\n");
|
||||
fprint(RESUlT, L, "> fprint(RESULT, L, ""\%9s"", TempString);\n");
|
||||
fprint(RESULT, L, "%9s", TempString);
|
||||
fprint(RESULT, L, "\n\n-- if the width is smaller then the number of characters in the string fprint\n"&
|
||||
"-- will output the string with the minimum of characters needed\n");
|
||||
fprint(RESULT, L, "\n--with specified width,using fo\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%2s"", fo(TempString));\n");
|
||||
fprint(RESULT, L, "%2s", fo(TempString));
|
||||
fprint(RESULT, L, "\n--with specified width without fo\n");
|
||||
fprint(RESUlT, L, "> fprint(RESULT, L, ""\%4s"", TempString);\n");
|
||||
fprint(RESULT, L, "%4s", TempString);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n------------------------------------\n" &
|
||||
"-- Support for bit-oriented types --\n" &
|
||||
"------------------------------------\n"
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "\n-- Reasonable format\n" &
|
||||
"> fprint(RESULT, L, ""Reasonable format: \%9{\%r }\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),\n" &
|
||||
"> fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse) \n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Reasonable format: %9{%r }\n",
|
||||
fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),
|
||||
fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse)
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "\n-- Decimal format\n" &
|
||||
"> fprint(RESULT, L, ""Decimal format: \%7{\%d }\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),\n" &
|
||||
"> fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse) \n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Decimal format: %9{%d }\n",
|
||||
fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),
|
||||
fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse)
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "\n-- Bit format\n" &
|
||||
"> fprint(RESULT, L, ""Bit format: \%7{\%b }\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),\n" &
|
||||
"> fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse) \n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Bit format: %9{%b }\n",
|
||||
fo(Std), fo(Uns), fo(SigPos), fo(SigNeg), fo(Unk),
|
||||
fo(Bit1), fo(BitX), fo(BoolTrue), fo(BoolFalse)
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n" &
|
||||
"-- Alignment\n-- Template of the call: (<fs> stands for the format specifier)\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "\n" &
|
||||
"> fprint(RESULT, L, ""Bitvectors with <fs>: \%4{<fs>|}\\n"",\n" &
|
||||
"> fo(Std), fo(Uns), fo(SigPos), fo(SigNeg)\n" &
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n" &
|
||||
"-- Results of the call with various format specifiers\n\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "Bitvectors with \%1r: %4{%1r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%2r: %4{%2r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%3r: %4{%3r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%4r: %4{%4r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%5r: %4{%5r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%6r: %4{%6r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%7r: %4{%7r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%8r: %4{%8r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%9r: %4{%9r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Bitvectors with \%-1r: %4{%-1r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-2r: %4{%-2r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-3r: %4{%-3r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-4r: %4{%-4r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-5r: %4{%-5r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-6r: %4{%-6r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-7r: %4{%-7r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-8r: %4{%-8r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-9r: %4{%-9r|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Bitvectors with \%1d: %4{%1d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%2d: %4{%2d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%3d: %4{%3d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%4d: %4{%4d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%5d: %4{%5d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%6d: %4{%6d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%7d: %4{%7d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%8d: %4{%8d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%9d: %4{%9d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Bitvectors with \%-1d: %4{%-1d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-2d: %4{%-2d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-3d: %4{%-3d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-4d: %4{%-4d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-5d: %4{%-5d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-6d: %4{%-6d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-7d: %4{%-7d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-8d: %4{%-8d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Bitvectors with \%-9d: %4{%-9d|} \n",
|
||||
fo(Uns), fo(Std), fo(SigPos), fo(SigNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n-------------------------------\n" &
|
||||
"-- Support for integer types --\n" &
|
||||
"-------------------------------\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n\n" &
|
||||
"-- Template of the call: (<fs> stands for the format specifier)\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "\n" &
|
||||
"> fprint(RESULT, L, ""Integers with <fs>: \%4{<fs>|}\\n"",\n" &
|
||||
"> fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)\n" &
|
||||
|
||||
"> );\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n" &
|
||||
"-- Results of the call with various format specifiers\n\n"
|
||||
);
|
||||
|
||||
|
||||
fprint(RESULT, L, "Integers with \%5d: %4{%5d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%6d: %4{%6d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%7d: %4{%7d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%8d: %4{%8d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%9d: %4{%9d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%10d: %4{%10d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Integers with \%-5d: %4{%-5d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-6d: %4{%-6d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-7d: %4{%-7d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-8d: %4{%-8d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-9d: %4{%-9d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-10d: %4{%-10d|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Integers with \%5r: %4{%5r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%6r: %4{%6r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%7r: %4{%7r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%8r: %4{%8r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%9r: %4{%9r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%10r: %4{%10r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
fprint(RESULT, L, "Integers with \%-5r: %4{%-5r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-6r: %4{%-6r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-7r: %4{%-7r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-8r: %4{%-8r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-9r: %4{%-9r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "Integers with \%-10r: %4{%-10r|} \n",
|
||||
fo(IntPos), fo(IntNeg), fo(BigIntPos), fo(BigIntNeg)
|
||||
);
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n----------------------\n" &
|
||||
"-- Support for time --\n" &
|
||||
"----------------------\n"
|
||||
);
|
||||
|
||||
fprint (RESULT, L, "-- For portability reasons, time is converted \n" &
|
||||
"-- into an integer value (of nanoseconds)\n"
|
||||
);
|
||||
fprint (RESULT, L, "> wait for 648 ns\n");
|
||||
fprint (RESULT, L, "> fprint (RESULT, L, ""The time is now \%d ns\\n"", fo(now));\n");
|
||||
|
||||
wait for 648 ns;
|
||||
|
||||
fprint (RESULT, L, "The time is now %d ns\n", fo(now));
|
||||
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n----------------------------------------\n" &
|
||||
"-- Erroneous calls and error messages --\n" &
|
||||
"----------------------------------------\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "\n-- Less arguments than formats specifiers\n" &
|
||||
"> fprint(RESULT, L, ""\%d \%d \%d \%d \\n"", fo(Uns), fo(Std));\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "%d %d %d %d \n", fo(Uns), fo(Std));
|
||||
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
fprint(RESULT, L, "-- Unsupported format specifier\n" &
|
||||
"> fprint(RESULT, L, ""\%r \%v \%r \%r\\n"", " &
|
||||
"fo(Uns), fo(Std), fo(Uns), fo(Std));\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "%r %v %r %r\n", fo(Uns), fo(Std), fo(Uns), fo(Std));
|
||||
|
||||
fprint(RESULT, L, "\n");
|
||||
|
||||
fprint(RESULT, L,
|
||||
"\n----------------------------------------\n" &
|
||||
"-- Things you wouldn't expect to work --\n" &
|
||||
"----------------------------------------\n"
|
||||
);
|
||||
|
||||
fprint(RESULT, L, "\n-- Nested iteration\n");
|
||||
fprint(RESULT, L, "> fprint(RESULT, L, ""\%3{<<\%3{_END_}>>}\\n"");\n");
|
||||
fprint(RESULT, L, "%3{<<%3{_END_}>>}\n");
|
||||
|
||||
wait;
|
||||
|
||||
end process USAGE;
|
||||
|
||||
end TB;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
### msMakefile generated by vma on Thu Oct 4 17:33:56 CEST 2001
|
||||
|
||||
ANALYZER = vcom -quiet -nologo
|
||||
ANALYZER_C = vcom -quiet -nologo
|
||||
all : \
|
||||
bin/tbe_pck_fio/tb.dat \
|
||||
bin/tbe_pck_fio/_primary.dat
|
||||
|
||||
# Prerequisites for architecture EASICS_PACKAGES.TBE_PCK_FIO(TB)
|
||||
# Prerequisites for entity EASICS_PACKAGES.TBE_PCK_FIO
|
||||
|
||||
bin/tbe_pck_fio/tb.dat \
|
||||
bin/tbe_pck_fio/_primary.dat : \
|
||||
bin/pck_fio/body.dat \
|
||||
bin/pck_fio/_primary.dat \
|
||||
TB_PCK_FIO_1987.vhd
|
||||
${ANALYZER_C} -work EASICS_PACKAGES TB_PCK_FIO_1987.vhd
|
||||
|
||||
|
||||
# Prerequisites for package body EASICS_PACKAGES.PCK_FIO(<body>)
|
||||
|
||||
bin/pck_fio/body.dat : \
|
||||
bin/pck_fio/_primary.dat \
|
||||
PCK_FIO_1987_BODY.vhd
|
||||
${ANALYZER_C} -work EASICS_PACKAGES PCK_FIO_1987_BODY.vhd
|
||||
|
||||
|
||||
# Prerequisites for package declaration EASICS_PACKAGES.PCK_FIO
|
||||
|
||||
bin/pck_fio/_primary.dat : \
|
||||
PCK_FIO_1987.vhd
|
||||
${ANALYZER} -work EASICS_PACKAGES PCK_FIO_1987.vhd
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
### msMakefile generated by vma on Thu Oct 4 17:32:23 CEST 2001
|
||||
|
||||
ANALYZER = vcom -quiet -nologo -93
|
||||
ANALYZER_C = vcom -quiet -nologo -93
|
||||
all : \
|
||||
bin/tbe_pck_fio/tb.dat \
|
||||
bin/tbe_pck_fio/_primary.dat
|
||||
|
||||
# Prerequisites for architecture EASICS_PACKAGES.TBE_PCK_FIO(TB)
|
||||
# Prerequisites for entity EASICS_PACKAGES.TBE_PCK_FIO
|
||||
|
||||
bin/tbe_pck_fio/tb.dat \
|
||||
bin/tbe_pck_fio/_primary.dat : \
|
||||
bin/pck_fio/body.dat \
|
||||
bin/pck_fio/_primary.dat \
|
||||
TB_PCK_FIO_1993.vhd
|
||||
${ANALYZER_C} -work EASICS_PACKAGES TB_PCK_FIO_1993.vhd
|
||||
|
||||
|
||||
# Prerequisites for package body EASICS_PACKAGES.PCK_FIO(<body>)
|
||||
|
||||
bin/pck_fio/body.dat : \
|
||||
bin/pck_fio/_primary.dat \
|
||||
PCK_FIO_1993_BODY.vhd
|
||||
${ANALYZER_C} -work EASICS_PACKAGES PCK_FIO_1993_BODY.vhd
|
||||
|
||||
|
||||
# Prerequisites for package declaration EASICS_PACKAGES.PCK_FIO
|
||||
|
||||
bin/pck_fio/_primary.dat : \
|
||||
PCK_FIO_1993.vhd
|
||||
${ANALYZER} -work EASICS_PACKAGES PCK_FIO_1993.vhd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user