Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] conversion from std_logic_vector to integer in numeric_std get me an error

Status
Not open for further replies.

qwerty_asdf

Member level 4
Joined
Mar 26, 2012
Messages
73
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,781
I have use those imports:
Code:
library IEEE;
use IEEE.std_logic_1164.all;

This is my code:
Code:
signal i:std_logic_vector(address_length-1 downto 0);

signal k: integer range 0 to 100:=0;
...
k<=to_integer(unsigned(i));

and this is my error:
Code:
com-1136) Unknown identifier "to_integer".

2) this one also get me an error.

Code:
Code:
out_temp<=inp1(0)+inp1(1);
where inp1.out_temp are std_logic_vectors. This is my error:
Code:
No feasible entries for infix operator "+".
** Error: C:/Modeltech_pe_edu_10.1a/examples/landmark_1.vhd(49): Type error resolving infix expression "+" as type ieee.std_logic_1164.STD_LOGIC_VECTOR.
Am I not allowed to add 2 std_logic_vectors or is something else?
 

To_unsigned is defined in numeric_std.
You forgot to tell that you want to use that library:

use ieee.numeric_std.all;

And yes, you are not allowed to add std_logic_vectors. You must tell the tools what the bits represent. With numeric_std, you can cast std_logic_vector to "unsigned" or "signed" and then do the addition.

If you want to do arithmetic stuff, it is often very convenient to use the types "unsigned" and "signed" directly, instead of std_logic_vector. You can so that for signals, variables and ports.
 
Thanks. i tried it on my own. I thought that use IEEE.std_logic_1164.all; was enough.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top