Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > any simple way to load test vector in testbench that contains decimal format?

Reply
Thread Tools

any simple way to load test vector in testbench that contains decimal format?

 
 
py
Guest
Posts: n/a
 
      10-24-2012
Let say I have a vector file in the following format

#input1 input2 input3
123 456 7
111 0 111
#end

Is there any method or package that would convert the decimal number into std_logic_vector? Or would it be too much effort and we should just stick with binary/hex?


Thanks,

 
Reply With Quote
 
 
 
 
Tricky
Guest
Posts: n/a
 
      10-24-2012
On Wednesday, October 24, 2012 9:03:24 AM UTC+1, py wrote:
> Let say I have a vector file in the following format
>
>
>
> #input1 input2 input3
>
> 123 456 7
>
> 111 0 111
>
> #end
>
>
>
> Is there any method or package that would convert the decimal number into std_logic_vector? Or would it be too much effort and we should just stick with binary/hex?
>
>
>
>
>
> Thanks,


read them in as an integer using std.textio, and then use numeric_std to convert to std_logic_vector

slv <= std_logic_vector( to_unsigned( input, slv'length) ) ;

BUT

if they are numbers in the test vector file, why are you using std_logic_vectors in your VHDL? why not integers or unsigned?
 
Reply With Quote
 
 
 
 
Nicolas Matringe
Guest
Posts: n/a
 
      10-24-2012
Le 24/10/2012 11:16, Tricky a écrit :
> if they are numbers in the test vector file, why are you using std_logic_vectors in your VHDL? why not integers or unsigned?


On a top-level entity it is better practice to use sl/slv ports only
because post-p&r models won't use anything else.
In case you want to simulate your p&r result you will then be able to
replace the source entity with the model without any change to the
testbench.

Nicolas

 
Reply With Quote
 
Pontus
Guest
Posts: n/a
 
      10-24-2012
On 24 Okt, 10:03, py <phoenixy...@gmail.com> wrote:
> Let say I have a vector file in the following format
>
> #input1 input2 input3
> 123 * * 456 * * *7
> 111 * * * 0 * *111
> #end
>
> Is there any method or package that would convert the decimal number intostd_logic_vector? Or would it be too much effort and we should just stick with binary/hex?
>
> Thanks,


If you attempt to parse the test vector file (TVF) with a VHDL
code written by you you will need to handle all the possible
irregularities of the test vector file (TVF) yourself.
What I mean is that your TVF *has* syntax, and so you can have
syntax errors...
Discovering those after a long simulation run may hurt.

Instead, try to embed your test vectors into a valid VHDL package
You will need a header part (package xyz is ...) declaring
types (arrays of integers) and then your TVF with correct
syntax, i.e. commas between values etc. Finnaly an tail part
(end package xyz.

The big pro is that you will catch those syntax errors at compile
time.

Converting the integers to slv's is best done using numeric_std
package (e.g. std_logic_vector(to_unsigned(int,16)) )

-- HTH Pontus
 
Reply With Quote
 
rickman
Guest
Posts: n/a
 
      11-05-2012
On 11/5/2012 3:59 AM, Ralf Hildebrandt wrote:
> Hi py!
>
>> Is there any method or package that would convert the decimal number

> into std_logic_vector? Or would it be too much effort and we should just
> stick with binary/hex?
>
> Maybe have a look at <http://bear.ces.case.edu/VHDL/index.html>. This is
> a package to have ANSI C - like file I/O in VHDL. It is often more
> easier to read than the standard VHDL methods.
>
> Ralf


Great! Thanks

Rick
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
Regex problem, match if line contains <a>, unless it also contains <b> James Dyer Perl 5 02-20-2004 12:29 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments
 



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