Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if a VHDL Integer is even or odd?

Tags:

vhdl

What is the easiest or simplest way to check if an integer signal is even or odd in VHDL?

like image 691
Stephane Beniak Avatar asked Dec 10 '22 05:12

Stephane Beniak


2 Answers

if (A mod 2) = 0 then
-- it's even
else
-- it's odd
end if;
like image 142
Jonathan M Avatar answered Dec 20 '22 02:12

Jonathan M


As a side note if the signal is a vector, then you can do the following:

if (A(0)) then
-- it's odd
else
-- it's even
like image 43
vipin Avatar answered Dec 20 '22 01:12

vipin