Altera_Forum
Honored Contributor
13 years agoDynamic width of inputs in VHDL.
Hi, I'm finishing my final year project and while connecting a lot of components together I ran into a problem I missed while writing the first component.
I would want to dynamically change the width of my std_logic_vector inputs or a least create signals that have dynamic width depending on an inputed natural, example: LIBRARY ieee; USE ieee.std_logic_1164.all; use ieee.numeric_std.all; entity test1111 is port( n: in natural ); end test1111; architecture archtest of test1111 is signal lk:std_logic_vector(n downto 0); begin end archtest; In this example I have to following problems: the signal lk gives the error: expression is not constant vhdl., does this mean that signals in vhdl HAVE to have constant widths? I got the same problem when declaring a function: function main (poly_in00:std_logic_vector ; n,k: natural) RETURN std_logic_vector is variable vPoly : std_logic_vector(n downto 0) := (others => '0'); Now, normally I would use the 'length parameter in a function, but in this case I have a 2000 wide std_logic_vector but only need a part of it(n) for calculations It would be awesome if anyone could help, thanks a lot! Fred