Discussion:
Cannot find function "TO_INTEGER" for these actuals
(too old to reply)
Travis
2013-06-15 01:21:11 UTC
Permalink
Hi all, I'm compiling the following VHDL to make a simple ROM, and I'm getting these errors:
# Error: COMP96_0305: SUBONE_MODULE_VHDL.vhd : (93, 23): Cannot find function "TO_INTEGER" for these actuals.
# Error: COMP96_0138: SUBONE_MODULE_VHDL.vhd : (93, 23): The index types in the reference to the array object are incompatible with its range type.

I'm using Active-HDL 9.2. This was based off an example I got online, but I had to switch to the NUMERIC_STD IEEE library because I want to synthesize this.

Thanks!

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;


entity SUBONE_MODULE_VHDL is
port(
addr : in STD_LOGIC_VECTOR(4 downto 0);
clk : in STD_LOGIC;
dout : out STD_LOGIC_VECTOR(4 downto 0)
);
end SUBONE_MODULE_VHDL;

--}} End of automatically maintained section

architecture SUBONE_MODULE_VHDL of SUBONE_MODULE_VHDL is

-- enter your statements here --

type ROM_Array is array (0 to 31)
of std_logic_vector(4 downto 0);


constant Content: ROM_Array := (
0 => "10011", -- Suppose ROM has
1 => "00000", -- prestored value
2 => "00001", -- like this table
3 => "00010", --
4 => "00011", --
5 => "00100", --
6 => "00101", --
7 => "00110", --
8 => "00111", --
9 => "01000", --
10 => "01001", --
11 => "01010", --
12 => "01011", --
13 => "01100", --
14 => "01101", --
15 => "01110", --
16 => "01111", --
17 => "01110", --
18 => "01110", --
19 => "01110", --
20 => "01110", --
21 => "00000", --
22 => "00001", --
23 => "00010", --
24 => "00011", --
25 => "00100", --
26 => "00101", --
27 => "00110", --
28 => "00111", --
29 => "01000", --
30 => "01001", --
31 => "01010", --
OTHERS => "00000"
);

begin
process(clk, addr)
variable addr : integer := 0;
begin
if( clk'event and clk = '1' ) then
dout <= Content(TO_INTEGER(addr));
end if;
end process;


end SUBONE_MODULE_VHDL;
KJ
2013-06-15 02:47:28 UTC
Permalink
You have...

dout <= Content(TO_INTEGER(addr));

should be...

dout <= Content(TO_INTEGER(unsigned(addr)));

The reason is that addr is defined to be a std_logic_vector. Std_logic_vector has no numeric interpretation it is just an arbitrary collection of bits. By casting it as 'unsigned' you are saying to interpret it as an unsigned numeric quantity which can then be converted to an integer value.

Kevin Jennings
Travis
2013-06-15 05:00:52 UTC
Permalink
Thank you so much! I'll try it ASAP and report back!
Post by KJ
You have...
dout <= Content(TO_INTEGER(addr));
should be...
dout <= Content(TO_INTEGER(unsigned(addr)));
The reason is that addr is defined to be a std_logic_vector. Std_logic_vector has no numeric interpretation it is just an arbitrary collection of bits. By casting it as 'unsigned' you are saying to interpret it as an unsigned numeric quantity which can then be converted to an integer value.
Kevin Jennings
Andy
2013-06-17 12:57:45 UTC
Permalink
Travis,

You also need to remove the unused variable declaration for addr in the process. It is hiding the addr port.

Andy
Travis
2013-06-17 15:53:59 UTC
Permalink
Hi Andy,

I just tried Kevin's solution, noticed the error, got bummed, noticed your solution, and now all is fixed. Thank you both!

Andy & Kevin, if I could ask, it appears I was interpreting what "variable addr : integer;" was doing. I thought it was providing context for use of "addr" within the process block, but this is apparently incorrect. Do you have a good reference or pointer for these types of things?

Thanks again!
Post by Andy
Travis,
You also need to remove the unused variable declaration for addr in the process. It is hiding the addr port.
Andy
Andy
2013-06-17 17:18:58 UTC
Permalink
Variables are storage objects that are usually local to processes or subprograms where they are declared. They are assigned using ":=" instead of "<=". Their value updates immediately upon execution of the assignment statement, instead of waiting until the process suspends, like signal values do.

Most VHDL texts cover variables, but most will tell you not to use them for RTL (or at least not for registers in RTL), which is unfortunate, since variables are quite powerful for both combinatorial and register logic, once you know how to use them.

Andy
k***@xilinx.com
2013-06-17 15:56:28 UTC
Permalink
Another option is to make the input 'unsigned', which is a better type in this context.
Andy
2013-06-17 17:28:03 UTC
Permalink
What Kevin said (make addr unsigned).

Or, if your tools support vhdl-2008, you can use the new package ieee.numeric_std_unsigned.all, and use to_integer(addr) without converting (or changing) addr to unsigned.

Andy
Travis
2013-06-18 16:45:45 UTC
Permalink
Xilinx ISE won't be supporting VHDL 2008 at all, apparently they're reserving that for the Vivado tools, which is truly sad because it looks like VHDL2008 is a meaningful update.
Post by Andy
What Kevin said (make addr unsigned).
Or, if your tools support vhdl-2008, you can use the new package ieee.numeric_std_unsigned.all, and use to_integer(addr) without converting (or changing) addr to unsigned.
Andy
k***@xilinx.com
2013-06-18 16:59:08 UTC
Permalink
And who knows how much 2008 Vivado really supports. Probably not much. Use Synplify, if possible. The VHDL 2008 additions are indispensable. One thing I could not do without is the fixed-point package.
Travis
2013-06-18 18:11:06 UTC
Permalink
I will examine the Synopsys tools; I'm converting a design that is largely schematic based in Active-HDL (that has components that date back to Active-CAD) to VHDL, and there are numerous headaches.
Post by k***@xilinx.com
And who knows how much 2008 Vivado really supports. Probably not much. Use Synplify, if possible. The VHDL 2008 additions are indispensable. One thing I could not do without is the fixed-point package.
k***@xilinx.com
2013-06-18 19:04:40 UTC
Permalink
I've had to do the same thing, but years ago. I assumed nobody was using schematics anymore. I do see a lot of HDL that looks like schematic netlists.
Travis
2013-06-18 22:49:06 UTC
Permalink
Schematics are great from a top down perspective, "The block does this", etc, but the design I'm converting has AND, OR, inverters, Virtex specific buffers, etc sprinkled throughout it.

We're using Active-HDL, and we have uncovered SO many problems with the tool it is ridiculous. Apparently so few people do it this way they're dropping support for updated Xilinx schematic input in Active-HDL 9.3.
Post by k***@xilinx.com
I've had to do the same thing, but years ago. I assumed nobody was using schematics anymore. I do see a lot of HDL that looks like schematic netlists.
rickman
2013-06-20 01:45:21 UTC
Permalink
Post by Travis
Xilinx ISE won't be supporting VHDL 2008 at all, apparently they're reserving that for the Vivado tools, which is truly sad because it looks like VHDL2008 is a meaningful update.
That is pretty amazing! I can't believe Xilinx is ignoring VHDL 2008.
I am coding in VHDL 2008 and expect my tools to support that.

I don't have any trouble with the Lattice tools including the Active-HDL
simulator. I was working with the iceCube tool for the iCE40 parts, but
haven't done anything with VHDL 2008 in the main line devices. I may
try it with the current design I'm working on. I need to get a new
laptop and will install the newer tools on it and give VHDL 2008 a run
under Diamond.
--
Rick
Anssi Saari
2013-06-24 10:31:06 UTC
Permalink
Post by rickman
Post by Travis
Xilinx ISE won't be supporting VHDL 2008 at all, apparently they're reserving that for the Vivado tools, which is truly sad because it looks like VHDL2008 is a meaningful update.
That is pretty amazing! I can't believe Xilinx is ignoring VHDL
2008. I am coding in VHDL 2008 and expect my tools to support that.
I'd also expect Xilinx to support at least the fixed point stuff in ISE.
Didn't everyone add that almost overnight?
k***@xilinx.com
2013-06-24 16:59:36 UTC
Permalink
Theoretically, the fixed point library shouldn't require any special synthesizer support but I wouldn't be surprised if ISE didn't like it for some reason. I definitely wouldn't try it with unconstrained i/o. And, as with integer math functions, I wouldn't expect it to map to DSP48s very well.
Andy
2013-06-25 12:50:55 UTC
Permalink
Unconstrained IO fixed point should work fine, since the bound object is static and therefore it's index range is static too. Just be real careful with bit string literals! (e.g. don't use bit string literals for fixed/floating point).

Fixed point arithmetic is implemented using numeric_std operators, so it should do fine for anything

IIRC, some synthesis tools had problems with fixed point because they did not support negative indices on arrays (slv/signed/unsigned have natural index ranges). There are '93 compatible versions of the fixed point package available, they just don't support package generics for saturate/rollover or round/truncate and number of guard bits for division. You have to change the constants in the '93 package.

Andy
Alan Fitch
2013-06-25 18:46:11 UTC
Permalink
Post by Andy
Unconstrained IO fixed point should work fine, since the bound object is static and therefore it's index range is static too. Just be real careful with bit string literals! (e.g. don't use bit string literals for fixed/floating point).
Fixed point arithmetic is implemented using numeric_std operators, so it should do fine for anything
IIRC, some synthesis tools had problems with fixed point because they did not support negative indices on arrays (slv/signed/unsigned have natural index ranges). There are '93 compatible versions of the fixed point package available, they just don't support package generics for saturate/rollover or round/truncate and number of guard bits for division. You have to change the constants in the '93 package.
Andy
From memory, there was an ieee_proposed library in Xilinx XST.

Also there are Xilinx (and other tool) versions of the packages at
www.eda.org/fphdl which should work fine.

I haven't tested the VHDL 2008 support in Vivado yet - amusingly Xilinx
now have three VHDL parsers. Two in ISE depending on which device you
select; and a new one in Vivado,

regards
Alan
--
Alan Fitch
Continue reading on narkive:
Loading...