Wrong index type

E

eeh

Guest
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;
 
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
 
Besides, could u tell me how to convert integer back to
std_logic_vector?
 
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.
 
Reiner Huober wrote:
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
 

Welcome to EDABoard.com

Sponsor

Back
Top