Я пытаюсь изучить методы сокращения массива в системном verilog.Написал ниже модуль:
module main;
localparam [7:0]PARAM_ARR0[3:0] = '{8'h1,8'h3,8'h4,8'h0};
localparam [3:0]PARAM_ARR1[7:0] = '{4'h3,4'h2,4'h2,4'h2,4'h1,4'h1,4'h1,4'h1};
int s = 0;
logic [7:0]arr0[3:0] = '{8'h1,8'h3,8'h4,8'h0};
logic [3:0]arr1[7:0] = '{4'h3,4'h2,4'h2,4'h2,4'h1,4'h1,4'h1,4'h1};
initial begin
//s = int'(PARAM_ARR0.sum() with (item.index<int'(PARAM_ARR1[0])?item:0));
//$display("sum0 = %0d",s);
//s = int'(PARAM_ARR0.sum() with (item.index<int'(PARAM_ARR1[4])?item:0));
//$display("sum1 = %0d",s);
s = int'(arr0.sum() with (item.index<int'(arr1[0])?item:0));
$display("sum0 = %0d",s);
s = int'(arr0.sum() with (item.index<int'(arr1[4])?item:0));
$display("sum1 = %0d",s);
s = int'(arr0.sum() with (item.index<int'(arr1[7])?item:0));
$display("sum2 = %0d",s);
end
endmodule
- Если я раскомментирую первые 4 строки после начальной (сокращение массива на двумерном массиве параметров), VCS выдаст ошибки компиляции, как показано ниже.Методы массива не применимы к массивам параметров?
Error-[XMRE] Cross-module reference resolution error
../../test_param_array_sum.sv, 10
Error found while trying to resolve cross-module reference.
token 'sum'. Originating module 'main'.
Source info: PARAM_ARR0.sum(item) with (((item.index < int'(4'b1))
? item : 0))
Error-[IND] Identifier not declared
../../test_param_array_sum.sv, 10
Identifier 'item' has not been declared yet. If this error is not expected,
please check if you have set `default_nettype to none.
Еще одно сомнение в том, что когда я симулирую код в VCS, как указано выше, я получаю следующие результаты:
sum0 = 1
sum1 = 4
sum2 = 8
Я ожидал, что результаты будут 0, 4 и 7соответственно.Потому что я пытался получить сумму всех элементов в arr0, чей индекс меньше чем arr1 [0] (1), arr1 [4] (2), arr1 [7] (3) соответственно.
Спасибо