Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)
-   -   Re: Writing Hex values to file in VHDL? (http://www.velocityreviews.com/forums/t718470-re-writing-hex-values-to-file-in-vhdl.html)

Magne Munkejord 03-23-2010 09:22 AM

Re: Writing Hex values to file in VHDL?
 
Pete Fraser wrote:
> I'm trying to dump eight hex values per line
> into a file, and can't work out how to do it.
>
> for index in 0 to 127 loop
> for sample_sel in 0 to 7 loop
> sample_val := integer(scale * sin(phase(sample_sel)));
> write ( sample_line, sample_val, RIGHT, 10);
> phase(sample_sel) := phase(sample_sel) + phase_inc(sample_sel);
> end loop;
> writeline ( ip_dat, sample_line );
> end loop;
>
> does what I want, but with decimal values.
>
> If I change to:
> hwrite ( sample_line, sample_val, RIGHT, 10);
> or:
> write ( sample_line, to_hstring(sample_val), RIGHT, 10);
> it doesn't compile.
>
> Any thoughts?
>
> Thanks
>
> Pete
>
>
>


From my experiences from modelsim :
* hwrite works on std_logic_vector but requires the vector to be of
"even length", that is the length must be a multiple of 4.
* to_hstring doesn't work for std_logic_vector, you'll have to convert
it to a bit_vector first.

In your case I would try using
hwrite(sample_line, std_logic_vector(to_unsigned(sample_val, <length>)));

replace <length> with a valid length for your vector: 4,8,12,16... etc.

(remember to add : use ieee.numeric_std.all;)

Magne

Magne Munkejord 03-23-2010 12:43 PM

Re: Writing Hex values to file in VHDL?
 
Pete Fraser wrote:
> "Magne Munkejord" <magnemunk@yahoo.no> wrote in message
> news:hoa188$2opp$1@toralf.uib.no...
>
>> From my experiences from modelsim :
>> * hwrite works on std_logic_vector but requires the vector to be of "even
>> length", that is the length must be a multiple of 4.
>> * to_hstring doesn't work for std_logic_vector, you'll have to convert it
>> to a bit_vector first.

>
> Probably my problem is that sample_val is an integer.
> How to I print an integer as hex?
>
> Thanks
>
> Pete
>
>

It was in the original post, if you missed it:
std_logic_vector(to_unsigned(sample_val, <length>))

make sure <length> is multiple of 4 if you intend to use it with hwrite.


All times are GMT. The time now is 05:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57