virtual class base;
rand bit[2:0] addr;
pure constraint addr_c;
// constraint addr_c{addr inside{[3:5]};} //works
endclass
class sub extends base;
virtual constraint addr_c{addr inside{[3:5]};}// virtual needed here similar to pure methods ?
rand int abc;
function void tester();
if(addr inside {[3:5]})begin
$displayh("value solved %0d",addr);
end
endfunction:tester
endclass
module tb();
sub c_h;
initial
begin
c_h = new();
if(!c_h.randomize())begin
$display("randomization failed");
end
c_h.tester();
end
endmodule
1] The normal constraints work fine but while using pure constraint i get following error may be still not supported in tool:-
** Error: testbench.sv(3): Missing ‘virtual’ keyword. ‘pure’ qualifier must be followed by ‘virtual’ qualifier.
2] Is it permissible for another subclass to inherits from abstract super class & add a different functionality for constraint?
Eg :- virtual constraint addr_c{addr ==2;} from sub_class_2