2011/12/22 luigi scarso <luigi.scarso@gmail.com>
mkiv or mkii ?
Anyway, metapost --- have you seen metafun ?

metafun or tikz is the answer. your request is pretty special, so you’ll have to do the majority of the work yourself (in contrast to using something like the circuit library for tikz)

i tikz, you’d do sth like:

\usetikzlibrary[matrix,fit]
\starttikzpicture
\matrix[
    matrix of nodes,
    ampersand replacement=\&
] (m) {
    0 \& 0 \& 1\& \1 \\
    0 \& 0 \& 1\& \1 \\
    0 \& 0 \& 0\& \1 \\
    0 \& 1 \& 1\& \1 \\
}

\node[red, fit = (m-1-3) (m-2-4)] {};
\node[green, fit = (m-1-4) (m-4-4)] {};
\node[green, fit = (m-4-2) (m-4-3)] {};
\stoptikzpicture

(untested)