Re: CP-007 and CP-008: textio for std_logic_1164


Subject: Re: CP-007 and CP-008: textio for std_logic_1164
From: Jim Lewis (Jim@synthworks.com)
Date: Mon Feb 17 2003 - 06:25:58 PST


I agree with the analysis of CP-008.

For CP-007, I agree with the analysis and proposed
solution. I would also like to propose a few
backward compatible enhancements.

1) Add decimal write (dwrite see 2).

2) Make hwrite, owrite, dwrite so they work with
the size of array passed and effectively consider the
non-provided bits 0. For example, if I have an
address that is 21 bits, I would like to treat the
value as if the 3 leftmost bits are '0' and print
the value. Anyone reading the printed value knows
the value is only 21 bits and hence would not have
a problem understanding the value.

variable addr : std_logic_vector(20 downto 0) ;
. . .
hwrite(WB, addr) ;

if Addr = 1 0000 0000 0101 1010 1111
then printed value = 1005AF

-- without this enhancement, I need to write:
hwrite(WB, "000" & addr) ;

3) Add decimal read (dread see 4)

4) For hread, oread, dread read enough characters to
fill the array (if enough characters are not present
then error). If there are extra characters, throw
out the leftmost bits of the extra characters.

This means to read a 21 bit hex address, I can simply

hread(RB, addr) ;

Otherwise to get the same meaning, I need to:
variable addr_temp : std_logic_vector(23 downto 0) ;

hread(RB, addr_temp) ;
addr <= addr_temp(addr'range) ;

5) TO_STR, TO_HSTR, TO_OSTR, TO_DSTR, ...
I would like a set of procedures that convert from a
std_logic_vector, std_ulogic_vector to a string value.
Very similar in concept to 'image except it works for
strings. These functions are currently built into
write, hwrite, and owrite. The advantage to providing
these separately is that someone using assert or
VHDL built-in write can use these conversions to allow
the printing of std_logic_vector values.

For example:

assert (ExpectedVal = ReadVal)
   report "In ... Expected Value /= Read Value. Expected = " &
         TO_STR(Expected) & " Read = " & TO_STR(ReadVal))
   severity error ;

Similarly without having the standard assert messages,
a quick error message can be dumped to the console:
if (ExpectedVal /= ReadVal) then
   write(OUTPUT, "In ... Expected Value /= Read Value. Expected = " &
         TO_HSTR(Expected) & " Read = " & TO_HSTR(ReadVal)) ) ;
   ErrCnt := ErrCnt + 1 ;
end if ;

While it is not printf, it is not a too bad alternative,
especially if we can make the conversion function names
short.

Note, this is something I am asking for in VHDL-200X,
so perhaps it needs to be coordinated with that effort.
Note for 200X, we are considering fast-tracking some
items (under circumstances like this) so they can get
put into the current generation of packages.

Cheers,
Jim

Peter Ashenden wrote:
> Dear colleagues,
>
> I have prepared analyses for CP-007 and CP-008 relating to text I/O for
> standard logic values. Please see
>
> www.eda.org/vhdl-std-logic/proposals/
>
> Let the discussion begin...
>
> Cheers,
>
> PA

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training             mailto:Jim@SynthWorks.com
SynthWorks Design Inc.           http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



This archive was generated by hypermail 2b28 : Mon Feb 17 2003 - 06:28:19 PST