Using loop vars in a testbench

S

sku11monkey

Guest
Is it possible to assign the value of a loop variable to a
std_logic_vector? I'm trying to make the following code work:

--A : in std_logic_vector(7 downto 0);

for i in 0 to 15 loop
A <= --gets value of i
wait for 20 ns;
loop;


Does anyone know the library and type conversion function that I can use to
assign the loop variable (which I think is of type integer) to A, which is
type std_logic_vector, width=8?

Thanks.
 
http://www.vhdl.org/vi/comp.lang.vhdl/FAQ1.html#4.8.1
Will answer all your question.

Egbert Molenkamp

"sku11monkey" <lord_abel@yahoo.com> schreef in bericht
news:YrKdnRZcXYOVg6zdRVn-gQ@comcast.com...
Is it possible to assign the value of a loop variable to a
std_logic_vector? I'm trying to make the following code work:

--A : in std_logic_vector(7 downto 0);

for i in 0 to 15 loop
A <= --gets value of i
wait for 20 ns;
loop;


Does anyone know the library and type conversion function that I can use
to
assign the loop variable (which I think is of type integer) to A, which is
type std_logic_vector, width=8?

Thanks.
 
i) Your declaration (A: in std_logic_vector(7 downto 0);) implies that A is
an input port to the entity (?)
You cannot assign to input ports.

ii) Assuming the above is just a typing error the following code seems to
compile fine for me:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
.
.
.
signal A : std_logic_vector(7 downto 0);
.
.
.
process is
begin
for i in 0 to 15 loop
A <= std_logic_vector(conv_unsigned(i, A'length));
wait for 20 ns;
end loop;
end process;

It goes without saying that your maximum loop variable should be able to
fit into the number of bits (in this case 8) you have available.
If it doesn't I don't think you'll get a compilation error but it
certainly won't work.

"sku11monkey" <lord_abel@yahoo.com> wrote in message
news:YrKdnRZcXYOVg6zdRVn-gQ@comcast.com...
Is it possible to assign the value of a loop variable to a
std_logic_vector? I'm trying to make the following code work:

--A : in std_logic_vector(7 downto 0);

for i in 0 to 15 loop
A <= --gets value of i
wait for 20 ns;
loop;


Does anyone know the library and type conversion function that I can use
to
assign the loop variable (which I think is of type integer) to A, which is
type std_logic_vector, width=8?

Thanks.
 

Welcome to EDABoard.com

Sponsor

Back
Top