Reputation: 899
I have assigned names to numbers using:
`define ADD 0
`define SUB 1
`define LSF 2
`define RSF 3
`define AND 4
`define OR 5
I'd like to handle in a case
block such that the code will apply for more than one option.
In C this can be done using:
switch (x){
case ADD:
case SUB:
case LSF:
case RSF:
case AND:
case OR:
printf ("Handling");
break;
}
Is there a way to achieve that in Verilog? Thanks!
Upvotes: 2
Views: 572
Reputation: 6644
Yup, commas!
case (x)
ADD, SUB, LSF, RSF, AND, OR: begin
$display("Handling multiple cases");
// no need for breaks
end
MULT: begin
$display("handle a single case");
end
default: begin
$display("do something to do for all other cases");
end
endcase
Upvotes: 6