Wrong index type

E

eeh

Hi,

Could anyone tell me how to solve the following error?

Thanks!

ERROR:

HDLParsers:821 - "C:/terry/prj/fpga/counter/delayed_shift_reg.vhd" Line
41. Wrong index type for qlocal.

Code:

entity delayed_shift_reg is
Port ( data : in std_logic;
clk : in std_logic;
outp : out std_logic;
sel : in std_logic_vector(8 downto 0));
end delayed_shift_reg;

architecture Behavioral of delayed_shift_reg is
signal qLocal: std_logic_vector(255 downto 0);
begin
qLocal <= qLocal(254 downto 0) & data;
outp<=qlocal(sel);
end Behavioral;
 
R

Reiner Huober

Note that std_logic_vector is array (natural range <>) of ...
so the index type must be of type natural.

You have to convert the std_logic_vector "sel" to natural using an
appropriate package
like ieee.numeric_std.all

library ieee;
use ieee.numeric_std.all;

....
outp <= qsel(conv_integer(unsigned(sel)));

Hubble
 
R

Reiner Huober

use numeric_std package and to_unsigned. You must convert the unsigned
to std_logic_vector
then.

Examlpe.

library ieee;
use ieee.numeric_std.all;

....
signal x: std_logic_vector(31 downto 0);
signal n: integer;
....
x<=std_logic_vector(to_unsigned(n,x'length));


Hubble.
 
N

Nicolas Matringe

Reiner said:
You have to convert the std_logic_vector "sel" to natural using an
appropriate package like ieee.numeric_std.all

library ieee;
use ieee.numeric_std.all;
...
outp <= qsel(conv_integer(unsigned(sel)));

The exact function is 'to_integer'. conv_integer comes from one of the
std_arith packages.

Nicolas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top