I am facing a problem while running below code on Questa Sim Tool i.e giving me Randomization Failure , as there may be conflict in the constaint.
But when tried to run using Synopsis VCS tool or Cadence tool , the code is running fine i.e without Randomization Failure .
Can somebody please tell if i am missing any system verilog concept or what should i change in the code to get it run on Questa Sim tool?
//---------------------------------------------------------------
class packet;
randc bit[31:0] src_addr;
randc bit[31:0] dst_addr;
typedef enum {SRAM, OTP, ROM, BUFFER}slave;
randc bit[5:0] burst_size ;
randc bit[8:0] transfer_count ;
randc bit[1:0] channel;
rand bit[31:0] start_address;
rand int end_address;
randc slave src_slave;
randc slave dst_slave;
constraint slave_dst_sram{if( dst_slave==SRAM) {(end_address inside {['h1000:'h2FFFF]} && dst_addr inside {['h1000:'h2FFFF]})};}
constraint slave_dst_otp{if( dst_slave==OTP) {(end_address inside {['h0:'h0FFF]} && dst_addr inside {['h0:'h0FFF]})};}
constraint slave_dst_rom{if(dst_slave==ROM) {(end_address inside {['h3000:'h4500]} && dst_addr inside {['h3000:'h4500]})};}
constraint slave_dst_buffer{if(dst_slave==BUFFER) {(!(end_address inside {['h0:'h4500],['h5000:$]}) && !(dst_addr inside {['h0:'h4500],['h5000:$]}))};}
constraint slave_sorce_sram_{if( src_slave==SRAM) {(src_addr inside {['h1000:'h2FFFF]})};}
constraint slave_source_otp{if( src_slave==OTP) {(src_addr inside {['h0:'h0FFF]})};}
constraint slave_source_rom{if(src_slave==ROM) {(src_addr inside {['h3000:'h4500]})};}
constraint slave_source_buffer{if(src_slave==BUFFER) {(!(src_addr inside {['h0:'h4500],['h5000:$]}))};}
constraint start_addr{/*start_address == src_addr;*/start_address == dst_addr;}
constraint end_addr{end_address == (start_address + transfer_count + burst_size );}
constraint address_range{solve start_address before end_address; }
constraint burst_size_range{burst_size inside {'h0,'h2,'h4,'h10,'h20};}
constraint transfer_count_range{transfer_count inside {['h0 : 'h100]};}
function void post_randomize;
$display("-------------------------------------------------------");
$display("Source Slave Selected : ",src_slave.name);
$display("Destination Slave Selected : ",dst_slave.name);
$display("Source address : %0h ",src_addr);
$display("Destination address : %0h ",dst_addr);
$display("Burst Size : %0h ",burst_size);
$display("Transfer_count range : %0h ",transfer_count);
$display("Start address and End address : %0h %0h ",start_address,end_address);
$display("Channel : %0d ",channel);
$display("-------------------------------------------------------");
endfunction
endclass
module top;
packet p1 = new();
initial begin
repeat(3) begin
if(!p1.randomize)
$display("---------------Randomization Failure-----------");
end
end
endmodule
Below is the output of the code :
---------------Randomization Failure-----------
---------------Randomization Failure-----------
---------------Randomization Failure-----------
//---------------------------------------------------------------