Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Using numeric_std packages

Reply
Thread Tools

Using numeric_std packages

 
 
hssig
Guest
Posts: n/a
 
      06-12-2012
Hi,

I am trying to use the VHDL-2008 library "numeric_std_unsigned" to
increment a std_logic_vector by one:

use ieee.numeric_std_unsigned.all;

signal vec : std_logic_vector(15 downto 0) := (others => '0');

vec <= vec + 1 when rising_edge(clk);


Now I have in the same VHDL file the following conversion:

constant cIniVec : std_logic_vector(15 downto 0) :=
std_logic_vector(to_unsigned(1,16));


That means that I have to include both libraries:
use ieee.numeric_std.all;
use ieee.numeric_std_unsigned.all;

Do I use the packages how nature intended it?

Cheers, hssig






 
Reply With Quote
 
 
 
 
nivparsons
Guest
Posts: n/a
 
      06-12-2012
On Tuesday, June 12, 2012 12:57:25 PM UTC+1, hssig wrote:
> Hi,
>
> I am trying to use the VHDL-2008 library "numeric_std_unsigned" to
> increment a std_logic_vector by one:
>
> use ieee.numeric_std_unsigned.all;
>
> signal vec : std_logic_vector(15 downto 0) := (others => '0');
>
> vec <= vec + 1 when rising_edge(clk);
>
>
> Now I have in the same VHDL file the following conversion:
>
> constant cIniVec : std_logic_vector(15 downto 0) :=
> std_logic_vector(to_unsigned(1,16));
>
>
> That means that I have to include both libraries:
> use ieee.numeric_std.all;
> use ieee.numeric_std_unsigned.all;
>
> Do I use the packages how nature intended it?
>
> Cheers, hssig


You can do something like this:
my_SLV <= SLV(UNSIGNED(my_SLV) + 1);

where SLV is STD_LOGIC_VECTOR, my_SLV is you vector/signal and then you only need the NUMERIC_STD package. (I think)!
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      06-13-2012
On Tuesday, June 12, 2012 7:57:25 AM UTC-4, hssig wrote:
> Hi,
>
> I am trying to use the VHDL-2008 library "numeric_std_unsigned" to
> increment a std_logic_vector by one:
>
> use ieee.numeric_std_unsigned.all;
>
> signal vec : std_logic_vector(15 downto 0) := (others => '0');
>
> vec <= vec + 1 when rising_edge(clk);
>
>
> Now I have in the same VHDL file the following conversion:
>
> constant cIniVec : std_logic_vector(15 downto 0) :=
> std_logic_vector(to_unsigned(1,16));
>
>
> That means that I have to include both libraries:
> use ieee.numeric_std.all;
> use ieee.numeric_std_unsigned.all;
>
> Do I use the packages how nature intended it?
>


No you're not. You should declare vec (and cIniVec) to be of type unsigned.. std_logic_vector is used for an arbitrary collection of bits that have no numeric interpretation as well as for interfacing to the outside world. Your usage doesn't meet either criteria. Also, simply use ieee.numeric_std..all

Kevin Jennings
 
Reply With Quote
 
hssig
Guest
Posts: n/a
 
      06-18-2012
As I already mentioned:

I am trying to increment a std_logic_vector by one (not possible with "numeric_std" but with "numeric_std_unsigned") in a testbench file.
At the same time I want to use conversions that are part of "numric_std" but
not of "numeric_std_unsigned", for example conversion functino "to_unsigend" of an integer.

So how can I use both?

Cheers, hssig
 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      06-18-2012
On Monday, June 18, 2012 3:36:50 AM UTC-4, hssig wrote:
> As I already mentioned:
>
> I am trying to increment a std_logic_vector by one (not possible with "numeric_std" but with "numeric_std_unsigned") in a testbench file.
> At the same time I want to use conversions that are part of "numric_std" but
> not of "numeric_std_unsigned", for example conversion functino "to_unsigend" of an integer.
>
> So how can I use both?
>


I already posted the best way to do that which is to change the type of the signal to unsigned rather than std_logic_vector.

The next best way is to cast them to the proper type

signal vec : std_logic_vector(15 downto 0) := (others => '0');
vec <= std_logic_vector(unsigned(vec) + 1) when rising_edge(clk);

Using ieee.numeric_std.all only

Kevin Jennings
 
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
Python Packages : A loomingproblem? packages might no longer work? (well not on your platform or python version anyway) David Lyon Python 19 04-23-2009 11:10 PM
How Do Perform STD_LOGIC_VECTOR Addition Using IEEE.NUMERIC_STD? Chris VHDL 10 06-29-2007 10:03 PM
Modelsim Slice error using numeric_std Beanut VHDL 5 09-22-2005 01:16 PM
Do the javax.imageio packages replace packages in com.sun.image? Paul Smith Java 0 11-18-2003 02:58 PM



Advertisments