interface Int(); class t1; integer a[string]; //REQ-EXT-10007 function new; //class constructor body need be modified according to REQ-EXT-10007 a["a"] =40; a["b"] =60; a["c"] =80; endfunction endclass class t2; integer b[string]; //REQ-EXT-10007 function new; //class constructor body need be modified according to REQ-EXT-10007 b["aa"] =44; b["bb"] =66; b["cc"] =88; endfunction endclass t1 inst1 =new; //REQ-EXT-10501 t2 inst2 =new; //REQ-EXT-10501 endinterface module top; Int in(); virtual Int testint =in; integer array[string]; //data type of array need be modified according to REQ-EXT-10007 initial begin #1; array =testint.inst1.a; $display("testint.inst1.a =%p", testint.inst1.a); //CHECK-001:'{"a":40, "b":60, "c":80} $display("array = %p", array); //CHECK-002:'{"a":40, "b":60, "c":80} #2; array =testint.inst2.b; $display("testint.inst2.b =%p", testint.inst2.b); //CHECK-003:'{"aa":44, "bb":66,"cc":88} $display("array =%p", array); //CHECK-004:'{"aa":44, "bb":66,"cc":88} end 根据REQ-EXT-10501这个拓展点,你可以帮我修改一下这段代码吗?如果能多修改几个版本就最好啦!
时间: 2024-03-04 14:49:21 浏览: 109
根据 REQ-EXT-10501 这个拓展点,我们需要修改的是 interface Int 中的构造函数,使其能够初始化 t1 和 t2 中的 a 和 b 数组。同时,我们需要修改 module top 中的 integer array 的数据类型,以支持 string 类型的索引。下面是修改后的代码:
```
interface Int();
class t1;
integer a[string]; //REQ-EXT-10007
function new();
a = '{"a":40, "b":60, "c":80}; //REQ-EXT-10007
endfunction
endclass
class t2;
integer b[string]; //REQ-EXT-10007
function new();
b = '{"aa":44, "bb":66, "cc":88}; //REQ-EXT-10007
endfunction
endclass
t1 inst1 = new(); //REQ-EXT-10501
t2 inst2 = new(); //REQ-EXT-10501
endinterface
module top;
Int in();
virtual Int testint = in;
int array[string]; //REQ-EXT-10007
initial begin
#1;
array = testint.inst1.a;
$display("testint.inst1.a = %p", testint.inst1.a); //CHECK-001: '{"a":40, "b":60, "c":80}'
$display("array = %p", array); //CHECK-002: '{"a":40, "b":60, "c":80}'
#2;
array = testint.inst2.b;
$display("testint.inst2.b = %p", testint.inst2.b); //CHECK-003: '{"aa":44, "bb":66, "cc":88}'
$display("array = %p", array); //CHECK-004: '{"aa":44, "bb":66, "cc":88}'
end
endmodule
```
这样就可以满足 REQ-EXT-10501 的要求了。如果有其他的要求或者需要修改的地方,可以再提出来,我会尽力帮忙修改。
阅读全文