Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unexpected Xs in the result of addition of two logic signals

I have a code where two signals are added. Only top bits of the signals are X. Bottom bits are 0s.
But, the result has all Xs. I would expect the bottom bits to be 0s in the result.

logic [3:0] a; // 4'bxx00
logic [3:0] b; // 4'bxx00
logic [4:0] c;

assign c = a + b; // Results in c = 4'bxxxxx

I am trying to understand why the bottom 2 bits are x in the result.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This behavior is specified in IEEE Std 1800-2017, section 11.4.3 Arithmetic operators:

For the arithmetic operators, if any operand bit value is the unknown
value x or the high-impedance value z , then the entire result value
shall be x .

The expression a + b contains an arithmetic operator: +

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading