Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I index into a vhdl std_logic_vector?

Tags:

vhdl

I have the following declarations:

signal count:STD_LOGIC_VECTOR (3 downto 0);
signal txbuff:STD_LOGIC_VECTOR (7 downto 0);
  1. dout is a std_logic output
  2. I am using IEEE.NUMERIC_STD.ALL;

I want to use the vector count as an index into txbuff. Among the many things I've tried is the following:

count<=std_logic_vector(unsigned(count)-1);
dout<=txbuff(unsigned(count));

but I get the following error:

Line 99. Wrong index type for txbuff.

like image 762
Jim Bob Avatar asked Sep 12 '25 10:09

Jim Bob


1 Answers

You need an integer as the index type. (Or with other arrays, you can use any discrete type, such as as enumeration).

Other answers have showed you how to get there using type conversion functions : I'll ask instead, why not make "count" an integer, like natural range 0 to 15 in the first place? It'll synthesise just the same, and make for cleaner simpler code.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!