Skip to content

Instantly share code, notes, and snippets.

@olofk
Created December 13, 2018 21:43
Show Gist options
  • Save olofk/a2549ce902e8e7e61e88d45d8199253e to your computer and use it in GitHub Desktop.
Save olofk/a2549ce902e8e7e61e88d45d8199253e to your computer and use it in GitHub Desktop.
from sympy.logic import SOPform
from sympy import symbols
a, w, x, y, z = symbols('opcode[4] opcode[3] opcode[2] opcode[1] opcode[0]')
dontcares = [
# [0, 0, 0, 0, 0],
[0, 0, 0, 0, 1],
[0, 0, 0, 1, 0],
[0, 0, 0, 1, 1],
# [0, 0, 1, 0, 0],
# [0, 0, 1, 0, 1],
[0, 0, 1, 1, 0],
[0, 0, 1, 1, 1],
# [0, 1, 0, 0, 0],
[0, 1, 0, 0, 1],
[0, 1, 0, 1, 0],
[0, 1, 0, 1, 1],
[0, 1, 1, 0, 0],
# [0, 1, 1, 0, 1],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 1],
[1, 0, 0, 0, 0],
[1, 0, 0, 0, 1],
[1, 0, 0, 1, 0],
[1, 0, 0, 1, 1],
[1, 0, 1, 0, 0],
[1, 0, 1, 0, 1],
[1, 0, 1, 1, 0],
[1, 0, 1, 1, 1],
# [1, 1, 0, 0, 0],
# [1, 1, 0, 0, 1],
[1, 1, 0, 1, 0],
# [1, 1, 0, 1, 1],
# [1, 1, 1, 0, 0],
[1, 1, 1, 0, 1],
[1, 1, 1, 1, 0],
[1, 1, 1, 1, 1],
]
itype = [
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[1, 1, 0, 0, 1],
[1, 1, 1, 0, 0],
]
jtype = [[1,1,0,1,1]]
print("wire itype = {};".format(SOPform([a, w, x, y, z], itype, dontcares)))
print("wire jtype = {};".format(SOPform([a, w, x, y, z], jtype, dontcares)))
print("wire iorjtype = {};".format(SOPform([a, w, x, y, z], itype+jtype, dontcares)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment