Site icon Hardware Design and Verification

What is the purpose of using a constraint implication operator (->) in System Verilog?

implication operator as it name suggest it is something related to “the conclusion that can be drawn from something”

same thing is valid for system verilog as well

where can you use in SV , it will be used where you want certain things you want to constraint certain things based on certain value/expression/signal

consider a packet can be of two type “GOOD” “BAD”

if it is good packet generate address from 1000 to FFFF

if it bad packet generate address from 0000 to 0111

“How will you do it , think of it“ it will some thing like this

class packet_type;

typedef enum { GOOD, BAD } packet_type;

rand packet_type packet;

rand bit [15:0] address;

constraint adress_const {

(packet==GOOD) -> address inside {[16’h1000:16’hFFFF]} ;

(packet==BAD) -> address inside {[16’h0000:16’h1111]};

}

endclass

-> is used in such scenario

Exit mobile version