# And operation between \`defines

**URL:** <https://verificationacademy.com/forums/t/and-operation-between-defines/39486>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog\
**Created:** [August 27, 2021, 7:07pm UTC](https://verificationacademy.com/forums/t/and-operation-between-defines/39486 "2021-08-27T19:07:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EnugalaSwetha](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/c89c15/32.png) [@EnugalaSwetha](https://verificationacademy.com/forums/u/EnugalaSwetha)\
**Post date:** [August 27, 2021, 7:07pm UTC](https://verificationacademy.com/forums/t/and-operation-between-defines/39486/1 "2021-08-27T19:07:00Z")

</div>

Hi,  
Can we do logical and operation between two `defines? If so how?  
For ex:  
I have two defines A and B.  
I need result like:

`ifdef A && B //both should be enabled at a time $display("Both are defined"); `else  
$display(“Some operation must happen”);  
`endif

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [August 27, 2021, 7:31pm UTC](https://verificationacademy.com/forums/t/and-operation-between-defines/39486/2 "2021-08-27T19:31:01Z")

</div>

_In reply to [Swetha Reddy E](https://verificationacademy.com/forums/t/and-operation-between-defines/39486):_

I suggest that you first see if there is a way of doing what you want without using ``ifdefs

But if not, you can do things like

```verilog
`ifdef A
  `define A_or_B
  `ifdef B
    `define A_and_B
  `endif
`elsif B
  `define A_or_B
`endif

`ifdef A_and_B
$display("Both are defined");
`else
$display("Both are not defined");
`endif

```
