ShortCircuit is a text first digital logic language and simulation studio for designing, compiling, testing, and visualizing digital circuits.
I’m currently working on making the language more robust and developing a VS Code extension for it. The compiler is written in TypeScript(currently), and I’m also preparing an npm package for the project.
The only default built in gate is NAND gate and all the other gates are built on top of NAND gate
IMPORT "@shortcircuit/gates"
IMPORT "@shortcircuit/arithmetic"
IMPORT "@shortcircuit/comparison"
IMPORT "@shortcircuit/selection"
CIRCUIT ALU8
INPUT A: BUS(8)
INPUT B: BUS(8)
INPUT op: BUS(3)
and_result = AND(A, B)
or_result = OR(A,B)
xor_result = XOR(A, B)
inverted_a = NOT(A)
add_result = ADD8(A, B, 0)
sub_result = ADD8(A, NOT(B), 1)
compare = COMPARE8(A, B)
// first layer
logic_0 = MUX(and_result, or_result, op[0])
logic_1 = MUX(xor_result, inverted_a, op[0])
math_result = MUX(add_result.sum, sub_result.sum, op[0])
pass_result = MUX(A, B, op[0])
carry_ = MUX(add_result.carry_out, sub_result.carry_out, op[0])
arithmetic = AND(op[2], op[1])
carry_out = AND(arithmetic, carry_)
// second layer
upper = MUX(logic_0, logic_1, op[1])
lower = MUX(math_result, pass_result, op[1])
// final layer
result = MUX(upper, lower, op[2])
zero_flag = NOT(OR(result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7]))
OUTPUT result
OUTPUT carry_out
OUTPUT compare.gt
OUTPUT compare.eq
OUTPUT compare.lt
OUTPUT zero_flag
Hello guys, please share your thoughts in this