Matrix 在vhdl中为矩阵(2D数组)插入行函数?

Matrix 在vhdl中为矩阵(2D数组)插入行函数?,matrix,vhdl,Matrix,Vhdl,是否有一种在矩阵中设置一行值的速记方法?我正在寻找函数/过程类型的解决方案 澄清一下,我所说的矩阵不是指数组的数组,而是指二维数组 我已通过以下方式读取了特定行: function extract_row(matrix : matrix_type; row_index : natural) return row_type is variable res : row_type (matrix'range(2)); begin for i in res'range loop

是否有一种在矩阵中设置一行值的速记方法?我正在寻找函数/过程类型的解决方案

澄清一下,我所说的矩阵不是指数组的数组,而是指二维数组

我已通过以下方式读取了特定行:

function extract_row(matrix : matrix_type; row_index : natural) return row_type is
    variable res : row_type (matrix'range(2));
begin
    for i in res'range loop
        res(i) := matrix(row, i);
    end loop;
    return res;
end function;
现在我需要一种方式来设置行,类似于在数组中设置子数组的方式:

signal x : array_of_rows_type(range_a)(range_b);
signal y : row_type(range_b);

x(0) <= y;

我没有你的类型,所以我无法编译它以确保它工作,但这可能会帮助你接近

function row_insert_solution(matrix : matrix_type; 
                             row_insert : row_type; 
                             row_index : natural
                             ) return matrix_type is

variable res : matrix_type := matrix;
begin
  for i in row_insert'range loop
    res(row_index, i) := row_insert(i);
  end loop;

  return res;
end function;

我似乎识别出
extract\u row
函数的代码。也许您可以调整同一软件包中提供的函数
replace\u matrix\u column

function replace_matrix_column(
    input_matrix: bit_matrix; 
    new_column: bit_vector; 
    column_index: integer
) return bit_matrix is
    variable output: bit_matrix(input_matrix'range(1), input_matrix'range(2));
begin
    for i in input_matrix'range(1) loop
        for j in input_matrix'range(2) loop
            if j = column_index then
                output(i, j) := new_column(i);
            else
                output(i, j) := input_matrix(i, j);
            end if;
        end loop;
    end loop;

    return output;
end;
那么你可以这样称呼它:

x <= replace_matrix_row(x, y, 0);
xy,行索引=>0);

什么矩阵?既不显示类型声明,也不显示上下文子句<代码>矩阵的范围(2)显示
矩阵类型
是一种数组类型。在子程序中可以使用在要隐藏的内联代码中使用的相同解决方案。如果您在子程序中写入信号,那么这是一个过程,并在组件实例化中模拟一个层次结构级别。是什么阻止了你写函数?(
x(0)
x <= replace_matrix_row(x, y, 0);
x <= replace_matrix_row(input_matrix => x, new_row => y, row_index => 0);