Create a high-level synthesis language assembler. Part 6

Overview

Create a high-level synthesis language assembler. I tried to find a logical formula from the truth table with python.

Sample code

import sympy as sym

#xor
print (sym.POSform(['a', 'b'], [[1, 0], [0, 1]]))
#or
print (sym.POSform(['a', 'b'], [[1, 1], [0, 1], [1, 0]]))
#and
print (sym.POSform(['a', 'b'], [[1, 1]]))
#nand
print (sym.POSform(['a', 'b'], [[0, 0], [0, 1], [1, 0]]))
#nor
print (sym.POSform(['a', 'b'], [[0, 0]]))

print (sym.POSform(['a', 'b', 'c'], [[1, 1, 1]]))

Execution result

(a | b) & (~a | ~b)
a | b
a & b
~a | ~b
~a & ~b
a & b & c

that's all.

Recommended Posts

Create a high-level synthesis language assembler. Part 6
Create an executable file in a scripting language
Create a web server in Go language (net/http) (2)
Create a web server in Go language (net / http) (1)
Create a Django schedule
Create a Python module
Create a Bootable LV
Create a Python environment
Create a slack bot
[Go language] Try to create a uselessly multi-threaded line counter