Can the indivdual variables of a SystemVerilog str

2019-06-11 03:28发布

I have defined a structure with three integers, then created a dynamic array of the structure. Later in the code, I want to increment some of the integer values in the structure:

typedef struct {
  integer tc;
  integer pass;
  integer fail;
} score_t; 

score_t    scorecard[]; 
integer    tc_count;

initial
....
scorecard = new[`MAX_TC]; 
....
scorecard[tc_count].fail  = 0;
....
scorecard[tc_count].fail++;

However, when I compile in Aldec Active-HDL I get the following error:

Error: VCP2615 ../../../m3_test_load_tb.sv : (283, 33): 
                    scorecard[tc_count].fail is not l-value.

Is this a limitation of the language? I can assign to a temporary variable to do the increment operation and then put the value back in the struct, but that seems clumsy.

1条回答
贪生不怕死
2楼-- · 2019-06-11 03:55

The code compiles with modelsim 10.1d. I have tested it on EDA Playground.

Seems the Aldec tool does not like the line:

scorecard[tc_count].fail++;

As a workaround you can replace the line with:

scorecard[tc_count].fail += 1;

Now it compiles with Aldec tool as well. http://www.edaplayground.com/x/VpV

查看更多
登录 后发表回答