根据REQ-EXT-10007,除了使用associative array代替integer array以外,还有其他方法修改这段代码吗?
时间: 2024-03-04 07:49:17 浏览: 26
根据REQ-EXT-10007,还可以使用queue或者dynamic array代替integer array。以下是使用queue代替integer array的修改方法:
```
interface Int();
class t1;
queue a; //使用queue
function new;
a = new[3];
a[0] = 40;
a[1] = 60;
a[2] = 80;
endfunction
endclass
class t2;
queue b; //使用queue
function new;
b = new[3];
b[0] = 44;
b[1] = 66;
b[2] = 88;
endfunction
endclass
t1 inst1 = new;
t2 inst2 = new;
endinterface
module top;
Int in();
virtual Int testint = in;
int unsigned array[]; //使用dynamic array
initial begin
#1;
array = testint.inst1.a;
$display("testint.inst1.a = %p", testint.inst1.a);
$display("array = %p", array);
#2;
array = testint.inst2.b;
$display("testint.inst2.b = %p", testint.inst2.b);
$display("array = %p", array);
end
end
```
这样修改后,代码仍然可以正常运行。需要注意的是,使用queue代替integer array时,需要使用new[]来创建queue并指定其大小。使用dynamic array时,则使用空的中括号来声明动态数组。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)