Skip to content

Instantly share code, notes, and snippets.

@KubaO
Last active January 21, 2024 15:09
Show Gist options
  • Save KubaO/75f53d82a849b65f1a8980b1a2901328 to your computer and use it in GitHub Desktop.
Save KubaO/75f53d82a849b65f1a8980b1a2901328 to your computer and use it in GitHub Desktop.

There are many ways of solving such circuits. For people who looked at lots of logic diagrams like these - they'll identify them pretty much just by looking at them for a minute. For someone who's just learning it for the first time, it helps to have a process. Here are the steps I'd take. You don't need to take those exact steps, of course!

  1. Replace the input lines with labels:

schematic

  1. Replace NANDs with shorted inputs with inverters:

schematic

  1. Propagate input dots forward, and output dots backward:

schematic

  1. The transformations above should be done for each output separately, to avoid confusion.

  2. Draw all the simplified circuits one above the other and see if they remind you of something visually.

  3. If not, write out the truth table.

    a) First, fill in the input columns in whatever systematic pattern you prefer. Below, I'm counting up in binary. You may as well use Gray code or whatever else you'd like. Leave the output columns empty.

    a b c
    0 0
    0 1
    1 0
    1 1

    b) Then, write the equation for each sub-circuit (output) in the column header for that output. In our case, the equation for c is $c=!a*b$.

    c) Finally, compute the values for each line for each output.

    a b $c=!a*b$
    0 0 0
    0 1 1
    1 0 0
    1 1 0
  4. Once you get columns for all the outputs, see if the pattern looks familiar. You may need to reorder the outputs to expose that pattern. On paper it's easy: just cut out the output columns, put them next to each other, and you can reshuffle them laterally.

@xzooos
Copy link

xzooos commented Jan 21, 2024

by the way did some more studying and that seems like a 1bit comparator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment