Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System Verilog - case with or

How can I create case with or?

Something like:

string str;

case (str)
   "abc" || "dfg": begin
       //some code
   end
   "yfg": begin
       //some code
   end
   default: //some code
endcase
like image 343
sara8d Avatar asked Feb 05 '23 09:02

sara8d


1 Answers

You can create a case with OR using a comma like this:

string str;

case (str)
   "abc" , "dfg": begin  
       //some code
   end
   "yfg": begin
       //some code
   end
   default: //some code
endcase

What you're doing is subtly different to ||. You are presenting a list of alternatives to the case statement instead of ORing several expressions together to give one alternative to the case statement.

like image 196
Matthew Taylor Avatar answered Feb 27 '23 19:02

Matthew Taylor