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 11:50:24 浏览: 138
根据REQ-EXT-10501,我们需要将代码中的interface改为interface class,并且将Int in()改为in_class(in)。修改后的代码如下:
interface class 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, "b":60, "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, "bb":66, "cc":88}';
endfunction
endclass
t1 inst1 = new(); //REQ-EXT-10501
t2 inst2 = new(); //REQ-EXT-10501
endclass
module top;
interface in_class;
Int in();
endinterface
in_class in(.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
end
除此之外,根据REQ-EXT-10007,我们还需要将integer array[string]改为integer array[$];,并且在class t1和class t2的new函数中,将a和b的赋值方式改为使用JSON格式字符串。
阅读全文