Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog Code: assign c = (a == b)

Status
Not open for further replies.
The result of the compare operation a==b is assigned to c.
 

I've never used this syntax before, but if it is compilable, it must mean c is the exclusive nor of a and b. It is using the equality operator to check if a is the same logical level as b. I would write it using the Verilog XNOR operator, since it is more intuitive to me:
assign c = a ~^ b;
 

I would write it using the Verilog XNOR operator, since it is more intuitive to me
Consider, that a and b may be bit vectors as well. Then the result of XNOR and compare would be different.
 

If both the vectors are equal then result will be logic level '1' else '0'.
 

Good point, I had made an assumption that a and b are each 1 bit, based on incomplete context. For the case where a and b are vectors of equal and arbitrary size you could get the desired behavior by ANDing all the bits from my previous equation as follows:
assign c = &(a ~^ b);
But that seems unnecessarily confusing.
I ran the original syntax (a == b) through Cadence's HAL lint checker, and theres no problem with it at all, so perhaps it is the most ideal solution.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top