Basic Logic Gates

Easy · Combinational Logic

Build the six basic logic gates side by side. Every output is a combinational function of the two 1-bit inputs a and b: it must change as soon as the inputs change, with no clock.

Ports

PortDirWidthMeaning
ainput1First input.
binput1Second input.
and_outoutput1a AND b: 1 only when both are 1.
or_outoutput1a OR b: 1 when at least one is 1.
xor_outoutput1a XOR b: 1 when exactly one is 1.
nand_outoutput1NOT (a AND b).
nor_outoutput1NOT (a OR b).
not_aoutput1NOT a (ignores b).

Truth table

aband_outor_outxor_outnand_outnor_outnot_a
00000111
01011101
10011100
11110000

The SystemVerilog operators you need are & (AND), | (OR), ^ (XOR) and ~ (NOT). Watch the parentheses: ~a & b means (~a) & b, which is not NAND.

Sign up free to solve Basic Logic Gates in your browser.

More Combinational Logic problems