Skip to content

Instantly share code, notes, and snippets.

@FrankBuss
Created October 31, 2018 17:10
Show Gist options
  • Save FrankBuss/e22e31d76edf273ee8e374a645af1f45 to your computer and use it in GitHub Desktop.
Save FrankBuss/e22e31d76edf273ee8e374a645af1f45 to your computer and use it in GitHub Desktop.
# create a NAND lookup table
#!/usr/bin/python3
import sys
for i in xrange(256):
if i % 16 == 0:
sys.stdout.write(" .db ")
# PB1 input
a = i & 2
# PB2 input
b = i & 4
# calculate PB0 output: A NAND B
q = not (a and b)
# set all other bits to 1, for pullup
q = q | 0xfe
sys.stdout.write("0x" + format(int(q), '02x'))
sys.stdout.flush()
if i % 16 == 15:
sys.stdout.write("\n")
else:
sys.stdout.write(", ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment