Loop operator "For" to fill an array in VHDL

Solution 1:

"m1(001) means a value on the first cell, m1(015) is on the 15th cell"

If by "first cell" you mean the cell with the smallest index then no, m1(1) is not the "first" cell, it is the "second" (and m1(15) is the "sixteenth") because you declared your array type with 0 as the "first" index, not 1. Note that, according these array definitions your loops are probably wrong: they should start at index 0, not 1.

"Can BrMet(0) mean something else?"

Else than what? BrMet(0) is the cell of array BrMet with the smallest index.

"How can I add BrMet in this loop?"

You apparently know how to declare array types and use them. This is no different. Just declare an array type and a constant of this type:

type BrMetIdx_t is array(0 to 15) of integer;
constant BrMetIdx: BrMetIdx_t := (3, 1, 0, 2, 0, 2, 3, 1, 2, 0, 1, 3, 1, 3, 2, 0);
...
for i in 0 to 15 loop 
  m1(i) <= MetricA(i) + BrMet(BrMetIdx(i));
end loop;
...

Note: it would probably be safer to restrict the type of elements of BrMetIdx_t arrays to integers in the 0 to 3 range:

type BrMetIdx_t is array(0 to 15) of integer range 0 to 3;

This way, if there is a typo with, e.g., value 4, in your constant declaration you will get a clear error message from the compiler.

Note: you don't have to declare your array types with a "downto" index range. This is a common practice for vectors of bits because indexing them from right to left is also common but for your m1, MetricA and BrMet arrays you could probably as well index them in a more "natural" way:

type   BRANCH_METRIC is array (0 to 3) of STD_LOGIC_VECTOR (7 downto 0);
type   PATH_METRIC is array (0 to 15) of STD_LOGIC_VECTOR (7 downto 0);

This would probably help the global understanding.

Note: I doubt that you will ever use multiple drive for the path and branch metrics of your (Viterbi?) decoder. It would thus be safer to use an unresolved type like std_ulogic_vector instead of std_logic_vector. This way, if by accident you create a multiple drive situation, you will get a clear error message from the compiler instead of spending hours trying to understand why you see all these X values during simulation.