Hi,
req.randomize() with {if(cfg.addr == 7)
addr inside {cfg.valid_slave_address};
if (index == 0 && command == (3'b011 || 3'b001))
data[1] == command;};
even though when I passing the command == 3’b011 & 3’b001 its not taking the command value instead of its taking some random value can any one help me how to rewrite that one.
thanks
In reply to lalithjithan :
Answering by inferring that the question is that :
You are getting data[1] not equal to command even when you are passing command as one of the following value :
3’b011
3’b001
The issue is with the way you have written the condition :
req.randomize() with {if(cfg.addr == 7)
addr inside {cfg.valid_slave_address};
if (index == 0 && command == (3'b011 || 3'b001)) // <--
data[1] == command;};
The code check -
command == ( 3’b011 || 3’b001 )
which is equivalent to -
command == (true logical_OR
true )
command == 1
you should write it as following to get data[1] = command when command is either 3 or 1 :
req.randomize() with {if(cfg.addr == 7)
addr inside {cfg.valid_slave_address};
if (index == 0 && (command == 3'b011 || command == 3'b001)) // <--
data[1] == command;};
Hope it helps.
dave_59
September 25, 2018, 5:36pm
3
In reply to @nurag :
You could also use the inside operator for this:
req.randomize() with {if(cfg.addr == 7)
addr inside {cfg.valid_slave_address};
if (index == 0 && command inside {3'b011, 3'b001}) // <--
data[1] == command;};