Skip to content

Instantly share code, notes, and snippets.

@mattvenn
Created January 9, 2019 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattvenn/c4d23ddd764c59e4840b46513fba7916 to your computer and use it in GitHub Desktop.
Save mattvenn/c4d23ddd764c59e4840b46513fba7916 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
instructions = [ 'Sync', 'Call', 'Return', 'Execute', 'LoadCode', 'LoadCoeff0', 'LoadCoeff1', 'ContinueLoad', 'SetVBP', 'AddVBP', 'SetLBP', 'AddLBP', 'SetSBP', 'AddSBP', 'SetCBP', 'AddCBP', 'Store', 'Store0', 'Store1', '---', 'ReLU', 'ReLU0', 'ReLU1', '---', 'Save', 'Save0', 'Save1', '---', 'LdSet', 'LdSet0', 'LdSet1', '---', 'LdAdd', 'LdAdd0', 'LdAdd1', '---', '---', '---', '---', '---', 'MACC', 'MMAX', 'MACCZ', 'MMAXZ', '---', 'MMAXN' ]
def main(argv0, *args):
fh_in = sys.stdin
fh_out = sys.stdout
# Repeat ...
while True:
# Read input until we get a full VCD input
l = fh_in.readline()
if not l:
return 0
try:
fh_out.write("%s\n" % instructions[0b111111 & int(l,16)])
except IndexError:
fh_out.write("no instruction\n")
except ValueError:
fh_out.write("undefined\n")
fh_out.flush()
if __name__ == '__main__':
sys.exit(main(*sys.argv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment