I have been looking at test benches and learning about FOR LOOPS. I wanted to write some simple VHDL to print out some the numbers in the index of a for loop. This turned out to be more difficult than I first thought until I discovered how to convert an integer into a string using integer'image(i). The following code loops around 11 time and outputs the index from the loop:
entity testxx is
end entity;
architecture arch of testxx is
begin
process
begin
for i in 0 to 10 loop
report "julian=" & integer'image(i);
wait for 10 ns;
end loop;
wait;
end process;
end architecture;
The output from modelsim can be seen below:
run -all
# ** Note: julian=0
# Time: 0 ps Iteration: 0 Instance: /testxx
# ** Note: julian=1
# Time: 10 ns Iteration: 0 Instance: /testxx
# ** Note: julian=2
# Time: 20 ns Iteration: 0 Instance: /testxx
# ** Note: julian=3
# Time: 30 ns Iteration: 0 Instance: /testxx
# ** Note: julian=4
# Time: 40 ns Iteration: 0 Instance: /testxx
# ** Note: julian=5
# Time: 50 ns Iteration: 0 Instance: /testxx
# ** Note: julian=6
# Time: 60 ns Iteration: 0 Instance: /testxx
# ** Note: julian=7
# Time: 70 ns Iteration: 0 Instance: /testxx
# ** Note: julian=8
# Time: 80 ns Iteration: 0 Instance: /testxx
# ** Note: julian=9
# Time: 90 ns Iteration: 0 Instance: /testxx
# ** Note: julian=10
# Time: 100 ns Iteration: 0 Instance: /testxx
No comments:
Post a Comment