I have an array of signals. I want to write to the appropriate cell in the array when a signal which is the "selector" is equal to the cells number. To save on writing and code lines I generate the assignment in a generate loop:
read_data_signals_gen: for i in 0 to (CAU_num -1) generate
v_direction_sig(i)(0) <= DATA_IN when (chosen_flow_sig = i) and (read_state = st_read_v_direction_0) else
v_direction_sig(i)(0);
v_direction_sig(i)(1) <= DATA_IN when (chosen_flow_sig = i) and (read_state = st_read_v_direction_1) else
v_direction_sig(i)(1);
v_direction_sig(i)(2) <= DATA_IN when (chosen_flow_sig = i) and (read_state = st_read_v_direction_2) else
v_direction_sig(i)
...
end generation read_data_signals_gen;
chosen_flow_sig is an std_logic_vector (1 downto 0) and gets "00", "01", "10" or "11" to denote the number of the cell, And CAU_num is an integer constant equal to 4. How do I create the comparison inside the when statement so that an integer number will be equal to its binary translation?
And a related question. Is there a way to perform the following code:
type BitArray is array (natural range <>) of std_logic;
sel_sig : std_logic_vector(0 to 1);
bit_arr : BitArray(0 to 3)
sel_sig <= "00"
bit_arr(sel_sig) <= '1' -- HOW TO PERFORM THIS?