3 ms·
I feel like there is a connection between the functional programming (FP) that logic circuits do, and the imperative programming (IP) of languages like C, throu
by zackmorris 8y ago
I feel like there is a connection between the functional programming (FP) that logic circuits do, and the imperative programming (IP) of languages like C, through parser generators like YACC. In other words:
(FP) Verilog/VHDL<->YACC<->C (IP)
I have seen many FP to C transpilers (where you write the spec in a FP language like Lisp and it generates IP language C) because it's trivial:
https://www.quora.com/How-can-I-compile-a-Common-Lisp-or-Scheme-to-C-or-C++ https://www.quora.com/How-can-I-compile-a-Common-Lisp-or-Sch...
But I've never seen a C to Lisp transpiler that breaks the code down into a series of basic functions. My guess is that mutability becomes a major problem and either can't be represented without monads, or becomes unreadable spaghetti where the mutations have to be expressed via types or generics somehow.
In other words, the difficulty of statically analyzing mutability leads to excessively complex FP code that is unreadable by humans.
This might be one of the only examples I've seen where someone went from relatively human readable C to the FP expressed in the circuit by way of YACC.
Edit: upon reading this again, it looks like only the input equations were parsed by the "YACC generated program". The C code was only used for the "event driven cycle accurate simulator". But I still think there is merit in what I said about FP<->YACC<->IP.