You should never use an assert statement with a call to randomize(). Instead, you should use the return code to determine if the call was successful:
case(cfg_axi::testname)
"TEST_10_WR_TX":begin
for(int i=0;i<9;i=i+1) begin
tx=new();
if (!(tx.randomize() with {tx.tx_type == WRITE;}))
$display("Randomization failed!");
else
cfg_axi::gen2bfm.put(tx);
end
end
In this case, you would receive the error message that the call to randomize() failed.
You would then focus on the error message:
axi_gen:: inside gen
gen.sv(10): randomize() failed due to conflicts between the following constraints:
gen.sv(10): (tx_type == WRITE);
Where:
tx_type = READ /* non-random */
In the axi_tx class, tx_type is not declared as ‘rand’, hence it can’t be randomized.
Even though I have declared pif, it is showing as undefined variable. Not sure what’s the issue.
//declaring clk & reset
reg clk,rst;
//logic to get user input
initial begin
$value$plusargs(“testname=%s”,cfg_axi::testname); cfg_axi::vif=pif;
end
At the time you are referencing ‘pif’, it hasn’t been declared. You should move your initial block to the end of your top module, after all of your module/interface instantiations.
You have a race condition where you are starting your test prior to setting the testname, hence the generator is creating nothing.
You should be sequencing getting/setting the test name and creating/running your environment at the top level. Don’t use an intermediate tb to start the environment.
The link that you posted doesn’t do anything similar to your question. If you want assistance, you need to ensure that you are posting correct information.