The following Common Lisp function provides a functional representation of a schematic for a digital logic circuit of three inputs and one output.
(defun foo (a b c)
(labels ((inv (m) (ecase m (0 1) (1 0)))
(f1 () (boole boole-and a b))
(f2 () (boole boole-and (inv b) c)))
(values (inv (boole boole-ior (f1) (f2))))))
Observations:
- Common Lisp does not define a monadic boolean compliment function.
- There are diadic boolean compliment operations available via the BOOLE function -- two of which, each one operating on only a single data value provided of the two arguments to the BOOLE function.
- Why doesn't CLtL2 define a monadic boolean compliment function?
- In the illustration, the INV function provides a switched implementation of an effective monadic boolean compliment function
- Is it not possible to define a more efficient monadic boolean compliment function, in actual machine code?
- Argument and return value types: CL:BIT
- The set of procedures provided by the CLtL2 BOOLE function may be represented, in each, with an inline function requiring of only two arguments and constrained in its argument types and return values exactly onto the data type CL:BIT
- When compiled, each such function might provide a trivial interface onto the implementation's own machine-specific encoding for each of the specific BOOLE procedures
- Observing DeMorgan's theorem, those implementation-specific implementations of the respective BOOLE procedures may be reviewed, in each, for its respective implementation-specific compiler optimizations -- thus creating a nice "Usage case" for studying implementation-specific procedures and methodologies for defining compiler optimizations onto specific implementations of CLtL2
- The methdology of defining a single function to represent each logical element in a circuit, such that the function accepts as many inputs as the circuit element has input pins, and returns as many values as the circuit element has output pins
- That each such "logical function" can be modeled in CLOS
- That it may serve to define an effective hardware definition language, in Common Lisp
- That it may not be appropriate to reinvent SPICE / XSPICE / NG SPICE / ...
- That it may be appropriate to define a hardware definition language optimized for Common Lisp
No comments:
Post a Comment